/* ════════════════════════════════════════════════════════════
   Nextty Operations Cockpit — LIGHT SaaS design system
   Hanken Grotesk + JetBrains Mono · OKLCH navy-tinted · airy
   ════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* surfaces — soft, low-glare (no pure white) */
  --bg:        oklch(0.955 0.008 255);   /* app background base */
  --surface:   oklch(0.992 0.003 255);   /* cards / panels (off-white) */
  --surface-2: oklch(0.972 0.005 255);   /* insets / inputs */
  --surface-3: oklch(0.945 0.008 255);   /* hover / subtle fill */
  --line:      oklch(0.905 0.009 255);   /* borders */
  --line-soft: oklch(0.935 0.007 255);

  /* ink — near-black for crisp, high-contrast text */
  --ink:       oklch(0.18 0.012 262);    /* primary text (almost black) */
  --ink-dim:   oklch(0.37 0.018 260);    /* secondary */
  --ink-faint: oklch(0.52 0.016 258);    /* labels / tertiary */

  --navy:      oklch(0.26 0.035 258);    /* primary action fill */
  --navy-hi:   oklch(0.32 0.04 258);

  --accent:    oklch(0.84 0.16 90);      /* brand yellow #F5C518 */
  --accent-soft: oklch(0.93 0.09 92);
  --accent-tint: oklch(0.965 0.045 95);

  --ok:        oklch(0.55 0.13 155);
  --ok-tint:   oklch(0.96 0.045 158);
  --warn:      oklch(0.58 0.12 65);
  --warn-tint: oklch(0.965 0.05 80);
  --err:       oklch(0.55 0.18 25);
  --err-tint:  oklch(0.965 0.035 25);

  /* 4pt scale */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:24px; --sp-6:32px; --sp-7:48px; --sp-8:64px;
  --r-sm:8px; --r-md:12px; --r-lg:16px; --r-xl:22px;

  --mono:'JetBrains Mono', ui-monospace, monospace;
  --sans:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --sidebar-w: 248px;
  --shadow-sm: 0 1px 2px oklch(0.27 0.03 256 / 0.06), 0 1px 3px oklch(0.27 0.03 256 / 0.04);
  --shadow-md: 0 1px 2px oklch(0.27 0.03 256 / 0.05), 0 6px 20px oklch(0.27 0.03 256 / 0.07);
  --shadow-lg: 0 2px 4px oklch(0.27 0.03 256 / 0.05), 0 16px 40px oklch(0.27 0.03 256 / 0.10);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1100px 760px at 78% -8%, oklch(0.985 0.014 248), transparent 55%),
    radial-gradient(900px 700px at 0% 110%, oklch(0.965 0.016 95 / 0.5), transparent 50%),
    linear-gradient(176deg, oklch(0.972 0.006 255) 0%, oklch(0.934 0.013 256) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, .btn-link:focus-visible, .nav-item:focus-visible { outline-offset: 3px; }

/* ─────────────── App shell ─────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns 0.28s var(--ease); }
.app.nav-collapsed { grid-template-columns: 0 1fr; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: oklch(0.985 0.004 255 / 0.7);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-3);
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s var(--ease);
}
.app.nav-collapsed .sidebar { border-right-color: transparent; opacity: 0; pointer-events: none; }

/* sidebar collapse toggle */
.sidebar-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; flex: 0 0 38px;
  background: var(--surface); color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: none; cursor: pointer;
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--ink); border-color: var(--ink-faint); }
.sidebar-toggle svg { width: 19px; height: 19px; stroke: currentColor; }
.topbar-left { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.sidebar .brand {
  display: flex; align-items: baseline; gap: 2px;
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em;
  padding: 0 var(--sp-3) var(--sp-2);
}
.sidebar .brand .dot { color: var(--accent); }
.sidebar .brand-sub {
  font-size: 10.5px; font-weight: 600; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.14em;
  padding: 0 var(--sp-3) var(--sp-5);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); padding: var(--sp-4) var(--sp-3) var(--sp-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3); border-radius: var(--r-sm);
  color: var(--ink-dim); text-decoration: none;
  font-size: 14.5px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; opacity: 0.8; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--accent-tint); color: var(--ink); font-weight: 700; }
.nav-item.active svg { color: oklch(0.6 0.13 80); opacity: 1; }
.sidebar-foot { margin-top: auto; padding: var(--sp-4) var(--sp-3) 0; font-size: 12px; color: var(--ink-faint); border-top: 1px solid var(--line-soft); }

