:root {
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-2: #1b1f26;
  --border: #262b33;
  --text: #e6e8eb;
  --text-muted: #939ba7;
  --accent: #5b8cff;
  --accent-dim: #2f3f66;
  --ok: #3ecf8e;
  --warn: #f2a93b;
  --err: #ef5350;
  --idle: #6b7280;
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Auth pages ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 320px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.auth-card--wide { width: 380px; }
.auth-card h1 { margin: 0 0 8px; font-size: 20px; }
.auth-sub { color: var(--text-muted); margin: 0 0 20px; font-size: 13px; }
.auth-error { color: var(--err); font-size: 13px; margin-bottom: 12px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  font-family: var(--mono);
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.qr { display: block; margin: 0 auto 16px; border-radius: 4px; background: #fff; padding: 8px; }
.secret-key {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 20px;
  word-break: break-all;
}

button, .btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger { background: var(--err); }
.btn-outline { background: transparent; color: var(--text); }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { color: var(--text-muted); font-size: 12px; font-family: var(--mono); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat-tile {
  background: var(--surface);
  padding: 14px 20px;
}
.stat-tile .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.stat-tile .value { font-size: 20px; font-weight: 600; margin-top: 4px; font-family: var(--mono); }
.stat-tile .sub { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.stat-tile canvas { margin-top: 8px; display: block; }

/* Dashboard fills the viewport; each column scrolls on its own. */
body.dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.dashboard > .topbar,
body.dashboard > .stat-row { flex: none; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  padding: 16px 24px;
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.column-title {
  flex: none;
  margin: 0;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.column-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.project-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .12s ease;
}
.card:hover { border-color: #3a4250; }
.card.selected { border-color: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-title { font-weight: 600; font-size: 15px; }
.card-domain { color: var(--text-muted); font-size: 12px; font-family: var(--mono); margin-bottom: 10px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.dot.running { background: var(--ok); }
.dot.stopped { background: var(--idle); }
.dot.mixed, .dot.restarting { background: var(--warn); }
.dot.paused { background: var(--warn); }
.dot.unknown { background: var(--idle); }

.card-containers { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.container-row { display: flex; justify-content: space-between; font-family: var(--mono); }

/* ---------- Detail panel ---------- */
.detail-panel-inner { padding: 20px; }
.detail-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.detail-panel h2 { margin: 0 0 4px; font-size: 17px; }
.detail-panel .domain { color: var(--text-muted); font-family: var(--mono); font-size: 12px; margin-bottom: 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.detail-section { margin-bottom: 18px; }
.detail-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 0 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.env-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.env-table td { padding: 3px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.env-table td:first-child { color: var(--text-muted); white-space: nowrap; }
.close-btn { float: right; }
.log-box {
  background: #000;
  color: #c8f0d8;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 10px;
  border-radius: 6px;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.commit-row { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.commit-row .hash { color: var(--accent); font-family: var(--mono); margin-right: 6px; }
.commit-row .meta { color: var(--text-muted); font-size: 11px; }

/* ---------- Activity feed ---------- */
.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-row {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  font-size: 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}
.activity-row .project { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row .action { color: var(--text-muted); font-family: var(--mono); }
.activity-row .timestamp { text-align: right; }
.activity-row .status { font-weight: 600; }
.activity-row .status.success { color: var(--ok); }
.activity-row .status.failed { color: var(--err); }
.activity-row .status.running { color: var(--warn); }
.timestamp { color: var(--text-muted); font-family: var(--mono); }

.empty { color: var(--text-muted); font-size: 13px; padding: 20px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 220px); }
  .column-activity { grid-column: 1 / -1; }
}

/* On phones, stack the columns and let the page scroll normally. */
@media (max-width: 760px) {
  body.dashboard { height: auto; overflow: visible; }
  .layout { grid-template-columns: 1fr; grid-template-rows: none; }
  .column-projects .column-body, .column-activity .column-body { max-height: 50vh; }
  .column-detail .column-body { overflow: visible; }
}
