/* Dashboard styling.
 *
 * No framework and no build step: this is a self-hosted tool for one family,
 * and a toolchain nobody maintains is a liability. Everything is CSS custom
 * properties, flex and grid.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #d9dde5;
  --text: #12141a;
  --muted: #5c6373;
  --accent: #5865f2;
  --success: #2ecc71;
  --warning: #f1c40f;
  --danger: #e74c3c;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(18 20 26 / 6%), 0 4px 12px rgb(18 20 26 / 4%);
}

[data-theme="dark"] {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- boot / login ------------------------------------------------------ */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
}

.boot-card h1 { margin: 0 0 8px; font-size: 22px; }
.boot-card p { color: var(--muted); margin: 0 0 20px; }

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
}

/* --- shell ------------------------------------------------------------- */

#app {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 16px;
}

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

.brand-mark {
  width: 10px;
  height: 26px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #8b5cf6);
  flex: none;
}

#family-picker {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
}

nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

nav button {
  text-align: left;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

nav button:hover { background: var(--surface-2); color: var(--text); }
nav button[aria-current="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.sidebar-foot img { border-radius: 50%; }
.sidebar-foot span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 4px;
}
.link:hover { color: var(--text); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h2 { margin: 0; font-size: 18px; }
.topbar-actions { display: flex; gap: 4px; }

.view { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* --- building blocks --------------------------------------------------- */

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }

.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .delta { font-size: 12px; margin-top: 4px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--surface-2); cursor: default; }
tbody tr[data-clickable] { cursor: pointer; }

.table-wrap { overflow-x: auto; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

input[type="search"], input[type="text"], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: #b8890a; }
.badge.bad { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.error { color: var(--danger); }

.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--muted);
}
.alert.warning { border-left-color: var(--warning); }
.alert.info { border-left-color: var(--accent); }

.chart { width: 100%; height: 180px; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .label { fill: var(--muted); font-size: 10px; }
.chart .bar-rect { fill: var(--accent); }

.profile-head { display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline; }
.profile-head h3 { font-size: 20px; color: var(--text); margin: 0; }

.ai-output {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.55;
}

button.action {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.action:disabled { opacity: 0.55; cursor: default; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; border-top: 0; padding-top: 0; width: 100%; }
  .view { padding: 16px; }
}