.main-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: oklch(0.975 0.006 255 / 0.72); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
}
.topbar .page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.topbar .page-title small { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-faint); margin-top: 1px; }
.topbar-meta { display: flex; align-items: center; gap: var(--sp-4); color: var(--ink-faint); font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-meta b { color: var(--ink-dim); font-weight: 700; }

.page { padding: var(--sp-6); max-width: 1500px; width: 100%; }

.model-select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 10px; font-family: var(--mono);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.model-select:focus { outline: none; border-color: var(--navy); }

/* ─────────────── Layout primitives ─────────────── */
.workbench {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-areas: "input pipeline" "results results";
  gap: var(--sp-5);
}
.stack { display: flex; flex-direction: column; gap: var(--sp-5); max-width: 1080px; }
.input { grid-area: input; }
.pipeline { grid-area: pipeline; max-height: 720px; overflow: auto; }
.results { grid-area: results; }

section, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
h2 { margin: 0 0 var(--sp-4); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
h3 { margin: 0 0 var(--sp-3); font-size: 15px; font-weight: 700; }
.hint { color: var(--ink-faint); margin: 0 0 var(--sp-4); font-size: 13.5px; max-width: 72ch; }

/* ─────────────── Forms ─────────────── */
textarea, input, select { font-family: var(--sans); }
textarea {
  width: 100%; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-size: 14px; line-height: 1.6; resize: vertical;
}
textarea::placeholder { color: var(--ink-faint); }
textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px oklch(0.26 0.035 258 / 0.1); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }
.form-grid label, label.field {
  display: flex; flex-direction: column; gap: var(--sp-2);
  font-size: 11.5px; font-weight: 700; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.form-grid input, .form-grid select, label.field input, label.field select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--sp-3); font-size: 15px; text-transform: none; letter-spacing: 0;
}
.form-grid input:focus, .form-grid select:focus, label.field input:focus, label.field select:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px oklch(0.26 0.035 258 / 0.1);
}

.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

button {
  background: var(--navy); color: oklch(0.99 0 0);
  border: none; padding: var(--sp-3) var(--sp-5); border-radius: var(--r-sm);
  font-family: var(--sans); font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform 0.1s var(--ease), background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
button:hover { background: var(--navy-hi); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
button.secondary { background: var(--surface); color: var(--ink-dim); border: 1px solid var(--line); box-shadow: none; }
button.secondary:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--surface-3); }
button.gate-btn { background: var(--ok); color: oklch(0.99 0 0); }
button.gate-btn:hover { background: oklch(0.5 0.13 155); }

.btn-link {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-dim);
  text-decoration: none; font-size: 14px; font-weight: 600; transition: color 0.15s, border-color 0.15s;
}
.btn-link:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ─────────────── Pipeline / process log ─────────────── */
.steps { list-style: none; padding: 0; margin: 0; }
.proc-log { margin: 0 0 var(--sp-3); }
.proc-log:empty { display: none; }
.step { display: flex; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line-soft); animation: fade 0.3s var(--ease); }
.step:last-child { border-bottom: none; }
.step .dot { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 7px; box-shadow: 0 0 0 4px var(--accent-tint); }
.step.done .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-tint); }
.step.error .dot { background: var(--err); box-shadow: 0 0 0 4px var(--err-tint); }
.step.info .dot { background: var(--ink-faint); box-shadow: none; }
.step.working .dot { animation: pulse 1.2s infinite; }
.step .body { flex: 1; min-width: 0; }
.step .title { font-weight: 600; font-size: 14px; }
.step .detail { color: var(--ink-faint); font-size: 13px; margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.step .detail .code { font-family: var(--mono); color: oklch(0.55 0.12 80); }
.step .detail details { margin-top: var(--sp-2); }
.step .detail summary { cursor: pointer; color: var(--navy); font-size: 12.5px; }
.step .detail ul { margin: var(--sp-2) 0 0; padding-left: 18px; font-size: 13px; }

@keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px var(--accent-tint); } 50% { box-shadow: 0 0 0 10px transparent; } }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ─────────────── Summary / totals ─────────────── */
.summary { color: var(--ink-dim); margin-bottom: var(--sp-4); font-size: 14px; }
.summary b { color: var(--ink); }
.totals {
  display: flex; gap: var(--sp-5); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4);
  background: var(--accent-tint); border: 1px solid var(--accent-soft); border-radius: var(--r-md);
}
.totals .kv { font-size: 13px; color: var(--ink-faint); }
.totals .kv b { color: var(--ink); font-family: var(--mono); font-size: 16px; margin-left: var(--sp-2); }

