/* tv-tradelocker admin panel — dark trading terminal */

:root {
  color-scheme: dark;

  --plane: #0b0e13;
  --surface-1: #12161d;
  --surface-2: #171c25;
  --surface-3: #1e2531;

  --text-primary: #ffffff;
  --text-secondary: #aab4c4;
  --text-muted: #6f7a8b;

  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --grid: #222a36;

  /* Status palette — fixed, never themed. Always paired with an icon + label. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* Categorical slots, dark steps (validated against --surface-1) */
  --series-1: #3987e5;
  --series-2: #d95926;

  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login form {
  width: 100%;
  max-width: 360px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.login h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.login .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login .logo { font-size: 28px; margin-bottom: 12px; }
.login input {
  width: 100%; margin-bottom: 12px; padding: 11px 13px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px;
}
.login input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.login button {
  width: 100%; padding: 11px; margin-top: 6px; border: 0;
  border-radius: var(--radius-sm); background: var(--series-1);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.login .err {
  background: rgba(208, 59, 59, 0.15); border: 1px solid var(--critical);
  color: #ffb3b3; padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}

/* ---------- shell ---------- */

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.brand span { color: var(--text-muted); font-weight: 400; }
.topbar .spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 100px; font-size: 12px;
  border: 1px solid var(--border); background: var(--surface-3);
  color: var(--text-secondary); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }

nav.tabs {
  display: flex; gap: 2px; padding: 0 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  overflow-x: auto; position: sticky; top: 53px; z-index: 19;
}
nav.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); padding: 11px 14px; font-size: 13px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
nav.tabs button:hover { color: var(--text-secondary); }
nav.tabs button[aria-selected='true'] { color: var(--text-primary); border-bottom-color: var(--series-1); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.view[hidden] { display: none; }

/* ---------- cards & grid ---------- */

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card > h2 {
  margin: 0 0 14px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- stat tiles ---------- */

.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.value.good { color: var(--good); }
.value.critical { color: var(--critical); }

/* ---------- drawdown meters ---------- */

.meter { margin-bottom: 18px; }
.meter:last-child { margin-bottom: 0; }
.meter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 7px; font-size: 13px; gap: 12px;
}
.meter-head .name { color: var(--text-secondary); }
.meter-head .fig { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.meter-track {
  height: 10px; background: var(--surface-3); border-radius: 5px;
  overflow: hidden; position: relative;
}
.meter-fill { height: 100%; border-radius: 5px; transition: width 0.4s ease, background 0.3s ease; }
.meter-fill.good { background: var(--good); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.serious { background: var(--serious); }
.meter-fill.critical { background: var(--critical); }
/* Soft-threshold marker: where new entries stop being accepted. */
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-secondary); opacity: 0.65; }
.meter-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 5px; }

/* ---------- chart ---------- */

.chart-wrap { position: relative; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
svg.chart .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .series-area { fill: var(--series-1); opacity: 0.10; }
svg.chart .crosshair { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
svg.chart .hover-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12px; white-space: nowrap; z-index: 5;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); transform: translate(-50%, -100%);
}
.tooltip .t-label { color: var(--text-muted); margin-bottom: 3px; }
.tooltip .t-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip[hidden] { display: none; }
.empty { color: var(--text-muted); font-size: 13px; padding: 28px; text-align: center; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px; color: var(--text-muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: 12px; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 100px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-3); color: var(--text-secondary);
}
.badge.executed { border-color: var(--good); color: #6de06d; }
.badge.captured { border-color: var(--series-1); color: #8fc0f5; }
.badge.blocked, .badge.rejected { border-color: var(--warning); color: #ffd57a; }
.badge.failed { border-color: var(--critical); color: #ff9a9a; }
.badge.live { border-color: var(--good); color: #6de06d; }
.badge.capture { border-color: var(--series-1); color: #8fc0f5; }
.badge.paused { border-color: var(--text-muted); color: var(--text-muted); }

/* ---------- forms & buttons ---------- */

button.btn {
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text-primary);
  font-size: 13px; cursor: pointer; font-family: inherit;
}
button.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
button.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }
button.btn.danger { background: var(--critical); border-color: var(--critical); color: #fff; font-weight: 600; }
button.btn.ghost { background: none; }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
label.field > .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
input[type='text'], input[type='number'], input[type='password'], select, textarea {
  width: 100%; padding: 8px 11px; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; font-family: inherit;
}
textarea { font-family: var(--mono); font-size: 12px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }

pre.payload {
  background: var(--plane); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  color: var(--text-secondary); margin: 0; white-space: pre-wrap; word-break: break-word;
}

.banner {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.banner.critical { background: rgba(208, 59, 59, 0.14); border: 1px solid var(--critical); color: #ffb3b3; }
.banner.warning { background: rgba(250, 178, 25, 0.12); border: 1px solid var(--warning); color: #ffdf9e; }
.banner .spacer { flex: 1; }

dialog {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 22px; max-width: 620px; width: calc(100% - 40px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog h3 { margin: 0 0 16px; font-size: 16px; }

.muted { color: var(--text-muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mb0 { margin-bottom: 0; }
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6); max-width: 420px;
}
.toast.err { border-color: var(--critical); color: #ffb3b3; }
.toast.ok { border-color: var(--good); }

@media (max-width: 640px) {
  main { padding: 14px; }
  .card { padding: 14px; }
  .topbar { padding: 10px 14px; }
  nav.tabs { padding: 0 8px; top: 49px; }
}
