/* ISKA SoundCloud — operator panel.
   One dark theme, tuned for a screen that stays open all day: low-glare
   surfaces, tabular numbers so a changing figure does not shift its neighbours,
   and a layout that holds from a phone to a wide monitor. */

:root {
  --bg:        #0a0c10;
  --bg-soft:   #0e1116;
  --surface:   #12151c;
  --surface-2: #171b24;
  --surface-3: #1d222d;
  --border:    #242a38;
  --border-sh: #2f3647;

  --text:      #e7eaf1;
  --text-dim:  #9aa3b8;
  --text-mute: #6b7488;

  --accent:    #ff5500;
  --accent-sh: #ff7a33;
  --accent-bg: rgba(255, 85, 0, .10);

  --ok:        #3ddc84;
  --ok-bg:     rgba(61, 220, 132, .12);
  --warn:      #ffb020;
  --warn-bg:   rgba(255, 176, 32, .12);
  --danger:    #ff5a5f;
  --danger-bg: rgba(255, 90, 95, .12);
  --info:      #4a9eff;
  --info-bg:   rgba(74, 158, 255, .12);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  --topbar-h: 56px;
  --tabs-h:   46px;
}

* { 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.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: 32px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ── top bar ───────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(12px, 2.5vw, 24px);
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { color: var(--accent); flex: none; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 15px; white-space: nowrap; }
.brand-dim { color: var(--text-mute); font-weight: 500; margin-left: 5px; }

.live {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-dim);
  padding: 4px 10px 4px 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); flex: none; }
.live.is-live .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 2.4s ease-in-out infinite; }
.live.is-down .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.live.is-live { color: var(--text); }