/* ─────────────── Tables ─────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: var(--sp-3) var(--sp-2); text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--ink-faint); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; font-weight: 700; }
tr:last-child td { border-bottom: none; }
td.code { font-family: var(--mono); color: oklch(0.5 0.1 80); white-space: nowrap; font-weight: 600; }
td.name { font-weight: 600; }
td.rationale { color: var(--ink-faint); font-size: 13px; }
td.rates, td.pkg { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.pkg { line-height: 1.7; }
.pkg-label { color: var(--ink-faint); display: inline-block; min-width: 56px; }
.pkg-charge { color: oklch(0.5 0.1 80); font-weight: 600; }

.conf { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.conf.high { background: var(--ok-tint); color: var(--ok); }
.conf.med  { background: var(--warn-tint); color: var(--warn); }
.conf.low  { background: var(--err-tint); color: var(--err); }

.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); font-size: 12px; margin: 2px 4px 0 0; }
.tag.warn { background: var(--warn-tint); color: var(--warn); }
.tag.red  { background: var(--err-tint); color: var(--err); }

/* clickable rows (cases list) */
tr.case-row { transition: background 0.12s; }
tr.case-row:hover { background: var(--surface-3); }

/* ─────────────── Quote cards ─────────────── */
.quote-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-2); }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4); box-shadow: var(--shadow-sm); transition: transform 0.12s var(--ease), box-shadow 0.15s; }
.qcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.qcard-best { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok-tint), var(--shadow-sm); }
.qcard-picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint), var(--shadow-sm); }
.qcard-disabled { opacity: 0.5; }
.qcard-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.qcard-svc { font-family: var(--mono); font-weight: 700; color: var(--navy); font-size: 17px; }
.qcard-name { font-size: 13px; color: var(--ink-faint); }
.qcard-badge { font-size: 11px; padding: 2px 7px; border-radius: var(--r-sm); font-weight: 700; }
.qcard-badge.best { background: var(--ok-tint); color: var(--ok); }
.qcard-badge.fast { background: var(--accent-tint); color: oklch(0.55 0.12 80); }
.qcard-badge.fail { background: var(--err-tint); color: var(--err); }
.qcard-price { font-family: var(--mono); }
.qcard-eur { font-size: 24px; font-weight: 700; color: var(--ink); }
.qcard-uah { font-size: 15px; color: var(--ink-dim); margin-left: var(--sp-3); }
.qcard-meta { font-size: 12px; color: var(--ink-faint); margin-top: var(--sp-2); font-family: var(--mono); }
.qcard-error { font-size: 12px; color: var(--err); margin-top: var(--sp-2); }
.qcard-details { margin-top: var(--sp-3); font-size: 13px; }
.qcard-details summary { cursor: pointer; color: var(--ink-faint); }
.qcard-details ul { margin: var(--sp-2) 0 0; padding-left: 18px; color: var(--ink-faint); }

/* ─────────────── Cases wizard ─────────────── */
.case-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.case-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.case-title .pill { font-family: var(--mono); color: var(--ink-faint); font-size: 18px; font-weight: 600; }
.case-sub { color: var(--ink-faint); font-size: 14px; margin-top: var(--sp-1); }
.rail { display: flex; align-items: center; gap: var(--sp-1); }
.rail .seg { width: 28px; height: 5px; border-radius: 999px; background: var(--line); transition: background 0.3s var(--ease); }
.rail .seg.done { background: var(--ok); }
.rail .seg.current { background: var(--accent); }

