/* Isolate dashboard — OpenCode TUI visual language, custom purple palette.
   Every colour comes from theme/theme.json via the generated theme.css. */

* {
  box-sizing: border-box;
}

html {
  scrollbar-color: var(--scrollbar) var(--background);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--background);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

::selection {
  background: var(--selected);
  color: var(--text);
}

body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  z-index: 10;
}

.rail-warn {
  background: var(--warning);
}

.rail-error {
  background: var(--error);
}

.frame {
  margin-left: 3px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.brand-mark {
  width: 8px;
  height: 8px;
  background: var(--accent);
}

.stats {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  min-width: 0;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.stat-value {
  font-weight: 600;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-spark {
  display: inline-flex;
}

.stat-spark .sparkline {
  width: 64px !important;
  height: 18px !important;
}

.stat-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.trend {
  font-size: 10px;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--error); }
.trend-flat { color: var(--muted); }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav a {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  border-bottom: 2px solid transparent;
}

.nav a:hover {
  color: var(--text);
  background: var(--element);
  text-decoration: none;
}

.nav a.nav-active {
  color: var(--accent);
  background: var(--selected);
  border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------- layout */

.content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-body {
  padding: 12px;
  overflow-x: auto;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--element);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--selected);
  text-decoration: none;
}

/* ---------------------------------------------------------------- chart */

.chart-wrap {
  position: relative;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--muted);
  font-size: 11px;
}

.chart .axis-title {
  fill: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.chart .axis-right {
  fill: var(--border-strong);
}

.chart .guide {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0;
}

.chart-wrap:hover .guide {
  opacity: 0.6;
}

.chart-tooltip {
  position: absolute;
  top: 6px;
  min-width: 148px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--accent);
  font-size: 12px;
  pointer-events: none;
  z-index: 2;
}

.tip-head {
  color: var(--muted);
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tip-swatch {
  width: 7px;
  height: 7px;
  display: inline-block;
}

.tip-label {
  color: var(--muted);
}

.tip-value {
  margin-left: auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
}

.sparkline {
  display: block;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
}

.segmented a {
  padding: 2px 10px;
  color: var(--muted);
  font-size: 11px;
}

.segmented a:hover {
  color: var(--text);
  background: var(--element);
  text-decoration: none;
}

.segmented a.seg-active {
  color: var(--accent);
  background: var(--selected);
}

/* ---------------------------------------------------------------- state */

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  background: var(--muted);
}

.dot-online {
  background: var(--success);
}

.dot-offline {
  background: var(--error);
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--success);
}

/* ---------------------------------------------------------------- tables */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--element);
}

td.num,
th.num {
  text-align: right;
}

/* Dense tables stay neutral; purple is reserved for hover affordance. */
td a {
  color: var(--text);
}

td a:hover {
  color: var(--accent);
}

td a.muted {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* ---------------------------------------------------------------- atoms */

.badge {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-accent { color: var(--accent); border-color: var(--accent); }
.badge-interactive { color: var(--accent-strong); border-color: var(--accent-strong); }
.badge-success { color: var(--success); border-color: var(--success); }
.badge-error { color: var(--error); border-color: var(--error); }
.badge-warning { color: var(--warning); border-color: var(--warning); }
.badge-info { color: var(--info); border-color: var(--info); }
.badge-muted { color: var(--muted); }

.tone-accent { color: var(--accent); }
.tone-interactive { color: var(--accent-strong); }
.tone-success { color: var(--success); }
.tone-error { color: var(--error); }
.tone-warning { color: var(--warning); }
.tone-info { color: var(--info); }
.tone-muted { color: var(--muted); }

.tone-bg-accent { background: var(--accent); }
.tone-bg-interactive { background: var(--accent-strong); }
.tone-bg-success { background: var(--success); }
.tone-bg-error { background: var(--error); }
.tone-bg-warning { background: var(--warning); }
.tone-bg-info { background: var(--info); }
.tone-bg-muted { background: var(--muted); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 24px 12px;
  color: var(--muted);
}

.empty-mark {
  width: 8px;
  height: 8px;
  background: var(--border-strong);
}

.empty-title {
  font-size: 12px;
}

.empty-hint {
  font-size: 11px;
}

.rank-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center;
  gap: 10px;
}

.rank-label {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-track {
  height: 6px;
  background: var(--element);
  display: block;
}

.rank-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.rank-value {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

/* ---------------------------------------------------------------- footer */

.statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}

.statusbar-brand {
  color: var(--accent);
  letter-spacing: 0.12em;
  font-weight: 600;
}

.statusbar-right {
  margin-left: auto;
}

/* ---------------------------------------------------------------- cards */

.server-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.server-card {
  border: 1px solid var(--border);
  background: var(--background);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.server-card:hover {
  border-color: var(--accent);
}

.server-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.server-card-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-card-stats {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.server-card-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.server-card-stat .value {
  font-size: 15px;
  font-weight: 600;
}

.server-card-stat .label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.server-card-spark {
  margin-left: auto;
}

/* ---------------------------------------------------------------- forms */

.login {
  max-width: 340px;
  margin: 12vh auto;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-page {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

input {
  background: var(--element);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

input::placeholder {
  color: var(--muted);
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

button {
  background: var(--element);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

button:hover {
  border-color: var(--accent-strong);
  color: var(--accent);
  background: var(--selected);
}

button:disabled {
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- mobile */

/* Low-priority columns are dropped before a table is allowed to scroll, so the
   page itself never overflows. */
@media (max-width: 900px) {
  td,
  th {
    padding: 5px 8px;
  }

  .t-servers th:nth-child(2),
  .t-servers td:nth-child(2),
  .t-servers th:nth-child(3),
  .t-servers td:nth-child(3),
  .t-servers th:nth-child(6),
  .t-servers td:nth-child(6),
  .t-sessions th:nth-child(3),
  .t-sessions td:nth-child(3),
  .t-sessions th:nth-child(4),
  .t-sessions td:nth-child(4),
  .t-sessions th:nth-child(5),
  .t-sessions td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 620px) {
  td,
  th {
    padding: 4px 6px;
    font-size: 12px;
  }

  .t-flags th:nth-child(2),
  .t-flags td:nth-child(2),
  .t-servers th:nth-child(5),
  .t-servers td:nth-child(5),
  .t-servers th:nth-child(7),
  .t-servers td:nth-child(7),
  .t-uploads th:nth-child(3),
  .t-uploads td:nth-child(3),
  .t-uploads th:nth-child(5),
  .t-uploads td:nth-child(5),
  .t-models th:nth-child(2),
  .t-models td:nth-child(2),
  .t-models th:nth-child(4),
  .t-models td:nth-child(4) {
    display: none;
  }

  /* Scaled to a narrow viewport the SVG's axis text renders ~3px tall, so the
     chart reads as a trend line and the legend carries the naming. */
  .chart .axis,
  .chart .axis-title,
  .t-secs {
    display: none;
  }
}

@media (max-width: 860px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 12px;
  }

  .brand {
    order: 1;
  }

  .nav {
    order: 2;
    margin-left: auto;
  }

  .stats {
    order: 3;
    flex-basis: 100%;
    gap: 12px;
  }

  .stat-spark {
    display: none;
  }

  .content {
    padding: 12px;
    gap: 10px;
  }

  .panel-head {
    flex-wrap: wrap;
    gap: 6px;
  }

  .statusbar {
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .nav {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .actions .action {
    width: 100%;
    justify-content: center;
  }

  .server-cards {
    grid-template-columns: 1fr;
  }
}
