/* Maverick Console — single stylesheet, no inline styles (CSP: style-src 'self').
   Dark-first professional theme with a light fallback via prefers-color-scheme. */

:root {
  --bg: #0f1419;
  --bg-raised: #171e26;
  --bg-inset: #0b0f13;
  --border: #2a3441;
  --text: #dbe4ee;
  --text-dim: #8b98a9;
  --accent: #4da3ff;
  --accent-soft: #163049;
  --ok: #3fb27f;
  --warn: #d9a13b;
  --bad: #e0635c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8;
    --bg-raised: #ffffff;
    --bg-inset: #eaeef2;
    --border: #d4dbe3;
    --text: #1c2733;
    --text-dim: #5c6b7c;
    --accent: #1266c4;
    --accent-soft: #dbeafe;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--bg-inset);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 18px;
}

.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  display: block;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
}
.nav-link:hover { background: var(--bg-raised); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.user-email { font-size: 12px; color: var(--text-dim); word-break: break-all; }

/* ---------- layout ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-full { max-width: 560px; margin: 0 auto; }

.topbar { padding: 20px 28px 0 28px; }
.page-title { margin: 0; font-size: 22px; font-weight: 650; }

.content { flex: 1; padding: 18px 28px 28px 28px; display: flex; flex-direction: column; gap: 18px; }

.footer {
  border-top: 1px solid var(--border);
  padding: 10px 28px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- cards / tiles ---------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.card h2 { margin: 0 0 10px 0; font-size: 15px; font-weight: 650; color: var(--text); }
.card h3 { margin: 12px 0 6px 0; font-size: 13px; font-weight: 650; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .tile-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.tile .tile-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.tile .tile-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- status pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.pill-ok { color: var(--ok); border-color: var(--ok); }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-bad { color: var(--bad); border-color: var(--bad); }
.pill-accent { color: var(--accent); border-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
tr:hover td { background: var(--bg-inset); }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }
td.dim, .dim { color: var(--text-dim); }
.wrap-text { white-space: pre-wrap; word-break: break-word; }

/* ---------- forms ---------- */
form.inline { display: inline; }
.form-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-dim); }

input[type="text"], input[type="date"], select, textarea {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
}
textarea { width: 100%; min-height: 110px; font-family: var(--mono); font-size: 13px; }
textarea.tall { min-height: 320px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); filter: none; }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-block { width: 100%; }

/* ---------- details / payloads ---------- */
details { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; background: var(--bg-inset); }
details summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
details[open] summary { margin-bottom: 6px; }
pre {
  margin: 0;
  padding: 10px;
  background: var(--bg-inset);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- misc ---------- */
.empty { color: var(--text-dim); font-style: italic; padding: 18px 0; text-align: center; }
.pager { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--text-dim); }
.muted-note { font-size: 12px; color: var(--text-dim); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 260px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- sign-in denied notice ----------
   The centred card the sign-in screen used to use. It kept the name `.login-card`
   until the photo replaced that layout; denied.html is now its only user. */
.notice-card { margin-top: 12vh; text-align: center; }
.notice-card .brand-name { font-size: 30px; }
.notice-card p { color: var(--text-dim); }

/* ---------- dashboard hero ---------- */
.hero {
  /* The frame hugs the photo instead of framing empty space beside it. */
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-inset);
}
.hero-photo { display: block; width: 100%; height: auto; }

/* ---------- login ----------
   The sign-in screen is the photograph plus one button, and the button has to land
   on the jet's starboard wing. So the photo lives in an aspect-locked stage and the
   form is positioned in PERCENTAGES of that stage — it then tracks the wing at every
   width instead of drifting into the sky. Measured on the 1672x941 original, the wing
   spans roughly x 1180-1560 / y 265-355, i.e. 70-93% x and 28-38% y. */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05080d;
}

.login-stage {
  position: relative;
  width: 100%;
  /* Cap the width by the viewport height so the whole aircraft always fits on screen:
     if the wing is cropped away there is nowhere for the button to sit. */
  max-width: calc(100vh * 16 / 9);
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}

.login-photo { display: block; width: 100%; height: 100%; object-fit: cover; }

.login-signin {
  position: absolute;
  left: 82%;
  top: 34%;
  /* 20% wide centred on 82% => spans 72%-92%, inside the wing's 70-93% span. */
  width: 20%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.btn-signin {
  width: 100%;
  /* Scales with the photo, so a 200px button never swamps a shrunken wing.
     cqw is exact (the stage is the query container); the vw line above it is the
     fallback for browsers that drop the cqw declaration. */
  font-size: clamp(10px, 1.15vw, 19px);
  font-size: clamp(10px, 1.2cqw, 19px);
  /* Fixed, opaque colours — NOT var(--accent), whose dark-theme value (#4da3ff) would
     leave white text at ~2:1 and vanish against the wing. White on #0b57a4 is ~7:1. */
  background: #0b57a4;
  border: 1px solid #f2f6fb;
  color: #fff;
  padding: 0.62em 0.5em;
  border-radius: 0.45em;
  box-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-signin:hover { background: #0d69c6; filter: none; }
/* Amber reads against both the pale wing and the dark backdrop of the mobile layout. */
.btn-signin:focus-visible { outline: 3px solid #ffc233; outline-offset: 3px; }

.login-unconfigured {
  width: 42%;
  left: 50%;
  top: 50%;
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: 10px 14px;
  background: #10161d;
  color: #ffb3ae;
  font-size: 13px;
  text-align: center;
}

/* Narrow screens: the wing is only a few dozen pixels across, so nothing readable
   fits on it. Drop the overlay and stack — full-width photo, button centred beneath
   it — which keeps the target big and the photo uncropped. */
@media (max-width: 700px) {
  .login-page { padding: 18px 16px 28px 16px; }
  .login-stage { max-width: 100%; aspect-ratio: auto; }
  .login-photo { height: auto; }
  .login-signin,
  .login-unconfigured {
    position: static;
    width: auto;
    max-width: 340px;
    transform: none;
    margin: 22px auto 0 auto;
  }
  .btn-signin { font-size: 16px; padding: 13px 26px; border-radius: 8px; }
}

.alert {
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--bg-raised);
}
