:root {
  --bg: #0b0f0e;
  --bg-2: #111715;
  --bg-3: #16201d;
  --line: #22302c;
  --text: #e6efec;
  --muted: #8ba49c;
  --accent: #1FA66D;
  --accent-2: #36CF8F;
  --danger: #e0555a;
  --warn: #d8a13a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 75% -10%, #14201c 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

code, pre, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,15,14,.85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(54,207,143,.25), 0 6px 18px -8px var(--accent);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ----------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); align-items: start; }
.sidebar {
  position: sticky; top: 61px; height: calc(100vh - 61px);
  padding: 18px 14px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  text-align: left; background: none; border: 0; color: var(--muted);
  padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; }
.content { padding: 26px 28px 80px; max-width: 1180px; }

.section-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 6px; font-size: 19px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 74ch; }
.section-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  padding: 8px 13px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: #2f423b; background: #1a2622; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04120c; font-weight: 650; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: none; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #3a2224; }

/* ----------------------------------------------------------------- badges */
.badge {
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge-ok { color: var(--accent-2); border-color: rgba(54,207,143,.4); background: rgba(31,166,109,.1); }
.badge-warn { color: var(--warn); border-color: rgba(216,161,58,.4); background: rgba(216,161,58,.1); }
.badge-bad { color: var(--danger); border-color: rgba(224,85,90,.4); background: rgba(224,85,90,.1); }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; gap: 14px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-2), #0e1412);
  padding: 16px 16px 14px; position: relative;
}
.card.dim { opacity: .62; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .label-input {
  font-size: 15px; font-weight: 650; background: none; border: 0; color: var(--text);
  padding: 4px 6px; border-radius: 7px; width: 130px;
}
.card-head .label-input:hover, .card-head .label-input:focus { background: var(--bg-3); outline: none; }
.card-head .spacer { flex: 1; }
.card-head .card-actions { display: flex; gap: 6px; }

.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.grid-fields .wide { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field small { color: #6f8880; font-size: 11.5px; }
.field input, .field select, .field textarea {
  background: #0c1110; border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input[type="checkbox"] { width: auto; }
.field-row { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------ derived math */
.derived {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px;
}
.derived div { font-size: 12.5px; color: var(--muted); }
.derived b { display: block; color: var(--text); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.derived .flag { color: var(--warn); }

/* ----------------------------------------------------------- validation */
.validation { margin-bottom: 14px; display: grid; gap: 8px; }
.note {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; background: var(--bg-2);
}
.note.err { border-left-color: var(--danger); }
.note.warn { border-left-color: var(--warn); }
.note.ok { border-left-color: var(--accent); }
.note b { font-weight: 600; }

/* ------------------------------------------------------------- form shell */
.panel-form { display: grid; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg-2); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.code {
  background: #080c0b; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px; font-size: 12.5px; color: #cfe6de; overflow-x: auto; white-space: pre;
}
.export-area {
  width: 100%; min-height: 380px; background: #080c0b; border: 1px solid var(--line);
  border-radius: var(--radius); color: #cfe6de; padding: 14px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; resize: vertical;
}
.hint { color: #6f8880; font-size: 11.5px; margin: 0 0 8px; }

/* --------------------------------------------------------------- live rows */
.rowline { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 5px 0; border-bottom: 1px dotted #1c2724; }
.rowline:last-child { border-bottom: 0; }
.rowline span:last-child { font-variant-numeric: tabular-nums; color: var(--text); }
.rowline span:first-child { color: var(--muted); }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 13px; z-index: 60;
  box-shadow: 0 18px 40px -20px #000;
}
.hidden { display: none !important; }
.bar { height: 7px; border-radius: 999px; background: #16201d; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-foot { display: none; }
  .content { padding: 18px 16px 60px; }
}
