/* ============================================================
   СВОД — design tokens & base styles
   Engineering B2B aesthetic: cool gray-blue, dense tables,
   monospace numerics, minimal radii, no gradients.
   ============================================================ */

:root {
  /* surfaces */
  --bg:            oklch(0.968 0.006 245);
  --surface:       oklch(0.995 0.002 245);
  --surface-2:     oklch(0.962 0.007 245);
  --surface-3:     oklch(0.945 0.009 245);

  /* lines */
  --border:        oklch(0.892 0.012 248);
  --border-strong: oklch(0.815 0.016 248);

  /* text */
  --text:    oklch(0.285 0.026 258);
  --text-2:  oklch(0.475 0.022 258);
  --text-3:  oklch(0.605 0.018 258);

  /* accent — steel blue */
  --accent:       oklch(0.475 0.088 256);
  --accent-2:     oklch(0.405 0.092 256);
  --accent-weak:  oklch(0.928 0.030 256);
  --accent-line:  oklch(0.80 0.05 256);

  /* status */
  --ok:        oklch(0.565 0.105 156);
  --ok-weak:   oklch(0.935 0.045 156);
  --ok-line:   oklch(0.80 0.07 156);
  --warn:      oklch(0.665 0.115 78);
  --warn-weak: oklch(0.945 0.055 84);
  --warn-line: oklch(0.83 0.09 82);
  --err:       oklch(0.545 0.175 28);
  --err-weak:  oklch(0.945 0.045 30);
  --err-line:  oklch(0.80 0.11 30);

  --shadow: 0 1px 2px oklch(0.4 0.03 258 / 0.06), 0 1px 1px oklch(0.4 0.03 258 / 0.04);
  --shadow-md: 0 6px 24px oklch(0.35 0.04 258 / 0.12), 0 2px 6px oklch(0.35 0.04 258 / 0.08);

  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --r: 3px;
  --r-lg: 5px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { min-height: 100vh; }

.num { font-family: var(--mono); font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-weak); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.brand .mark {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 2px;
  display: grid; place-items: center;
  position: relative;
}
.brand .mark::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1.5px solid oklch(0.99 0 0 / 0.85);
  border-radius: 1px;
}
.brand .mark::after {
  content: "";
  position: absolute;
  width: 14px; height: 1.5px;
  background: oklch(0.99 0 0 / 0.85);
  transform: rotate(-32deg);
}
.brand .name { font-weight: 600; font-size: 15px; letter-spacing: 0.06em; }
.brand .sub { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }

.topbar .spacer { flex: 1; }
.topbar .env {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border); padding: 3px 8px; border-radius: var(--r);
  letter-spacing: 0.03em;
}
.topbar .user {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2);
}
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--text-2);
}

.main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---------- Breadcrumb ---------- */
.crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); margin-bottom: 16px; }
.crumb a { color: var(--text-2); text-decoration: none; cursor: pointer; }
.crumb a:hover { color: var(--accent); }
.crumb .sep { color: var(--border-strong); }

/* ---------- Headings ---------- */
.page-title { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 3px; }
.page-sub { font-size: 13px; color: var(--text-3); margin: 0 0 22px; }

