/* Transport Ledger phone viewer. Colours are the desktop app's own, so it reads as
   the same product. Scale follows the mobile lane: body 16, working sizes 14 / 16 / 18,
   weight 400 jumping to 700, icons 20, gaps 8 and 16, padding 16, controls 44-48. */

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0f0f13;
  --surface: #16161d;
  --surface-2: #1e1e28;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8e8f0;
  --muted: #a3a3c0;
  --accent: #6c5ef0;
  --accent-text: #a79ffa;
  --on-accent: #ffffff;
  --good: #3de88a;
  --bad: #f77b7b;
  --warn: #f5a623;
  --warn-bg: rgba(245, 166, 35, 0.12);
  --hero-a: #3a2fa8;
  --hero-b: #1b1640;
  --hero-text: #ffffff;
  --hero-muted: #cfc9ff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 12px;
  --control: 10px;
  --tab-height: 64px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef0f8;
    --line: rgba(20, 20, 50, 0.1);
    --text: #1a1a2e;
    --muted: #55557a;
    --accent: #5b4fd4;
    --accent-text: #4a3fc0;
    --on-accent: #ffffff;
    --good: #0d7a3e;
    --bad: #c62828;
    --warn: #8f5600;
    --warn-bg: rgba(201, 122, 13, 0.14);
    --hero-a: #5b4fd4;
    --hero-b: #33298f;
    --hero-text: #ffffff;
    --hero-muted: #ebe8ff;
    --shadow: 0 8px 24px rgba(40, 40, 90, 0.12);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --line: rgba(20, 20, 50, 0.1);
  --text: #1a1a2e;
  --muted: #55557a;
  --accent: #5b4fd4;
  --accent-text: #4a3fc0;
  --on-accent: #ffffff;
  --good: #0d7a3e;
  --bad: #c62828;
  --warn: #8f5600;
  --warn-bg: rgba(201, 122, 13, 0.14);
  --hero-a: #5b4fd4;
  --hero-b: #33298f;
  --hero-text: #ffffff;
  --hero-muted: #ebe8ff;
  --shadow: 0 8px 24px rgba(40, 40, 90, 0.12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
#view:focus { outline: none; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.noscript { padding: 16px; }

.icon { display: inline-flex; flex: none; width: 20px; height: 20px; }
.fig { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ── buttons and inputs ───────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: 24px;
  font-size: 16px; cursor: pointer;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--line); color: var(--bad); }
.input {
  width: 100%; min-height: 48px; padding: 8px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--control);
  font: inherit;
}
.input::placeholder { color: var(--muted); opacity: 1; }
.field-label { display: block; font-size: 14px; color: var(--muted); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0;
  background: transparent; border: 0; border-radius: 22px; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.spin .icon { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── pairing, lock and message screens ────────────────── */
.center-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  max-width: 400px; min-height: 100dvh; margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}
.center-screen .btn { max-width: 320px; }
.mark {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(145deg, var(--hero-a), var(--hero-b));
  color: var(--hero-text); box-shadow: var(--shadow);
}
.center-title { font-size: 24px; font-weight: 700; line-height: 1.25; }
.center-text { color: var(--muted); }
.pair-form { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.pair-form .btn { max-width: none; margin-top: 8px; }

.pin-screen { gap: 8px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; padding: 16px 0 8px; }
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.pin-dot.on { background: var(--accent-text); border-color: var(--accent-text); }
.pin-dots.shake { animation: shake 300ms ease-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}
.pin-error { min-height: 24px; color: var(--bad); font-size: 14px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px 16px; justify-content: center; }
.key {
  width: 72px; height: 72px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  font: 400 24px var(--mono); cursor: pointer;
  transition: background 100ms ease-out;
}
.key:active { background: var(--surface-2); }
.key-back { display: inline-flex; align-items: center; justify-content: center; background: transparent; border-color: transparent; color: var(--muted); }

/* ── app shell ────────────────────────────────────────── */
#root { min-height: 100dvh; }
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top-text { flex: 1; min-width: 0; }
.top-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.top-sub { font-size: 14px; color: var(--muted); line-height: 1.25; }

#notice { display: flex; flex-direction: column; gap: 8px; max-width: 640px; margin: 0 auto; padding: 0 16px; }
#notice:not(:empty) { padding-top: 16px; }
.notice {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 12px; border-radius: var(--control);
  background: var(--warn-bg); color: var(--warn); font-size: 14px;
}

#view {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--tab-height) + 24px + env(safe-area-inset-bottom));
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--tab-height); color: var(--muted); font-size: 12px; line-height: 1;
}
.tab.active { color: var(--accent-text); font-weight: 700; }
.tab:active { background: var(--surface-2); }

/* ── layout pieces ────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack-tight { display: flex; flex-direction: column; gap: 12px; }
.list-holder { display: flex; flex-direction: column; gap: 12px; }
.page-title { font-size: 24px; font-weight: 700; line-height: 1.25; }
.page-sub { font-size: 14px; color: var(--muted); }
.page-head { display: flex; align-items: flex-start; gap: 8px; margin-left: -12px; }
.page-head-text { flex: 1; min-width: 0; padding-top: 4px; }
.section-title { font-size: 18px; font-weight: 700; line-height: 1.25; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--accent-text); font-size: 14px; }
.hint { font-size: 14px; color: var(--muted); }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ── home ─────────────────────────────────────────────── */
.hero {
  display: flex; flex-direction: column; gap: 4px;
  padding: 24px 16px 16px; border-radius: 16px;
  background: linear-gradient(150deg, var(--hero-a) 0%, var(--hero-b) 100%);
  color: var(--hero-text); box-shadow: var(--shadow);
}
.hero-label { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.hero-caption { font-size: 14px; color: var(--hero-muted); }
.hero-value { font-size: 32px; font-weight: 700; line-height: 1.2; }
.hero-row {
  display: grid; grid-template-columns: 1fr auto; gap: 16px;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.hero-small { font-size: 16px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; min-height: 112px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 150ms ease-out;
}
.tile:active { transform: scale(0.98); }
.tile-icon { color: var(--accent-text); margin-bottom: 4px; }
.tile-label { font-size: 14px; color: var(--muted); line-height: 1.25; }
.tile-value { font-size: 14px; font-weight: 700; margin-top: auto; }

/* ── rows ─────────────────────────────────────────────── */
.list { overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
a.row:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 700; line-height: 1.3; }
.row-title-text { min-width: 0; }
.row-sub { font-size: 14px; color: var(--muted); line-height: 1.35; }
.row-meta { font-size: 14px; color: var(--muted); line-height: 1.35; }
.row-side { flex: none; max-width: 60%; text-align: right; }
.row-amount { font-size: 14px; font-weight: 700; }
.row-note { font-size: 14px; color: var(--muted); white-space: nowrap; }
.row-note.pos { color: var(--good); }
.row-note.neg { color: var(--bad); }
.trip { border-top: 1px solid var(--line); }
.trip:first-child { border-top: 0; }
.trip > .row { border-top: 0; padding-bottom: 0; }
.trip-uid { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 0 16px; }
.trip-uid-text { font-size: 14px; color: var(--accent-text); }
.trip-actions { display: flex; align-items: center; flex: none; }
.change-btn {
  min-height: 44px; padding: 0 8px; border: 0; border-radius: 22px;
  background: transparent; color: var(--text); font-size: 14px; cursor: pointer;
  transition: background 150ms ease-out;
}
.change-btn:active { background: var(--surface-2); }
/* Anchored to the top so the phone's keyboard cannot cover it. */
.sheet {
  width: calc(100% - 32px); max-width: 480px; max-height: calc(100dvh - 32px);
  margin: calc(16px + env(safe-area-inset-top)) auto auto; padding: 16px;
  overflow: auto; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.sheet[open] { display: flex; flex-direction: column; gap: 8px; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.change-text { min-height: 120px; resize: vertical; line-height: 1.5; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0;
  background: transparent; border: 0; border-radius: 22px; color: var(--muted); cursor: pointer;
  transition: background 150ms ease-out;
}
.copy-btn:active { background: var(--surface-2); }
.copy-btn.done { color: var(--good); }
.trip-head { display: flex; align-items: flex-start; gap: 8px; }
.trip-head .page-head { flex: 1; min-width: 0; }
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 20; max-width: 400px; margin: 0 auto;
  bottom: calc(var(--tab-height) + 16px + env(safe-area-inset-bottom));
  padding: 12px 16px; border-radius: var(--control);
  background: var(--text); color: var(--bg); font-size: 14px; text-align: center;
  box-shadow: var(--shadow); pointer-events: none;
}
.row-icon { color: var(--accent-text); }
.row-chevron { color: var(--muted); }
.tag {
  padding: 0 8px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 400; line-height: 20px; text-transform: capitalize;
}
.tag-warn { background: var(--warn-bg); color: var(--warn); }

.rows { padding: 4px 16px; }
.line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.line:first-child { border-top: 0; }
.line-label { color: var(--muted); font-size: 14px; }
.line-value { font-size: 14px; font-weight: 700; text-align: right; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-value { font-size: 14px; font-weight: 700; }
.note { padding: 12px 16px; }
.note-text { white-space: pre-wrap; }

/* ── search and filters ───────────────────────────────── */
.search { position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-input { padding-left: 40px; padding-right: 44px; -webkit-appearance: none; appearance: none; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 2px; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; background: transparent; border: 0; color: var(--muted); cursor: pointer;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 22px;
  background: transparent; border: 1px solid var(--line); color: var(--text);
  font-size: 14px; cursor: pointer;
  transition: background 150ms ease-out;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.date-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.date-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.summary {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius);
}
.summary-wide {
  grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.summary-label { font-size: 14px; color: var(--muted); }
.summary-value { font-size: 14px; font-weight: 700; }

@media (max-width: 359px) {
  .summary { grid-template-columns: 1fr; }
  .hero-value { font-size: 28px; }
  .keypad { grid-template-columns: repeat(3, 64px); }
  .key { width: 64px; height: 64px; }
}

/* Landscape: the lock screen has to fit without scrolling past the keypad. */
@media (orientation: landscape) and (max-height: 500px) {
  .pin-screen { display: grid; grid-template-columns: 1fr auto; column-gap: 32px; align-content: center; max-width: 640px; }
  .pin-screen .keypad { grid-column: 2; grid-row: 1 / span 6; grid-template-columns: repeat(3, 64px); }
  .pin-screen .key { width: 64px; height: 64px; }
  .pin-screen .mark { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
