:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1b2a33;
  --muted: #5b7180;
  --brand: #1b4965;
  --brand-ink: #ffffff;
  --line: #dbe3e8;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 42, 51, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171c;
    --card: #18232b;
    --ink: #e7eef2;
    --muted: #9fb2bd;
    --brand: #5fa8d3;
    --brand-ink: #0b1116;
    --line: #26343d;
    --danger: #ff8a80;
    --danger-bg: #35211f;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px
           max(16px, env(safe-area-inset-bottom));
}

/* --- flash messages --- */
.flash-stack { margin-bottom: 14px; }
.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 8px;
}
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* --- cards --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h1 { margin: 0 0 8px; font-size: 20px; }
.card p { margin: 0; color: var(--muted); line-height: 1.5; }

/* --- brand --- */
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-weight: 800; font-size: 22px; letter-spacing: -.5px; color: var(--brand); }
.brand-sub {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--muted);
}

/* --- login screen --- */
.auth-screen {
  min-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card { width: 100%; }
.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.error-code { font-size: 40px; text-align: center; margin: 0 0 6px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input {
  font-size: 17px; /* >=16px stops iOS zoom-on-focus */
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

/* --- buttons --- */
.btn {
  font-size: 16px; font-weight: 600;
  padding: 13px 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 46px;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }

/* --- dashboard --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.topbar form { margin: 0; }
.greeting { font-size: 17px; margin: 0 0 14px; }
.content { display: flex; flex-direction: column; gap: 16px; }

.module-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.module-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px;
  font-size: 16px; font-weight: 600;
  display: flex; flex-direction: column; gap: 4px;
}
.module-tile span { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.module-tile.is-pending { opacity: .7; }
