/* FSS Crew — mobile-first app styles (brand colors from the website) */
:root {
  --navy-900: #06122e;
  --navy-800: #0b2547;
  --navy-700: #123a68;
  --blue-500: #1462d4;
  --blue-600: #0a4fa4;
  --blue-100: #e4eefb;
  --ink: #16202e;
  --slate-600: #4a5a6e;
  --slate-500: #6b7c8f;
  --slate-400: #93a2b3;
  --line: #e6ecf3;
  --bg: #f5f8fc;
  --card: #ffffff;
  --green: #12824a;
  --green-bg: #e3f5eb;
  --amber: #a15c00;
  --amber-bg: #fff2dc;
  --red: #d42020;
  --red-700: #a8141a;
  --red-bg: #fde8e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11,37,71,.06), 0 4px 14px rgba(11,37,71,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue-500); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.boot { min-height: 100vh; display: grid; place-items: center; opacity: .6; }

/* ---- Top bar --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy-800); color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px; min-height: 56px;
}
.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; flex: 1; min-width: 0; }
.topbar .brand img { width: 30px; height: 30px; }
.topbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { background: none; border: 0; color: #fff; font-size: 16px; padding: 6px 8px 6px 0; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }

.sos {
  background: var(--red); color: #fff; border: 0; border-radius: 999px;
  padding: 9px 14px; font-weight: 800; font-size: 14px; letter-spacing: .03em;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.18); white-space: nowrap;
}
.sos:active { background: var(--red-700); }

/* ---- Layout ------------------------------------------------------------ */
main.page { padding: 16px 16px calc(96px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }
main.page.no-nav { padding-bottom: calc(32px + var(--safe-bottom)); }
h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 4px; }
.muted { color: var(--slate-500); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.wrap { flex-wrap: wrap; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border: 1px solid var(--line);
}
.card + .card { margin-top: 12px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--bg); }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { color: var(--slate-500); font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--slate-400); flex: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--slate-500); }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 700; font-size: 16px;
  background: var(--blue-500); color: #fff; cursor: pointer; text-decoration: none; min-height: 48px;
}
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 19px; border-radius: 16px; }
.btn.secondary { background: var(--blue-100); color: var(--blue-600); }
.btn.ghost { background: transparent; color: var(--blue-600); border: 1.5px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.danger-ghost { background: var(--red-bg); color: var(--red-700); }
.btn.success { background: var(--green); }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.link-btn { background: none; border: 0; color: var(--blue-500); font-weight: 600; cursor: pointer; padding: 6px 0; }

/* ---- Forms -------------------------------------------------------------- */
label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--slate-600); }
.input, textarea.input, select.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; font-size: 16px; min-height: 48px; outline: none;
}
.input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(20,98,212,.15); }
textarea.input { min-height: 110px; resize: vertical; }
.hint { font-size: 13px; color: var(--slate-500); margin-top: 5px; }
.error { background: var(--red-bg); color: var(--red-700); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 500; }
.notice { background: var(--blue-100); color: var(--navy-700); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.warn { background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--slate-600); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy-800); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.checklist { max-height: 55vh; overflow: auto; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-item input { width: 22px; height: 22px; accent-color: var(--blue-500); flex: none; }

/* ---- Auth / PIN --------------------------------------------------------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; padding: calc(32px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); max-width: 440px; margin: 0 auto; }
.auth .logo { width: 72px; height: 72px; margin: 8px auto 14px; border-radius: 18px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; color: var(--slate-500); margin-bottom: 22px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 26px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--navy-700); }
.pin-dots i.on { background: var(--navy-700); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 300px; margin: 0 auto; }
.keypad button {
  height: 70px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow);
  font-size: 28px; font-weight: 600; cursor: pointer; aspect-ratio: 1; width: 70px; justify-self: center;
}
.keypad button:active { background: var(--blue-100); }
.keypad button.ghost { background: transparent; box-shadow: none; font-size: 15px; color: var(--blue-600); }

/* ---- Crew home ---------------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, #081c3a 0%, #0d2f5e 45%, #124f9c 100%); color: #fff;
  border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
.hero .label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; font-weight: 700; }
.hero h1 { color: #fff; margin: 6px 0 2px; }
.hero .addr { opacity: .85; font-size: 15px; }
.hero .timer { font-size: 34px; font-weight: 800; margin-top: 12px; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red-700); }
.pill.gray { background: var(--line); color: var(--slate-600); }
.pill.blue { background: var(--blue-100); color: var(--blue-600); }
.hero .pill { background: rgba(255,255,255,.16); color: #fff; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); border: 0; padding: 0; cursor: pointer; }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .ph .tag { position: absolute; left: 5px; bottom: 5px; background: rgba(6,18,46,.72); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: capitalize; }
.photo-grid.selecting .ph img { opacity: .8; }
.photo-grid .ph.selected { outline: 3px solid var(--blue-500); outline-offset: -3px; }
.photo-grid .ph.selected img { opacity: 1; }
.photo-grid .ph.selected::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-500); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.photo-grid .ph .state { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6,18,46,.45); color: #fff; font-size: 12px; font-weight: 700; }
.note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.note + .note { margin-top: 8px; }
.note .meta { font-size: 12.5px; color: var(--slate-500); margin-top: 4px; }
.note .text { white-space: pre-wrap; word-wrap: break-word; }

/* ---- Admin -------------------------------------------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff;
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--slate-500); font-size: 11.5px; font-weight: 600; padding: 4px 0; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--blue-500); }
.nav .badge { position: absolute; top: 0; left: calc(50% + 6px); }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 800; min-width: 19px; height: 19px; border-radius: 999px; display: inline-grid; place-items: center; padding: 0 5px; }

.alert-item { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.alert-main { display: flex; gap: 12px; padding: 14px 4px 14px 16px; cursor: pointer; background: none; border: 0; flex: 1; min-width: 0; text-align: left; }
.alert-del { flex: none; width: 44px; border: 0; background: none; color: var(--slate-400); font-size: 16px; cursor: pointer; }
.alert-del:active { color: var(--red); }
.alert-item:last-child { border-bottom: 0; }
.alert-item.unread { background: #f3f8ff; }
.alert-item.unread .msg { font-weight: 600; }
.alert-item .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 18px; }
.alert-item .when { font-size: 12.5px; color: var(--slate-500); margin-top: 2px; }
.alert-item.emergency { background: var(--red-bg); }
.alert-item.emergency .msg { color: var(--red-700); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue-500); flex: none; margin-top: 6px; }

.onsite { display: flex; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-100); color: var(--blue-600); font-weight: 800; display: grid; place-items: center; flex: none; font-size: 15px; }
.avatar.live { background: var(--green-bg); color: var(--green); box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3cc47c; }

.tabs { display: flex; gap: 6px; margin: 18px 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: var(--line); color: var(--slate-600); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-pressed="true"] { background: var(--navy-800); color: #fff; }

.visit { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.visit:last-child { border-bottom: 0; }
.visit .times { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--slate-500); }
.kv dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Sheets / modals ---------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(6,18,46,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom)); max-height: 92vh; overflow: auto; animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin-top: 0; }
.viewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }
.viewer .bar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-top)) 14px 10px; color: #fff; }
.viewer .img { flex: 1; display: grid; place-items: center; overflow: hidden; }
.viewer .img img { max-height: 100%; max-width: 100%; object-fit: contain; }
.viewer .foot { color: #ddd; padding: 12px 16px calc(14px + var(--safe-bottom)); font-size: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--navy-900); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner { width: 22px; height: 22px; border: 3px solid rgba(20,98,212,.2); border-top-color: var(--blue-500); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .sheet { border-radius: 20px; margin-bottom: 5vh; }
  .sheet-backdrop { align-items: center; }
}

/* Language switch on sign-in screens and the crew menu */
.auth .lang-switch { align-self: flex-end; width: 200px; margin-bottom: 4px; }
.demo-bar { background: #fff4cc; color: #7a5200; font-size: 13px; font-weight: 600; text-align: center; padding: 7px 12px; border-bottom: 1px solid #f0dc92; }
