/* AegisGate brand: royal blue with silver lettering, orange for contrast, Arial.
   Layout: blue top bar; a side navigation beside the work area on wide
   screens, stacked above it on phones. */
:root {
  --royal: #1c3f94;
  --royal-ink: #ffffff;
  --silver: #c9d0da;
  --blue: #2a55c6;
  --orange: #e8730c;
  --orange-ink: #ffffff;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #17213a;
  --muted: #5a6680;
  --line: #d9dfe9;
  --blue-soft: #e6ecfa;
  --good: #187245;
  --good-soft: #e2f3e9;
  --warn: #8a5300;
  --warn-soft: #fcefd8;
  --bad: #b3261e;
  --bad-soft: #fce8e6;
  --font: Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --royal: #13285e; --silver: #b9c2cf; --blue: #8aa8ff; --orange: #ff9a3d; --orange-ink: #231200;
    --bg: #0c111c; --surface: #141b2a; --surface-2: #1a2334; --ink: #e6ebf5; --muted: #9aa6bd; --line: #2a3550;
    --blue-soft: #1a2747; --good: #5fd39a; --good-soft: #10301f; --warn: #f0b056; --warn-soft: #36270f;
    --bad: #ff8a80; --bad-soft: #3c1816; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --royal: #13285e; --silver: #b9c2cf; --blue: #8aa8ff; --orange: #ff9a3d; --orange-ink: #231200;
  --bg: #0c111c; --surface: #141b2a; --surface-2: #1a2334; --ink: #e6ebf5; --muted: #9aa6bd; --line: #2a3550;
  --blue-soft: #1a2747; --good: #5fd39a; --good-soft: #10301f; --warn: #f0b056; --warn-soft: #36270f;
  --bad: #ff8a80; --bad-soft: #3c1816; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; min-height: 100vh; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); font-size: 0.88rem; }
[hidden] { display: none !important; }

/* top bar */
.bar {
  background: var(--royal); color: var(--royal-ink);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--silver); text-decoration: none; }
.shield {
  width: 26px; height: 30px; background: var(--silver); flex: none;
  clip-path: polygon(50% 0, 100% 16%, 100% 52%, 50% 100%, 0 52%, 0 16%);
  position: relative;
}
.shield::after {
  content: ''; position: absolute; inset: 7px 8px 9px; background: var(--orange);
  clip-path: polygon(50% 0, 100% 16%, 100% 52%, 50% 100%, 0 52%, 0 16%);
}
.wordmark { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.wordmark span { font-weight: 400; }
.bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; }
.bar-right .who { color: var(--silver); }
.bar button { background: transparent; color: var(--royal-ink); border-color: rgba(255, 255, 255, 0.45); }
.bar button:hover { border-color: var(--royal-ink); }

.banner { padding: 8px 20px; font-size: 0.86rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); }

/* layout */
.app { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.loading { color: var(--muted); }
.narrow { max-width: 480px; margin: 24px auto; display: grid; gap: 16px; }
.shell { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .shell { grid-template-columns: 220px minmax(0, 1fr); align-items: start; } }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
@media (min-width: 900px) { .nav { flex-direction: column; position: sticky; top: 16px; } }
.nav button { text-align: left; border: none; background: transparent; padding: 9px 12px; border-radius: 8px; font-weight: 700; color: var(--muted); }
.nav button[aria-current="page"] { background: var(--blue-soft); color: var(--ink); }
.work { display: grid; gap: 16px; min-width: 0; }

/* controls */
button, .button {
  font: inherit; font-size: 0.92rem; cursor: pointer; line-height: 1.3;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); font-weight: 700; }
button.primary:hover { filter: brightness(1.06); }
button.secondary { color: var(--blue); border-color: var(--blue); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.link { border: none; background: none; padding: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: 12px; min-width: 0; }
label { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 700; }
label .hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], select {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink); font-weight: 400;
}
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); font-weight: 700; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--orange); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--blue-soft); color: var(--ink); }
.eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted); }
.keyblock { font-family: var(--mono); font-size: 1.05rem; line-height: 1.8; word-spacing: 0.3em; letter-spacing: 0.03em; background: var(--surface-2); border: 1px dashed var(--muted); border-radius: 8px; padding: 12px 14px; overflow-wrap: anywhere; }
.digits { font-family: var(--mono); font-size: 1rem; line-height: 1.8; word-spacing: 0.25em; overflow-wrap: anywhere; }
.busy { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 0.9rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--orange); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--orange); }

/* spaces and documents */
.spaces { display: flex; gap: 6px; flex-wrap: wrap; }
.space { display: grid; text-align: left; gap: 1px; }
.space .n { font-weight: 700; }
.space .m { font-size: 0.76rem; color: var(--muted); }
.space[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); }
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.9rem; }
.crumbs button { padding: 2px 6px; border: none; background: none; color: var(--blue); }
.crumbs .sep { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { padding: 5px 10px; font-size: 0.84rem; }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell button.link { text-decoration: none; font-weight: 700; color: var(--ink); text-align: left; }
.kind { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; color: var(--blue); background: var(--blue-soft); border-radius: 5px; padding: 3px 6px; min-width: 40px; text-align: center; flex: none; }
.kind.folder { color: var(--orange); background: var(--warn-soft); }
.versions { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.versions li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 0.88rem; }
.empty { color: var(--muted); padding: 18px 4px; }
.pill { display: inline-block; font-size: 0.74rem; font-weight: 700; border-radius: 99px; padding: 2px 8px; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.muted { background: var(--surface-2); color: var(--muted); }
.meter { width: 120px; max-width: 100%; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; }
.meter > span { display: block; height: 100%; background: var(--blue); }
.compare { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.compare .card { gap: 6px; }

/* Phones: each table row becomes a small stacked card so actions stay visible. */
@media (max-width: 640px) {
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { border: none; padding: 3px 0; }
  td.num { display: inline-block; width: auto; margin-right: 14px; }
  td.actions { text-align: left; white-space: normal; padding-top: 8px; }
  td.actions button { margin: 0 4px 6px 0; }
  .table-wrap { overflow-x: visible; }
}
details.card > summary { cursor: pointer; font-weight: 700; color: var(--blue); }