/* ---------- Summary cards ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 15px 16px 14px; position: relative; box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--text-3); letter-spacing: 0.01em; }
.stat .value { font-family: var(--mono); font-size: 30px; font-weight: 500; letter-spacing: -0.02em; margin-top: 6px; line-height: 1; }
.stat .foot { font-size: 11.5px; color: var(--text-3); margin-top: 8px; }
.stat .tick { position: absolute; top: 16px; right: 16px; width: 8px; height: 8px; border-radius: 50%; }
.stat.is-err .value { color: var(--err); }
.tick.ok { background: var(--ok); }
.tick.warn { background: var(--warn); }
.tick.err { background: var(--err); }
.tick.accent { background: var(--accent); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .seg { display: flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.toolbar .seg button {
  border: 0; background: transparent; font-family: var(--sans); font-size: 12.5px; color: var(--text-2);
  padding: 6px 13px; cursor: pointer; border-right: 1px solid var(--border);
}
.toolbar .seg button:last-child { border-right: 0; }
.toolbar .seg button.active { background: var(--accent); color: #fff; }
.toolbar .grow { flex: 1; }
.search {
  display: flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); padding: 6px 11px; min-width: 240px;
}
.search input { border: 0; outline: 0; background: transparent; font-family: var(--sans); font-size: 13px; width: 100%; color: var(--text); }
.search svg { color: var(--text-3); flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: var(--r); cursor: pointer; display: inline-flex;
  align-items: center; gap: 8px; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn svg { flex-shrink: 0; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr.hoverable { cursor: pointer; }
table.grid tbody tr.hoverable:hover { background: var(--accent-weak); }
table.grid td.r, table.grid th.r { text-align: right; }
table.grid td.c, table.grid th.c { text-align: center; }
.cell-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sub-cell { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* section group row inside tables */
tr.group-row td {
  background: var(--surface-3); font-weight: 600; font-size: 11.5px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-2); padding: 7px 14px;
}

/* ---------- Status badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  padding: 3px 9px 3px 8px; border-radius: 100px; border: 1px solid; line-height: 1.3; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.ok { background: var(--ok-weak); border-color: var(--ok-line); color: oklch(0.42 0.09 156); }
.badge.ok .dot { background: var(--ok); }
.badge.warn { background: var(--warn-weak); border-color: var(--warn-line); color: oklch(0.50 0.10 70); }
.badge.warn .dot { background: var(--warn); }
.badge.err { background: var(--err-weak); border-color: var(--err-line); color: var(--err); }
.badge.err .dot { background: var(--err); }
.badge.neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.badge.neutral .dot { background: var(--text-3); }

.pill-stage {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2);
}

/* ---------- Project detail header ---------- */
.proj-head {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 0; box-shadow: var(--shadow); border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.proj-head .top { display: flex; align-items: flex-start; gap: 16px; }
.proj-head h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -0.01em; line-height: 1.3; flex: 1; }
.proj-head .meta-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; margin-top: 18px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
}
.proj-head .meta {
  background: var(--surface); padding: 11px 14px;
}
.proj-head .meta .k { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }
.proj-head .meta .v { font-size: 13.5px; font-weight: 500; margin-top: 3px; }
.proj-head .meta .v.mono { font-family: var(--mono); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 0; background: var(--surface); border: 1px solid var(--border); border-top: 0;
  padding: 0 12px; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.tabs button {
  border: 0; background: transparent; font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  color: var(--text-2); padding: 13px 16px 12px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; display: inline-flex; align-items: center; gap: 8px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); color: var(--text-2);
  padding: 1px 5px; border-radius: 100px; font-weight: 600;
}
.tabs button.active .tab-count { background: var(--accent-weak); color: var(--accent-2); }
.tab-count.err { background: var(--err-weak); color: var(--err); }

