/* Parser admin — compact B2B dashboard. Spacing base = 4px. Radius = 6px. */

:root {
  --bg: #111213;
  --surface: #18191b;
  --hover: #1e1f22;
  --line: #2a2b2e;
  --line-2: #3a3b40;
  --text: #ececef;
  --muted: #8b8d94;
  --faint: #5c5e66;
  --accent: #ececef;
  --accent-fg: #111213;
  --link: #c8c9ce;
  --ok: #5dba87;
  --warn: #c9a227;
  --danger: #d4676e;
  --focus: #ececef;
  --control-h: 32px;
  --sidebar: 232px;
  --pad: 24px;
  --font: ui-sans-serif, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--text); }
code, pre {
  font-family: var(--mono);
  font-size: 12px;
  font-feature-settings: "tnum" 1;
}
pre { margin: 0; white-space: pre-wrap; color: var(--muted); }
:focus { outline: none; }
:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

/* --- chrome ----------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand {
  padding: 4px 10px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand span {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav { flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 10px 0 8px;
  margin-bottom: 1px;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  border-left: 2px solid transparent;
}
.nav a:hover {
  color: var(--text);
  background: var(--hover);
  text-decoration: none;
}
.nav a.active {
  color: var(--text);
  background: var(--hover);
  border-left-color: var(--text);
}
.side-foot {
  padding: 8px 10px 0;
  border-top: 1px solid var(--line);
}
.side-foot form { margin: 0; }
.side-foot button {
  width: 100%;
  justify-content: flex-start;
  height: 32px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  text-align: left;
}
.side-foot button:hover { color: var(--text); background: var(--hover); }

.main {
  padding: 20px var(--pad) 48px;
  max-width: 1180px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.flash {
  margin-bottom: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}
.flash.ok { border-color: #2a4a38; color: var(--ok); }
.flash.err { border-color: #5a3034; color: var(--danger); }

/* --- surfaces --------------------------------------------------------- */

.panel {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.panel > h2:first-child { margin-top: 0; }

.section { margin-top: 24px; }
.section > h2 { margin-bottom: 8px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* stats strip — not a card wall */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}
.stat {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}
.stat:nth-child(4n) { border-right: 0; }
.stats.five {
  grid-template-columns: repeat(5, 1fr);
}
.stats.five .stat:nth-child(4n) { border-right: 1px solid var(--line); }
.stats.five .stat:nth-child(5n) { border-right: 0; }
.stats.five .stat:nth-child(n+5) { border-top: 0; }
.stat-k {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stat-v {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-s { display: block; margin-top: 2px; color: var(--faint); font-size: 12px; }

.identity {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.identity .stat-v { font-size: 14px; }

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

/* --- tables ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th,
.table td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.table th {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.table tbody tr:hover td { background: var(--hover); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; }

/* --- controls --------------------------------------------------------- */

.btn, button, input[type=submit] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  font: 13px/1 var(--font);
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover, button:hover, input[type=submit]:hover { filter: none; background: #fff; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost, .ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn.ghost:hover, .ghost:hover { background: var(--hover); border-color: var(--line-2); }
.btn.danger, .danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--line);
}
.btn.danger:hover, .danger:hover { background: #2a1518; border-color: #5a3034; }
.btn.ok, .okbtn {
  background: transparent;
  color: var(--ok);
  border-color: var(--line);
}
.btn.ok:hover, .okbtn:hover { background: #14241c; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.stack { display: grid; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.nowrap { white-space: nowrap; }

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
input, select, textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea {
  height: auto;
  min-height: 112px;
  padding: 8px 10px;
  resize: vertical;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--text);
}
.grow { flex: 1; min-width: 160px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.check input { width: auto; height: auto; }

.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.seg a {
  height: 26px;
  padding: 0 10px;
  border-radius: 4px;
  color: var(--muted);
  line-height: 26px;
  font-size: 12px;
}
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { color: var(--text); background: var(--hover); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tabs a {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  line-height: 28px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); background: var(--hover); }

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.pill.paid, .pill.sent, .pill.ok { color: var(--ok); border-color: #2a4a38; }
.pill.pending, .pill.running { color: var(--warn); border-color: #4a4020; }
.pill.fail, .pill.error, .pill.blocked { color: var(--danger); border-color: #5a3034; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.toolbar > div { min-width: 140px; }

.empty {
  margin: 12px 0 4px;
  color: var(--faint);
  font-size: 13px;
}
.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* --- chart ------------------------------------------------------------ */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
}
.chart .bar {
  width: 100%;
  min-height: 2px;
  background: #c8c9ce;
  opacity: 1;
  border-radius: 1px 1px 0 0;
}
.chart-col:hover .bar { background: var(--text); }
.chart-label {
  display: none;
  margin-top: 6px;
  color: var(--faint);
  font-size: 9px;
  text-align: center;
}
.chart-col:nth-child(2n) .chart-label { display: block; }

/* --- shop tree -------------------------------------------------------- */

.shop-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}
.tree-panel { padding: 10px; }
.tree-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text);
}
.tree-row:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.tree-row.is-on { background: var(--hover); }
.tree-row.is-off .tree-title { color: var(--faint); }
.tree-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-meta {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
  color: var(--faint);
  font-size: 12px;
}
.tree-add {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.editor {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.editor-go { padding-bottom: 0; }
.sub-add {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* --- auth ------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login {
  width: 360px;
  padding: 0;
  background: transparent;
  border: 0;
}
.login h1 { margin-bottom: 8px; }
.login .muted { margin-bottom: 20px; }
.login button { width: 100%; }

@media (max-width: 980px) {
  .layout,
  .shop-layout,
  .split,
  .editor,
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat:nth-child(n+5) { border-top: 0; }
  .stat:last-child { border-bottom: 0; }
  .side { height: auto; position: relative; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
}
