/* Rein Dashboard — developer-tool aesthetic.
   Design Read: personal ops tool, ENERGY 1 / RHYTHM 1 / MOTION 1.
   Identity motif: tabular numerals + status dots. No gradients, no glass, no glow. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1e26;
  --muted: #5c6270;
  --border: #d9dde3;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --warn: #b45309;
  --bad: #b3261e;
  --focus: #0f766e;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --surface: #1c1f25;
  --text: #e8eaf0;
  --muted: #9aa1ad;
  --border: #2c3039;
  --accent: #14b8a6;
  --accent-text: #08251f;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --focus: #14b8a6;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
/* hidden attribute must always win over any display rule (login overlay bug) */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.num, .metric-value { font-variant-numeric: tabular-nums; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 0.5rem; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  color: var(--muted); text-decoration: none; padding: 0.45rem 0.8rem; border-radius: 6px; cursor: pointer;
}
.topbar nav a:hover { color: var(--text); background: var(--bg); }
.topbar nav a.active { color: var(--accent); font-weight: 600; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* generic controls — semantic + states (R-26/R-32/R-39) */
button, .btn {
  font: inherit; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 0.5rem 0.9rem;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active { filter: brightness(0.95); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
input, select {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.6rem;
}
label { display: block; margin: 0.6rem 0 0.2rem; font-size: 0.9rem; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

/* cards / grid — uniform grid is deliberate for a dashboard (RHYTHM 1) */
.grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.9rem 1rem;
}
.card h2 { margin: 0 0 0.6rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }
.card.wide { grid-column: 1 / -1; }

.metric-value { font-size: 1.7rem; font-weight: 650; line-height: 1; }
.metric-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.spark { width: 100%; height: 34px; margin-top: 0.5rem; display: block; }

/* disk bars */
.disk-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; }
.disk-row .mount { flex: 1; font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { flex: 2; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar > span.warn { background: var(--warn); }
.bar > span.bad { background: var(--bad); }

/* lists */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 0.82rem; }

/* files table */
table.files { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.files th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--border); }
table.files td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--border); }
table.files tr:hover td { background: var(--bg); }
.fname { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text); }
.row-actions { display: flex; gap: 0.3rem; }
.row-actions button { padding: 0.2rem 0.5rem; font-size: 0.8rem; }

/* breadcrumb */
.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.6rem; font-size: 0.9rem; }
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; }
.crumbs .sep { color: var(--muted); }

/* upload */
.dropzone {
  border: 1px dashed var(--border); border-radius: 8px; padding: 1.1rem;
  text-align: center; color: var(--muted); margin: 0.75rem 0; cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); color: var(--accent); }
.prog { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; margin: 0.3rem 0; }
.prog .bar { flex: 3; }
.prog .pname { flex: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* network card: two stacked stat lines, no wrap (mobile-safe) */
.net-stats { display: flex; flex-direction: column; gap: 0.35rem; }
.net-stats > div { display: flex; align-items: baseline; gap: 0.5rem; white-space: nowrap; }

/* states (R-27) */
.state { padding: 1.2rem; text-align: center; color: var(--muted); }
.skeleton { height: 1rem; border-radius: 4px; background: linear-gradient(100deg, var(--bg) 40%, var(--border) 50%, var(--bg) 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* login */
.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: min(360px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.4rem; }
.login-card h1 { margin: 0 0 0.8rem; font-size: 1.2rem; }
.login-card button { width: 100%; margin-top: 1rem; }
.form-error { color: var(--bad); font-size: 0.88rem; margin: 0.5rem 0 0; }

/* dialog */
dialog {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  padding: 1.1rem; min-width: min(340px, 90vw);
}
dialog::backdrop { background: rgba(0,0,0,0.45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* mobile (R-03) */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 0.5rem; gap: 0.5rem; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav a { flex: 1; text-align: center; padding: 0.5rem 0.2rem; }
  .container { padding: 0.6rem; }
  .grid { grid-template-columns: 1fr; }
  table.files { font-size: 0.85rem; }
  .row-actions button { padding: 0.25rem 0.45rem; }
}
