:root {
  --bg: #1e1e1e; --panel: #252526; --panel2: #2d2d30; --border: #3e3e42;
  --text: #cccccc; --muted: #858585; --bright: #d4d4d4;
  --accent: #569cd6; --accent2: #4ec9b0;
  --go: #4ec9b0; --stop: #f14c4c; --warn: #cca700;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #333333;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 18px; width: 32px; height: 32px; border-radius: 6px;
  display: grid; place-items: center; background: var(--accent); color: #fff;
}
.title { font-weight: 600; font-size: 14px; color: var(--bright); }
.subtitle { color: var(--muted); font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.auto { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.auto input { accent-color: var(--accent); }

/* ── Auth button & popup ───────────────────────────────────── */
.auth-area { position: relative; }
.auth-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 16px; cursor: pointer; line-height: 1;
  transition: all .15s;
}
.auth-btn:hover { border-color: var(--accent); background: var(--panel2); }
.auth-popup {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: #333333; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 6px;
}
.auth-popup.hidden { display: none; }
.auth-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--bright); padding: 6px 10px; font-size: 13px; width: 180px;
  outline: none;
}
.auth-input:focus { border-color: var(--accent); }
.auth-error { color: var(--stop); font-size: 11px; min-height: 14px; }

/* ── Layout ─────────────────────────────────────────────────── */
main { padding: 16px 20px; max-width: 1380px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
}
.hero { background: var(--panel2); }
.card-label {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600;
}
.card-title { font-weight: 600; font-size: 13px; margin-bottom: 10px; color: var(--bright); }
.card-sub { color: var(--muted); font-size: 11px; margin-top: 4px; }
.big { font-size: 24px; font-weight: 700; margin-top: 4px; color: var(--bright); }
.big .unit { font-size: 13px; color: var(--muted); font-weight: 500; }
.hero-val { font-size: 32px; font-weight: 700; margin-top: 2px; color: var(--accent2); }
.hero-val .unit { font-size: 14px; color: var(--muted); margin-left: 4px; font-weight: 500; }

/* ── Tables ─────────────────────────────────────────────────── */
.tablecard { padding-bottom: 4px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td {
  text-align: left; padding: 7px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
th {
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--panel2); position: sticky; top: 0;
}
tbody tr:hover { background: #2a2d2e; }
td.num, th.num { text-align: right; }
.empty { color: var(--muted); font-style: italic; text-align: center; padding: 20px; }

/* ── Miner row elements ─────────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--go); box-shadow: 0 0 6px rgba(78, 201, 176, .5); }
.dot.off { background: var(--stop); opacity: .7; }
.mono { font-family: "Cascadia Code", "Fira Code", Consolas, monospace; font-size: 11px; color: var(--muted); }
.id { font-weight: 600; font-size: 12px; }
.phase {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: var(--panel2); border: 1px solid var(--border);
  display: inline-block; line-height: 1.4;
}
.phase.mining { color: var(--go); border-color: rgba(78, 201, 176, .4); }
.phase.calibrating, .phase.bootstrapping { color: var(--warn); border-color: rgba(204, 167, 0, .4); }
.offrow { opacity: .45; }

/* ── Auth-gated controls: hidden until authenticated ────────── */
.ctrl-only { display: none !important; }
body.authed .ctrl-only { display: inline !important; }
body.authed tr:hover .threads-edit { opacity: 1; }

/* ── Threads column ─────────────────────────────────────────── */
.threads-val { font-variant-numeric: tabular-nums; }
.threads-edit {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 11px; padding: 0 0 0 4px; line-height: 1; vertical-align: middle;
  opacity: 0; transition: opacity .15s;
}
.threads-edit:hover { color: var(--accent); }

/* ── Control cell (single pause/resume button) ──────────────── */
.ctrl-cell { text-align: center; width: 40px; }
.ctrl-btn {
  background: none; border: 1px solid transparent; color: var(--muted);
  border-radius: 4px; cursor: pointer; padding: 3px 6px;
  font-size: 12px; line-height: 1; transition: all .15s;
}
.ctrl-btn:hover { border-color: var(--border); background: var(--panel2); }
.ctrl-btn.pause:hover { color: var(--warn); }
.ctrl-btn.resume:hover { color: var(--go); }

/* ── Block pagination ───────────────────────────────────────── */
.pager {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 0 6px;
}
.page-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 4px; cursor: pointer; padding: 4px 10px;
  font-size: 12px; line-height: 1.3; transition: all .15s;
}
.page-btn:hover:not(:disabled) { color: var(--bright); background: var(--panel2); }
.page-btn.active { color: var(--bright); background: var(--accent); border-color: var(--accent); }
.page-btn:disabled { opacity: .3; cursor: default; }

/* ── Thread slider popup (fixed overlay) ───────────────────── */
.slider-popup {
  position: absolute; z-index: 100;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 0; min-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6); white-space: nowrap;
}
.slider-header {
  padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--bright);
  border-bottom: 1px solid var(--border); background: var(--panel2); border-radius: 8px 8px 0 0;
}
.slider-body {
  padding: 14px; display: flex; align-items: center; gap: 10px;
}
.thread-range {
  flex: 1; accent-color: var(--accent); cursor: pointer;
}
.slider-val {
  font-weight: 700; font-size: 18px; color: var(--accent2); min-width: 24px; text-align: center;
}
.slider-footer {
  padding: 8px 14px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
}
.slider-cancel {
  background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.slider-cancel:hover { color: var(--bright); background: var(--panel2); }
.slider-apply {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 5px 14px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.slider-apply:hover { background: #4a8ac4; }

/* ── Expandable miner rows ─────────────────────────────────── */
.miner-row { cursor: pointer; transition: background .1s; }
.miner-row:hover { background: #2a2d2e; }
.miner-row.expanded { background: var(--panel2); }
.chevron { font-size: 10px; color: var(--muted); margin-right: 4px; display: inline-block; width: 10px; }
.detail-row td { padding: 0 !important; border-bottom: 1px solid var(--border); }
.detail-cell { background: var(--bg); }
.detail-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px;
  padding: 14px 20px;
}
.detail-item { min-width: 0; }
.detail-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin-bottom: 4px;
}
.detail-val { font-size: 13px; font-weight: 600; color: var(--bright); margin-bottom: 4px; }
.detail-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.muted-val { color: var(--muted); font-style: italic; font-size: 12px; padding: 12px 20px; display: block; }
.meter {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 2px;
}
.meter-fill { height: 100%; border-radius: 3px; transition: width .3s; }

/* ── CPU limit toggle ──────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; gap: 8px; cursor: pointer; margin-top: 2px;
}
.toggle-row input[type="checkbox"] {
  accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer;
}
.toggle-text { font-size: 13px; color: var(--bright); font-weight: 500; }

@media (max-width: 1000px) { .detail-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .detail-grid { grid-template-columns: 1fr; } }

/* ── Install card ──────────────────────────────────────────── */
.install-desc { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.install-cmd {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 14px;
}
.install-cmd code {
  flex: 1; font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 13px; color: var(--accent2); user-select: all;
}
.copy-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .15s;
}
.copy-btn:hover { background: #4a8ac4; }

@media (max-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }
