/* EmberGuard — modern station theme
   Matte charcoal, engine red as the one accent, amber only for warnings. */
:root {
  --red: #d7263d;          /* engine red */
  --red-dark: #a51b2e;
  --red-soft: rgba(215,38,61,.14);
  --amber: #f5a524;        /* warnings only */
  --amber-soft: rgba(245,165,36,.14);
  --green: #2fbf71;
  --green-soft: rgba(47,191,113,.14);

  --bg: #0f1114;           /* bay at night */
  --panel: #181b1f;        /* cards */
  --panel-2: #20242a;      /* raised / hover */
  --field: #121417;        /* input wells */
  --line: #2a2f36;
  --line-2: #363c44;

  --ink: #f1f3f5;
  --ink-2: #c9ced5;
  --muted: #8a929c;

  --radius: 14px;
  --top: calc(60px + env(safe-area-inset-top));
  --tabs: env(safe-area-inset-bottom, 0px);
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--body);
  color: var(--ink);
  background:
    radial-gradient(900px 380px at 50% -140px, rgba(215,38,61,.22), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; font-weight: 600; }
a:hover { color: #fff; }
.page a:not(.btn):not(.list-item):not(.pick):not(.back):not(.stat) { color: #ff6b7d; }

h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
h1 { font-size: 2.1rem; font-weight: 700; letter-spacing: .01em; margin: .2rem 0 .8rem; }
h2 {
  font-size: .95rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-2); margin: 1.6rem 0 .75rem;
  display: flex; align-items: center; gap: 10px;
}
h2::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--red); flex: none; }
.card h2:first-child, .card > .row:first-child h2 { margin-top: 0; }
details summary h2 { margin: 0; }
h3 { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.1rem 0 .4rem; }
p { margin: .4rem 0; }
[hidden] { display: none !important; }
.user-text { white-space: pre-wrap; overflow-wrap: anywhere; } /* keep line breaks people type */