.wizard { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 1080px; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color 0.25s, box-shadow 0.25s, opacity 0.25s; }
.stage.active { border-color: var(--accent-soft); box-shadow: var(--shadow-md); }
.stage.locked { opacity: 0.55; }
.stage-head { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); cursor: pointer; user-select: none; }
.stage.locked .stage-head { cursor: not-allowed; }
.stage-num { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; font-family: var(--mono); background: var(--surface-3); border: 1.5px solid var(--line); color: var(--ink-faint); transition: all 0.25s var(--ease); }
.stage.active .stage-num { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.stage.done .stage-num { background: var(--ok); border-color: var(--ok); color: oklch(0.99 0 0); }
.stage-titles { flex: 1; min-width: 0; }
.stage-name { font-size: 16px; font-weight: 700; }
.stage.locked .stage-name { color: var(--ink-faint); }
.stage-summary { font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.stage-status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.stage-status.s-done { background: var(--ok-tint); color: var(--ok); }
.stage-status.s-active { background: var(--accent-tint); color: oklch(0.55 0.12 80); }
.stage-status.s-locked { background: var(--surface-3); color: var(--ink-faint); }
.stage-body-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.32s var(--ease); }
.stage.active .stage-body-wrap { grid-template-rows: 1fr; }
.stage-body { overflow: hidden; }
.stage-body-inner { padding: var(--sp-5); border-top: 1px solid var(--line-soft); }

/* editable items table */
.tbl-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.items-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-tbl th { font-size: 10.5px; padding: var(--sp-2); color: var(--ink-faint); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; border-bottom: 1px solid var(--line); }
.items-tbl td { padding: 3px; border-bottom: 1px solid var(--line-soft); }
.items-tbl input.cell { width: 100%; min-width: 64px; background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 6px; padding: var(--sp-2); font-size: 13px; font-family: var(--sans); }
.items-tbl input.cell:hover { border-color: var(--line); background: var(--surface-2); }
.items-tbl input.cell:focus { outline: none; background: var(--surface); border-color: var(--navy); }
.items-tbl input.cell.ro { color: oklch(0.5 0.1 80); font-family: var(--mono); font-weight: 600; }
.items-tbl .flags-row td { padding: 0 var(--sp-2) var(--sp-2); }

/* offer breakdown */
.offer-card { margin-top: var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.offer-card table { font-size: 14px; }
.offer-card td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.offer-card td:last-child { text-align: right; font-family: var(--mono); }
.offer-card tr.sub td { color: var(--ink-dim); }
.offer-card tr.total td { font-weight: 800; font-size: 17px; background: var(--accent-tint); border-bottom: none; }
.offer-card tr.total td:last-child { color: var(--ink); }

/* ─────────────── Misc ─────────────── */
.creds-warning {
  background: var(--warn-tint); border: 1px solid oklch(0.85 0.08 80); border-radius: var(--r-md);
  padding: var(--sp-4); margin-bottom: var(--sp-4); font-size: 14px; line-height: 1.6;
}
.creds-warning code { background: oklch(0.27 0.03 256 / 0.08); padding: 1px 6px; border-radius: 4px; font-family: var(--mono); }
.creds-warning pre, .request-json {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: var(--sp-3); margin: var(--sp-2) 0; font-size: 12.5px; overflow: auto; font-family: var(--mono); color: var(--ink-dim);
}
.request-json { max-height: 400px; }
.boxes-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin: var(--sp-2) 0 var(--sp-3); }
.boxes-table { width: 100%; border-collapse: collapse; }
.boxes-table th { font-size: 11px; padding: var(--sp-2) var(--sp-1); border: none; }
.boxes-table td { padding: var(--sp-1); border: none; }
.boxes-table input { width: 100%; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: var(--sp-2); font-size: 14px; font-family: var(--mono); }
.boxes-table input:focus { outline: none; border-color: var(--navy); }
.boxes-table .b-del { padding: var(--sp-2) var(--sp-3); }

/* ─────────────── CRM: clients ─────────────── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.client-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-4); box-shadow: var(--shadow-sm); transition: transform 0.12s var(--ease), box-shadow 0.15s, border-color 0.15s;
}
.client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--ink-faint); }
.client-card-top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-tint); color: oklch(0.45 0.1 80); font-weight: 800; font-size: 18px;
}
.client-name { font-weight: 700; font-size: 15px; }
.client-co { font-size: 12.5px; color: var(--ink-faint); }
.client-stats { display: flex; gap: var(--sp-4); font-size: 13px; color: var(--ink-faint); }
.client-stats b { color: var(--ink); }
.client-last { font-size: 12px; color: var(--ink-faint); margin-top: var(--sp-2); }

/* AI recognize box */
.recognize-box { background: var(--accent-tint); border: 1px solid var(--accent-soft); border-radius: var(--r-md); padding: var(--sp-4); margin-bottom: var(--sp-5); }
.rec-head { font-size: 14px; font-weight: 700; margin-bottom: var(--sp-3); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.recognize-box textarea { background: var(--surface); }
.rec-actions { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); flex-wrap: wrap; }
.rec-file-label { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-dim); }
.rec-file-label:hover { border-color: var(--ink-faint); color: var(--ink); }

