/* =========================================================================
   slipa — operator console
   Pro dev-tool aesthetic: dense tables, clear forms, dark mode by default.
   ========================================================================= */

:root {
  /* surfaces */
  --bg:          #09090b;
  --bg-2:        #0e0e11;
  --surface:     #121217;
  --surface-2:   #17171c;
  --surface-hi:  #1c1c22;
  --border:      #23232b;
  --border-hi:   #2e2e38;

  /* text */
  --text:        #f4f4f5;
  --text-2:      #c4c4cc;
  --text-muted:  #8b8b95;
  --text-dim:    #5a5a63;

  /* brand / accent */
  --accent:      #22d3ee;   /* cyan-400 */
  --accent-dim:  #0891b2;   /* cyan-600 */
  --accent-ink:  #022c33;

  /* semantic */
  --success:     #34d399;
  --warning:     #f59e0b;
  --danger:      #f87171;
  --info:        #60a5fa;
  --neutral:     #9ca3af;

  /* spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  /* type */
  --ff-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ff-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* shape */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  /* motion */
  --ease:      cubic-bezier(.2,.65,.2,1);
  --dur:       .16s;

  /* layout */
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; }
input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

code { font-family: var(--ff-mono); font-size: .92em; background: var(--surface-2);
       padding: 1px 6px; border-radius: 4px; color: var(--text-2); }

.muted { color: var(--text-muted); }

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 10;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 18px var(--s-5);
  border-bottom: 1px solid var(--border);
}
.brand__mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  background:
    radial-gradient(120% 120% at 20% 15%, rgba(255,255,255,.22) 0%, transparent 50%),
    linear-gradient(135deg, #22d3ee 0%, #0891b2 100%);
  color: #022c33;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--ff-sans);
  letter-spacing: -.04em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.15),
    0 1px 2px rgba(0,0,0,.4);
}
.brand__mark::after {
  /* hairline ring for precision */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,.08);
  pointer-events: none;
}
.brand__name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 16px;
}

.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--s-3);
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.is-active {
  background: var(--surface-hi);
  color: var(--text);
}
.nav-item.is-active .nav-item__icon { color: var(--accent); }
.nav-item__icon {
  width: 16px; height: 16px;
  color: var(--text-muted);
  fill: currentColor;
  stroke: currentColor;
}

.sidebar__foot {
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}

.conn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  transition: background var(--dur);
  text-align: left;
}
.conn:hover { background: var(--surface); }
.conn__label { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.conn__title { font-weight: 500; font-size: 13px; color: var(--text); }
.conn__sub { font-size: 11.5px; color: var(--text-muted); font-family: var(--ff-mono); }
.conn__icon { width: 14px; height: 14px; color: var(--text-muted); fill: none; stroke: currentColor; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.dot--ok      { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot--err     { background: var(--danger);  box-shadow: 0 0 8px var(--danger); }
.dot--pending { background: var(--warning); }

/* =========================================================================
   APP LAYOUT
   ========================================================================= */
.app {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 14px var(--s-7);
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.topbar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar__sub {
  color: var(--text-muted);
  font-size: 13px;
}
.topbar__spacer { flex: 1; }

.page {
  padding: var(--s-7);
  max-width: 1400px;
  width: 100%;
}

/* =========================================================================
   BUTTONS / CONTROLS
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background var(--dur), border-color var(--dur), color var(--dur);
  white-space: nowrap;
}
.btn:hover   { background: var(--surface-2); border-color: var(--border-hi); }
.btn:active  { background: var(--surface-hi); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn--primary:hover { background: var(--accent); filter: brightness(1.1); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface); }

.btn--sm { padding: 5px 10px; font-size: 12px; }

.iconbtn {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--dur), color var(--dur);
}
.iconbtn:hover { background: var(--surface); color: var(--text); }

/* =========================================================================
   FORMS
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field__label {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}
.field__help {
  font-size: 12px; color: var(--text-muted); margin-top: -2px;
}
.field__input, .field__select, .field__textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur), background var(--dur);
}
.field__input:focus, .field__select:focus, .field__textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
.field__textarea { min-height: 84px; resize: vertical; font-family: var(--ff-mono); font-size: 12.5px; }
.input--mono { font-family: var(--ff-mono); font-size: 12.5px; }

.field__select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 8l5 5 5-5' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 34px;
}

/* Segmented control (lora / qlora / full) */
.segment {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 2px;
}
.segment__opt {
  position: relative;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.segment__opt:hover { color: var(--text-2); }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment__opt:has(input:checked) {
  background: var(--surface-hi);
  color: var(--text);
}

/* Chip group */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.chip:hover { background: var(--surface-2); border-color: var(--border-hi); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.35);
}

/* Toggle */
.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__switch {
  position: relative;
  width: 32px; height: 18px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background var(--dur);
}
.toggle__switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--dur), background var(--dur);
}
.toggle:has(input:checked) .toggle__switch {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle:has(input:checked) .toggle__switch::after {
  transform: translateX(14px);
  background: var(--accent-ink);
}
.toggle__label { font-size: 13px; color: var(--text-2); }
.toggle__hint { font-size: 12px; color: var(--text-muted); }

/* =========================================================================
   CARDS / STATS
   ========================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 14px; font-weight: 600; }
.card__sub   { font-size: 12px; color: var(--text-muted); font-family: var(--ff-mono); }
.card__body  { padding: var(--s-5); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.stat__value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--text);
}
.stat__value.accent { color: var(--accent); }
.stat__unit { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat__delta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--ff-mono);
}

/* =========================================================================
   TABLES
   ========================================================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  position: sticky; top: 0;
  background: var(--bg-2);
  text-align: left;
  padding: 10px var(--s-4);
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr.is-clickable { cursor: pointer; }
.table .num { font-variant-numeric: tabular-nums; font-family: var(--ff-mono); }
.table .ellip {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table__wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table tbody tr:last-child td { border-bottom: 0; }

/* =========================================================================
   STATUS PILLS
   ========================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--ff-mono);
  letter-spacing: 0.02em;
}
.pill .pilldot { width: 6px; height: 6px; border-radius: 50%; }
.pill[data-status="training"],
.pill[data-status="running"],
.pill[data-status="checkpointing"],
.pill[data-status="rebidding"],
.pill[data-status="provisioning"] {
  background: rgba(34, 211, 238, 0.1);
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.25);
}
.pill[data-status="training"] .pilldot,
.pill[data-status="running"] .pilldot,
.pill[data-status="checkpointing"] .pilldot,
.pill[data-status="rebidding"] .pilldot,
.pill[data-status="provisioning"] .pilldot {
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 1.6s ease-out infinite;
}
.pill[data-status="completed"] {
  background: rgba(52, 211, 153, 0.08);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.25);
}
.pill[data-status="completed"] .pilldot { background: var(--success); }
.pill[data-status="failed"],
.pill[data-status="evicted"],
.pill[data-status="cancelled"] {
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
}
.pill[data-status="failed"] .pilldot,
.pill[data-status="evicted"] .pilldot,
.pill[data-status="cancelled"] .pilldot { background: var(--danger); }
.pill[data-status="pending"],
.pill[data-status="queued"],
.pill[data-status="awaiting_price"],
.pill[data-status="validating"] {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.22);
}
.pill[data-status="pending"] .pilldot,
.pill[data-status="queued"] .pilldot,
.pill[data-status="awaiting_price"] .pilldot,
.pill[data-status="validating"] .pilldot { background: var(--warning); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(34, 211, 238, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0);    }
  100% { box-shadow: 0 0 0 0   rgba(34, 211, 238, 0);    }
}

/* Simple inline status bar */
.progress {
  position: relative;
  width: 64px;
  height: 4px;
  background: var(--surface-hi);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s var(--ease);
}
.progress--cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================================================
   JOB DETAIL
   ========================================================================= */
.detail__head {
  display: flex; align-items: center; gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.backlink {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px;
  transition: color var(--dur);
}
.backlink:hover { color: var(--text); }

.detail__grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--s-5);
  margin-top: var(--s-5);
}
@media (max-width: 1100px) { .detail__grid { grid-template-columns: 1fr; } }

.meta-list {
  display: flex;
  flex-direction: column;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-4);
  padding: 10px var(--s-5);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.meta-row:last-child { border-bottom: 0; }
.meta-row__k { color: var(--text-muted); font-size: 12px; }
.meta-row__v { font-family: var(--ff-mono); font-variant-numeric: tabular-nums;
                color: var(--text); text-align: right; max-width: 60%;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chart */
.loss-chart { width: 100%; height: 240px; display: block; }
.loss-chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.loss-chart .axis { stroke: var(--border-hi); stroke-width: 1; }
.loss-chart .line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.loss-chart .area { fill: var(--accent); opacity: 0.08; }
.loss-chart .tick { font-family: var(--ff-mono); font-size: 10.5px; fill: var(--text-muted); }
.loss-chart .cursor { font-family: var(--ff-mono); font-size: 11px; fill: var(--accent); }

/* Logs */
.logs {
  background: #050506;
  color: #d4d4d8;
  font-family: var(--ff-mono);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.logs__line { white-space: pre-wrap; padding: 1px 0; }
.logs__line .t { color: #5a5a63; margin-right: 10px; }
.logs__line .lvl {
  display: inline-block; min-width: 46px; margin-right: 8px; font-weight: 500;
}
.logs__line .lvl-info  { color: #60a5fa; }
.logs__line .lvl-warn  { color: #f59e0b; }
.logs__line .lvl-error { color: #f87171; }
.logs__line .lvl-ok    { color: #34d399; }
.logs__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--ff-mono);
}

/* =========================================================================
   FORM (new run) layout
   ========================================================================= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--s-6);
  align-items: start;
}
@media (max-width: 1100px) { .form-grid { grid-template-columns: 1fr; } }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
}
.form-section__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
}
.form-section__desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 var(--s-4);
}

.form-summary {
  position: sticky;
  top: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.form-summary__head {
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border);
}
.form-summary__actions {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--s-2);
}

/* =========================================================================
   MARKET (prices) table
   ========================================================================= */
.market-filters {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.supply {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.supply__bar {
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--surface-hi);
  border-radius: 1px;
}
.supply__bar.on { background: var(--accent); }

.best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 500;
  font-size: 11px;
  font-family: var(--ff-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* =========================================================================
   EMPTY / LOADING STATES
   ========================================================================= */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
.empty h3 { color: var(--text); font-size: 15px; margin: 0 0 4px; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--s-5);
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: var(--radius);
  color: var(--warning);
  font-size: 13px;
  margin-bottom: var(--s-5);
}
.beta-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--s-5);
  background: rgba(96, 165, 250, 0.06);
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  margin: var(--s-5) var(--s-5) 0;
}
.beta-banner strong { color: var(--text); }
.beta-banner .beta-banner__spend {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.beta-banner .beta-banner__spend.over {
  color: var(--warning);
}
.demo-banner strong { color: var(--text); }
.demo-banner button {
  margin-left: auto;
  color: var(--warning);
  font-weight: 500;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================================================================
   MODAL
   ========================================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal__card {
  position: relative;
  width: min(480px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.modal__body { padding: var(--s-5); }
.modal__body p { margin: 0 0 var(--s-4); }
.modal__actions {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

/* =========================================================================
   FILTERS & UTILITIES
   ========================================================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.toolbar__spacer { flex: 1; }

.filter-input {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  transition: border-color var(--dur), background var(--dur);
  min-width: 240px;
}
.filter-input:focus-within {
  border-color: var(--accent);
  background: var(--surface-2);
}
.filter-input svg {
  width: 14px; height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.filter-input input {
  width: 100%;
  padding: 7px 8px;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 13px;
  color: var(--text);
}
.filter-input input::placeholder { color: var(--text-dim); }

.select-inline {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 30px 7px 10px;
  font-size: 13px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 8l5 5 5-5' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
.select-inline:hover { border-color: var(--border-hi); }
.select-inline:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--text-muted);
  font-family: var(--ff-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--ff-mono);
  letter-spacing: 0.02em;
}
.badge--accent { background: rgba(34,211,238,.1); color: var(--accent); }
.badge--muted  { background: var(--surface-2); color: var(--text-muted); }

/* Toasts */
.toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  min-width: 260px;
  max-width: 380px;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  animation: toast-in .18s var(--ease);
  pointer-events: auto;
}
.toast--ok  { border-left: 2px solid var(--success); }
.toast--err { border-left: 2px solid var(--danger); }
.toast--info { border-left: 2px solid var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.page-head__title  { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.page-head__sub    { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }

/* Slider */
input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  margin: 0;
}
input[type="range"].slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--surface-hi);
  border-radius: 999px;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  margin-top: -5px;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--accent);
  transition: transform .12s;
}
input[type="range"].slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"].slider::-moz-range-track {
  height: 4px;
  background: var(--surface-hi);
  border-radius: 999px;
}
input[type="range"].slider::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--accent);
}

/* Row accent on hover (subtle cyan edge indicating interactivity) */
.table tbody tr.is-clickable {
  position: relative;
}
.table tbody tr.is-clickable::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--dur);
}
.table tbody tr.is-clickable:hover::after { opacity: .7; }

/* Filter chip group (scrollable on small) */
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .sidebar__brand .brand__name,
  .nav-item span:not(.nav-item__icon),
  .conn__label { display: none; }
  .sidebar__brand { justify-content: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .conn { justify-content: center; padding: 10px; }
  .conn__icon { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .page { padding: var(--s-4); }
  .topbar { padding: var(--s-3) var(--s-4); }
  .stats { grid-template-columns: 1fr; }
  .table thead { display: none; }
}
