:root {
  --brand: #016236;
  --brand-2: #03a65a;
  --brand-soft: #e7f4ec;
  --gold: #febe10;
  --gold-soft: #fff6dc;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --line: #e6e7e2;
  --line-strong: #d4d6cf;
  --text: #1c211e;
  --text-2: #4e5751;
  --muted: #7d867f;
  --danger: #c4372b;
  --danger-soft: #fdecea;
  --warn: #b86e00;
  --warn-soft: #fff3df;
  --info: #1f5fbf;
  --info-soft: #e9f0fc;
  --series-1: #0b8a4e;
  --series-2: #d99a00;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --shadow-lg: 0 10px 40px rgba(20, 30, 25, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.svg-icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .logo { padding: 18px 20px 14px; display: block; }
.sidebar .logo img { height: 30px; display: block; }
.sidebar .logo small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 4px 10px 24px; }
.nav-group { margin-top: 14px; }
.nav-backdrop { display: none; }
.nav-group > .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 4px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a .svg-icon { color: var(--muted); }
.nav a.active .svg-icon { color: var(--brand); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .burger { display: none; }
.content { padding: 24px; max-width: 1800px; width: 100%; transition: opacity .15s; }
.content.loading { opacity: .55; pointer-events: none; }
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search input { width: 100%; padding-left: 34px; background: var(--surface-2); }
.global-search .svg-icon { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: 6px; }
.search-results a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); }
.search-results a:hover, .search-results a.focus { background: var(--brand-soft); text-decoration: none; }
.search-results .sub { color: var(--muted); font-size: 12px; }
.search-results .ent { font-size: 11px; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); position: relative; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.user-chip .who { line-height: 1.2; }
.user-chip .who small { color: var(--muted); display: block; }
.menu { position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 50; }
.menu button, .menu a { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: var(--radius-sm); font: inherit; color: var(--text); cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.notif-panel { width: 380px; max-width: calc(100vw - 24px); padding: 0; right: -8px; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: min(480px, 70vh); overflow-y: auto; padding: 6px; }
.menu a.notif { display: block; padding: 9px 10px 9px 18px; border-radius: var(--radius-sm); position: relative; white-space: normal; }
.menu a.notif .t { font-weight: 600; font-size: 13.5px; }
.menu a.notif .b { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.menu a.notif .w { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.menu a.notif.unread::before { content: ""; position: absolute; left: 6px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); }
.menu a.notif:not(.unread) .t { font-weight: 500; color: var(--text-2); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.page-head .crumbs a { color: var(--muted); }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Controls ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 10px; min-height: 36px; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(3, 166, 90, .15); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); }
input[readonly], input:disabled, select:disabled { background: var(--surface-2); color: var(--text-2); }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: #c3c6bd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #014d2a; }
.btn.accent { background: var(--gold); border-color: var(--gold); color: #3a2b00; }
.btn.accent:hover { background: #f0b000; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #f0b9b3; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 36px; justify-content: center; }
.btn.sm.icon { width: 30px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 16px; }

/* ---------- Cards, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { flex: 1 1 160px; }
.period { flex-wrap: wrap; }
.period input { width: auto; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; overflow-x: auto; }
.card { min-width: 0; }
.dash table.data td { white-space: normal; }
.dash table.data td.num, .dash table.data td b { white-space: nowrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.reports-grid { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar .search { position: relative; width: 280px; }
.toolbar .search input { padding-left: 32px; }
.toolbar .search .svg-icon { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.toolbar select, .toolbar input.f { width: auto; min-width: 140px; max-width: 220px; }
.table-wrap {
  overflow-x: auto;
  /* тени по краям подсказывают, что таблицу можно прокрутить */
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(20, 30, 25, .14), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(20, 30, 25, .14), transparent) right / 10px 100% no-repeat scroll;
}
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
table.data td.num { white-space: nowrap; }
table.data th.num { text-align: right; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { font-size: 10px; margin-left: 3px; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1440px) { table.data td { max-width: 240px; } table.data th { white-space: normal; min-width: 60px; } }
@media (max-width: 1280px) { table.data td, table.data th { padding-left: 10px; padding-right: 10px; } table.data td { max-width: 180px; } }
table.data td.wrap { white-space: normal; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover td, table.data tbody tr.click:hover { background: #f7faf8; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line); padding: 9px 12px; }
table.data.compact td, table.data.compact th { padding: 6px 10px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty .svg-icon { width: 28px; height: 28px; margin-bottom: 6px; color: var(--line-strong); }

/* ---------- Badges ---------- */
.badge { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; line-height: 1.5; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0ec; color: var(--text-2); }
.badge::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; margin-right: 5px; vertical-align: 1px; }
.badge.green { background: var(--brand-soft); color: #08703f; }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.yellow { background: var(--gold-soft); color: #8a6200; }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.grey { background: #eef0ec; color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.stars { color: var(--gold); letter-spacing: 1px; }
.stars .off { color: var(--line-strong); }
.ok { color: #08703f; font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { white-space: nowrap; font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.kpi .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--brand-2); }
.kpi.warn { border-top: 3px solid var(--gold); }
.kpi.alert { border-top: 3px solid var(--danger); }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; }
.detail-grid .item .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.detail-grid .item .v { font-weight: 500; word-break: break-word; }
.detail-grid .item.full { grid-column: 1 / -1; }
.detail-grid .item .v.pre { white-space: pre-wrap; font-weight: 400; }
.section-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 12px 12px 10px; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.tabs button:focus { outline: none; }
.tabs button:focus-visible { outline: 2px solid var(--brand-2); outline-offset: -4px; border-radius: 8px; }
.tabs .count { font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 4px; color: var(--muted); }
.progress { height: 8px; background: #edefea; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-2); border-radius: 99px; }
.progress.gold > div { background: var(--gold); }
.progress-row { display: grid; grid-template-columns: 150px 1fr 140px; gap: 12px; align-items: center; margin: 8px 0; font-size: 13px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand-2); }
.timeline .when { font-size: 12px; color: var(--muted); }
.diff { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.diff del { color: var(--danger); text-decoration: line-through; }
.diff ins { color: #08703f; text-decoration: none; }
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: #173f7d; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); color: #6b4300; }
.notice.danger { background: var(--danger-soft); color: #7a1f17; }
.notice.ok { background: var(--brand-soft); color: #08502e; }

/* ---------- Lines editor ---------- */
.lines-editor table { width: 100%; border-collapse: collapse; }
.lines-editor th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 600; padding: 4px 6px; }
.lines-editor td { padding: 3px 4px; vertical-align: top; }
.lines-editor td input, .lines-editor td select { min-height: 32px; padding: 5px 8px; }
.lines-editor .total { font-size: 12.5px; color: var(--text-2); margin-top: 6px; }
.lines-editor td.pt { padding-top: 10px; }
.lines-editor .row { flex-wrap: wrap; }
@media (max-width: 640px) {
  .lines-editor thead { display: none; }
  .lines-editor table, .lines-editor tbody { display: block; }
  .lines-editor tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; position: relative; background: var(--surface-2); }
  .lines-editor td { display: block; padding: 0; min-width: 0; }
  .lines-editor td.pt { padding-top: 0; }
  .lines-editor td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
  .lines-editor td:first-child { grid-column: 1 / -1; padding-right: 34px; }
  .lines-editor td.del { position: absolute; top: 6px; right: 6px; }
  .lines-editor .total { width: 100%; text-align: left !important; }
}

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 28, 24, .42); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 760px; animation: pop .14s ease-out; }
.modal.wide { max-width: 1040px; }
.modal.narrow { max-width: 460px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 420px; }
.toast { background: #1d2a23; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .15s ease-out; display: flex; gap: 8px; align-items: flex-start; }
.toast.error { background: var(--danger); }
.toast.ok .svg-icon { color: #7ee2ae; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .hero { background: linear-gradient(160deg, #016236 0%, #014a29 70%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(254, 190, 16, .35), transparent 65%); }
.login .hero h1 { font-size: 34px; line-height: 1.15; max-width: 520px; }
.login .hero p { opacity: .85; max-width: 480px; font-size: 15px; }
.login .hero .motto { font-size: 13px; letter-spacing: .04em; opacity: .8; }
.login .hero .cats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.login .hero .cats span { border: 1px solid rgba(255, 255, 255, .3); padding: 5px 12px; border-radius: 99px; font-size: 13px; }
.login .panel { display: grid; place-items: center; padding: 32px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login form img { height: 40px; align-self: flex-start; margin-bottom: 10px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: #eef0eb; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kcol.over { outline: 2px dashed var(--brand-2); outline-offset: -2px; background: var(--brand-soft); }
.kcol-head { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px 10px; }
.kcol-head b { flex: 1; font-size: 13px; }
.kcol-head .sum { font-size: 12px; color: var(--text-2); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.kcard:hover { border-color: var(--line-strong); }
.kcard.dragging { opacity: .5; }
.kcard .t { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.kcard .c { color: var(--text-2); font-size: 12.5px; }
.kcard .m { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; }
.kcard .m b { font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tick { font-size: 11px; fill: var(--muted); }
.chart .grid-line { stroke: #eceee9; stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); }
.chart .bar { transition: opacity .12s; }
.chart .hit:hover + .bar, .chart .bar:hover { opacity: .8; }
.chart-tip { position: absolute; pointer-events: none; background: #1d2a23; color: #fff; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); margin-top: -8px; }
.chart-tip .sw, .legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; }
.hbar { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 110px; gap: 10px; align-items: center; font-size: 13px; margin: 7px 0; }
.hbar .track { height: 14px; background: #f0f1ed; border-radius: 4px; overflow: hidden; display: flex; gap: 2px; }
.hbar .track > div { height: 100%; border-radius: 0 4px 4px 0; }

/* ---------- Trace ---------- */
.trace-node { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); margin: 8px 0; }
.trace-node .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.trace-node .meta { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.trace-children { margin-left: 22px; padding-left: 14px; border-left: 2px dashed var(--line-strong); }
.trace-step { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.trace-node.origin { border-left: 4px solid var(--gold); }
.trace-node.shipment { border-left: 4px solid var(--info); }
.trace-node.root { border: 2px solid var(--brand-2); }

/* ---------- Документация API ---------- */
.doc { max-width: 980px; }
.doc h3 { margin: 22px 0 8px; }
.doc h3:first-child { margin-top: 0; }
.doc p, .doc li { color: var(--text-2); line-height: 1.6; }
.doc ol, .doc ul { padding-left: 22px; }
pre.code { position: relative; background: #17201b; color: #e3efe7; border-radius: var(--radius-sm); padding: 12px 44px 12px 14px; overflow-x: auto; font: 12.5px/1.55 var(--mono); margin: 8px 0 14px; white-space: pre; }
pre.code .copy { position: absolute; top: 6px; right: 6px; color: #b9cbbf; }
pre.code .copy:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ---------- Attachments ---------- */
.dropzone { display: block; border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--brand-2); background: var(--brand-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1680px) {
  .col-wide { display: none !important; }
}
@media (max-width: 1200px) {
  .dash .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .dash .span-2 { grid-column: auto; }
}
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1440px) {
  .reports-grid { grid-template-columns: minmax(0, 1fr); }
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 28, 24, .35); z-index: 55; }
  .topbar .burger { display: inline-flex; }
}
@media (max-width: 860px) {
  .topbar { padding: 0 16px; }
  .user-chip .who { display: none; }
  .notif-panel { position: fixed; top: 58px; right: 12px; left: 12px; width: auto; }
  .topbar > .grow { display: none; }
  .kpis, .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 20px; }
  .page-head h1 { font-size: 19px; }
  .content { padding: 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .login { grid-template-columns: 1fr; }
  .login .hero { display: none; }
  .toolbar .search { width: 100%; }
  .toolbar select, .toolbar input.f { flex: 1 1 45%; max-width: none; min-width: 0; }
  .progress-row { grid-template-columns: 1fr; gap: 4px; }
  .hbar { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; }
  .hbar .track { grid-column: 1 / -1; grid-row: 2; }
  .period { width: 100%; }
  .period input { flex: 1 1 120px; min-width: 0; }
}

.table-wrap, .card-body { container-type: inline-size; }
@container (max-width: 780px) {
  table.data.cards:not(.cards-sm) thead { display: none; }
  table.data.cards:not(.cards-sm), table.data.cards:not(.cards-sm) tbody, table.data.cards:not(.cards-sm) tfoot, table.data.cards:not(.cards-sm) tr { display: block; width: 100%; }
  table.data.cards:not(.cards-sm) tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.data.cards:not(.cards-sm) tbody tr:last-child { border-bottom: 0; }
  table.data.cards:not(.cards-sm) td, table.data.cards:not(.cards-sm) tfoot td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; max-width: none; white-space: normal; text-align: right; background: none; }
  table.data.cards:not(.cards-sm) td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; flex: none; max-width: 48%; }
  table.data.cards:not(.cards-sm) td:first-child { font-weight: 650; font-size: 14.5px; text-align: left; }
  table.data.cards:not(.cards-sm) td:first-child::before { display: none; }
  table.data.cards:not(.cards-sm) td:empty, table.data.cards:not(.cards-sm) td[data-label=""] { display: none; }
  table.data.cards:not(.cards-sm) tfoot { background: var(--surface-2); border-top: 1px solid var(--line); }
  table.data.cards:not(.cards-sm) tfoot td:not(:first-child):empty { display: none; }
  table.data.cards:not(.cards-sm) tbody tr.click:active { background: #f2f6f3; }
  table.data.cards:not(.cards-sm) tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; background: var(--line); }
  table.data.cards:not(.cards-sm) tbody tr, table.data.cards:not(.cards-sm) tbody tr:last-child { background: var(--surface); border-bottom: 0; }
}
@container (max-width: 460px) {
  table.data.cards.cards-sm thead { display: none; }
  table.data.cards.cards-sm, table.data.cards.cards-sm tbody, table.data.cards.cards-sm tfoot, table.data.cards.cards-sm tr { display: block; width: 100%; }
  table.data.cards.cards-sm tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.data.cards.cards-sm tbody tr:last-child { border-bottom: 0; }
  table.data.cards.cards-sm td, table.data.cards.cards-sm tfoot td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; max-width: none; white-space: normal; text-align: right; background: none; }
  table.data.cards.cards-sm td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; flex: none; max-width: 48%; }
  table.data.cards.cards-sm td:first-child { font-weight: 650; font-size: 14.5px; text-align: left; }
  table.data.cards.cards-sm td:first-child::before { display: none; }
  table.data.cards.cards-sm td:empty, table.data.cards.cards-sm td[data-label=""] { display: none; }
  table.data.cards.cards-sm tfoot { background: var(--surface-2); border-top: 1px solid var(--line); }
  table.data.cards.cards-sm tfoot td:not(:first-child):empty { display: none; }
  table.data.cards.cards-sm tbody tr.click:active { background: #f2f6f3; }
  table.data.cards.cards-sm tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; background: var(--line); }
  table.data.cards.cards-sm tbody tr, table.data.cards.cards-sm tbody tr:last-child { background: var(--surface); border-bottom: 0; }
}
@media (max-width: 640px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .foot-hint { display: none; }
  .modal-back { padding: 12px 10px; }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding: 12px 16px; }
  .kanban { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
  .trace-children { margin-left: 8px; padding-left: 10px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .actions, .toolbar, .pager, .tabs { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
