*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Courier New', monospace;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
  padding: 0;
}

/* ── header ──────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0d1117;
  border-bottom: 1px solid #30363d;
  padding: 14px 24px 0;
}
.app-header h1 { color: #58a6ff; font-size: 1.4rem; margin-bottom: 2px; }
.subtitle { color: #8b949e; font-size: 0.8rem; margin-bottom: 12px; }

/* ── tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #30363d; }
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: -1px;
  border-radius: 0;
}
.tab-btn:hover { color: #c9d1d9; }
.tab-btn.active { color: #58a6ff; border-bottom-color: #58a6ff; }

/* ── main content ────────────────────────────────────────────────────────── */
.tab-panel { display: none; padding: 24px; }
.tab-panel.active { display: block; }

/* ── layout grid ─────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.model-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }

/* ── cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px;
}
.card h2 {
  font-size: 0.85rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.model-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px;
}
.model-card h3 {
  font-size: 0.8rem;
  color: #c9d1d9;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* loading overlay on model cards */
.model-card.loading { opacity: 0.5; pointer-events: none; }

/* ── badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 0.72rem; font-weight: bold; }
.b-starter    { background: #21262d; color: #8b949e;  border: 1px solid #30363d; }
.b-plus       { background: #1c3553; color: #58a6ff;  border: 1px solid #1f6feb; }
.b-pro        { background: #2d1f3d; color: #d2a8ff;  border: 1px solid #8957e5; }
.b-queued     { background: #1c2e1c; color: #3fb950;  border: 1px solid #238636; }
.b-processing { background: #3d2200; color: #f0883e;  border: 1px solid #d29922; }
.b-done       { background: #21262d; color: #6e7681;  border: 1px solid #30363d; }

/* ── metrics ─────────────────────────────────────────────────────────────── */
.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #21262d;
}
.metric:last-child { border-bottom: none; }
.metric-label { color: #8b949e; font-size: 0.78rem; }
.metric-value { font-size: 1rem; font-weight: bold; }
.mv-danger { color: #f85149; }
.mv-warn   { color: #d29922; }
.mv-ok     { color: #3fb950; }
.mv-dim    { color: #6e7681; }

.model-row { display: flex; justify-content: space-between; font-size: 0.72rem; padding: 3px 0; border-bottom: 1px solid #21262d; }
.model-row:last-child { border-bottom: none; }
.model-row-label { color: #8b949e; }

.queue-items { margin-top: 6px; max-height: 80px; overflow-y: auto; }
.queue-item { font-size: 0.7rem; color: #6e7681; padding: 1px 0; }

/* ── active counters ─────────────────────────────────────────────────────── */
.active-counters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.active-chip { background: #21262d; border: 1px solid #30363d; border-radius: 4px; padding: 3px 8px; font-size: 0.7rem; }

/* ── section title ───────────────────────────────────────────────────────── */
.section-title { font-size: 0.8rem; color: #8b949e; text-transform: uppercase; letter-spacing: 1px; margin: 18px 0 8px; }

/* ── forms ───────────────────────────────────────────────────────────────── */
label { font-size: 0.75rem; color: #8b949e; display: block; margin-bottom: 4px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }

select, input[type=text], input[type=number] {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
}
select:focus, input:focus { outline: none; border-color: #58a6ff; }

.queue-hint {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: #8b949e;
  padding: 6px 10px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1;
}

/* ── buttons ─────────────────────────────────────────────────────────────── */
button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: bold;
  transition: opacity .15s, transform .1s;
}
button:hover  { opacity: 0.85; }
button:active { opacity: 0.65; transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-blue   { background: #1f6feb; color: #fff; }
.btn-purple { background: #8957e5; color: #fff; }
.btn-green  { background: #238636; color: #fff; }
.btn-orange { background: #d29922; color: #0d1117; }
.btn-red    { background: #b91c1c; color: #fff; }
.btn-grey   { background: #21262d; color: #8b949e; border: 1px solid #30363d; }

/* flush confirm state */
.btn-red.confirm-pending {
  background: #7f1d1d;
  animation: pulse-red 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-red { from { opacity: 0.8; } to { opacity: 1; } }

/* ── log ─────────────────────────────────────────────────────────────────── */
.log {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px;
  height: 140px;
  overflow-y: auto;
  font-size: 0.7rem;
}
.log-entry { padding: 2px 0; border-bottom: 1px solid #161b22; display: flex; gap: 8px; }
.log-ts   { color: #3fb950; flex-shrink: 0; }
.log-ok   { color: #58a6ff; }
.log-err  { color: #f85149; }
.log-warn { color: #d29922; }

/* ── requests table ──────────────────────────────────────────────────────── */
.req-table-wrap {
  overflow-x: auto;
  border: 1px solid #30363d;
  border-radius: 6px;
  max-height: 420px;
  overflow-y: auto;
}
table.req-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.req-table th {
  color: #8b949e;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #30363d;
  position: sticky;
  top: 0;
  background: #161b22;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.req-table th:hover { color: #c9d1d9; }
.req-table th .chv { opacity: 0.4; font-size: 0.65rem; margin-left: 4px; }
.req-table th.sort-asc  .chv::after { content: '▲'; opacity: 1; }
.req-table th.sort-desc .chv::after { content: '▼'; opacity: 1; }
.req-table th:not(.sort-asc):not(.sort-desc) .chv::after { content: '⇅'; }
.req-table td { padding: 5px 10px; border-bottom: 1px solid #21262d; }
.req-table tr:hover td { background: #1c2128; }
.req-table td.req-id-cell { color: #58a6ff; font-size: 0.7rem; }

.action-btn {
  padding: 2px 8px;
  font-size: 0.68rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
}
.action-btn:hover { opacity: 0.8; }
.act-consume  { background: #d29922; color: #0d1117; }
.act-complete { background: #238636; color: #fff; }

/* ── info tables ─────────────────────────────────────────────────────────── */
.info-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.info-table th { color: #8b949e; text-align: left; padding: 4px 8px; border-bottom: 1px solid #30363d; }
.info-table td { padding: 4px 8px; border-bottom: 1px solid #21262d; }

/* ── readme / docs ───────────────────────────────────────────────────────── */
.readme {
  max-width: 860px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9rem;
  line-height: 1.7;
}
.readme h1, .readme h2 { color: #58a6ff; border-bottom: 1px solid #30363d; padding-bottom: 4px; margin: 20px 0 8px; }
.readme h3 { color: #d2a8ff; margin: 16px 0 6px; }
.readme p, .readme li { margin: 6px 0; }
.readme ul, .readme ol { margin-left: 24px; }
.readme code { background: #21262d; border-radius: 3px; padding: 1px 5px; font-size: 0.82rem; }
.readme pre { background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 14px; overflow-x: auto; margin: 10px 0; }
.readme pre code { background: none; border: none; padding: 0; }
.readme table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 10px 0; }
.readme th { color: #8b949e; text-align: left; padding: 5px 8px; border-bottom: 1px solid #30363d; }
.readme td { padding: 4px 8px; border-bottom: 1px solid #21262d; }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .grid, .model-grid { grid-template-columns: 1fr; }
}
