/* =========================================================================
   Операционный директор: доска задач.
   Один файл стилей: токены (переменные) -> база -> компоненты -> экраны.
   Светлая тема по умолчанию, тёмная через prefers-color-scheme.
   ========================================================================= */

/* ---------- 1. Токены ---------- */
:root {
  /* Шрифт: системный стек (на Mac и iPhone это SF Pro) */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Шкала размеров */
  --fs-12: 12px; --fs-13: 13px; --fs-15: 15px; --fs-17: 17px;
  --fs-21: 21px; --fs-28: 28px; --fs-40: 40px;

  /* Сетка 8px */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* Цвета: светлая тема */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --column: rgba(0, 0, 0, .028);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --separator: rgba(0, 0, 0, .08);
  --hairline: rgba(0, 0, 0, .06);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .08);
  --fill-hover: rgba(118, 118, 128, .16);
  --segment-on: #ffffff;
  --nav-bg: rgba(245, 245, 247, .72);
  --overlay: rgba(0, 0, 0, .28);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-press: #006edb;
  --accent-text: #0066cc;
  --accent-soft: rgba(0, 113, 227, .10);
  --ring: rgba(0, 113, 227, .20);

  /* Семантика: только для статусов */
  --green: #34c759;  --green-text: #248a3d; --green-soft: rgba(52, 199, 89, .14);
  --orange: #ff9f0a; --orange-text: #c93400; --orange-soft: rgba(255, 159, 10, .14);
  --red: #ff3b30;    --red-text: #d70015;  --red-soft: rgba(255, 59, 48, .10);

  /* Форма */
  --r-field: 10px; --r-card: 14px; --r-panel: 18px; --r-pill: 999px;
  --sh-card: 0 0 0 1px var(--hairline), 0 1px 2px rgba(0, 0, 0, .04);
  --sh-card-hover: 0 0 0 1px var(--hairline), 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --sh-lift: 0 0 0 1px var(--hairline), 0 12px 32px rgba(0, 0, 0, .14);
  --sh-segment: 0 0 0 .5px rgba(0, 0, 0, .04), 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  --sh-sheet: 0 0 0 1px var(--hairline), 0 24px 64px rgba(0, 0, 0, .18);

  /* Движение */
  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 150ms; --t: 200ms; --t-slow: 250ms;

  --container: 1120px;
  --gutter: var(--s-8);
  --nav-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-raised: #2c2c2e;
    --column: rgba(255, 255, 255, .04);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --separator: rgba(255, 255, 255, .10);
    --hairline: rgba(255, 255, 255, .07);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .18);
    --fill-hover: rgba(118, 118, 128, .32);
    --segment-on: #636366;
    --nav-bg: rgba(22, 22, 23, .72);
    --overlay: rgba(0, 0, 0, .55);

    --accent: #0a84ff;
    --accent-hover: #1a8cff;
    --accent-press: #0077ed;
    --accent-text: #2997ff;
    --accent-soft: rgba(10, 132, 255, .18);
    --ring: rgba(10, 132, 255, .32);

    --green: #30d158;  --green-text: #30d158; --green-soft: rgba(48, 209, 88, .18);
    --orange: #ff9f0a; --orange-text: #ffb340; --orange-soft: rgba(255, 159, 10, .18);
    --red: #ff453a;    --red-text: #ff6961;  --red-soft: rgba(255, 69, 58, .16);

    --sh-card: 0 0 0 1px var(--hairline);
    --sh-card-hover: 0 0 0 1px rgba(255, 255, 255, .12), 0 8px 24px rgba(0, 0, 0, .4);
    --sh-lift: 0 0 0 1px rgba(255, 255, 255, .14), 0 16px 40px rgba(0, 0, 0, .6);
    --sh-segment: 0 3px 8px rgba(0, 0, 0, .3);
    --sh-sheet: 0 0 0 1px var(--hairline), 0 24px 64px rgba(0, 0, 0, .6);
  }
}

/* ---------- 2. База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-15);
  line-height: 1.47;
  letter-spacing: -0.01em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern";
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.icon { flex: none; display: block; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.text-red { color: var(--red-text); }
.text-green { color: var(--green-text); }
.text-orange { color: var(--orange-text); }
.text-accent { color: var(--accent-text); }
.text-3 { color: var(--text-3); }

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- 3. Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 36px; padding: 0 var(--s-4);
  border: 0; border-radius: var(--r-pill);
  font-size: var(--fs-15); font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--fill); color: var(--text);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:hover { background: var(--fill-hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--fill-2); color: var(--text); }
.btn-danger-text { background: transparent; color: var(--red-text); padding-inline: var(--s-3); }
.btn-danger-text:hover { background: var(--red-soft); }
.btn-large { min-height: 48px; font-size: var(--fs-17); padding: 0 var(--s-6); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--fill-2); color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--fill-hover); color: var(--text); }

/* ---------- 4. Навигация ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--separator);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); height: var(--nav-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.logo-mark { display: block; flex: none; border-radius: 22.5%; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.brand-name { font-size: var(--fs-17); font-weight: 600; letter-spacing: -0.022em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-15); }
.btn-logout .icon { margin-left: -2px; }
.nav-end { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-15); font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-link:hover { background: var(--fill-2); color: var(--text); }
.nav-link.is-active { background: var(--fill); color: var(--text); }

/* ---------- 5. Заголовок страницы ---------- */
.page { padding-top: var(--s-10); padding-bottom: var(--s-16); }
.page-head { margin-bottom: var(--s-6); }
.page-title {
  font-size: var(--fs-40); line-height: 1.1; font-weight: 700; letter-spacing: -0.028em;
  overflow-wrap: anywhere;
}
.page-title-tag { color: var(--text-3); font-weight: 600; }
.page-sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  margin-top: var(--s-2);
  font-size: var(--fs-17); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }

/* ---------- 6. Быстрое добавление ---------- */
.quick-add { margin-bottom: var(--s-6); }
.quick-add-field {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 60px; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  transition: box-shadow var(--t) var(--ease);
}
.quick-add-field:focus-within { box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--ring); }
.quick-add-icon { display: grid; place-items: center; color: var(--accent); cursor: text; }
.quick-add-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 var(--s-1);
  border: 0; background: transparent; outline: none;
  font-size: var(--fs-17); letter-spacing: -0.022em;
}
.quick-add-input:focus-visible { box-shadow: none; }
.quick-add-input::placeholder { color: var(--text-3); }
.quick-add-submit { min-height: 44px; padding: 0 var(--s-5); }
.quick-add-hint {
  margin-top: var(--s-3); padding-inline: var(--s-1);
  font-size: var(--fs-13); line-height: 1.7; color: var(--text-2);
}
.token {
  display: inline-block; padding: 0 7px; margin-inline: 1px;
  border-radius: 6px; background: var(--fill-2);
  font-weight: 500; color: var(--text); line-height: 1.6; white-space: nowrap;
}

/* ---------- 7. Фильтры: сегменты и чипы ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-8);
  margin-bottom: var(--s-8);
}
.filter-group { display: flex; align-items: center; gap: var(--s-3); min-width: 0; max-width: 100%; }
.filter-label { flex: none; font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }

.segmented {
  display: inline-flex; gap: 2px; padding: 2px; min-width: 0; max-width: 100%;
  border-radius: 9px; background: var(--fill);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.segment {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  min-height: 30px; padding: 0 var(--s-3);
  border-radius: 7px;
  font-size: var(--fs-13); font-weight: 500; color: var(--text); white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.segment:hover { background: var(--fill-2); }
.segment:has(input:checked) { background: var(--segment-on); box-shadow: var(--sh-segment); font-weight: 600; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
.segmented-block { display: flex; width: 100%; }
.segmented-block .segment { flex: 1 1 0; min-height: 34px; }

.project-dot {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: var(--dot, var(--text-3));
}

.chips { display: flex; gap: var(--s-2); min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chip {
  position: relative; display: inline-flex; align-items: center; flex: none;
  min-height: 30px; padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--fill-2); color: var(--text);
  font-size: var(--fs-13); font-weight: 500; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip:hover { background: var(--fill-hover); }
.chip.is-active { background: var(--text); color: var(--bg); }
.chip .project-dot { margin-right: 6px; }
.chip.is-active .project-dot { box-shadow: 0 0 0 1.5px var(--text); }
/* Невидимое расширение тач-зоны до 44px */
.segment::after, .chip::after { content: ""; position: absolute; inset: -7px -2px; }

/* ---------- 8. Доска ---------- */
.board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5);
  align-items: start;
}
.column {
  display: flex; flex-direction: column;
  padding: var(--s-2);
  border-radius: var(--r-panel);
  background: var(--column);
}
.column-head {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-2) 0 var(--s-3);
  font-size: var(--fs-15); font-weight: 600; letter-spacing: -0.016em;
}
.column-title { flex: 1; min-width: 0; }
.column-count {
  min-width: 24px; padding: 0 7px; border-radius: var(--r-pill);
  font-size: var(--fs-13); font-weight: 500; line-height: 22px; text-align: center;
  color: var(--text-2); background: var(--fill-2);
  font-variant-numeric: tabular-nums;
}
.status-mark { flex: none; display: block; }
.status-mark.status-todo { color: var(--text-3); }
.status-mark.status-in_progress { color: var(--accent); }
.status-mark.status-done { color: var(--green); }

.cards { display: flex; flex-direction: column; gap: var(--s-2); min-height: 96px; padding-top: var(--s-1); }
.cards:empty {
  align-items: center; justify-content: center;
  border: 1.5px dashed var(--separator); border-radius: var(--r-card);
  margin-top: var(--s-1);
}
.cards:empty::before {
  content: attr(data-empty);
  font-size: var(--fs-13); color: var(--text-3);
}

/* ---------- 9. Карточка ---------- */
.card {
  position: relative;
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-3);
  padding: 14px 16px 14px 14px;
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  cursor: grab;
  transition: box-shadow var(--t) var(--ease), background-color var(--t) var(--ease);
}
.card:hover { box-shadow: var(--sh-card-hover); }
.card .status-mark { margin-top: 1px; }
.card-body { min-width: 0; }
.card-title {
  padding-right: 24px; /* место под кнопку правки */
  font-size: var(--fs-15); font-weight: 500; line-height: 1.35; letter-spacing: -0.016em;
  overflow-wrap: anywhere;
}
.prio-mark { margin-right: 5px; font-weight: 700; letter-spacing: 0; }
.prio-mark-urgent { color: var(--red-text); }
.prio-mark-high { color: var(--orange-text); }
.card.status-done .card-title { color: var(--text-2); }
.card.status-done .prio-mark { color: inherit; }

.card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3);
  margin-top: 6px;
  font-size: var(--fs-13); line-height: 18px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.card-meta > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.meta-due.is-overdue {
  margin-left: -6px; padding: 1px 7px 1px 6px; border-radius: var(--r-pill);
  background: var(--red-soft); color: var(--red-text); font-weight: 500;
}
.meta-tag { color: var(--accent-text); }
.meta-id { margin-left: auto; color: var(--text-2); font-size: var(--fs-12); }

.card-edit {
  position: absolute; top: 10px; right: 10px;
  display: grid; place-items: center;
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-3);
  transition: opacity var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.card-edit::after { content: ""; position: absolute; inset: -8px; }
.card-edit:hover { background: var(--fill-2); color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
  .card-edit { opacity: 0; }
  .card:hover .card-edit, .card:focus-within .card-edit, .card-edit:focus-visible { opacity: 1; }
}