.client-detail { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: var(--sp-5); align-items: start; }
.cd-left, .cd-right { min-width: 0; display: flex; flex-direction: column; }

/* files */
.file-list { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.file-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--surface-2); }
.file-row.sm { padding: var(--sp-1) var(--sp-2); font-size: 13px; }
.file-ico { flex: 0 0 auto; }
.file-name { flex: 1; min-width: 0; color: var(--navy); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { text-decoration: underline; }
.file-meta { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }
.file-del { padding: 3px 8px; font-size: 12px; }
.file-empty { color: var(--ink-faint); font-size: 13px; padding: var(--sp-2) 0; }
.upload-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.upload-row.sm { margin-top: var(--sp-2); }
.upl-input { font-size: 12.5px; color: var(--ink-dim); max-width: 200px; }

/* orders */
.order-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
.order-item { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4); background: var(--surface-2); }
.order-main { display: block; text-decoration: none; color: inherit; }
.order-title { font-weight: 700; font-size: 15px; }
.order-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.order-item .conf { margin-top: var(--sp-2); }
.order-files { margin-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); }

@media (max-width: 1000px) { .client-detail { grid-template-columns: 1fr; } }

/* ─────────────── Документообіг ─────────────── */
.docs-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin: 0 0 var(--sp-3); }
.docs-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.doc-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.doc-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.doc-row.done { background: var(--ok-tint); border-color: oklch(0.85 0.06 158); }
.doc-check { flex: 0 0 26px; width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--surface); color: var(--ink-faint); border: 1.5px solid var(--line); font-size: 14px; box-shadow: none; }
.doc-row.done .doc-check { background: var(--ok); color: #fff; border-color: var(--ok); }
.doc-body { flex: 1; min-width: 0; }
.doc-title { font-size: 13.5px; font-weight: 600; }
.doc-file { font-size: 12px; color: var(--navy); text-decoration: none; }
.doc-file:hover { text-decoration: underline; }
.doc-stat { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--surface-3); color: var(--ink-faint); }
.doc-stat.on { background: var(--ok-tint); color: var(--ok); }
.doc-attach, .doc-del { padding: 4px 9px; font-size: 13px; }
.doc-add { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.doc-add-input { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); font-size: 13px; }
.doc-add-input:focus { outline: none; border-color: var(--navy); }
.doc-add-btn { padding: var(--sp-2) var(--sp-4); }

.folder-list { display: flex; flex-direction: column; gap: var(--sp-1); }

@media (max-width: 900px) { .docs-cols { grid-template-columns: 1fr; } }

/* compare two columns */
.compare-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.compare-cols .quote-cards { grid-template-columns: 1fr; }
.cmp-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin: 0 0 var(--sp-3); }
@media (max-width: 900px) { .compare-cols { grid-template-columns: 1fr; } }

/* empty state */
.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--ink-faint); }
.empty .ico { font-size: 32px; opacity: 0.5; margin-bottom: var(--sp-3); }
.empty h3 { color: var(--ink-dim); margin-bottom: var(--sp-2); }

/* ─────────────── Responsive ─────────────── */
@media (max-width: 1100px) {
  .workbench { grid-template-columns: 1fr; grid-template-areas: "input" "pipeline" "results"; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: var(--sp-2); overflow-x: auto; padding: var(--sp-3); }
  .sidebar .brand, .sidebar .brand-sub, .sidebar-foot { display: none; }
  .nav { flex-direction: row; }
  .nav-item { white-space: nowrap; }
  .nav-item span { display: none; }
  .page { padding: var(--sp-4); }
}

/* ════════════════════════════════════════════════════════════
   CRM REDESIGN LAYER (Phase 1) — additive; modern SaaS components.
   Nothing above is changed; these are new classes only.
   ════════════════════════════════════════════════════════════ */
:root {
  /* CRM status ramp (semantic) */
  --st-lead:   oklch(0.52 0.14 255);  --st-lead-tint:   oklch(0.955 0.03 255);
  --st-active: oklch(0.52 0.12 158);  --st-active-tint: oklch(0.955 0.045 158);
  --st-quoted: oklch(0.58 0.12 65);   --st-quoted-tint: oklch(0.965 0.05 80);
  --st-won:    oklch(0.48 0.14 150);  --st-won-tint:    oklch(0.95 0.06 150);
  --st-lost:   oklch(0.55 0.17 25);   --st-lost-tint:   oklch(0.965 0.035 25);
  --indigo:    oklch(0.5 0.17 268);   --indigo-tint:    oklch(0.955 0.035 268);
  --z-modal: 110; --z-cmdk: 120; --z-toast: 140;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
}