/* ---------- Top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: var(--top);
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 12px;
  background: rgba(15,17,20,.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
#topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--red) 30%, var(--red) 70%, transparent);
  opacity: .8;
}
.topbar-logo { width: 32px; height: 32px; border-radius: 8px; }
#districtName {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink);
}
#offline { background: var(--amber-soft); color: var(--amber); font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }

/* Account button */
.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: .05em;
  transition: border-color .15s, box-shadow .15s;
}
/* Manage Profile button (top right) */
.profile-btn {
  flex: none; display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 16px 4px 4px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.profile-btn .avatar { width: 34px; height: 34px; font-size: .95rem; background: var(--red); border: 0; color: #fff; }
.profile-btn:hover, .profile-btn.active { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); background: #262b32; color: #fff; }
@media (max-width: 420px) {
  .profile-btn { padding-right: 12px; gap: 8px; font-size: .9rem; }
  .profile-label { max-width: 64px; white-space: normal; line-height: 1; font-size: .8rem; }
}
.inline-select { width: auto; padding: 7px 12px; font-size: .9rem; }
.avatar.big { width: 68px; height: 68px; font-size: 1.7rem; background: linear-gradient(145deg, var(--red), var(--red-dark)); border: 0; color: #fff; box-shadow: 0 8px 22px rgba(215,38,61,.35); }
.acct-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 18px; }
.acct-head h1 { margin: 0; }
.acct-head p { margin: 2px 0 0; }

#view { padding: calc(var(--top) + 18px) 16px calc(var(--tabs) + 32px); }
.page { max-width: 720px; margin: 0 auto; }

/* ---------- ☰ Menu ---------- */
.menu-btn {
  flex: none; width: 40px; height: 40px; margin-left: -6px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
}
.menu-btn:hover { background: var(--panel-2); }
.menu-btn span { display: block; width: 20px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#menuScrim {
  position: fixed; inset: 0; z-index: 8; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#menuScrim.open { opacity: 1; pointer-events: auto; }
#menu {
  position: fixed; z-index: 9; top: var(--top); left: 0; right: 0;
  max-height: calc(100vh - var(--top)); overflow-y: auto;
  background: rgba(20,23,27,.98);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  padding: 8px 10px 14px;
  transform: translateY(-12px); opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform .2s ease, opacity .2s ease, visibility 0s .2s;
}
#menu.open { transform: none; opacity: 1; pointer-events: auto; visibility: visible; transition: transform .2s ease, opacity .2s ease; }
@media (min-width: 640px) {
  #menu { left: 12px; right: auto; width: 300px; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
}
.menu-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-head b { display: block; font-size: 1rem; }
.menu-head span { display: block; font-size: .8rem; color: var(--muted); }
#menu a, #menu button {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font: 600 1rem var(--body); text-align: left;
}
#menu a svg, #menu button svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
#menu a:hover, #menu button:hover { background: var(--panel-2); color: #fff; }
#menu a.active { background: var(--red-soft); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
#menu a.active svg { color: var(--red); }
#menu button:hover { color: #ff6b7d; }
#menu button:hover svg { color: #ff6b7d; }
.menu-section { padding: 4px 0; }
.menu-section + .menu-section { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.menu-label {
  padding: 6px 12px 4px; color: var(--muted);
  font-family: var(--display); font-size: .75rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
}

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.gap { gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; }
/* iPhone Safari draws date/time boxes its own way: make them match the other fields */
input[type=date], input[type=time], input[type=datetime-local], input[type=month] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%;
  min-height: 48px; line-height: 1.3; text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.3em; }
input::-webkit-datetime-edit { padding: 0; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); opacity: .7; cursor: pointer; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.empty { text-align: center; padding: 34px 16px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.back:hover { color: var(--ink); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
input:not([type=checkbox]):not([type=radio]), select { min-height: 48px; }
input, select, textarea {
  font: inherit; font-weight: 500; color: var(--ink);
  width: 100%; padding: 12px 14px;
  background: var(--field); border: 1px solid var(--line-2); border-radius: 10px;
  color-scheme: dark; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5d646d; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
input:disabled, select:disabled { opacity: .55; }
textarea { resize: vertical; }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-size: 1.5rem; text-align: center; font-weight: 700; font-family: var(--display); }
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 52px; }
.input-unit.prefix input { padding-right: 14px; padding-left: 30px; }
.input-unit.prefix span { right: auto; left: 14px; }
.input-unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; padding: 7px 0; font-size: .95rem; color: var(--ink); }
label.check input { width: 20px; height: 20px; accent-color: var(--red); }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 68px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; padding: 6px 10px; border-radius: 8px;
  font: 600 .8rem var(--body); letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); background: var(--panel-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { border-color: #4a515a; background: #252a31; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(215,38,61,.3); }
.btn.primary:hover { background: #e23a50; border-color: #e23a50; }
.btn.danger { color: #ff6b7d; background: transparent; border-color: rgba(215,38,61,.45); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .9rem; border-radius: 10px; }
.btn.link { border: 0; background: none; color: var(--muted); padding: 0; min-height: 0; text-decoration: underline; font-size: .85rem; box-shadow: none; }
.btn.block { display: flex; width: 100%; margin: 12px 0; }
.btn.big { min-height: 62px; font-size: 1.25rem; border-radius: 14px; }
.icon-btn { width: 38px; height: 38px; flex: none; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); color: var(--ink-2); font-size: 1rem; cursor: pointer; }
.icon-btn:hover { color: #fff; border-color: #4a515a; }

/* ---------- Lists ---------- */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); color: inherit; font-weight: 400; transition: background .15s; }
a.list-item:hover { background: var(--panel-2); color: inherit; }
.list-item:last-child { border-bottom: 0; }
.list-empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: .03em; }
.li-sub { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.li-end { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.li-end select { width: auto; padding: 7px 10px; font-size: .85rem; }
.member-end { flex-wrap: wrap; justify-content: flex-end; }
/* Phones: put role / status controls on their own line under the name */
@media (max-width: 560px) {
  .list-item:has(.member-end) { flex-wrap: wrap; }
  .list-item:has(.member-end) .li-main { flex-basis: 100%; }
  .member-end { flex-basis: 100%; justify-content: flex-start; }
  .member-end select { flex: 1; min-width: 0; }
  .li-sub { white-space: normal; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.bad { background: var(--red-soft); color: #ff6b7d; border-color: transparent; }
.badge.gold { background: rgba(140,160,255,.14); color: #a9b7ff; border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--display); font-size: 2.3rem; font-weight: 700; line-height: 1; color: var(--ink); }
.stat b small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
a.stat { color: inherit; font-weight: 400; transition: border-color .15s, transform .1s; }
a.stat:hover { border-color: #4a515a; color: inherit; }
a.stat:active { transform: scale(.98); }
.stat.good b { color: var(--green); }
.stat span { display: block; margin-top: 6px; font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat.warn b { color: var(--amber); }
.stat.bad b { color: #ff6b7d; }
.stat.warn { border-color: rgba(245,165,36,.35); }
.stat.bad { border-color: rgba(215,38,61,.45); background: linear-gradient(160deg, rgba(215,38,61,.12), var(--panel) 60%); }

/* ---------- Truck picker ---------- */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.pick {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 18px 16px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-weight: 400; box-shadow: var(--shadow); overflow: hidden;
  transition: border-color .15s, transform .1s;
}
.pick::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.pick:hover { border-color: var(--red); color: var(--ink); }
.pick:active { transform: scale(.98); }
.pick b { font-family: var(--display); font-size: 1.4rem; font-weight: 700; letter-spacing: .03em; }
.pick span { font-size: .875rem; color: var(--ink-2); }
.pick small { color: var(--muted); }

/* ---------- Check form ---------- */
.check-head {
  position: sticky; top: var(--top); z-index: 5;
  background: rgba(15,17,20,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 8px 0 12px; margin: 0 -2px 6px;
}
.check-head h1 { margin-bottom: 0; }
.check-head p { margin: 0 0 10px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--red-dark), var(--red)); border-radius: 99px; transition: width .25s; box-shadow: 0 0 10px rgba(215,38,61,.6); }
.item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-label { display: block; font-weight: 600; margin-bottom: 10px; font-size: 1rem; color: var(--ink); letter-spacing: 0; }
.item.missing { margin: 0 -18px; padding: 14px 18px; background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--field); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button {
  min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); background: var(--panel-2); }
.item[data-v="pass"] .seg button.on { background: var(--green); color: #06210f; }
.item[data-v="attention"] .seg button.on { background: var(--amber); color: #2a1a00; }
.item[data-v="fail"] .seg button.on { background: var(--red); color: #fff; }
.seg.seg-2 { grid-template-columns: 1fr 1fr; }
.seg button.on[data-v="pass"] { background: var(--green); color: #06210f; }
.seg button.on[data-v="fail"] { background: var(--red); color: #fff; }
.item-extra { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line-2); }
.sig { width: 100%; height: 160px; border: 1px dashed #5d646d; border-radius: 12px; background: #eef0f2; touch-action: none; }

/* ---------- Check detail ---------- */
.ok-text { color: var(--green); font-weight: 700; }
.progress.slim { height: 4px; margin: 2px 0 6px; }
.progress.slim > div { height: 100%; background: var(--green); border-radius: 99px; transition: width .25s; }
.issues.all-done { border-color: rgba(47,191,113,.4); }
.issue.is-resolved > b, .issue.is-resolved > .row b { color: var(--ink-2); }
.resolution { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--green-soft); border-left: 3px solid var(--green); }
.resolution p { margin: 6px 0 0; }
.resolution .row { margin-top: 10px; }
.resolve-box { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.resolve-box .row { justify-content: flex-end; }
.issue { padding: 12px 0; border-bottom: 1px solid var(--line); }
.issue:last-child { border-bottom: 0; }
.issues { border-color: rgba(215,38,61,.45); }
.photo { max-width: 100%; max-height: 260px; border-radius: 10px; margin-top: 8px; }
.results { width: 100%; border-collapse: collapse; font-size: .92rem; }
.results td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.results td:last-child { text-align: right; }
details summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
details[open] summary::after { transform: rotate(180deg); }
.sig-img { max-width: 280px; width: 100%; background: #eef0f2; border-radius: 10px; padding: 6px; }
.warn-box { background: var(--amber-soft); color: var(--amber); padding: 12px 14px; border-radius: 12px; }
.ok-box { border-color: rgba(47,191,113,.4); background: linear-gradient(160deg, var(--green-soft), var(--panel) 60%); }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; }
dl.info dt { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding-top: 2px; }
dl.info dd { margin: 0; font-weight: 600; }

/* ---------- Crew invite ---------- */
.invite { background: linear-gradient(160deg, rgba(215,38,61,.14), var(--panel) 55%); }
.invite .code {
  font-family: var(--display); font-size: 2.6rem; font-weight: 700; letter-spacing: .3em; text-align: center;
  padding: 14px 10px; margin: 10px 0 14px; border-radius: 12px;
  background: var(--field); color: #fff; border: 1px solid var(--line-2);
}

/* ---------- Join requests ---------- */
.requests { border-color: rgba(245,165,36,.45); background: linear-gradient(160deg, var(--amber-soft), var(--panel) 55%); }
.req { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; padding-bottom: 0; }
.req-who b { display: block; font-family: var(--display); font-size: 1.2rem; letter-spacing: .02em; }
.req-who small { display: block; }
.join-alert { margin-bottom: 14px; border: 1px solid rgba(245,165,36,.45); border-radius: var(--radius); background: var(--amber-soft); }
.pending-pulse { width: 18px; height: 18px; margin: 4px auto 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 0 rgba(245,165,36,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { to { box-shadow: 0 0 0 16px rgba(245,165,36,0); } }

/* ---------- Roles ---------- */
.role-head { flex-wrap: nowrap; }
.role-head h2 { margin: 0; }
.icon-btn:disabled { opacity: .3; cursor: default; }
@keyframes flash { from { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft), var(--shadow); } }
.role.just-moved { animation: flash 1.2s ease-out; }
.role-name { font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: .03em; }
.perms { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin: 10px 0 14px; }

/* ---------- Equipment ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.due-list { display: flex; flex-direction: column; gap: 8px; }
.due-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: var(--field); border-left: 3px solid var(--green);
}
.due-row b { display: block; text-align: right; }
.due-row small { display: block; text-align: right; color: var(--muted); }
.due-row.soon { border-left-color: var(--amber); }
.due-row.soon small { color: var(--amber); }
.due-row.overdue { border-left-color: var(--red); background: var(--red-soft); }
.due-row.overdue small { color: #ff6b7d; }
.eq-fields:empty { display: none; }
@media (max-width: 520px) { .filters .grid3 { grid-template-columns: 1fr; } }

/* ---------- Switch + schedule ---------- */
.schedule { display: flex; flex-direction: column; gap: 12px; }
.switch-row {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; border-radius: 12px; background: var(--field); border: 1px solid var(--line-2); cursor: pointer;
}
.switch-row b { display: block; font-size: .95rem; color: var(--ink); }
.switch-row small { display: block; font-weight: 500; margin-top: 2px; }
.switch { position: relative; flex: none; width: 50px; height: 30px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #3a4048; transition: background .2s; }
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .2s;
}
.switch input:checked + i { background: var(--red); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--red-soft); }
.switch input:disabled + i { opacity: .5; }
.truck-days { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.truck-day { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.truck-day:last-child { border-bottom: 0; }
.truck-day b { display: block; font-family: var(--display); font-size: 1.1rem; letter-spacing: .02em; }
.truck-day small { display: block; }
.truck-day .input-unit input { width: 86px; text-align: center; }

/* ---------- Form editor ---------- */
.label-like { font-size: .8rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex-direction: row; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; padding: 9px 14px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--field); color: var(--ink-2);
  font-weight: 600; font-size: .9rem; transition: .15s;
}
.chip input:checked + span { background: var(--red-soft); border-color: var(--red); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--red-soft); }

.tpl-item { display: flex; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tpl-item input.grow { flex: 1 1 100%; }
.tpl-item select { flex: 1; width: auto; min-width: 0; }
.tpl-item .unit { width: 90px; flex: none; }
@media (min-width: 560px) { .tpl-item input.grow { flex: 1 1 220px; } .tpl-item select { flex: none; } }
.tpl-sec .btn.small { margin-top: 12px; }
.sec-title { font-family: var(--display); font-weight: 700; font-size: 1.1rem; letter-spacing: .03em; }
.sticky-actions {
  position: sticky; bottom: calc(var(--tabs) + 10px); display: flex; gap: 8px; padding: 10px;
  background: rgba(24,27,31,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
}

/* ---------- Sign in ---------- */
.auth { max-width: 400px; margin: 4vh auto 0; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo img { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 14px 40px rgba(215,38,61,.35); }
.auth-logo h1 { margin: 14px 0 2px; font-size: 2.4rem; letter-spacing: .1em; text-transform: uppercase; }
.auth-logo p.muted { font-size: .95rem; }
.auth .card { padding: 22px; }

/* ---------- Confirm dialog ---------- */
.dialog-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .15s;
}
.dialog-scrim.open { opacity: 1; }
.dialog {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 26px 22px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.6);
  transform: translateY(10px) scale(.97); transition: transform .15s;
}
.dialog-scrim.open .dialog { transform: none; }
.dialog-icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 1.5rem;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
}
.dialog.danger .dialog-icon { background: var(--red-soft); color: #ff6b7d; border-color: rgba(215,38,61,.45); }
.dialog h3 { font-size: 1.4rem; letter-spacing: .02em; text-transform: none; color: var(--ink); margin: 0 0 6px; }
.dialog p { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.dialog-actions .btn { width: 100%; }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(215,38,61,.3); }
.btn.danger-solid:hover { background: #e23a50; border-color: #e23a50; }

/* ---------- Update bar ---------- */
#updateBar {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 16px); z-index: 55;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px;
  background: #23272d; border: 1px solid var(--line-2); border-radius: 99px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); color: #fff; font-weight: 600;
  transform: translate(-50%, 30px); opacity: 0; transition: .25s;
}
#updateBar.show { transform: translate(-50%, 0); opacity: 1; }
#updateBar button {
  border: 0; border-radius: 99px; padding: 8px 16px; cursor: pointer;
  background: var(--red); color: #fff; font-family: var(--display); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 16px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 90vw; padding: 12px 18px; border-radius: 12px;
  background: #23272d; color: #fff; font-weight: 600; transition: .2s;
  border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: rgba(47,191,113,.5); }
#toast.error { border-color: var(--red); background: #2a1519; }

@media (max-width: 420px) {
  .perms { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.85rem; }
}

/* ---------- Print (Save as PDF for audits) ---------- */

/* Roles: permission groups */
.perm-group { margin: 14px 0 4px; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* Email report dialog */
.email-dialog { text-align: left; max-width: 440px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.email-dialog h3 { margin: 0; }
.email-dialog > p { margin: 0 0 2px; }
.email-dialog label small { font-weight: 500; text-transform: none; letter-spacing: 0; }
.radio-cards { display: grid; gap: 8px; }
.radio-card {
  flex-direction: row; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--field); cursor: pointer; transition: border-color .15s, background .15s;
}
.radio-card:hover { border-color: #4a515b; }
.radio-card:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.radio-card input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 20px; height: 20px; padding: 0; margin: 0; border-radius: 50%;
  border: 2px solid #5a626d; background: transparent; display: grid; place-items: center; cursor: pointer;
}
.radio-card input::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--red); transform: scale(0); transition: transform .15s; }
.radio-card input:checked { border-color: var(--red); }
.radio-card input:checked::after { transform: scale(1); }
.radio-card input:focus-visible { box-shadow: 0 0 0 3px var(--red-soft); }
.radio-card span { min-width: 0; }
.radio-card b { display: block; font-size: .98rem; color: var(--ink); }
.radio-card small { display: block; margin-top: 2px; color: var(--muted); font-size: .82rem; font-weight: 500; overflow-wrap: anywhere; }
.email-dialog .switch-row small { overflow-wrap: anywhere; }
.email-dialog .dialog-actions { margin-top: 4px; }

/* Email link landing page (/auth/action) */
.action-result { align-items: center; padding: 6px 0; }
.action-result h2 { margin: 4px 0 0; }
.action-result p { margin: 0 0 6px; }
.action-result .btn { width: 100%; }
.action-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font: 800 1.6rem var(--display); border: 1px solid var(--line-2); background: var(--field); color: var(--muted); }
.action-icon.ok { background: rgba(46,160,90,.14); border-color: rgba(46,160,90,.5); color: #5fd38d; }
.action-icon.bad { background: var(--red-soft); border-color: rgba(215,38,61,.5); color: #ff6b7d; }

/* Password rules checklist */
.pw-rules { list-style: none; margin: -4px 0 2px; padding: 10px 12px; display: grid; gap: 5px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.pw-rules li { display: flex; align-items: center; gap: 8px; transition: color .15s; }
.pw-dot { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #4a515b; display: grid; place-items: center; transition: all .15s; }
.pw-rules.started li:not(.ok) { color: var(--ink-2); }
.pw-rules li.ok { color: #5fd38d; }
.pw-rules li.ok .pw-dot { border-color: #2ea05a; background: #2ea05a; }
.pw-rules li.ok .pw-dot::after { content: ""; width: 7px; height: 4px; border: 2px solid #0f1114; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.pw-match { margin: -6px 0 0; color: #ff8a99; }
.pw-match.ok { color: #5fd38d; }

/* Announcements */
.ann-head { margin-top: 4px; }
.ann-head h2 { display: flex; align-items: center; gap: 8px; }
.ann-list { display: grid; gap: 10px; margin-bottom: 18px; }
.ann { display: block; padding: 14px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none; position: relative; transition: border-color .15s; }
.ann:hover { border-color: var(--line-2); }
.ann.unread { border-left: 3px solid var(--red); }
.ann.urgent { background: linear-gradient(180deg, rgba(215,38,61,.16), rgba(215,38,61,.05)); border-color: rgba(215,38,61,.55); }
.ann-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 18px; }
.ann-meta { margin-left: auto; font-size: .78rem; color: var(--muted); }
.ann-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px rgba(215,38,61,.8); }
.ann-title { font-weight: 700; font-size: 1.05rem; margin-top: 6px; }
.ann-body { color: var(--ink-2); font-size: .92rem; margin-top: 4px; }
.ann-full.urgent { border-color: rgba(215,38,61,.55); }
.ann-full h1 { margin: 0; }
.ann-old summary { cursor: pointer; color: var(--muted); font-weight: 600; margin: 8px 0 12px; }
.row.gap { gap: 8px; justify-content: flex-start; }

/* Drills attendance picker */
.attend-head { margin-top: 6px; }
.attend { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; max-height: 360px; overflow: auto; padding: 2px; }
.attend-item { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--field); border: 1px solid var(--line-2); font-size: .95rem; font-weight: 500; color: var(--ink); cursor: pointer; }
.attend-item:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.attend-item input { width: 18px; height: 18px; margin: 0; padding: 0; flex: none; accent-color: var(--red); }
.year-pick { max-width: 160px; margin-bottom: 12px; }

/* Activity log */
.activity-filters { margin-bottom: 6px; }
.act-day { margin-top: 18px; }
.list-item.act { align-items: flex-start; gap: 12px; }
.act-icon { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--field); border: 1px solid var(--line); font-size: 1rem; }
.act-text { font-weight: 600; font-size: .98rem; line-height: 1.35; white-space: normal; }

/* Report section picker */
.pick-head { margin-bottom: 8px; }
.pick-chips button.chip { padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--field); color: var(--ink-2); font: inherit; font-size: .85rem; font-weight: 600; }
.pick-chips button.chip.on { background: var(--red-soft); border-color: var(--red); color: #fff; }

/* Date rule messages */
.field-error { display: block; margin-top: 6px; color: #ff8a99; font-size: .82rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
input.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px var(--red-soft); }

/* Grouped fields (e.g. "Next due" on Log service) */
.subgroup { border: 1px solid var(--line-2); border-radius: 12px; padding: 14px 14px 12px; margin: 4px 0 0; display: flex; flex-direction: column; gap: 10px; background: rgba(255,255,255,.015); }
.subgroup legend { padding: 0 6px; margin-left: -6px; font: 700 1.15rem/1 var(--display); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.subgroup-note { margin: -2px 0 0; }

/* Legal pages */
.legal { max-width: 720px; }
.legal h2 { margin-top: 26px; }
.legal p, .legal li { line-height: 1.6; color: var(--ink-2, #c9ced6); }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin: 4px 0; }
.legal-links a { color: var(--muted); }
.card-link { display: flex; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 14px; background: var(--panel, #171a1f); }

/* Reports */
.print-only { display: none; }
.right { text-align: right; }
.report-sec { margin-bottom: 14px; }
.report-sec h2 { margin: 0; }
.table-wrap { overflow-x: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
table.report { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.report th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.report td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.report tr:last-child td { border-bottom: 0; }
table.report .num { text-align: right; font-variant-numeric: tabular-nums; }
table.report td.zero { color: var(--muted); }

@media print {
  #topbar, #menu, #menuScrim, #toast, .no-print { display: none !important; }
  body { background: #fff !important; color: #111; }
  #view { padding: 0; }
  .card, .list, .list-item { background: #fff !important; color: #111; box-shadow: none; border-color: #ccc; break-inside: avoid; }
  h2 { color: #333; }
  .muted, label, dl.info dt { color: #555 !important; }
  .results td { border-color: #ddd; }
  .print-only { display: block; }
  .report-head h1 { color: #111; margin: 0 0 4px; }
  .stat { background: #fff !important; border: 1px solid #ccc; box-shadow: none !important; }
  .stat b, table.report td { color: #111 !important; }
  table.report th, table.report td { border-color: #ccc; }
  .table-wrap { overflow: visible; }
  .badge { border: 1px solid #999; background: #fff !important; color: #111 !important; }
}

/* Transfer chief */
.danger-zone { border-color: rgba(215,38,61,.45); }

/* ---------- Printed report ---------- */
@page {
  size: letter;
  margin: 14mm 13mm 16mm;
  /* Our own footer replaces the browser's date / title / URL */
  @top-left { content: ""; }
  @top-center { content: ""; }
  @top-right { content: ""; }
  @bottom-left { content: "EmberGuard  ·  emberguard.app"; font: 600 8pt Barlow, Arial, sans-serif; color: #8a929c; }
  @bottom-center { content: ""; }
  @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 600 8pt Barlow, Arial, sans-serif; color: #8a929c; }
}
@media print {
  html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-out { color: #1b1e23; font-size: 10pt; }
  .rp-head { display: flex !important; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 3px solid #d7263d; }
  .rp-brand { display: flex; align-items: center; gap: 8px; }
  .rp-brand img { width: 28px; height: 28px; }
  .rp-brand span { font-family: var(--display); font-weight: 800; font-size: 17pt; letter-spacing: .04em; text-transform: uppercase; color: #111; }
  .rp-meta { text-align: right; line-height: 1.35; }
  .rp-meta span { display: block; font-size: 7.5pt; letter-spacing: .1em; text-transform: uppercase; color: #6b727c; }
  .rp-meta b { display: block; font-size: 11pt; color: #111; }
  .rp-title { margin: 16px 0 14px; }
  .rp-title h1 { margin: 0; font-size: 24pt; line-height: 1.05; color: #111; }
  .rp-title p { margin: 2px 0 0; color: #6b727c; font-size: 10pt; }

  .rp-stats { display: grid !important; grid-template-columns: repeat(7, 1fr); gap: 0; margin: 0 0 18px;
    border: 1px solid #d9dce1; border-radius: 8px; overflow: hidden; }
  .rp-stats .stat { border: 0 !important; border-right: 1px solid #d9dce1 !important; border-radius: 0; padding: 10px 10px 9px; min-height: 0; background: #f6f7f9 !important; }
  .rp-stats .stat:last-child { border-right: 0 !important; }
  .rp-stats .stat::before, .rp-stats .stat::after { display: none !important; }
  .rp-stats .stat b { font-size: 17pt; color: #111 !important; }
  .rp-stats .stat span { font-size: 6.5pt; margin-top: 3px; color: #6b727c !important; }
  .rp-stats .stat.warn b { color: #b86e00 !important; }
  .rp-stats .stat.bad b { color: #c21d33 !important; }

  .report-sec { border: 0 !important; border-radius: 0; padding: 0 !important; margin: 0 0 16px; background: none !important; break-inside: auto; }
  .report-sec h2 { font-size: 10.5pt; color: #111; padding-left: 8px; border-left: 3px solid #d7263d; margin: 0 0 6px; }
  .report-sec h2::before { display: none; }
  .report-sec > p.muted { margin: 0; padding: 8px 10px; background: #f6f7f9; border-radius: 6px; color: #6b727c !important; font-size: 9pt; }
  .report-sec .right { margin: 6px 0 0; font-size: 10pt; }
  .report-out .table-wrap { margin-top: 0; }
  table.report { font-size: 9pt; border: 1px solid #d9dce1; }
  table.report thead { display: table-header-group; }
  table.report th { background: #1b1e23 !important; color: #fff !important; font-size: 7pt; padding: 6px 8px; border: 0; }
  table.report td { padding: 6px 8px; border-bottom: 1px solid #e6e8eb; color: #1b1e23 !important; }
  table.report tbody tr:nth-child(even) td { background: #f6f7f9 !important; }
  table.report tr { break-inside: avoid; }
  table.report td.zero { color: #a3a9b1 !important; }
  table.report .muted { color: #6b727c !important; }
  .report-out .badge { border: 0 !important; padding: 2px 7px; font-size: 7pt; }
  .report-out .badge::before { display: none; }
  .report-out .badge.bad { background: #fde8eb !important; color: #b0182c !important; }
  .report-out .badge.warn { background: #fdf1dc !important; color: #8a5300 !important; }
  .report-out .badge.ok { background: #e3f6ec !important; color: #17713f !important; }
}