/* Перетаскивание */
.sortable-ghost { opacity: 1; background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.sortable-ghost > * { visibility: hidden; }
.sortable-drag, .sortable-fallback { box-shadow: var(--sh-lift) !important; cursor: grabbing; transform: rotate(1deg); }
.sortable-chosen { cursor: grabbing; }

/* ---------- 10. Окно правки (sheet) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in var(--t) var(--ease) both;
}
.sheet {
  display: flex; flex-direction: column;
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--s-12));
  background: var(--surface-raised);
  border-radius: var(--r-panel);
  box-shadow: var(--sh-sheet);
  overflow: hidden;
  animation: sheet-in var(--t-slow) var(--ease-out) both;
}
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-6) var(--s-6) var(--s-4);
}
.sheet-eyebrow { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sheet-title { margin-top: 2px; font-size: var(--fs-21); font-weight: 600; line-height: 1.2; letter-spacing: -0.022em; }
.sheet-body {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-2) var(--s-6) var(--s-6);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--separator);
}
.sheet-foot .btn-danger-text { margin-left: calc(var(--s-3) * -1); }
.sheet-actions { display: flex; gap: var(--s-2); }

/* Поля */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.field-row-due { grid-template-columns: 1.4fr 1fr; }
.input {
  width: 100%; min-height: 44px; padding: 10px var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-field);
  background: var(--fill-2); color: var(--text);
  font-size: var(--fs-15); line-height: 1.4;
  outline: none; -webkit-appearance: none; appearance: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:hover { background: var(--fill); }
.input:focus, .input:focus-visible { background: var(--surface-raised); border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.input::placeholder { color: var(--text-3); }
textarea.input { resize: none; min-height: 88px; max-height: 240px; field-sizing: content; }
.input-date, .input-time { font-variant-numeric: tabular-nums; }
.input::-webkit-date-and-time-value { text-align: left; }
.input::-webkit-calendar-picker-indicator {
  width: 18px; height: 18px; padding: 0; margin: 0; cursor: pointer; opacity: .55;
  transition: opacity var(--t-fast) var(--ease);
}
.input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
@media (prefers-color-scheme: dark) {
  .input::-webkit-calendar-picker-indicator { filter: invert(1); }
}
input[list]::-webkit-calendar-picker-indicator { display: none !important; }

/* ---------- 11. Вход ---------- */
.page-auth { min-height: 100vh; min-height: 100dvh; }
.auth {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-6);
  min-height: 100vh; min-height: 100dvh;
  padding: var(--s-10) var(--s-4);
}
.auth-card {
  width: 100%; max-width: 420px;
  padding: var(--s-10) var(--s-8) var(--s-8);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--sh-card-hover);
  text-align: center;
}
.auth-mark { display: flex; justify-content: center; margin-bottom: var(--s-6); }
.auth-mark .logo-mark { box-shadow: 0 4px 12px rgba(0, 102, 214, .25); }
.auth-title { font-size: var(--fs-28); font-weight: 700; line-height: 1.15; letter-spacing: -0.026em; }
.auth-text { margin: var(--s-3) auto var(--s-8); max-width: 320px; font-size: var(--fs-17); line-height: 1.47; color: var(--text-2); }
.auth-card form + *, .auth-card .code-block { margin-top: 0; }
.auth-divider {
  display: flex; align-items: center; gap: var(--s-3);
  margin: calc(var(--s-2) * -1) 0 var(--s-4);
  font-size: var(--fs-13); color: var(--text-3);
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--separator); }
.auth-foot { font-size: var(--fs-13); color: var(--text-2); text-align: center; }
.kbd {
  padding: 2px 7px; border-radius: 6px; background: var(--fill);
  font-family: var(--font-mono); font-size: .88em; color: var(--text); white-space: nowrap;
}
.code-block {
  display: block; padding: var(--s-3) var(--s-4); border-radius: var(--r-field);
  background: var(--fill-2); text-align: left;
  font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text); overflow-x: auto; white-space: nowrap;
}

/* ---------- 12. Импорт и статус ---------- */
.page-narrow { max-width: calc(760px + var(--gutter) * 2); }
.panel {
  display: flex; flex-direction: column; gap: var(--s-4);
  margin-bottom: var(--s-6); padding: var(--s-6);
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--sh-card);
}
.panel-title { font-size: var(--fs-21); font-weight: 600; line-height: 1.2; letter-spacing: -0.022em; }
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
.field-hint { font-size: var(--fs-13); line-height: 1.7; color: var(--text-2); }
.input-mono { font-family: var(--font-mono); font-size: var(--fs-13); line-height: 1.6; }
textarea.input.input-mono { min-height: 200px; max-height: 420px; }

.file-field {
  position: relative; display: flex; align-items: center; gap: var(--s-3);
  min-height: 56px; padding: var(--s-3) var(--s-4);
  border: 1.5px dashed var(--separator); border-radius: var(--r-card);
  color: var(--text-2); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.file-field:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.file-field input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-field-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--fill-2); color: var(--accent-text); }
