:root {
  --bg: #f6f7f9; --surface: #fff; --text: #17202a; --muted: #5f6b78; --line: #e2e6eb;
  --accent: #0066ff; --accent-text: #fff; --accent-soft: #e6f0ff;
  --good: #137a3c; --good-bg: #e3f5ea; --warn: #8a5a00; --warn-bg: #fff3d6;
  --bad: #b42318; --bad-bg: #fde8e6; --off: #5f6b78; --off-bg: #eef0f3;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --surface: #171e26; --text: #e6eaef; --muted: #9aa5b1; --line: #2a3440;
    --accent: #6d97ff; --accent-text: #0b1020; --accent-soft: #1c2a4a;
    --good: #5fd08b; --good-bg: #143322; --warn: #f2c25b; --warn-bg: #3a2c0c;
    --bad: #ff8a80; --bad-bg: #3d1714; --off: #9aa5b1; --off-bg: #222b35;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
small { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.muted { color: var(--muted); }

/* header */
.top { display: flex; align-items: center; gap: 1.5rem; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
/* Logo from navionyxwebsite (assets/images/navionyx-with-text.png). Dark green text: on a dark theme it sits
   on a white chip so it stays readable. */
.brand { display: inline-flex; align-items: center; gap: .5rem; margin: 0; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 26px; width: auto; }
.brand b { font-size: .8rem; font-weight: 700; letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); padding: .1rem .4rem; border-radius: 5px; }
@media (prefers-color-scheme: dark) {
  .brand img { background: #fff; padding: 3px 6px; border-radius: 6px; box-sizing: content-box; }
}
.top nav { display: flex; gap: .25rem; }
.top nav a { padding: .35rem .7rem; border-radius: 6px; color: var(--muted); }
.top nav a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { color: var(--muted); font-size: .9rem; }

.page { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1, .head h2 { margin: 0; }
.crumbs { margin: 0 0 .25rem; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel.narrow { max-width: 460px; }
.panel.empty { text-align: center; padding: 2.5rem 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; color: var(--muted); }
.stats span { display: block; font-size: 1.6rem; font-weight: 650; color: var(--text); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel .table-wrap { border: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; }
.actions form { margin: 0; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.off { background: var(--off-bg); color: var(--off); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: middle; }
.dot.green { background: var(--good); } .dot.amber { background: var(--warn); } .dot.red { background: var(--bad); }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .8rem; border-radius: 6px; color: var(--muted); border: 1px solid transparent; }
.tabs a[aria-current] { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 600; }
.tabs span { color: var(--muted); font-weight: 400; margin-left: .25rem; }

/* notes */
.note { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; }
.note.ok { background: var(--good-bg); color: var(--good); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.err { background: var(--bad-bg); color: var(--bad); }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 550; font-size: .9rem; }
input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: .5rem .65rem; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label.check { flex-direction: row; align-items: center; gap: .5rem; flex-wrap: wrap; }
label.check input { width: auto; }
label.check small { flex-basis: 100%; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
/* Field rows: every field is label, control, hint, top-aligned, and every control is the same height,
   so inputs, switches and buttons line up whatever hints sit under them. */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; align-items: start; border: 0; margin: 0; padding: 0; min-width: 0; }
.fields.subscription { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 1rem; border-top: 1px solid var(--line); }
.fields-title { grid-column: 1 / -1; margin: 0; font-size: .95rem; }
.fields.add-vehicle { grid-template-columns: 1.2fr 1fr 1fr auto auto; align-items: start; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field > label, .field > .label { font-weight: 550; font-size: .9rem; line-height: 1.3; }
.field input:not([type=checkbox]), .field button, .field .switch { height: 2.625rem; }
.field button { white-space: nowrap; }
.field small { margin-top: -.1rem; }
.switch { display: inline-flex; flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; font-size: .95rem; cursor: pointer; white-space: nowrap; }
.switch input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }
@media (max-width: 860px) {
  .fields.add-vehicle { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields.add-vehicle .field:last-child { grid-column: 1 / -1; }
  .fields.add-vehicle .field:last-child .label { display: none; }
  .fields.subscription { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .fields, .fields.add-vehicle { grid-template-columns: 1fr; }
}

button, .button { font: inherit; font-weight: 600; display: inline-block; padding: .5rem 1rem; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { text-decoration: none; filter: brightness(.97); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.small { padding: .25rem .6rem; font-size: .85rem; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* login pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; }
.card .brand { margin-bottom: 1.5rem; }
.card .brand img { height: 34px; }
.card h1 { font-size: 1.3rem; }

@media (max-width: 640px) {
  .top { gap: .75rem; }
  .logout { margin-left: 0; width: 100%; justify-content: space-between; }
  .who { overflow: hidden; text-overflow: ellipsis; }
}
