/* USN·IT — админка выездной службы.
   Идея: диспетчерская. Задача — «наряд» с отрывным корешком и номером-биркой,
   цвет статуса — как маркировка патч-корда. Всё остальное — тихое и плотное. */

/* ─── Шрифты (лежат локально, никаких внешних запросов) ─── */
@font-face { font-family: "Unbounded"; font-weight: 600; font-display: swap; src: url(fonts/unbounded-cyr-600.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-weight: 600; font-display: swap; src: url(fonts/unbounded-lat-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD; }
@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(fonts/golos-cyr-400.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(fonts/golos-lat-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(fonts/golos-cyr-500.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(fonts/golos-lat-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(fonts/golos-cyr-600.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(fonts/golos-lat-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD; }
@font-face { font-family: "JB Mono"; font-weight: 500; font-display: swap; src: url(fonts/jbmono-cyr-500.woff2) format("woff2"); unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: "JB Mono"; font-weight: 500; font-display: swap; src: url(fonts/jbmono-lat-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD; }

/* ─── Токены ─── */
:root {
  --bg: #E9EDF1;        /* сталь кабельного лотка */
  --surface: #FFFFFF;
  --surface-2: #F4F6F8;
  --ink: #16202A;       /* основной текст и главные кнопки */
  --ink-2: #536170;     /* подписи */
  --line: #D3DAE1;
  --bar: #16202A;       /* верхняя панель */
  --bar-ink: #E6EBF0;

  --s-new: #D9480F;     /* сигнальный оранжевый */
  --s-wip: #1971C2;
  --s-waiting: #D99A00;
  --s-done: #2F9E44;
  --danger: #C92A2A;

  --font-display: "Unbounded", "Golos", system-ui, sans-serif;
  --font-body: "Golos", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JB Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r: 6px;
  --shadow: 0 1px 2px rgb(22 32 42 / .06), 0 2px 8px rgb(22 32 42 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F151B; --surface: #172029; --surface-2: #1D2833; --ink: #E6EBF0; --ink-2: #97A6B4;
    --line: #2A3642; --bar: #0A0F14; --bar-ink: #E6EBF0;
    --s-new: #FF6B2C; --s-wip: #4DA3FF; --s-waiting: #F5B82E; --s-done: #51CF66; --danger: #FF6B6B;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

/* ─── База ─── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font-body); }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.mono { font-family: var(--font-mono); font-weight: 500; font-feature-settings: "zero"; }
.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--s-wip); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Верхняя панель ─── */
.bar { background: var(--bar); color: var(--bar-ink); }
.bar-in { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 28px; min-height: 56px; }
.brand { font: 600 15px/1 var(--font-display); letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.brand b { color: var(--s-new); font-weight: 600; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 12px; border-radius: var(--r); text-decoration: none; color: color-mix(in srgb, var(--bar-ink) 70%, transparent); font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--bar-ink); background: rgb(255 255 255 / .06); }
.nav a[aria-current="page"] { color: var(--bar-ink); background: rgb(255 255 255 / .1); }
.nav .count { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 10px; background: var(--s-new); color: #fff; font: 500 12px/20px var(--font-mono); text-align: center; }
.logout button { background: none; border: 0; color: color-mix(in srgb, var(--bar-ink) 60%, transparent); font: inherit; cursor: pointer; padding: 8px 0; }
.logout button:hover { color: var(--bar-ink); }

/* ─── Страница ─── */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 20px 64px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.head h1 { font: 600 26px/1.15 var(--font-display); letter-spacing: -.01em; }
.head .sub { margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.head .sub b { color: var(--ink); font: 500 14px/1 var(--font-mono); }
.back { display: inline-block; margin-bottom: 12px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }
h2.section { font: 600 13px/1 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin: 32px 0 12px; }

/* ─── Кнопки ─── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 14px/1.2 var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn-main { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-main:hover { opacity: .88; border-color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-s { padding: 6px 11px; font-size: 13px; }
.btn[data-s] { border-left: 4px solid var(--sc); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Цвет статуса через одну переменную --sc */
[data-s="new"] { --sc: var(--s-new); }
[data-s="wip"] { --sc: var(--s-wip); }
[data-s="waiting"] { --sc: var(--s-waiting); }
[data-s="done"] { --sc: var(--s-done); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sc); flex: none; }
.tag { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }

/* ─── Сообщения ─── */
.flash { margin-bottom: 20px; padding: 11px 16px; border-radius: var(--r); background: var(--surface); border-left: 4px solid var(--s-done); box-shadow: var(--shadow); }
.flash-error { border-left-color: var(--danger); }

/* ─── Доска выездов ─── */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.col-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 12px; border-bottom: 2px solid var(--sc); margin-bottom: 14px; }
.col-head h2 { font: 600 14px/1 var(--font-display); }
.col-head .n { margin-left: auto; font: 500 13px/1 var(--font-mono); color: var(--ink-2); }
.col-empty { padding: 28px 12px; text-align: center; color: var(--ink-2); font-size: 14px; border: 1px dashed var(--line); border-radius: var(--r); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.board > section { min-width: 0; }

/* Наряд: корешок слева, перфорация, тело */
.ticket { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); min-width: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.ticket:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgb(22 32 42 / .08), 0 8px 20px rgb(22 32 42 / .08); }
.stub { position: relative; padding: 14px 8px 14px 14px; border-left: 4px solid var(--sc); border-radius: var(--r) 0 0 var(--r); background: color-mix(in srgb, var(--sc) 7%, var(--surface)); display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.stub::after { content: ""; position: absolute; top: 8px; bottom: 8px; right: -1px; border-right: 2px dashed var(--line); }
.stub-no { font: 500 13px/1.2 var(--font-mono); }
.stub-no small { display: block; font-size: 10px; color: var(--ink-2); letter-spacing: .06em; }
.stub-age { font: 500 11px/1.2 var(--font-mono); color: var(--ink-2); }
/* вырубки перфорации сверху и снизу */
.ticket::before, .ticket::after { content: ""; position: absolute; left: 72px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--bg); }
.ticket::before { top: -6px; }
.ticket::after { bottom: -6px; }
.t-body { padding: 13px 16px 14px 18px; min-width: 0; }
.t-company { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.t-desc { margin-top: 4px; overflow-wrap: anywhere; color: var(--ink-2); font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.t-meta .who { color: var(--ink); font-weight: 500; }
.t-note { margin-top: 10px; padding: 7px 10px; border-radius: 4px; background: color-mix(in srgb, var(--s-waiting) 14%, var(--surface)); font-size: 13px; line-height: 1.4; }

/* ─── Фильтры и поиск ─── */
.filters { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; margin-bottom: 16px; }
.chip { padding: 7px 12px; border-radius: 20px; text-decoration: none; color: var(--ink-2); font-size: 14px; font-weight: 500; display: inline-flex; gap: 7px; align-items: center; }
.chip:hover { color: var(--ink); background: var(--surface); }
.chip[aria-current="true"] { background: var(--ink); color: var(--surface); }
.chip .mono { font-size: 12px; opacity: .7; }
.search { display: flex; gap: 8px; margin-left: auto; }
.search input { width: 260px; max-width: 100%; }

/* ─── Таблицы ─── */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); padding: 14px 14px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
td.rail { box-shadow: inset 4px 0 0 var(--sc); padding-left: 18px; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
td a.cell { text-decoration: none; font-weight: 600; }
td a.cell:hover { text-decoration: underline; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 0 14px; }

/* ─── Карточка задачи ─── */
.detail { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px 24px; }
.panel + .panel { margin-top: 20px; }
.panel h2 { font: 600 13px/1 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 16px; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.facts dt { color: var(--ink-2); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 10px; }
.big-tag { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: 20px; background: color-mix(in srgb, var(--sc) 14%, var(--surface)); font-weight: 600; font-size: 14px; }
.actions { display: grid; gap: 10px; }
.actions form { display: contents; }
.actions .btn { justify-content: flex-start; }
.wait-form { display: grid; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--surface-2); }

/* Хронология: вертикальная линия, точка цвета статуса */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 6px; background: var(--sc, var(--ink-2)); }
.timeline .when { font: 500 12px/1.3 var(--font-mono); color: var(--ink-2); }
.timeline .what { font-size: 14px; }
.timeline .why { margin-top: 4px; font-size: 14px; color: var(--ink-2); font-style: italic; }

/* ─── Формы ─── */
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 16px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: 400 15px/1.4 var(--font-body);
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--s-wip); box-shadow: 0 0 0 3px color-mix(in srgb, var(--s-wip) 20%, transparent); }
.form { max-width: 640px; }
.form-foot { display: flex; gap: 10px; margin-top: 24px; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
[hidden] { display: none !important; }

/* ─── Поставки ─── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="true"] { color: var(--ink); border-color: var(--ink); }
.thumb { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: var(--surface-2); display: block; }
.thumb-empty { display: grid; place-items: center; color: var(--ink-2); font-size: 18px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }

/* ─── Люди ─── */
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .who { flex: 1; min-width: 200px; }
.person .who b { display: block; }
.person form { display: flex; gap: 6px; }
.person select { width: auto; padding: 6px 10px; font-size: 14px; }
.request { border-left: 4px solid var(--s-new); }

/* ─── Вход ─── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; }
.login-mark { font: 600 22px/1 var(--font-display); margin-bottom: 6px; }
.login-mark b { color: var(--s-new); font-weight: 600; }
.login-sub { color: var(--ink-2); margin: 0 0 28px; }
.login .panel { padding: 28px; }
.login .btn-main { width: 100%; justify-content: center; margin-top: 24px; padding: 11px; }

/* ─── Мобильные ─── */
@media (max-width: 960px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail > aside { order: -1; } /* на телефоне кнопки статуса — первыми */
}
@media (max-width: 640px) {
  .bar-in { flex-wrap: wrap; gap: 4px 16px; padding: 10px 16px 0; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -4px; }
  .logout { margin-left: auto; }
  .page { padding: 20px 16px 48px; }
  .head h1 { font-size: 21px; }
  .search { margin-left: 0; width: 100%; }
  .search input { flex: 1; width: auto; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 10px; }
  .panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
