:root {
  --bg: #0a0d12;
  --bg-elevated: #11161d;
  --card: #131922;
  --card-border: #232b38;
  --text: #e8edf4;
  --text-dim: #8b96a8;
  --text-faint: #5a6678;

  --accent: #6ee7d9;
  --accent-soft: rgba(110, 231, 217, 0.12);

  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;

  --sonnet: #6ee7d9;
  --opus: #c4a3ff;
  --haiku: #86efac;
  --fable: #fdba74;
  --other: #93c5fd;

  --font-sans: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;

  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(110, 231, 217, 0.07), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(196, 163, 255, 0.06), transparent 40%);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  background: rgba(10, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--opus));
  box-shadow: 0 0 16px rgba(110, 231, 217, 0.6);
  flex: none;
}

.brand h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.clock {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s ease;
}

.status.live::before {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.status.error::before {
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}

/* ---------- Layout ---------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin: 0 0 12px 2px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

@media (max-width: 860px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-sessions {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-totals {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
}

.empty {
  color: var(--text-faint);
  font-size: 14px;
  padding: 8px 0;
}

/* ---------- Session cards ---------- */

.session-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.session-project {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  flex: none;
}

.model-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

/* ---------- Progress bars ---------- */

.bar-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transition: width 0.6s ease;
}

.bar-fill.warn {
  background: linear-gradient(90deg, var(--warn), #f59e0b);
}

.bar-fill.bad {
  background: linear-gradient(90deg, #f87171, #ef4444);
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Block card ---------- */

.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.block-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.block-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
}

/* ---------- Passcode gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 13, 18, 0.92);
  backdrop-filter: blur(12px);
}

.gate[hidden] {
  display: none;
}

.gate-card {
  width: min(340px, 88vw);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.gate-mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.gate-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}

.gate-sub {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0 0 16px;
}

.gate-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  outline: none;
  text-align: center;
  letter-spacing: 0.15em;
}

.gate-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-btn {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #06251f;
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.gate-btn:hover {
  filter: brightness(1.08);
}

.gate-error {
  font-size: 12px;
  color: var(--bad);
  margin: 12px 0 0;
}

.gate-error[hidden] {
  display: none;
}

.status.snapshot::before {
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

/* ---------- Today / Goals cards ---------- */

.today-block-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.priority-list,
.task-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.priority-list li {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(110, 231, 217, 0.25);
}

.task-list li {
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 16px;
  position: relative;
}

.task-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
}

.today-footer {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  border-top: 1px solid var(--card-border);
  padding-top: 12px;
  margin-top: 4px;
}

.goals-life {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 16px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding-left: 0 !important;
}

.checklist-item::before {
  content: none;
}

.checklist-box {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ok);
  margin-top: 1px;
}

.checklist-item.done {
  color: var(--text-faint);
  text-decoration: line-through;
}

.checklist-item.done .checklist-box {
  border-color: var(--ok);
}

.checklist-item.toggle {
  cursor: pointer;
  border-radius: 6px;
  margin: 0 -6px;
  padding: 3px 6px !important;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.checklist-item.toggle:hover {
  background: var(--bg-elevated);
}

.checklist-item.toggle.toggling {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Stat tiles ---------- */

.stat-tile {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-tile-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.stat-tile-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
}

.stat-tile-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 7-day chart ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 140px;
  padding-top: 10px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 8px;
}

.chart-bar {
  width: 100%;
  max-width: 38px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent), rgba(110, 231, 217, 0.25));
  min-height: 3px;
  transition: height 0.6s ease;
}

.chart-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.chart-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--card-border);
}

td {
  padding: 10px;
  border-bottom: 1px solid rgba(35, 43, 56, 0.5);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

td.num, th.num {
  font-family: var(--font-mono);
  text-align: right;
}

td.proj {
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.time {
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}

.cost {
  color: var(--accent);
}

/* ---------- Section head (title + inline control) ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.count-pill {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-transform: none;
}

.filter-input {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 12px;
  width: 200px;
  max-width: 45%;
  margin-bottom: 12px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Automations ---------- */

.next-up {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(110, 231, 217, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.next-up-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.next-up-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.next-up-name {
  font-size: 15px;
  font-weight: 600;
}

.next-up-when {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.auto-table td {
  vertical-align: top;
}

.auto-name {
  font-weight: 500;
}

.run-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.run-dot.ok { background: var(--ok); box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
.run-dot.fail { background: var(--bad); box-shadow: 0 0 6px rgba(248, 113, 113, 0.5); }
.run-dot.none { background: var(--text-faint); }
.run-dot.running { background: var(--warn); animation: dot-pulse 1.2s ease-in-out infinite; }

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0); }
}

.auto-desc {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-faint);
  margin: 3px 0 0 16px;
  max-width: 460px;
}

.auto-sched {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.auto-next {
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}

.auto-next.soon {
  color: var(--accent);
}

tr.row-off {
  opacity: 0.5;
}

/* ---------- Notes & overnight queue ---------- */

.note-box {
  margin-bottom: 16px;
}

.seg {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 10px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.note-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.4;
}

.note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.note-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.note-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.note-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.note-btn {
  background: var(--accent);
  color: #06231f;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.note-btn:hover { filter: brightness(1.08); }
.note-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ov-done-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

#ov-done .checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Overnight result & alert ---------- */

.ov-result-box {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.ov-result-box.has-err { border-color: rgba(248, 113, 113, 0.4); }

.ov-result-body {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 4px;
}

.ov-alert {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 9px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: var(--bad);
  font-size: 13px;
}

.ov-alert pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---------- Quick actions ---------- */

.qa-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.qa-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-right: 4px;
}

.qa-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 7px 12px;
  cursor: pointer;
}

.qa-btn:hover { border-color: var(--accent); }
.qa-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.qa-status {
  font-size: 12px;
  color: var(--text-dim);
}
.qa-status.ok { color: var(--ok); }
.qa-status.err { color: var(--bad); }

.qa-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

/* ---------- Fleet & deploy budget ---------- */

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.fleet-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}

.fleet-num {
  font-size: 26px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.fleet-num.warn-text { color: var(--warn); }

.fleet-lbl {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.gauge-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.gauge-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

@media (max-width: 620px) {
  .fleet-grid { grid-template-columns: repeat(2, 1fr); }
  .gauge-row { grid-template-columns: 1fr; }
}

/* ---------- Skills grid ---------- */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.skill-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-left: 2px solid var(--text-faint);
  border-radius: 8px;
  padding: 10px 12px;
  overflow: hidden;
}

.skill-chip.skill-mine { border-left-color: var(--accent); }
.skill-chip.skill-plugin { border-left-color: var(--opus); }

.skill-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.skill-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.4;
}
