/*
 * Tokens: the navy chrome is the same in both schemes; each content token holds its light and its dark value, and
 * color-scheme picks one: the OS scheme by default, Light or Dark when picked.
 */
:root {
  color-scheme: light dark;
  --top: #053f5e;
  --side: #0b4f78;
  --bg: light-dark(#ffffff, #1e2124);
  --surface: light-dark(#ffffff, #262a2e);
  --chip: light-dark(#ebebeb, #363b40);
  --border: light-dark(#dfe4e8, #3a4046);
  --text: light-dark(#1f2a33, #eef1f3);
  --muted: light-dark(#5c6872, #a9b2ba);
  --accent: light-dark(#0b4f78, #8cc4ea);
  --primary: light-dark(#0b4f78, #1d6390);
  --danger: light-dark(#c0505f, #d27782);
  --open: light-dark(#e6eef5, #223241);
  --warn-bg: light-dark(#fff7ec, #2e2a22);
  --warn-border: light-dark(#f1d3a6, #5a4630);
  --fail-bg: light-dark(#fdf0f1, #3a2c2e);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }

/* Header: the app name on the left; the signed-in name, roles, Settings, theme picker and Sign out on the right. */
header.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-height: 56px; padding: 0 24px;
  background: var(--top); color: #ffffff;
}
.app-title { font-size: 16px; font-weight: 700; }
header.topbar .signin {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-left: auto; min-width: 0; overflow-wrap: anywhere;
}
header.topbar .user-name { font-weight: 600; }
header.topbar .sub { color: #b7c9d8; font-size: 12px; }
header.topbar a.settings-link { color: #ffffff; font-size: 13px; }
header.topbar button:not(.primary) {
  background: transparent; border: 1px solid #ffffff; color: #ffffff; padding: 0 10px; font-size: 12px;
}
header.topbar button:not(.primary):hover { background: rgba(255, 255, 255, 0.12); }
header.topbar select.theme-pick {
  background: transparent; border: 1px solid #ffffff; color: #ffffff; padding: 0 4px; font-size: 12px; height: 32px;
}
header.topbar select.theme-pick:hover { background: rgba(255, 255, 255, 0.12); }
header.topbar select.theme-pick option { background: var(--surface); color: var(--text); }

/* The next-step line under the header: what to do now; red when the page cannot start. */
.next-step {
  margin: 0; padding: 10px 24px; background: var(--open); border-bottom: 1px solid var(--border);
  color: var(--text); font-weight: 600;
}
.next-step:empty { display: none; }
.next-step.problem { background: var(--fail-bg); color: var(--danger); }

/* The quote page: panels top to bottom. */
main.quote { padding: 12px 24px 28px; }
.panel {
  margin: 12px 0 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.panel h2 { font-size: 15px; font-weight: 700; margin: 0 0 8px; color: var(--accent); }
.panel .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.panel.waiting { color: var(--muted); }
.panel .warn { margin: 8px 0 0; padding: 6px 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 6px; }
.sub, .muted { color: var(--muted); }
.sub { font-size: 12px; }

/* Buttons are grey; each panel's one main button is navy (.primary). */
button {
  min-height: 32px; padding: 0 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer;
}
button:hover { background: var(--chip); }
button.primary { background: var(--primary); border-color: var(--primary); color: #ffffff; font-weight: 600; min-height: 36px; padding: 0 16px; }
button.primary:hover { background: var(--primary); filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger); color: #ffffff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); filter: none; }
button.primary:disabled:hover { background: var(--primary); }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

select, input[type=search], input[type=text], input[type=email], input[type=number] {
  height: 32px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 13px; padding: 0 8px; max-width: 100%;
}
select:disabled, input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Busy state: a turning spinner on the pressed button and a status line with the seconds so far. */
.spinner {
  display: inline-block; width: 28px; height: 28px; border-radius: 50%; vertical-align: middle;
  border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
.spinner-small { width: 14px; height: 14px; }
button .spinner { margin-right: 6px; border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.busy-status { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
