/*
 * Mobile first throughout. The client works from his phone while travelling, so the phone
 * layout is the design and the desktop one is the same thing given more room.
 *
 * Two rules that are not decoration:
 *   Actions sit at the bottom of the screen, where a thumb already is. A primary button at
 *   the top of a phone screen is a button that needs a second hand.
 *   Tap targets are never below 44px. Approving two hundred accounts on a moving train is
 *   the actual use case.
 */

:root {
  --ink: #16211c;
  --ink-soft: #5c6b64;
  --line: #dde5e0;
  --paper: #ffffff;
  --ground: #f4f7f5;
  --green: #1f7a4d;
  --green-dark: #17603c;
  --red: #a8302a;
  --red-soft: #fdf1f0;
  --amber: #8a6100;
  --amber-soft: #fdf6e6;
  --radius: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Stops iOS inflating text in landscape and breaking the layout. */
  -webkit-text-size-adjust: 100%;
}

/* Room for the bottom navigation, plus the home indicator on a modern phone. */
.app { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.hint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 4px; }

header.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-top));
  background: var(--paper); border-bottom: 1px solid var(--line);
}

main { padding: 16px; max-width: 880px; margin: 0 auto; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card.selected { border-color: var(--green); box-shadow: 0 0 0 2px rgba(31, 122, 77, 0.15); }
.card.focused { outline: 3px solid var(--green); outline-offset: 2px; }

button {
  font: inherit; border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  min-height: var(--tap); padding: 0 16px; cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--green-dark); }
button.danger { background: var(--paper); border-color: var(--red); color: var(--red); font-weight: 600; }
button.wide { width: 100%; }
button.small { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.grow { flex: 1; }

label { display: block; font-weight: 600; margin: 14px 0 2px; }
input[type='text'], input[type='password'], input[type='number'], textarea, select {
  font: inherit; width: 100%; min-height: var(--tap);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink);
}
textarea { min-height: 80px; }

/* Multi-select as chips: far easier on a phone than a native multiple select. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  border-radius: 999px; padding: 9px 14px; min-height: 42px; font-size: 0.92rem;
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }

.pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; font-weight: 600; }
.pill.green { background: #e8f4ee; color: var(--green-dark); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.grey { background: var(--ground); color: var(--ink-soft); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.idle { background: #c3cec8; }

.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; border: 1px solid; }
.banner.ok { background: #e8f4ee; border-color: #b9dcc9; color: var(--green-dark); }
.banner.bad { background: var(--red-soft); border-color: #eec6c3; color: var(--red); }
.banner.warn { background: var(--amber-soft); border-color: #ecd9a6; color: var(--amber); }

.stat { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stat .value { font-weight: 700; font-variant-numeric: tabular-nums; }

.progress { height: 8px; background: var(--ground); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > span { display: block; height: 100%; background: var(--green); }

/* The account card's own sections, so the eye finds the same thing in the same place. */
.section-label {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-soft); font-weight: 700; margin: 14px 0 4px;
}
ul.reasons { margin: 0; padding-left: 18px; }
ul.reasons li { margin-bottom: 3px; }

/* Sticky action bar: the two buttons he presses two hundred times, under his thumb. */
.actions {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; padding: 10px 0; background: linear-gradient(transparent, var(--ground) 30%);
}
.actions button { flex: 1; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; border: 0; border-radius: 0; background: none; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 0.72rem; color: var(--ink-soft); padding: 0 4px;
}
nav.tabs button.on { color: var(--green); font-weight: 700; }
nav.tabs .glyph { font-size: 1.25rem; line-height: 1; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 30; background: var(--ink); color: #fff; border-radius: var(--radius);
  padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast button { background: none; border: 0; color: #8fe3b6; font-weight: 700; min-height: 40px; padding: 0 6px; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 15, 0.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--paper); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
}
.sheet h2 { margin-bottom: 12px; }
.sheet .stack button { width: 100%; margin-bottom: 8px; justify-content: flex-start; text-align: left; }

.centre { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }

.keyshelp { font-size: 0.82rem; color: var(--ink-soft); }
.keyshelp kbd {
  background: var(--ground); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font: inherit; font-size: 0.8rem;
}

.select-bar {
  position: sticky; top: 64px; z-index: 9;
  background: var(--ink); color: #fff; border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.select-bar button { min-height: 40px; }

.skeleton { height: 88px; border-radius: var(--radius); background: linear-gradient(90deg, #eef2f0, #f7faf8, #eef2f0); }

/* Desktop: list and detail side by side, and the keyboard shortcuts become visible. */
@media (min-width: 900px) {
  .app { padding-bottom: 0; }
  main { padding: 24px; max-width: 1100px; }
  nav.tabs {
    position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
    max-width: 1100px; margin: 0 auto;
  }
  nav.tabs button { min-height: 52px; flex-direction: row; gap: 8px; font-size: 0.9rem; }
  .actions { position: static; background: none; }
  .toast { left: auto; right: 24px; bottom: 24px; min-width: 320px; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
  .select-bar { top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
