/* ════════════════════════════════════════════════════════
   FaultWall Control Plane — light theme
   Matches faultwall.com (Oct 2026): paper background, ink text,
   deep green accent, Georgia headings, system sans, mono for SQL/ids.
   Variable names are kept from the earlier theme so page stylesheets
   (activity, agents, approvals, approve, report) follow automatically.
════════════════════════════════════════════════════════ */
:root {
  /* site palette */
  --paper: #f8f7f2;
  --card: #fffefa;
  --ink: #222923;
  --faint: #6f766c;
  --rule: #dcdfd5;
  --rule-2: #e9ebe3;
  --green-2: #244731;
  --green-soft: #e6eee6;
  --amber-soft: #f6eedb;
  --red-soft: #f5e4df;
  --serif: Georgia, 'Times New Roman', serif;

  /* theme variables used across the app */
  --bg: var(--paper);
  --grid: transparent;
  --line: var(--rule);
  --border: var(--rule);
  --panel: var(--card);
  --panel-2: #f3f2ec;
  --surface-solid: var(--card);
  --fg: var(--ink);
  --muted: #535a51;
  --accent: #315b40;
  --accent3: #315b40;
  --accent-dim: var(--green-soft);
  --blue: #2f5d8a;
  --green: #315b40;
  --red: #9e3a2c;
  --yellow: #946410;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font: var(--sans);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; background: var(--paper); }
body {
  background: var(--paper);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
::selection { background: var(--green-soft); color: var(--ink); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Top bar: same feel as the faultwall.com header ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px;
  background: rgba(248,247,242,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 13.5px;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; }

/* One nav for every page */
.topbar .nav { display: flex; gap: 22px; margin-left: 24px; font-size: 13.5px; }
.topbar .nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.topbar .nav a:hover { color: var(--ink); }
.topbar .nav a.on { color: var(--ink); border-bottom-color: var(--ink); }
#whoami { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .topbar .nav { order: 3; width: 100%; margin-left: 0; gap: 18px; overflow-x: auto; padding-bottom: 2px; }
  #whoami, .tenant { display: none; }
  .wrap { padding: 24px 14px 48px; }
  .card { padding: 20px 16px; }
}
.brand span { color: var(--accent); }
.brand-logo { height: 24px; width: auto; display: block; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.wrap { max-width: 980px; margin: 0 auto; padding: 40px 20px 60px; position: relative; z-index: 1; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 26px 28px;
  margin-bottom: 18px;
  box-shadow: 0 18px 40px -32px rgba(36,55,36,.28);
  overflow-x: auto; /* wide tables scroll inside the card on phones */
}

/* Auth card */
#authView {
  max-width: 440px; margin: 64px auto;
  padding: 40px 36px;
}
.auth-logo { height: 44px; width: auto; display: block; margin-bottom: 18px; }

h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: -0.03em; margin: 0 0 8px; line-height: 1.12;
}
h2 { font-family: var(--serif); font-size: 21px; font-weight: 400; margin: 0 0 12px; letter-spacing: -0.02em; line-height: 1.2; }

.field { margin: 14px 0; }
label { display: block; font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, textarea {
  width: 100%; padding: 11px 14px; border-radius: 3px;
  border: 1px solid var(--rule); background: #fff;
  color: var(--fg); font-size: 14px; font-family: var(--sans);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder, textarea::placeholder { color: #9aa096; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--green-soft); }

.row { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

/* ── Buttons: solid green primary, outlined secondary ── */
button {
  padding: 10px 20px; border-radius: 3px; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
button:hover { background: var(--green-2); border-color: var(--green-2); }
button:disabled { opacity: .55; cursor: default; }
button.secondary {
  background: transparent; color: var(--ink);
  border: 1px solid var(--ink);
}
button.secondary:hover { background: var(--panel-2); color: var(--ink); border-color: var(--ink); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--rule); }
button.ghost:hover { color: var(--ink); border-color: var(--muted); background: transparent; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.codeblock {
  background: var(--panel-2); border: 1px solid var(--rule-2); border-radius: 3px;
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-break: break-all;
}

.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule-2); font-size: 13.5px; }
.kv div:last-child { border-bottom: none; }
.kv b { color: var(--muted); font-weight: 500; }
.kv span { font-family: var(--mono); font-size: 12.5px; text-align: right; word-break: break-all; }

/* ── Stats ── */
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  text-align: left; flex: 1; min-width: 90px;
  padding: 14px 16px; border-radius: 4px;
  background: var(--paper); border: 1px solid var(--rule-2);
}
.stat .num {
  font-family: var(--serif);
  font-size: 30px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--ink);
}
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat.block .num { color: var(--red); }
.stat.flag .num { color: var(--yellow); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--rule-2); }
th { color: var(--faint); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; }
td { font-size: 13px; }

.msg { min-height: 18px; font-size: 13.5px; margin-top: 10px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }
.foot { text-align: center; padding: 28px; font-size: 12.5px; color: var(--faint); position: relative; z-index: 1; }

h1 .pill, h2 .pill, h2 span { font-family: var(--sans); vertical-align: middle; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 3px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; letter-spacing: .02em; }
.pill.on { background: var(--green-soft); color: var(--green); border-color: #c9d9cb; }
.pill.off { background: var(--red-soft); color: var(--red); border-color: #e8c9c1; }
.pill.auto { background: #e4ecf4; color: var(--blue); border-color: #c8d6e5; }

/* APA review queue */
.apa-item { border: 1px solid var(--rule); border-radius: 4px; padding: 16px; margin-bottom: 14px; background: var(--paper); }
.apa-item:last-child { margin-bottom: 0; }
.apa-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.apa-head .muted { font-size: 12px; }
.codeblock.diff { color: var(--fg); max-height: 280px; overflow-y: auto; white-space: pre; }
.apa-actions { margin-top: 12px; }

/* Automation toggle */
.toggle-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--rule); border: 1px solid var(--rule);
  border-radius: 12px; transition: background .15s, border-color .15s;
}
.slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

code { background: var(--panel-2); border: 1px solid var(--rule-2); border-radius: 3px; padding: 1px 6px; font-family: var(--mono); font-size: 12px; color: var(--ink); }

/* Advanced (legacy) sections collapsed under Overview */
details.advanced { margin-top: 8px; }
details.advanced > summary { cursor: pointer; color: var(--muted); font-size: 13.5px; padding: 8px 0; list-style: none; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "+ "; font-family: var(--mono); }
details.advanced[open] > summary::before { content: "- "; }
