/* Ripper Ready — mobile-first, high-contrast, light/dark. No external fonts or assets. */
:root {
  --bg: #f3f4f1; --surface: #ffffff; --surface-2: #e9ebe6; --text: #14181f; --muted: #555d68; --border: #c9cdc4;
  --accent: #8a1c1c; --accent-text: #ffffff; --gold: #a8841c;
  --green: #1f7a3a; --green-bg: #e3f3e7; --amber: #8a5a00; --amber-bg: #fff2d6; --red: #b3121f; --red-bg: #fde4e4;
  --blue: #1f4f8f; --blue-bg: #e2ebf7; --warn: #6b2d91; --warn-bg: #f1e4f8;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171b22; --surface-2: #222833; --text: #eef0f3; --muted: #a2aab5; --border: #333b47;
    --accent: #c0392b; --gold: #d4af37;
    --green: #5fd38a; --green-bg: #12301d; --amber: #f2c14e; --amber-bg: #3a2c0b; --red: #ff6b6b; --red-bg: #3d1417;
    --blue: #8ab4f8; --blue-bg: #14243d; --warn: #d6a4ff; --warn-bg: #2e1840; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b22; --surface-2: #222833; --text: #eef0f3; --muted: #a2aab5; --border: #333b47;
  --accent: #c0392b; --gold: #d4af37;
  --green: #5fd38a; --green-bg: #12301d; --amber: #f2c14e; --amber-bg: #3a2c0b; --red: #ff6b6b; --red-bg: #3d1417;
  --blue: #8ab4f8; --blue-bg: #14243d; --warn: #d6a4ff; --warn-bg: #2e1840; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top)); background: #111418; color: #fff; border-bottom: 3px solid var(--accent); }
.brand { display: flex; flex-direction: column; line-height: 1.05; text-decoration: none; color: #fff; }
.brand b { letter-spacing: .14em; font-size: 15px; }
.brand small { color: #d4af37; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #cfd3d8; display: flex; gap: 8px; align-items: center; }
.nav { display: flex; gap: 2px; }
.nav a { color: #e8eaed; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.14); }
.bell { position: relative; background: none; border: 0; color: #fff; font-size: 20px; padding: 6px; cursor: pointer; }
.bell .dot { position: absolute; top: 2px; right: 0; background: var(--red); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
main.narrow { max-width: 560px; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar .who .name { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; text-align: center; padding: 8px 2px 10px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
  .tabbar a .ic { display: block; font-size: 20px; line-height: 1.2; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
}

/* Cards & typography */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 10px; }
h1 { font-size: 22px; margin: 4px 0 14px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.dash { grid-template-columns: 2fr 1fr; } }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.huge { min-height: 76px; font-size: 21px; letter-spacing: .06em; width: 100%; border-radius: 14px; }
.btn.opt-safe { background: var(--green); border-color: var(--green); color: #fff; }
.btn.opt-assist { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.opt-unable { background: var(--amber); border-color: var(--amber); color: #111; }
:root[data-theme="dark"] .btn.opt-safe, :root[data-theme="dark"] .btn.opt-assist { color: #0e1116; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.opt-safe, :root:not([data-theme="light"]) .btn.opt-assist { color: #0e1116; } }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
textarea { min-height: 90px; font-family: var(--mono); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 36px; }
.check input { width: 20px; height: 20px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.error { color: var(--red); font-weight: 600; }

/* Status pills: always icon + text, never color alone */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800;
  letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap; }
.pill.accounted, .pill.green { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.pill.pending, .pill.amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber); }
.pill.overdue, .pill.unaccounted, .pill.red { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.pill.authorized, .pill.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.pill.assist { background: var(--warn-bg); color: var(--warn); border: 2px dashed var(--warn); }
.pill.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

/* Marine home */
.hero-name { display: flex; align-items: center; gap: 12px; }
.hero-name .nm { font-size: 20px; font-weight: 800; }
.statusline { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.statusline:first-of-type { border-top: 0; }
.big-state { font-size: 15px; padding: 6px 12px; }
.emergency { border: 3px solid var(--red); background: var(--red-bg); }
.emergency .label { color: var(--red); font-weight: 900; letter-spacing: .12em; font-size: 13px; }
.emergency h2 { font-size: 20px; }
.confirmed { text-align: center; padding: 6px 0; }
.confirmed .tick { font-size: 44px; color: var(--green); line-height: 1; }
.motto { text-align: center; font-weight: 900; letter-spacing: .2em; color: var(--gold); font-size: 13px; margin-top: 8px; }
.status-list { display: grid; gap: 8px; }
.status-list button { text-align: left; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; min-height: 48px; }
.status-list button[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--surface-2); }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.banner.info { background: var(--blue-bg); color: var(--blue); }
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner.bad { background: var(--red-bg); color: var(--red); }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.kpi .v { font-size: 28px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi.big .v { color: var(--accent); }
.kpi.bad .v { color: var(--red); } .kpi.warn .v { color: var(--warn); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip { white-space: nowrap; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip.emerg { border-color: var(--red); color: var(--red); }
.chip.emerg[aria-pressed="true"] { background: var(--red); color: #fff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 8px; }
.person .rk { font-weight: 800; }
.rank-insignia { flex: none; border-radius: 6px; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.25)); }
pre.report { background: var(--surface-2); padding: 12px; border-radius: 8px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; margin: 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .modal-bg { align-items: center; } }
.modal { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { border-radius: 14px; } }
.modal .x { float: right; background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; }
.toast { background: #111418; color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 90vw; }
.toast.bad { background: var(--red); }
.login-wrap { max-width: 420px; margin: 7vh auto 0; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .logo { width: 84px; height: 84px; border-radius: 18px; }
.login-brand h1 { margin: 10px 0 0; letter-spacing: .18em; }
.login-brand .tag { color: var(--gold); font-weight: 800; letter-spacing: .12em; font-size: 12px; text-transform: uppercase; }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; }
.steps { padding-left: 20px; } .steps li { margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.offline-flag { background: var(--amber); color: #111; text-align: center; font-weight: 800; font-size: 13px; padding: 4px; }