/* page header */
.page-header { display:flex; align-items:flex-start; justify-content:space-between; gap:var(--sp-4); flex-wrap:wrap; margin-bottom:var(--sp-5); }
.ph-title { font-size:22px; font-weight:800; letter-spacing:-0.02em; margin:0; }
.ph-sub { font-size:13px; color:var(--ink-faint); margin-top:3px; }
.ph-actions { display:flex; align-items:center; gap:var(--sp-2); flex-wrap:wrap; }

/* metric cards */
.metric-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:var(--sp-3); margin-bottom:var(--sp-5); }
.metric { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); padding:var(--sp-4); transition:box-shadow .15s, transform .12s var(--ease); }
.metric:hover { box-shadow:var(--shadow-sm); }
.metric .m-label { font-size:12px; color:var(--ink-faint); font-weight:600; display:flex; align-items:center; gap:6px; }
.metric .m-label svg { width:14px; height:14px; }
.metric .m-value { font-size:26px; font-weight:800; letter-spacing:-0.02em; margin-top:6px; font-variant-numeric:tabular-nums; }
.metric .m-value.mono { font-family:var(--mono); font-weight:700; }
.metric .m-delta { font-size:12px; margin-top:4px; color:var(--ink-faint); }
.metric .m-delta.up { color:var(--ok); } .metric .m-delta.down { color:var(--err); }

/* status pill */
.pill { display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:700; line-height:1.45; white-space:nowrap; }
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
.pill.lead{background:var(--st-lead-tint);color:var(--st-lead);} .pill.active{background:var(--st-active-tint);color:var(--st-active);}
.pill.quoted{background:var(--st-quoted-tint);color:var(--st-quoted);} .pill.won{background:var(--st-won-tint);color:var(--st-won);}
.pill.lost{background:var(--st-lost-tint);color:var(--st-lost);} .pill.muted{background:var(--surface-3);color:var(--ink-faint);} .pill.muted::before{display:none;}

/* meta / source badge */
.badge { display:inline-flex; align-items:center; gap:4px; padding:2px 7px; border-radius:var(--r-sm); font-size:11.5px; font-weight:600; background:var(--surface-3); color:var(--ink-faint); }
.badge svg { width:12px; height:12px; }

/* segmented toggle */
.seg-toggle { display:inline-flex; background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-sm); padding:2px; gap:2px; }
.seg-toggle button { background:transparent; color:var(--ink-faint); box-shadow:none; padding:6px 12px; font-size:13px; font-weight:600; border-radius:6px; display:inline-flex; align-items:center; gap:6px; }
.seg-toggle button:hover { color:var(--ink); background:transparent; }
.seg-toggle button.on { background:var(--surface); color:var(--ink); box-shadow:var(--shadow-sm); }
.seg-toggle button svg { width:15px; height:15px; }

/* toolbar + inline search + chips */
.toolbar { display:flex; align-items:center; gap:var(--sp-2); flex-wrap:wrap; margin-bottom:var(--sp-4); }
.search-inline { display:flex; align-items:center; gap:8px; height:38px; padding:0 12px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-sm); min-width:200px; flex:1; max-width:360px; }
.search-inline:focus-within { border-color:var(--navy); box-shadow:0 0 0 3px oklch(0.26 0.035 258 / 0.1); }
.search-inline svg { width:16px; height:16px; color:var(--ink-faint); flex:0 0 16px; }
.search-inline input { border:none; background:transparent; outline:none; width:100%; font-size:14px; color:var(--ink); }
.chip { display:inline-flex; align-items:center; gap:6px; padding:7px 12px; border-radius:var(--r-sm); border:1px solid var(--line); background:var(--surface); color:var(--ink-dim); font-size:13px; font-weight:600; cursor:pointer; transition:.15s; }
.chip:hover { border-color:var(--ink-faint); color:var(--ink); }
.chip.on { background:var(--navy); color:oklch(0.99 0 0); border-color:var(--navy); }
.chip svg { width:14px; height:14px; }

