:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #122033;
  --muted: #66758a;
  --line: #e4eaf2;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --danger: #e11d48;
  --shadow: 0 10px 30px rgba(18, 32, 51, 0.08);
  font-family: "Segoe UI", "Nunito", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  display: grid;
  grid-template-columns: 240px 1fr;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, #c7d2fe, transparent 35%),
    radial-gradient(circle at 80% 10%, #fce7f3, transparent 30%),
    var(--bg);
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border-radius: 24px;
  padding: 36px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.logo,
.brand {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--brand);
}

.auth-card h1,
.content h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.muted,
.hint {
  color: var(--muted);
  margin: 0 0 10px;
}

.hint {
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #f8fafc;
}

.alert {
  background: #ffe4e6;
  color: #9f1239;
  padding: 10px 12px;
  border-radius: 12px;
  margin: 0;
}

.sidebar {
  background: #111827;
  color: #e5e7eb;
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  color: #cbd5e1;
}

.sidebar a.active,
.sidebar a:hover {
  background: #1f2937;
  color: #fff;
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.sidebar-user span,
.sidebar-user a {
  color: #94a3b8;
  padding: 0;
}

.sidebar-link {
  color: #93c5fd;
  text-align: left;
  padding: 0;
  font-weight: 700;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.check-line input {
  width: auto;
}

.content {
  padding: 28px;
  min-width: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}

.btn,
.auth-card button {
  border: 0;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  color: #fff;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stats article {
  background: var(--panel);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.stats strong {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

.board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 62vh;
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
}

.column header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

.column h2 {
  font-size: 14px;
  margin: 0;
  flex: 1;
}

.column em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.column-body {
  padding: 0 10px 10px;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 120px;
  flex: 1;
}

.column-body.dragover {
  background: #eef2ff;
}

.card {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.card p,
.card footer span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.table-wrap {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.is-done td {
  opacity: 0.55;
}

.is-done .linkish {
  text-decoration: line-through;
}

.overdue {
  color: var(--danger);
  font-weight: 700;
}

.linkish,
.text-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
}

.text-btn.danger {
  color: var(--danger);
  margin-left: 10px;
}

.check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
}

.check.on {
  background: var(--brand);
  border-color: var(--brand);
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(560px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 22px;
  display: grid;
  gap: 12px;
}

.modal h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-actions-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.modal-actions-right .text-btn.danger {
  margin-left: 0;
}

.contacts-block {
  display: grid;
  gap: 8px;
}

.contacts-label {
  font-size: 13px;
  font-weight: 700;
}

.contact-list {
  display: grid;
  gap: 8px;
}

.contact-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.ghost {
  background: #e2e8f0;
  color: var(--ink);
}

.ghost-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.ghost-icon:disabled {
  opacity: 0.35;
  cursor: default;
}

input[type="color"] {
  width: 52px;
  height: 36px;
  padding: 3px;
}

.mobile-bar,
.sidebar-backdrop {
  display: none;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

input,
select,
textarea,
button {
  font-size: 16px;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  body.menu-open {
    overflow: hidden;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: #111827;
    color: #fff;
  }

  .mobile-bar .brand {
    color: #c7d2fe;
  }

  .desktop-brand {
    display: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 40;
    min-height: 100dvh;
    padding-top: calc(24px + env(safe-area-inset-top));
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    flex-direction: column;
    align-items: stretch;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar nav {
    grid-auto-flow: row;
  }

  .sidebar a,
  .sidebar-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .sidebar-user {
    margin: auto 0 0;
  }

  .content {
    padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
  }

  .content h1,
  .auth-card h1 {
    font-size: 24px;
  }

  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .top .btn {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stats strong {
    font-size: 18px;
  }

  .board {
    margin: 0 -14px;
    padding: 4px 14px 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .column {
    flex: 0 0 min(84vw, 320px);
    min-height: 52vh;
    scroll-snap-align: start;
  }

  .table-wrap {
    overflow: visible;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    background: var(--panel);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  th,
  td {
    border: 0;
    padding: 6px 0;
  }

  td[data-label] {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    align-items: start;
  }

  td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  td.row-check,
  td.row-actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
  }

  .text-btn.danger {
    margin-left: 0;
  }

  .check {
    width: 28px;
    height: 28px;
  }

  .ghost-icon {
    width: 40px;
    height: 40px;
  }

  .modal-back {
    padding: 0;
    align-items: end;
  }

  .modal {
    width: 100%;
    max-height: min(94dvh, 100%);
    border-radius: 20px 20px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions .btn,
  .modal-actions-right {
    width: 100%;
    justify-content: space-between;
  }

  .contact-row {
    grid-template-columns: 1fr;
  }

  .auth-card {
    width: min(420px, calc(100vw - 24px));
    padding: 24px 18px;
    margin: 16px;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr;
  }
}