.tab-body {
  background: var(--surface); border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--r-lg) var(--r-lg); padding: 20px; box-shadow: var(--shadow);
}
.tab-bar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 14px; flex-wrap: wrap;
}
.tab-bar h2 { font-size: 15px; font-weight: 600; margin: 0; }
.tab-bar .hint { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

/* info strip (e.g. "данные посчитаны из объёмов") */
.info-strip {
  display: flex; align-items: flex-start; gap: 10px; background: var(--accent-weak);
  border: 1px solid var(--accent-line); border-radius: var(--r); padding: 10px 13px; margin-bottom: 16px;
  font-size: 12.5px; color: var(--accent-2);
}
.info-strip svg { flex-shrink: 0; margin-top: 1px; }
.info-strip b { font-weight: 600; }

/* ---------- Convergence verdict ---------- */
.verdict {
  display: flex; align-items: center; gap: 16px; border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 18px; border: 1px solid;
}
.verdict.err { background: var(--err-weak); border-color: var(--err-line); }
.verdict.ok { background: var(--ok-weak); border-color: var(--ok-line); }
.verdict .icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.verdict.err .icon { background: var(--err); color: #fff; }
.verdict.ok .icon { background: var(--ok); color: #fff; }
.verdict .vtext { flex: 1; }
.verdict .vtext .vt { font-size: 16px; font-weight: 600; }
.verdict.err .vtext .vt { color: var(--err); }
.verdict.ok .vtext .vt { color: oklch(0.42 0.09 156); }
.verdict .vtext .vs { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.verdict .vstats { display: flex; gap: 22px; }
.verdict .vstat { text-align: right; }
.verdict .vstat .n { font-family: var(--mono); font-size: 22px; font-weight: 500; line-height: 1; }
.verdict .vstat .l { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* convergence rows */
tr.check-row.err-row td { background: var(--err-weak); }
tr.check-row.err-row:hover td { background: oklch(0.925 0.05 30); }
tr.check-row td.expander { width: 34px; cursor: pointer; color: var(--text-3); user-select: none; }
tr.check-row td.expander:hover { color: var(--accent); }
.delta { font-family: var(--mono); font-weight: 600; }
.delta.pos { color: var(--err); }
.delta.zero { color: var(--text-3); }
tr.detail-row td { background: var(--surface-2); padding: 0 !important; }
.detail-inner { padding: 14px 16px 16px 48px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-inner .src-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.detail-inner .src-box .sk { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }
.detail-inner .src-box .sv { font-family: var(--mono); font-size: 13px; font-weight: 500; margin-top: 4px; }
.detail-note { grid-column: 1 / -1; font-size: 13px; color: var(--text); line-height: 1.5; }
.detail-note .nlabel { font-weight: 600; color: var(--err); }
.detail-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 2px; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: oklch(0.3 0.03 258 / 0.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 24px;
  animation: fade 0.14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); width: 100%; max-width: 760px; max-height: 86vh; display: flex; flex-direction: column;
  animation: pop 0.16s cubic-bezier(0.2,0.8,0.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal .mhead { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .mhead h3 { font-size: 15px; font-weight: 600; margin: 0; }
.modal .mhead .x { border: 0; background: transparent; cursor: pointer; color: var(--text-3); padding: 4px; border-radius: var(--r); display: grid; place-items: center; }
.modal .mhead .x:hover { background: var(--surface-2); color: var(--text); }
.modal .mbody { padding: 20px; overflow: auto; }
.modal .mfoot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: 32px 20px;
  text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color 0.14s, background 0.14s;
}
.dropzone:hover { border-color: var(--accent-line); background: var(--accent-weak); }
.dropzone .dz-icon { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--accent); }
.dropzone .dz-title { font-size: 14px; font-weight: 600; }
.dropzone .dz-sub { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.dropzone .dz-formats { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 12px; }

/* uploading */
.uploading { text-align: center; padding: 26px 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 13px; font-size: 13px; margin-bottom: 18px;
}
.file-chip .xls { width: 26px; height: 26px; background: var(--ok); color: #fff; border-radius: 3px; display: grid; place-items: center; font-size: 9px; font-weight: 700; font-family: var(--mono); }
.progress-track { height: 6px; background: var(--surface-3); border-radius: 100px; overflow: hidden; max-width: 420px; margin: 0 auto; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 100px; transition: width 0.2s linear; }
.upload-stat { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-top: 12px; }

/* preview within modal */
.preview-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; }
.conf-tag { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border-radius: 100px; font-weight: 600; }
.conf-tag.ok { background: var(--ok-weak); color: oklch(0.42 0.09 156); }
.conf-tag.warn { background: var(--warn-weak); color: oklch(0.50 0.10 70); }

/* empty/foot note */
.foot-note { font-size: 12px; color: var(--text-3); margin-top: 14px; display: flex; align-items: center; gap: 7px; }

@media (max-width: 1000px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .proj-head .meta-grid { grid-template-columns: repeat(2, 1fr); }
}