/* data table */
.dtable-wrap { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; box-shadow:var(--shadow-sm); }
table.dtable { width:100%; border-collapse:collapse; font-size:14px; }
table.dtable thead th { background:var(--surface-2); font-size:11px; letter-spacing:0.05em; color:var(--ink-faint); font-weight:700; text-transform:uppercase; padding:10px 14px; border-bottom:1px solid var(--line); white-space:nowrap; }
table.dtable thead th.sortable { cursor:pointer; user-select:none; }
table.dtable thead th.sortable:hover { color:var(--ink); }
table.dtable tbody td { padding:11px 14px; border-bottom:1px solid var(--line-soft); vertical-align:middle; }
table.dtable tbody tr { transition:background .12s; cursor:pointer; }
table.dtable tbody tr:hover { background:var(--surface-2); }
table.dtable tbody tr:last-child td { border-bottom:none; }
.cell-client { display:flex; align-items:center; gap:10px; min-width:0; }
.cell-client .ci-name { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cell-client .ci-sub { font-size:12px; color:var(--ink-faint); display:flex; align-items:center; gap:4px; }
.cell-client .ci-sub svg { width:12px; height:12px; }
.avatar-sm { width:32px; height:32px; flex:0 0 32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; background:var(--accent-tint); color:oklch(0.45 0.1 80); }

/* kanban */
.kanban { display:grid; grid-auto-flow:column; grid-auto-columns:minmax(250px,1fr); gap:var(--sp-3); overflow-x:auto; padding-bottom:var(--sp-3); align-items:start; }
.kcol { background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-md); display:flex; flex-direction:column; min-height:120px; }
.kcol-head { display:flex; align-items:center; justify-content:space-between; padding:10px 12px; font-size:12px; font-weight:700; color:var(--ink-dim); border-bottom:1px solid var(--line); }
.kcol-head .k-count { background:var(--surface-3); color:var(--ink-faint); border-radius:999px; padding:1px 8px; font-size:11px; }
.kcol-body { padding:8px; display:flex; flex-direction:column; gap:8px; min-height:48px; }
.kcard { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-sm); padding:10px 12px; cursor:grab; box-shadow:var(--shadow-sm); transition:transform .12s var(--ease), box-shadow .15s, border-color .15s; }
.kcard:hover { border-color:var(--ink-faint); box-shadow:var(--shadow-md); }
.kcard.dragging { opacity:0.45; }
.kcol.drop-target { outline:2px dashed var(--navy); outline-offset:-4px; }
.kc-top { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.kc-name { font-weight:600; font-size:14px; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.kc-meta { display:flex; align-items:center; justify-content:space-between; font-size:12px; color:var(--ink-faint); }
.kc-val { font-family:var(--mono); font-weight:600; color:var(--ink-dim); }

/* activity timeline */
.timeline { position:relative; padding-left:28px; }
.timeline::before { content:""; position:absolute; left:9px; top:4px; bottom:4px; width:2px; background:var(--line); }
.tl-item { position:relative; padding-bottom:var(--sp-4); }
.tl-item:last-child { padding-bottom:0; }
.tl-dot { position:absolute; left:-28px; top:0; width:20px; height:20px; border-radius:50%; background:var(--surface); border:2px solid var(--line); display:flex; align-items:center; justify-content:center; color:var(--ink-faint); }
.tl-dot svg { width:11px; height:11px; }
.tl-item.note .tl-dot{color:var(--st-lead);border-color:var(--st-lead-tint);} .tl-item.order .tl-dot{color:var(--ok);border-color:var(--ok-tint);}
.tl-item.status .tl-dot{color:oklch(0.6 0.12 80);border-color:var(--accent-soft);} .tl-item.sync .tl-dot{color:var(--indigo);border-color:var(--indigo-tint);}
.tl-body { font-size:14px; } .tl-meta { font-size:12px; color:var(--ink-faint); margin-top:2px; }

/* icon button */
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; padding:0; background:var(--surface); color:var(--ink-dim); border:1px solid var(--line); border-radius:var(--r-sm); box-shadow:none; cursor:pointer; transition:.15s; }
.icon-btn:hover { background:var(--surface-3); color:var(--ink); border-color:var(--ink-faint); }
.icon-btn svg { width:18px; height:18px; }

/* ⌘K trigger in topbar */
.cmdk-trigger { display:inline-flex; align-items:center; gap:8px; height:36px; padding:0 8px 0 12px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-sm); color:var(--ink-faint); font-size:13px; font-weight:500; cursor:pointer; min-width:210px; transition:.15s; font-family:var(--sans); }
.cmdk-trigger:hover { border-color:var(--ink-faint); color:var(--ink-dim); }
.cmdk-trigger svg { width:15px; height:15px; }
.cmdk-trigger .kbd { margin-left:auto; font-family:var(--mono); font-size:11px; background:var(--surface-3); border:1px solid var(--line); border-radius:5px; padding:1px 6px; color:var(--ink-faint); }
@media (max-width:820px){ .cmdk-trigger span:not(.kbd){ display:none; } .cmdk-trigger{ min-width:0; } }