.file-field-text { font-size: var(--fs-13); line-height: 1.5; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-4); border-radius: var(--r-card);
  background: var(--fill-2);
}
.stat-label { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.stat-value { font-size: var(--fs-28); font-weight: 700; line-height: 1.15; letter-spacing: -0.026em; font-variant-numeric: tabular-nums; }

/* Список в стиле «inset grouped» из настроек iOS */
.list-inset { list-style: none; margin: 0; padding: 0; border-radius: var(--r-card); background: var(--fill-2); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: var(--s-3) var(--s-4); }
.list-row + .list-row { box-shadow: inset 0 1px 0 var(--separator); }
.list-row-icon { flex: none; display: grid; place-items: center; }
.list-row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row-title { font-size: var(--fs-15); font-weight: 500; overflow-wrap: anywhere; }
.list-row-sub { font-size: var(--fs-13); color: var(--text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: var(--fs-13); font-weight: 600; white-space: nowrap;
  background: var(--fill); color: var(--text-2);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill-ok { background: var(--green-soft); color: var(--green-text); }
.pill-warn { background: var(--orange-soft); color: var(--orange-text); }
.pill-error { background: var(--red-soft); color: var(--red-text); }

.alert {
  display: flex; align-items: flex-start; gap: var(--s-3);
  margin-bottom: var(--s-6); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-card);
  font-size: var(--fs-15); line-height: 1.5;
}
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--red-soft); color: var(--red-text); }
.alert-error p { color: var(--text); }
.empty-note { font-size: var(--fs-15); color: var(--text-2); }

/* ---------- 13. Движение ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal.is-closing { animation: fade-out var(--t-fast) var(--ease) both; }
@keyframes fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .sortable-drag, .sortable-fallback { transform: none; }
}

/* ---------- 14. Адаптив ---------- */
@media (max-width: 960px) {
  .board { gap: var(--s-4); }
}
@media (max-width: 820px) {
  :root { --gutter: var(--s-4); }
  .page { padding-top: var(--s-6); padding-bottom: var(--s-12); }
  .page-title { font-size: 34px; }
  .board { grid-template-columns: 1fr; gap: var(--s-4); }
  .cards:empty { min-height: 72px; }
  .filters { flex-direction: column; align-items: stretch; gap: var(--s-3); margin-bottom: var(--s-6); }
  .filter-group { flex-direction: column; align-items: stretch; gap: var(--s-2); }
  /* Ряд тегов прокручивается до края экрана, как в iOS */
  .chips { margin-right: calc(var(--gutter) * -1); padding-right: var(--gutter); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel { padding: var(--s-5) var(--s-4); }
}
@media (max-width: 560px) {
  .brand-name { font-size: var(--fs-17); }
  .btn-logout { width: 44px; height: 44px; padding: 0; margin-right: -10px; border-radius: 50%; }
  .btn-logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .btn-logout .icon { margin: 0; }
  .page-sub { font-size: var(--fs-15); }
  .quick-add-field { min-height: 56px; padding-left: var(--s-3); }
  .quick-add-input { font-size: var(--fs-17); }
  .quick-add-submit { padding: 0 var(--s-4); }
  .segment, .chip { min-height: 32px; }
  .card-edit { top: 6px; right: 6px; width: 36px; height: 36px; }
  .card-title { padding-right: 28px; }
  .input { font-size: 16px; } /* iOS не приближает поле при фокусе */

  /* Окно правки снизу, как sheet в iOS */
  .modal { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; max-height: 92dvh; border-radius: var(--r-panel) var(--r-panel) 0 0; }
  .sheet-head { padding: var(--s-5) var(--s-4) var(--s-3); }
  .sheet-body { padding: var(--s-2) var(--s-4) var(--s-5); }
  .sheet-foot { padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .sheet-foot .btn-danger-text { margin-left: calc(var(--s-2) * -1); min-height: 44px; padding-inline: var(--s-2); }
  .sheet-actions .btn-secondary { display: none; } /* закрывает крестик в шапке */
  .sheet-actions .btn-primary { min-height: 44px; padding: 0 var(--s-6); font-size: var(--fs-17); }
  .field-row { grid-template-columns: 1fr; }
  .field-row-due { grid-template-columns: 1fr 1fr; }
  .segmented-block .segment { padding: 0 var(--s-1); }

  .auth-card { padding: var(--s-8) var(--s-6) var(--s-6); }
  .auth-title { font-size: 26px; }

  /* Разделы в шапке: только иконки с зоной касания 44px */
  .nav-link { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .nav-link-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stat { padding: var(--s-3); }
  .stat-value { font-size: var(--fs-21); }
  .panel-actions .btn { flex: 1; }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .nav-end { gap: 0; }
}