@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .live.is-live .dot { animation: none; } }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip {
  font-family: var(--mono); font-size: 11.5px;
  padding: 4px 9px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip-ghost { color: var(--text-mute); }
.chip.is-hot { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }

/* ── tabs ──────────────────────────────────────────────────────── */

.tabs {
  position: sticky; top: var(--topbar-h); z-index: 25;
  height: var(--tabs-h);
  display: flex; gap: 2px; align-items: stretch;
  padding: 0 clamp(8px, 2.5vw, 20px);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none; border: 0; background: none;
  color: var(--text-dim); font: inherit; font-weight: 500; font-size: 13.5px;
  padding: 0 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── layout ────────────────────────────────────────────────────── */

main { padding: clamp(14px, 2.5vw, 24px); max-width: 1680px; margin: 0 auto; }

.view { display: none; flex-direction: column; gap: clamp(14px, 2vw, 18px); }
.view.is-active { display: flex; }

.grid-2 {
  display: grid; gap: clamp(14px, 2vw, 18px);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: clamp(14px, 2vw, 18px);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex; align-items: baseline; gap: 10px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.card-head h2 { font-size: 14px; letter-spacing: .01em; }
.card-note { font-size: 11.5px; color: var(--text-mute); margin-left: auto; }

/* ── KPIs ──────────────────────────────────────────────────────── */

.kpis {
  display: grid; gap: clamp(10px, 1.6vw, 14px);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
}

.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
}
.kpi-accent { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.kpi-accent::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); font-weight: 600; }
.kpi-value {
  font-family: var(--mono); font-size: clamp(22px, 3.4vw, 28px); font-weight: 600;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-sub { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.kpi-value.is-ok { color: var(--ok); }
.kpi-value.is-warn { color: var(--warn); }
.kpi-value.is-bad { color: var(--danger); }

/* ── charts ────────────────────────────────────────────────────── */

.chart { width: 100%; height: 168px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-mute); font-size: 10px; font-family: var(--mono); }
.chart .bar { fill: var(--accent); }
.chart .bar-dim { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
.chart .line { fill: none; stroke: var(--info); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--info-bg); }
.chart .empty-text { fill: var(--text-mute); font-size: 12px; font-family: var(--sans); }

/* ── bar lists ─────────────────────────────────────────────────── */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bar-name { font-size: 12.5px; color: var(--text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-val { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); }
.bar-track { grid-column: 1 / -1; height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.bar-fill.c-ok { background: var(--ok); }
.bar-fill.c-warn { background: var(--warn); }
.bar-fill.c-bad { background: var(--danger); }
.bar-fill.c-info { background: var(--info); }
.bar-fill.c-mute { background: var(--text-mute); }
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }

/* ── tables ────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-soft);
  -webkit-overflow-scrolling: touch;
}

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { padding: 9px 12px; text-align: left; white-space: nowrap; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-mute);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--text-mute); padding: 26px 12px; }
.table-accounts td { font-family: var(--mono); font-size: 12px; }
.table-accounts td.copyable { cursor: pointer; }
.table-accounts td.copyable:hover { color: var(--accent-sh); }
.table-accounts td.copied { color: var(--ok); }
.minibar { width: 110px; height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; display: inline-block; vertical-align: middle; }
.minibar > i { display: block; height: 100%; background: var(--accent); }

/* ── carrier split ─────────────────────────────────────────────── */

.carriers {
  display: grid; gap: 12px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
}
.carrier {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--text-mute);
  border-radius: var(--r); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.carrier.k-mobile  { border-left-color: var(--ok); }
.carrier.k-fixed   { border-left-color: var(--warn); }
.carrier.k-unknown { border-left-color: var(--text-mute); }

.carrier-name { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); font-weight: 600; }
.carrier-rate { font-family: var(--mono); font-size: 23px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.carrier.k-mobile  .carrier-rate { color: var(--ok); }
.carrier.k-fixed   .carrier-rate { color: var(--warn); }
.carrier-meta { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.carrier-track { height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.carrier-track > i { display: block; height: 100%; background: var(--text-mute); transition: width .3s ease; }
.carrier.k-mobile .carrier-track > i { background: var(--ok); }
.carrier.k-fixed  .carrier-track > i { background: var(--warn); }
@media (prefers-reduced-motion: reduce) { .carrier-track > i { transition: none; } }

/* ── badges ────────────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; font-family: var(--sans);
  border: 1px solid transparent; white-space: nowrap;
}
.badge.s-active     { color: var(--ok);     background: var(--ok-bg);     border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.badge.s-creating   { color: var(--info);   background: var(--info-bg);   border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.badge.s-challenged { color: var(--warn);   background: var(--warn-bg);   border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.badge.s-failed,
.badge.s-banned     { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.badge.s-other      { color: var(--text-dim); background: var(--surface-3); border-color: var(--border); }

/* ── forms & buttons ───────────────────────────────────────────── */

.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 180px; }
.field-sm { flex: 0 1 118px; }
.field > span { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

.input, .field input, .field select {
  appearance: none;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px; font: inherit; font-size: 13px;
  min-width: 0; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field select, .input { background-image: none; }
.input:focus, .field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.field input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.btn {
  appearance: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--border-sh); background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--text-mute); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-sh); border-color: var(--accent-sh); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 85%, #fff); }
.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* Inside a toolbar the controls sit on one line and wrap only when they run
   out of room. The shared .input rule sets width:100% for the stacked form
   fields, which in a wrapping flex row would otherwise give every control a
   line of its own. */
.toolbar .input { width: auto; flex: 0 1 auto; min-width: 7rem; }
.toolbar .input-grow { flex: 1 1 220px; min-width: 10rem; }
.input-grow { flex: 1 1 200px; }
.toolbar-sep { flex: 0 0 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.check input { accent-color: var(--accent); }

.hint { margin: 12px 0 0; font-size: 11.5px; color: var(--text-mute); line-height: 1.55; }
.hint strong { color: var(--text-dim); font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager-info { font-family: var(--mono); font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ── runs ──────────────────────────────────────────────────────── */

.runs { display: grid; gap: clamp(12px, 1.8vw, 16px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }

.run {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  border-radius: var(--r-lg); padding: 15px 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
}
.run.is-stopping { border-left-color: var(--warn); }
.run.is-foreign { border-left-color: var(--info); }

.run-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.run-kind { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.run-pid { font-family: var(--mono); font-size: 11.5px; color: var(--text-mute); }
.run-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 4px; background: var(--info-bg); color: var(--info);
}
.run-tag.t-own { background: var(--ok-bg); color: var(--ok); }
.run-tag.t-stop { background: var(--warn-bg); color: var(--warn); }
.run-actions { margin-left: auto; display: flex; gap: 7px; }

.run-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 11px 14px; }
.run-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.run-stat b { font-family: var(--mono); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-stat span { font-size: 10.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.run-log { font-family: var(--mono); font-size: 11px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.runs-empty { color: var(--text-mute); text-align: center; padding: 40px 16px; border: 1px dashed var(--border); border-radius: var(--r-lg); font-size: 13px; }

/* ── system grid ───────────────────────────────────────────────── */

.sysgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.sysitem { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.sysitem span { display: block; font-size: 10.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.sysitem b { font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── log view ──────────────────────────────────────────────────── */

.logview {
  margin: 0; padding: 12px 14px;
  background: #06080b; border: 1px solid var(--border); border-radius: var(--r);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: #c3cad8;
  height: clamp(320px, 58vh, 720px); overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
.logview .l-err  { color: var(--danger); }
.logview .l-warn { color: var(--warn); }
.logview .l-ok   { color: var(--ok); }
.logview .l-dim  { color: var(--text-mute); }

/* ── banner / toasts / modal ───────────────────────────────────── */

.banner {
  margin: 0 clamp(14px, 2.5vw, 24px); margin-top: 14px;
  padding: 10px 14px; border-radius: var(--r);
  font-size: 12.5px; font-family: var(--mono);
}
.banner-err { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 9px; max-width: min(92vw, 400px); }
.toast {
  background: var(--surface-2); border: 1px solid var(--border-sh);
  border-left: 3px solid var(--info);
  border-radius: var(--r); padding: 11px 14px; font-size: 12.5px;
  box-shadow: var(--shadow); animation: slide-in .22s ease;
}
.toast.t-ok { border-left-color: var(--ok); }
.toast.t-err { border-left-color: var(--danger); }
.toast b { display: block; margin-bottom: 2px; font-size: 12px; }
.toast pre { margin: 5px 0 0; font-family: var(--mono); font-size: 11px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.modal {
  border: 1px solid var(--border-sh); background: var(--surface);
  color: var(--text); border-radius: var(--r-lg);
  padding: 20px 22px; max-width: min(92vw, 440px);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal::backdrop { background: rgba(4, 6, 9, .72); backdrop-filter: blur(3px); }
.modal h3 { font-size: 15px; margin-bottom: 8px; }
.modal p { margin: 0 0 18px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; }

/* ── login ─────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(255,85,0,.10), transparent 70%),
    var(--bg);
}
.login-card {
  width: min(100%, 352px); text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 34px 28px 28px;
  box-shadow: var(--shadow);
}
.login-mark {
  width: 58px; height: 58px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 15px; color: var(--accent);
  background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.login-card h1 { font-size: 19px; letter-spacing: -0.02em; }
.login-sub { margin: 4px 0 24px; font-size: 13px; color: var(--text-mute); }
.login-card .field { text-align: left; margin-bottom: 16px; }
.login-card input { text-align: center; font-family: var(--mono); font-size: 17px; letter-spacing: .3em; padding: 11px; }
.login-err { margin: 13px 0 0; font-size: 12.5px; color: var(--danger); }

/* ── narrow screens ───────────────────────────────────────────── */

@media (max-width: 720px) {
  .brand-dim { display: none; }
  .topbar { gap: 9px; }
  .chip { display: none; }
  .chip#sys-load { display: inline-block; }
  .card-note { margin-left: 0; flex-basis: 100%; }
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .btn { width: 100%; }
  .field, .field-sm { flex: 1 1 auto; width: 100%; }
  .run-actions { margin-left: 0; width: 100%; }
  .run-actions .btn { flex: 1; }
  .toolbar { gap: 7px; }
  .toolbar-sep { display: none; }
  .table th, .table td { padding: 8px 10px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  main { padding: 12px; }
}
