/* Кабинет группы — рабочие экраны логиста. Светлая и тёмная тема, 360–1440 px. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --text: #1c2129;
  --muted: #667085;
  --accent: #1f8a3b;        /* «Новая отгрузка», «Назначить» */
  --accent-ink: #ffffff;
  --accent-soft: #e6f4ea;
  --free: #e7f5ea;          /* свободна */
  --free-ink: #1f8a3b;
  --go: #2f6fde;            /* едет с грузом, выгрузка */
  --go-ink: #ffffff;
  --back: #a3bff2;          /* едет обратно пустая */
  --back-ink: #13294f;
  --pos: #cddcf7;           /* едет к погрузке */
  --pos-ink: #13294f;
  --repair: #9aa0a8;
  --repair-ink: #ffffff;
  --today: #fff6cf;
  --today-line: #e8c547;
  --weekend: #fafbfc;
  --warn: #c4720c;
  --warn-soft: #fdf1df;
  --danger: #c2372b;
  --danger-soft: #fdecea;
  --soon: #2f6fde;
  --busy: #d98a84;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --line: #2a3039; --line-strong: #39404b;
    --text: #e7eaee; --muted: #98a2b3; --accent: #34a853; --accent-ink: #08130b; --accent-soft: #15301d;
    --free: #15291b; --free-ink: #6fd28b; --go: #3d7cf0; --back: #34507f; --back-ink: #e4ecfb; --pos: #253753; --pos-ink: #d8e3f8;
    --repair: #5d636c; --today: #3a3214; --today-line: #b89a2c; --weekend: #14181d;
    --warn: #e3a04a; --warn-soft: #33260f; --danger: #ef7a6f; --danger-soft: #3a1714; --busy: #9e5b56;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --line: #2a3039; --line-strong: #39404b;
  --text: #e7eaee; --muted: #98a2b3; --accent: #34a853; --accent-ink: #08130b; --accent-soft: #15301d;
  --free: #15291b; --free-ink: #6fd28b; --go: #3d7cf0; --back: #34507f; --back-ink: #e4ecfb; --pos: #253753; --pos-ink: #d8e3f8;
  --repair: #5d636c; --today: #3a3214; --today-line: #b89a2c; --weekend: #14181d;
  --warn: #e3a04a; --warn-soft: #33260f; --danger: #ef7a6f; --danger-soft: #3a1714; --busy: #9e5b56;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--go); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--go); outline-offset: 2px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent) 0 50%, var(--go) 50% 100%); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-right form { margin: 0; }
.me { color: var(--text); font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; width: 34px; height: 34px; display: inline-grid; place-items: center; cursor: pointer; }
.corner { position: fixed; top: 12px; right: 16px; }
.link-btn { border: 0; background: none; color: var(--go); cursor: pointer; padding: 0; font: inherit; }

.main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px; flex: 1; }
.main-narrow { max-width: 420px; padding-top: 12vh; }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 16px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.crumbs { margin: 0 0 4px; font-size: 13px; }

/* кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-outline { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost { border-color: var(--line); }
.btn-danger { color: var(--danger); }
.btn-wide { width: 100%; }
.form { display: grid; gap: 14px; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; min-width: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 15px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
input:disabled, select:disabled { opacity: .75; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.actions form { margin: 0; }
.inline-form { display: flex; gap: 8px; margin: 0 0 8px; }
.inline-form input { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.empty { text-align: center; padding: 32px; }
.empty .btn { margin-top: 8px; }
.login-card h1 { font-size: 22px; }
.login-card .form { margin-top: 16px; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; overflow-wrap: anywhere; }
.flash-ok { background: var(--accent-soft); color: var(--free-ink); }
.flash-err { background: var(--danger-soft); color: var(--danger); }

/* счётчики */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 130px; display: grid; }
.stat b { font-size: 28px; line-height: 1.1; }
.stat span { color: var(--text); }
.c-free { color: var(--free-ink); } .c-go { color: var(--go); } .c-back { color: #5c7fc4; } .c-repair { color: var(--repair); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.filters label { min-width: 150px; }
.filters select { min-height: 38px; padding: 6px 10px; }
.filters .check { min-width: 0; padding-bottom: 8px; }
.pager { margin-left: auto; display: flex; gap: 6px; }
.pager .btn { min-height: 38px; padding: 6px 12px; }

/* график */
.gantt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); -webkit-overflow-scrolling: touch; }
.gantt { display: grid; grid-template-columns: minmax(170px, 240px) repeat(var(--days), minmax(76px, 1fr)); grid-auto-rows: minmax(76px, auto); grid-template-rows: 52px; min-width: max-content; }
.g-head { display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 500; font-size: 14px; border-bottom: 1px solid var(--line-strong); border-left: 1px solid var(--line); background: var(--surface-2); }
.g-head small { color: var(--muted); font-size: 11px; font-weight: 400; }
.g-head.is-weekend small { color: var(--danger); }
.g-head.is-today { background: var(--today); box-shadow: inset 0 -2px 0 var(--today-line); }
.g-name { position: sticky; left: 0; z-index: 3; background: var(--surface); padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; min-width: 0; box-shadow: 1px 0 0 var(--line-strong); }
.g-head.g-name { align-items: flex-start; background: var(--surface-2); z-index: 4; }
.g-name a { color: var(--text); }
.g-name b { font-size: 15px; letter-spacing: .01em; }
.g-name small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.g-cell { border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.g-cell.is-free { background: var(--free); }
.g-cell.is-today { background: var(--today); }
.g-cell.is-free.is-today { background: color-mix(in srgb, var(--today) 70%, var(--free)); }
.g-bar { z-index: 2; align-self: center; margin: 0 3px; height: 40px; border: 0; border-radius: 6px; padding: 0 10px; font: inherit; font-size: 14px; text-align: left; cursor: pointer; overflow: hidden; display: flex; align-items: center; min-width: 0; }
.g-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-bar:hover { filter: brightness(1.07); }
.g-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.g-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.k-go, .k-unload { background: var(--go); color: var(--go-ink); }
.k-back { background: var(--back); color: var(--back-ink); }
.k-pos { background: var(--pos); color: var(--pos-ink); }
.k-repair, .k-dayoff { background: var(--repair); color: var(--repair-ink); }
.k-free { background: var(--free); border: 1px solid var(--free-ink); }
.g-none { padding: 24px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; list-style: none; padding: 0; margin: 14px 0 0; color: var(--text); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 22px; height: 22px; border-radius: 5px; display: inline-block; }

/* окно деталей */
.sheet { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.sheet::backdrop { background: rgba(10, 14, 20, .45); }
.sheet-body { padding: 20px 20px 8px; }
.sheet form { padding: 0 20px 20px; margin: 0; }
.lead { font-size: 16px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 12px 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* списки */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.list { display: grid; gap: 8px; }
.row-card { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.row-card:hover { text-decoration: none; border-color: var(--line-strong); }
.row-card.is-off { opacity: .6; }
.rc-main { display: grid; gap: 2px; min-width: 0; }
.rc-main > * { overflow-wrap: anywhere; }
.rc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.date { font-weight: 600; }
.plain { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.down-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.down-row form { margin: 0; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.b-free { background: var(--accent); color: var(--accent-ink); }
.b-soon { background: var(--soon); color: #fff; }
.b-back { background: #6b4bc8; color: #fff; }
.b-busy { background: var(--busy); color: #fff; }
.b-own { background: #d4900f; color: #fff; }
.s-new { background: var(--warn-soft); color: var(--warn); }
.s-assigned { background: var(--accent-soft); color: var(--free-ink); }
.s-cancelled { background: var(--surface-2); color: var(--muted); }

/* отгрузка и подбор */
.split { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 24px; align-items: start; }
.split > .card + .card { margin-top: 0; }
.fields { display: grid; gap: 4px; margin: 0 0 12px; }
.fields dt { color: var(--muted); font-size: 13px; margin-top: 8px; }
.fields dd { margin: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
.picks h2 { margin-bottom: 12px; }
.cand { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.cand + .cand { margin-top: 12px; }
.cand-body { min-width: 0; }
.cand-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.cand-title b { font-size: 16px; }
.cand p { margin: 2px 0; color: var(--muted); }
.cand p:first-of-type { color: var(--muted); }
.cand-act form { margin: 0; }
.cand.st-busy { opacity: .6; }
.cand.st-busy .btn-outline { border-color: var(--line-strong); color: var(--free-ink); }
.variants { margin-bottom: 20px; }
.variant .v-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.variant ul { margin: 0 0 12px; padding-left: 18px; }
.variant form { margin: 0; }
.users .user-row { display: grid; grid-template-columns: 1fr 150px 140px auto; gap: 8px; align-items: center; margin: 0; }
.users li { display: grid; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.u-name { display: grid; gap: 2px; }
.users li > form:last-child { margin: 0; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { padding: 8px 16px; gap: 8px; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .me { display: none; }
  .main { padding: 16px; }
  h1 { font-size: 22px; }
  .grid2 { grid-template-columns: 1fr; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { min-width: 0; padding: 10px 12px; }
  .stat b { font-size: 24px; }
  .filters label { min-width: calc(50% - 6px); flex: 1; }
  .pager { margin-left: 0; width: 100%; }
  .pager .btn { flex: 1; }
  .gantt { grid-template-columns: 132px repeat(var(--days), 64px); grid-auto-rows: minmax(64px, auto); }
  .g-name { padding: 8px 10px; }
  .g-name b { font-size: 13px; }
  .g-name small { font-size: 11px; }
  .g-bar { height: 34px; font-size: 12px; padding: 0 6px; }
  .cand { flex-direction: column; align-items: stretch; }
  .cand-act .btn { width: 100%; }
  .page-head .btn { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  .users .user-row { grid-template-columns: 1fr 1fr; }
  .users .user-row .u-name { grid-column: 1 / -1; }
  .row-card { padding: 12px 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .g-bar, .row-card { transition: filter .12s ease, background-color .12s ease, border-color .12s ease; }
}
