/* ===== Design tokens: поменяйте брендинг здесь ===== */
:root {
  --brand: #ff5a1f;          /* основной акцент */
  --brand-ink: #ffffff;      /* текст на акценте */
  --brand-soft: #fff1ea;
  --qr: #3346d3;             /* цвет QR в графиках */
  --ink: #0d1117;
  --ink-2: #2b313b;
  --muted: #6b7280;
  --line: #e7e9ee;
  --line-2: #f1f2f5;
  --bg: #f7f7f9;
  --surface: #ffffff;
  --ok: #12a150;
  --warn: #d98a00;
  --bad: #e03131;
  --idle: #9aa1ad;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(13,17,23,.05), 0 4px 16px rgba(13,17,23,.05);
  --shadow-lg: 0 24px 60px rgba(13,17,23,.14);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .g6, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font: 600 14px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .08s ease, background .15s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, black); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #cdd1d9; }
.btn-danger { background: #fff; color: var(--bad); border-color: #f4c7c7; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ===== Forms ===== */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; height: 44px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff;
  font: 400 15px var(--font); color: var(--ink); transition: border .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-error { background: #fff0f0; color: var(--bad); border: 1px solid #f6cccc; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 16px; }
.metric .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.metric .value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.metric .delta { font-size: 13px; font-weight: 600; margin-top: 2px; }
.up { color: var(--ok); }
.down { color: var(--bad); }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok { background: #e7f7ee; color: var(--ok); }
.b-warn { background: #fff5e0; color: var(--warn); }
.b-bad { background: #ffeded; color: var(--bad); }
.b-idle { background: #f1f2f5; color: var(--idle); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.b-qr { background: #eceefe; color: var(--qr); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table a { text-decoration: none; font-weight: 600; }
@media (max-width: 760px) {
  table.table.mobile-cards thead { display: none; }
  table.table.mobile-cards tr { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.table.mobile-cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 0; text-align: right; }
  table.table.mobile-cards td::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; }
  table.table.mobile-cards td.cb::before { content: ""; }
}

/* ===== Tabs / segmented ===== */
.seg { display: inline-flex; background: var(--line-2); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font: 600 13px var(--font); color: var(--muted); text-decoration: none; cursor: pointer; }
.seg a.on, .seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }

/* ===== Flash / toast ===== */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; animation: toastIn .25s ease; }
.toast.warning { background: #7a4b00; }
.toast.error { background: #a51d1d; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ===== Modal (dialog) ===== */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(13,17,23,.45); backdrop-filter: blur(2px); }
.modal-b { padding: 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfc; }

/* ===== Empty / skeleton ===== */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; font-size: 24px; }
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===== App shell ===== */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ink); color: #c9ced8; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .logo { color: #fff; margin: 4px 8px 18px; }
.sidebar a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none; font-weight: 500; font-size: 14px; color: #c9ced8; }
.sidebar a.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.nav.on { background: rgba(255,255,255,.1); color: #fff; }
.sidebar a.nav .i { width: 18px; text-align: center; opacity: .9; }
.sidebar .sect { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7684; margin: 14px 12px 4px; }
.sidebar .foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar select { background: rgba(255,255,255,.06); color: #fff; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; height: 38px; width: 100%; padding: 0 10px; }
.sidebar select option { color: #000; }
.main { padding: 28px 32px 60px; min-width: 0; }
.scrim { display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 26px; margin: 0; }
.mob-head { display: none; }
.demo-bar { background: var(--brand); color: #fff; text-align: center; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.demo-bar a { color: #fff; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .mob-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .mob-head button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; }
  .main { padding: 18px 16px 60px; }
  .topbar h1 { font-size: 22px; }
}

/* ===== Charts ===== */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars .bar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 70px; gap: 10px; align-items: center; margin: 8px 0; font-size: 14px; }
.bars .track { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; display: flex; }
.bars .fill { height: 100%; background: var(--brand); }
.bars .fill.qr { background: var(--qr); }
.split { height: 12px; border-radius: 999px; overflow: hidden; display: flex; background: var(--line-2); }
.split .a { background: var(--brand); }
.split .b { background: var(--qr); }
.heat { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 3px; font-size: 11px; }
.heat .h { color: var(--muted); text-align: right; padding-right: 6px; line-height: 16px; }
.heat .d { color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 4px; }
.heat .c { height: 16px; border-radius: 4px; background: var(--brand); }
.live li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.live li:last-child { border-bottom: 0; }
.live { list-style: none; margin: 0; padding: 0; }
.live time { color: var(--muted); font-variant-numeric: tabular-nums; width: 48px; }

/* ===== Steps / onboarding ===== */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; border-radius: 999px; background: var(--line-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.steps span.on { background: var(--ink); color: #fff; }
.steps span.done { background: #e7f7ee; color: var(--ok); }

/* ===== Auth pages ===== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 80% -10%, #ffe2d6 0, transparent 60%), var(--bg); }
.auth .card { width: min(440px, 100%); padding: 28px; }
.auth h1 { font-size: 24px; }

/* ===== Logo ===== */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; text-decoration: none; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.logo .mark svg { width: 18px; height: 18px; }

/* ===== Kanban (CRM) ===== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--line-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kcol h4 { font-size: 13px; margin: 4px 6px 10px; display: flex; justify-content: space-between; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; display: block; text-decoration: none; }
.kcard b { display: block; font-size: 14px; margin-bottom: 2px; }

/* ===== Misc ===== */
.copy { display: flex; gap: 8px; align-items: center; background: var(--line-2); border-radius: 10px; padding: 8px 10px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }
.copy span { flex: 1; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }
.lock { background: linear-gradient(135deg, #fff7f2, #fff); border: 1px dashed #ffc9b3; border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.qrbox { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; width: 180px; }
.pill-note { display: inline-block; background: #fff5e0; color: #8a5a00; padding: 6px 12px; border-radius: 10px; font-size: 13px; }
.notif-dot { display: inline-block; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; padding: 0 5px; margin-left: auto; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
@media (max-width: 960px) { [data-resp] { grid-template-columns: minmax(0, 1fr) !important; } }
@media print { .btn, .toasts, .sidebar, .mob-head, a.small { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
.table th.right, .table td.right { text-align: right; }
