/* 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; }
.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, 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 { display: flex; align-items: center; gap: 10px; }
.input-unit span { color: var(--muted); font-weight: 600; min-width: 32px; }
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);
}

/* ---------- 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; }

/* ---------- 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) ---------- */
@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; }
}
