/* Neumorphic (soft UI) admin theme - same token set as trayvo/admin-app and myrooots'
   admin/server.ts (see /opt/apps/myrooots/docs/ADMIN-STYLEGUIDE.md), hand-written in plain
   CSS here since this admin has no build step and no Tailwind. */

:root {
  color-scheme: light;
  --bg: #e9edf4;
  --shadow-dark: #c8cedb;
  --shadow-light: #ffffff;
  --text: #1c2d4a;
  --text-soft: #45597d;
  --muted: #55617a;
  --faint: #5f6c85;
  --accent: #3d5a95;
  --accent-on: #ffffff;
  --success: #047857;
  --warning: #9a5109;
  --danger: #be123c;
  --info: #0369a1;
  --line: rgba(28, 45, 74, .08);
  --row-hover: rgba(255, 255, 255, .55);
  --overlay: rgba(28, 45, 74, .35);
  --modal-shadow: 0 20px 40px rgba(15, 23, 42, .35);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #262b36;
  --shadow-dark: #1b1f27;
  --shadow-light: #313846;
  --text: #e4eaf6;
  --text-soft: #c2cbdd;
  --muted: #94a2bd;
  --faint: #8b99b3;
  --accent: #9fb6dd;
  --accent-on: #1b1f27;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --info: #38bdf8;
  --line: rgba(226, 232, 245, .09);
  --row-hover: rgba(255, 255, 255, .035);
  --overlay: rgba(10, 12, 16, .55);
  --modal-shadow: 0 20px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 { margin: 0; }
h2 { font-size: 17px; }

/* ---- Surfaces ---- */
.neu-raised {
  background: var(--bg);
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  border-radius: 20px;
}
.neu-raised-sm {
  background: var(--bg);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  border-radius: 14px;
}
.neu-inset {
  background: var(--bg);
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  border-radius: 14px;
}
.neu-inset-sm {
  background: var(--bg);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
  border-radius: 10px;
}
.neu-flat {
  background: var(--bg);
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  border-radius: 9999px;
}

/* ---- Text tones ---- */
.t-strong { color: var(--text); font-weight: 600; }
.t-body { color: var(--text-soft); }
.t-muted { color: var(--muted); }
.t-faint { color: var(--faint); font-size: 13px; }
.t-accent { color: var(--accent); }
.t-success { color: var(--success); }
.t-warning { color: var(--warning); }
.t-danger { color: var(--danger); }
.t-info { color: var(--info); }

/* ---- Layout ---- */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.tab-bar {
  display: inline-flex;
  gap: 4px;
  padding: 6px;
  align-self: flex-start;
}
.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.tab-panel { display: none; flex-direction: column; gap: 20px; }
.tab-panel.active { display: flex; }

.panel { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
/* A grid item's default minimum width is its content's min-content size, not 0 - a table
   with nowrap cells (long referrer URLs) would otherwise force this column, and the whole
   page, wider than the viewport instead of scrolling inside its own .table-wrap. */
.two-col > * { min-width: 0; }
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.stat-tile { padding: 16px; text-align: left; }
.stat-value { font-size: 24px; }
.stat-label { font-size: 13px; margin-top: 2px; }

/* ---- Buttons ---- */
.neu-btn {
  border: none;
  background: var(--bg);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
.neu-btn:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}
.neu-btn-primary { background: var(--accent); color: var(--accent-on); }
.neu-btn-primary:active {
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, .25);
}
.neu-btn-sm {
  border: none;
  background: var(--bg);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  margin-left: 8px;
  border-radius: 9px;
  cursor: pointer;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}
.neu-btn-sm:active {
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}
.neu-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  border: none;
  background: var(--bg);
  color: var(--text-soft);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.neu-icon-btn:active {
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

/* moon/sun swap - pure CSS, no JS state (see js/theme.js) */
.icon-moon { display: inline; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--row-hover); }
td.col-actions, th.col-actions { text-align: right; white-space: nowrap; }

/* ---- Forms ---- */
.neu-input {
  background: var(--bg);
  border: none;
  border-radius: 10px;
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
.neu-input:focus {
  outline: none;
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light), 0 0 0 2px var(--accent);
}
.neu-input::placeholder { color: var(--faint); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-soft); font-weight: 600; margin-bottom: 14px; }
.body-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---- Modal ---- */
.neu-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.neu-modal-backdrop.open { display: flex; }
.neu-modal {
  /* A plain single drop-shadow, not the usual neu- dual light/dark recipe: that recipe's
     white "highlight" shadow is meant to read against the page's own --bg, but a modal sits
     over the darker blurred --overlay instead, where the highlight just glows - see
     myrooots' admin/server.ts (--modal-shadow) for the same fix applied there. */
  background: var(--bg);
  border-radius: 20px;
  box-shadow: var(--modal-shadow);
  padding: 26px 28px;
  width: 100%;
  max-width: 640px;
}
.neu-modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-error { min-height: 18px; margin: 8px 0 0; }

/* ---- Bar chart (plain divs, no chart library) ---- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding-top: 8px;
}
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar-fill {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: .85;
}
.bar:hover .bar-fill { opacity: 1; }

/* ---- Login page ---- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-fixed { position: fixed; top: 20px; right: 20px; }
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card { padding: 32px 30px; display: flex; flex-direction: column; gap: 4px; }
.login-card h1 { font-size: 19px; text-align: center; }
.login-sub { text-align: center; margin: 4px 0 20px; }
.login-submit { margin-top: 8px; width: 100%; }

/* ---- Scrollbar (matches the neu-inset/neu-raised shadow recipe) ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track {
  background: var(--bg);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb {
  background: var(--bg);
  background-clip: padding-box;
  border: 1px solid transparent;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--shadow-dark) var(--bg);
}