/* command palette */
.cmdk-overlay { position:fixed; inset:0; background:oklch(0.2 0.02 260 / 0.32); backdrop-filter:blur(2px); z-index:var(--z-cmdk); display:flex; align-items:flex-start; justify-content:center; padding-top:12vh; opacity:0; pointer-events:none; transition:opacity .15s; }
.cmdk-overlay.open { opacity:1; pointer-events:auto; }
.cmdk { width:560px; max-width:92vw; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-lg); overflow:hidden; transform:translateY(-8px) scale(0.98); transition:transform .18s var(--ease); }
.cmdk-overlay.open .cmdk { transform:none; }
.cmdk-input-row { display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--line); }
.cmdk-input-row svg { width:18px; height:18px; color:var(--ink-faint); flex:0 0 18px; }
.cmdk-input-row input { flex:1; border:none; outline:none; background:transparent; font-size:16px; color:var(--ink); font-family:var(--sans); }
.cmdk-list { max-height:340px; overflow:auto; padding:6px; }
.cmdk-group { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:var(--ink-faint); padding:8px 10px 4px; }
.cmdk-item { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:var(--r-sm); cursor:pointer; font-size:14px; color:var(--ink-dim); }
.cmdk-item .ci-ic { width:24px; height:24px; flex:0 0 24px; border-radius:6px; background:var(--surface-3); display:flex; align-items:center; justify-content:center; color:var(--ink-faint); }
.cmdk-item .ci-ic svg { width:14px; height:14px; }
.cmdk-item.sel { background:var(--surface-3); color:var(--ink); }
.cmdk-item .ci-hint { margin-left:auto; font-size:11px; color:var(--ink-faint); }
.cmdk-empty { padding:24px; text-align:center; color:var(--ink-faint); font-size:14px; }

/* toast */
.toast-wrap { position:fixed; right:18px; bottom:18px; z-index:var(--z-toast); display:flex; flex-direction:column; gap:8px; }
.toast { display:flex; align-items:center; gap:10px; background:var(--ink); color:oklch(0.98 0 0); padding:11px 14px; border-radius:var(--r-md); box-shadow:var(--shadow-lg); font-size:14px; font-weight:600; transform:translateY(8px); opacity:0; transition:.2s var(--ease); max-width:360px; }
.toast.show { transform:none; opacity:1; }
.toast.ok { background:var(--ok); } .toast.err { background:var(--err); }
.toast svg { width:16px; height:16px; flex:0 0 16px; }

/* skeleton */
.skel { background:linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size:200% 100%; animation:skel 1.3s infinite; border-radius:6px; }
@keyframes skel { from { background-position:200% 0; } to { background-position:-200% 0; } }

/* modal */
.modal-overlay { position:fixed; inset:0; background:oklch(0.2 0.02 260 / 0.4); z-index:var(--z-modal); display:flex; align-items:center; justify-content:center; padding:var(--sp-4); opacity:0; pointer-events:none; transition:opacity .15s; }
.modal-overlay.open { opacity:1; pointer-events:auto; }
.modal { width:520px; max-width:94vw; max-height:88vh; overflow:auto; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-lg); transform:translateY(8px) scale(0.99); transition:transform .18s var(--ease); }
.modal-overlay.open .modal { transform:none; }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding:var(--sp-4) var(--sp-5); border-bottom:1px solid var(--line); }
.modal-head h3 { margin:0; font-size:16px; }
.modal-body { padding:var(--sp-5); }
.modal-foot { display:flex; justify-content:flex-end; gap:var(--sp-2); padding:var(--sp-4) var(--sp-5); border-top:1px solid var(--line); }

/* staggered fade-in */
@keyframes fade-up { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.animate-in { animation:fade-up 0.3s var(--ease) both; }
