/* Site Badge Log website.
   Mobile first (phones at the muster point), large touch targets (>= 44 px),
   high contrast for outdoor use, dark mode via prefers-color-scheme, and a
   print stylesheet for the muster roll (Print > Save as PDF).
   No external fonts: the system UI font of each device. */

:root {
  color-scheme: light dark;
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --text: #0c1116;
  --text-2: #2f3a47;
  --muted: #4a5563;
  --border: #d4d9e0;
  --border-strong: #7b8594;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --brand: #f67a19;
  --link: #1d4ed8;
  --in: #166534;
  --in-strong: #15803d;
  --ok-soft: #dcfce7;
  --out: #92400e;
  --out-strong: #b45309;
  --out-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-strong: #b91c1c;
  --danger-soft: #fee2e2;
  --warn-bg: #fef3c7;
  --warn-border: #d97706;
  --warn-ink: #78350f;
  --info-soft: #e0ecff;
  --info-ink: #1e3a8a;
  --focus: #2563eb;
  --topbar: #14181f;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --radius: 14px;
  --brand-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #151b23;
    --surface-2: #1b232d;
    --text: #f3f6f9;
    --text-2: #cdd5df;
    --muted: #a3aebb;
    --border: #2c3642;
    --border-strong: #6b7786;
    --accent: #fb8c3c;
    --accent-ink: #1a0a00;
    --link: #8ab4ff;
    --in: #4ade80;
    --in-strong: #15803d;
    --ok-soft: #0f2e1b;
    --out: #fbbf24;
    --out-strong: #b45309;
    --out-soft: #3a2a0a;
    --danger: #fb7185;
    --danger-strong: #b91c1c;
    --danger-soft: #3a1418;
    --warn-bg: #33250a;
    --warn-border: #d97706;
    --warn-ink: #fcd34d;
    --info-soft: #132544;
    --info-ink: #bcd3ff;
    --focus: #60a5fa;
    --topbar: #0f1319;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 750;
}

p {
  margin: 0 0 10px;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 1000;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.skip-link:focus {
  left: 8px;
}

.icon {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.mono {
  font-family: var(--mono);
  font-size: 0.95em;
}

.text-warning {
  color: var(--warn-ink);
  font-weight: 650;
}

.text-danger {
  color: var(--danger);
  font-weight: 700;
}

.text-ok {
  color: var(--in);
  font-weight: 700;
}

.print-only {
  display: none;
}

/* ---------- header: brand row scrolls away, tabs stay ---------- */

.topbar {
  position: sticky;
  top: calc(-1 * var(--brand-h));
  z-index: 20;
  background: var(--topbar);
  color: #fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--brand-h);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  border-top: 4px solid var(--brand);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.site-name {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.25;
  color: #c9d1d9;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-name:empty {
  display: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  max-width: 45%;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip .tag {
  margin-left: 0;
}

.user-chip-initials {
  display: none;
  font-weight: 800;
}

@media (max-width: 479px) {
  .user-chip {
    justify-content: center;
    width: 44px;
    padding: 0;
  }

  .user-chip-initials {
    display: inline;
  }

  .user-chip-name,
  .user-chip .tag {
    display: none;
  }
}

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs-list {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 6px;
  list-style: none;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 13px;
  border-bottom: 4px solid transparent;
  color: var(--text-2);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 800;
}

.tab-alert {
  color: var(--danger);
}

.tab-alert::after {
  content: "";
  width: 9px;
  height: 9px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--danger-strong);
}

body.booting .tabs,
body.signed-out .tabs {
  display: none;
}

/* ---------- layout ---------- */

main {
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

main:focus {
  outline: none;
}

.page > * + * {
  margin-top: 16px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.page-head > div:first-child {
  min-width: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.title-row .tag {
  margin-left: 0;
}

.page-sub,
.refresh-status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.refresh-status-error {
  color: var(--danger);
  font-weight: 650;
}

.section > h2 {
  margin-bottom: 10px;
}

.stack > * + * {
  margin-top: 10px;
}

.stack:empty {
  display: none;
}

.back-link {
  margin: 0 0 -6px;
  font-weight: 600;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.banners {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 14px 0;
}

.banners:empty {
  display: none;
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.loading-screen {
  padding: 18vh 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- cards, banners, messages ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 16px;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 16px;
  border: 2px solid;
  border-radius: 12px;
}

.banner-text {
  flex: 1 1 260px;
  min-width: 0;
}

.banner-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.banner-icon {
  width: 28px;
  height: 28px;
}

.banner-danger {
  background: var(--danger-strong);
  border-color: #7f1d1d;
  color: #fff;
}

.banner-warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.banner-warning .banner-text {
  color: var(--text);
}

.banner-ok {
  background: var(--ok-soft);
  border-color: var(--in-strong);
  color: var(--text);
}

.form-message {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid;
  border-radius: 10px;
  font-weight: 600;
}

.form-message-error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--text);
}

.form-message-success {
  background: var(--ok-soft);
  border-color: var(--in-strong);
  color: var(--text);
}

.form-message-info {
  background: var(--info-soft);
  border-color: var(--focus);
  color: var(--text);
}

.empty {
  padding: 24px 16px;
  color: var(--text-2);
  text-align: center;
}

.empty-title {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}

.empty-ok {
  color: var(--in);
  font-weight: 800;
}

/* ---------- buttons, inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled,
.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 0.65;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger-strong);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-danger-outline {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-on-danger {
  background: #fff;
  color: #7f1d1d;
}

.btn-large {
  min-height: 56px;
  padding: 14px 24px;
  font-size: 1.1rem;
}

.btn-block {
  width: 100%;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input:focus {
  border-color: var(--focus);
  outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 0;
}

input[type="date"].input {
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

.checkbox {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-weight: 650;
  cursor: pointer;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.field-check {
  align-self: end;
}

.field-check .check-label {
  margin-bottom: 0;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row .input {
  flex: 1;
  min-width: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 16px;
}

.filter-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.search-wrap {
  position: relative;
  flex: 1 1 260px;
  max-width: 560px;
}

.search-wrap .input {
  padding-left: 42px;
}

.search-wrap:not(:has(.search-icon)) .input {
  padding-left: 12px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 20px;
  height: 20px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.result-summary {
  margin: 0;
  color: var(--text-2);
  font-weight: 650;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  min-height: 44px;
  padding: 8px 15px;
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

.segmented {
  display: inline-flex;
  flex: none;
  overflow: hidden;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
}

.seg {
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}

.seg + .seg {
  border-left: 2px solid var(--border-strong);
}

.seg[aria-pressed="true"] {
  background: var(--text);
  color: var(--surface);
}

/* ---------- tags, dots, pills ---------- */

.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.6;
  text-transform: uppercase;
  vertical-align: 2px;
  white-space: nowrap;
}

.tag-manual,
.tag-src-manual {
  background: var(--out-soft);
  border-color: var(--out);
  color: var(--out);
}

.tag-src-autoClosed {
  background: var(--info-soft);
  border-color: var(--info-ink);
  color: var(--info-ink);
}

.tag-src-badge {
  color: var(--text-2);
}

.tag-admin {
  background: var(--brand);
  border-color: var(--brand);
  color: #1a0a00;
}

.tag-danger {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}

.tag-ok {
  background: var(--ok-soft);
  border-color: var(--in);
  color: var(--in);
}

.tag-warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.dot {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--dot, #7f7f7f);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);
  vertical-align: -1px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.count-pill {
  margin-left: auto;
  padding: 2px 11px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.count-pill-danger {
  background: var(--danger-strong);
  color: #fff;
}

.count-pill-ok {
  background: var(--in-strong);
  color: #fff;
}

.dir {
  display: inline-block;
  min-width: 3.3em;
  padding: 2px 8px;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}

.dir-in {
  background: var(--in-strong);
}

.dir-out {
  background: var(--out-strong);
}

/* ---------- headcount ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2.3rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.stat-label {
  overflow-wrap: anywhere;
  color: var(--text-2);
  font-weight: 700;
  line-height: 1.25;
}

.stat-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-total {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: baseline;
  gap: 12px;
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

.stat-total .stat-value {
  font-size: 3rem;
}

.stat-total .stat-label {
  color: inherit;
  font-size: 1.15rem;
}

.stat-stale {
  border: 2px solid var(--warn-border);
  background: var(--warn-bg);
}

.stat-stale .stat-sub {
  color: var(--warn-ink);
  font-weight: 700;
}

.stat-sub .icon {
  width: 1em;
  height: 1em;
  vertical-align: -2px;
}

/* ---------- company groups and rows ---------- */

.groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.group {
  overflow: hidden;
  border-left: 7px solid var(--company, var(--border-strong));
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.08rem;
}

.group-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows > li + li {
  border-top: 1px solid var(--border);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 1px;
  padding: 9px 14px;
}

.row-main {
  grid-column: 1;
  min-width: 0;
}

.row-time {
  grid-column: 2;
  grid-row: 1;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.row-time-label {
  color: var(--muted);
  font-weight: 600;
}

.row-meta {
  grid-column: 1;
  color: var(--text-2);
  font-size: 0.9rem;
}

.row-phone,
.row-action {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
}

.row-action {
  grid-row: 1 / span 2;
}

.person-name {
  font-size: 1.05rem;
  font-weight: 750;
}

.phone-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}

.phone-link .icon {
  width: 18px;
  height: 18px;
}

.link-rows .row {
  color: inherit;
  text-decoration: none;
  min-height: 64px;
}

.link-rows .row:hover {
  background: var(--surface-2);
}

/* ---------- muster ---------- */

.muster-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.muster-stats .stat {
  align-items: flex-start;
}

.stat-ok .stat-value {
  color: var(--in);
}

.stat-missing .stat-value {
  color: var(--danger);
}

.progress {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-fill {
  width: var(--pct, 0%);
  height: 100%;
  border-radius: 999px;
  background: var(--in-strong);
  transition: width 0.3s ease;
}

.muster-search {
  max-width: none;
}

.muster-toolbar {
  position: sticky;
  top: 51px;
  z-index: 10;
  justify-content: space-between;
  margin-left: -14px;
  margin-right: -14px;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.page .muster-toolbar {
  margin-top: 10px;
}

.mini-count {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.muster-stats .stat-label {
  overflow-wrap: normal;
}

.m-row {
  display: flex;
  align-items: stretch;
}

.m-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 76px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.m-toggle:disabled {
  cursor: default;
  color: inherit;
  opacity: 1;
}

.m-toggle:hover:not(:disabled) {
  background: var(--surface-2);
}

.m-check {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 3px solid var(--danger);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
}

.m-check .icon {
  width: 28px;
  height: 28px;
  stroke-width: 3.2;
}

.m-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.m-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.m-meta {
  color: var(--text-2);
  font-size: 0.9rem;
}

.m-status {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 750;
}

.is-accounted {
  background: var(--ok-soft);
}

.is-accounted .m-check {
  border-color: var(--in-strong);
  background: var(--in-strong);
  color: #fff;
}

.is-accounted .m-status {
  color: var(--in);
}

.is-accounted .m-toggle:hover:not(:disabled) {
  background: transparent;
}

.is-saving .m-check {
  border-style: dashed;
}

.muster-closed .is-missing .m-check {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.m-call {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 60px;
  padding: 0 14px;
  border-left: 1px solid var(--border);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.m-call .icon {
  width: 22px;
  height: 22px;
}

.m-call span {
  display: none;
}

.print-box {
  display: none;
}

@media screen {
  .filtered-out {
    display: none !important;
  }
}

/* ---------- tables (cards on phones) ---------- */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th {
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .tag {
  margin-left: 6px;
}

.table .cell-how .tag {
  margin-left: 0;
}

.cell-name {
  font-weight: 700;
}

@media (min-width: 760px) {
  .table .cell-name {
    white-space: nowrap;
  }
}

.cell-time,
.cell-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-company {
  white-space: nowrap;
}

.reason {
  color: var(--text-2);
}

.row-inactive td {
  color: var(--muted);
}

.cell-mobile {
  display: none;
}

@media (max-width: 759px) {
  .table-cards.table-compact tr {
    display: block;
  }

  .table-cards.table-compact td:not(.cell-mobile) {
    display: none;
  }

  .table-cards.table-compact td.cell-mobile {
    display: block;
  }

  .table-cards.table-compact td.cell-mobile::before {
    display: none;
  }

  .cm-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .cm-top .phone-link {
    align-self: center;
    margin: -8px 0;
  }

  .cm-name {
    font-size: 1.05rem;
    font-weight: 750;
  }

  .cm-when {
    font-variant-numeric: tabular-nums;
  }

  .cm-meta,
  .cm-how {
    color: var(--text-2);
    font-size: 0.92rem;
  }

  .cm-how .tag {
    margin-left: 0;
  }

  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table-cards,
  .table-cards tbody {
    display: block;
  }

  .table-cards tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .table-cards tbody tr:last-child {
    border-bottom: 0;
  }

  .table-cards td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .table-cards td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .table-cards .cell-name {
    grid-column: 1 / -1;
    order: -1;
    font-size: 1.05rem;
  }

  .table-cards .cell-name::before {
    display: none;
  }

  .table-cards .cell-company {
    white-space: normal;
  }
}

/* ---------- export ---------- */

.filter-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.download-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-option + .download-option {
  margin-top: 18px;
}

.download-option .btn {
  align-self: stretch;
}

.download-log {
  margin: 14px 0 0;
  padding: 0;
  color: var(--in);
  font-weight: 650;
  list-style: none;
}

.download-log li {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

/* ---------- iPads ---------- */

.device-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.device-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-head .tag {
  margin-left: 0;
}

.device-name {
  margin: 0;
  font-size: 1.2rem;
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 12px 0 0;
}

.facts > div {
  display: contents;
}

.facts dt {
  color: var(--muted);
  font-weight: 650;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.device-actions {
  margin-top: 14px;
}

.device .text-warning {
  margin: 12px 0 0;
}

.device-revoked {
  opacity: 0.72;
}

.device-stale {
  border: 2px solid var(--warn-border);
}

.pairing {
  border: 2px solid var(--accent);
}

.pairing h2 .icon {
  color: var(--in);
  vertical-align: -3px;
}

.pairing-ok {
  border-color: var(--in-strong);
}

.pairing-grid {
  display: grid;
  gap: 18px;
}

.code-box {
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
}

.code-label {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

/* "K7QM-3XWD": 9 monospaced characters on one line, sized to fit the code
   box from a 320 px phone up to the 320 px desktop column. */
.pair-code {
  margin: 4px 0 6px;
  font-family: var(--mono);
  font-size: clamp(1.9rem, 9.5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums slashed-zero;
  user-select: all;
}

.pair-code + .small {
  margin: 0 0 6px;
}

.pair-code-expired {
  color: var(--muted);
  text-decoration: line-through;
}

.steps {
  margin: 0;
  padding-left: 1.4em;
}

.steps li + li {
  margin-top: 8px;
}

.pairing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pairing > p:last-child {
  margin-top: 10px;
}

/* ---------- users, account ---------- */

.user-row {
  min-height: 64px;
}

.dupe-list {
  margin: 8px 0 0;
  padding-left: 1.2em;
}

.dupes .banner-text p {
  color: var(--text-2);
}

/* ---------- sign in ---------- */

.page-auth {
  display: flex;
  justify-content: center;
  padding-top: 4vh;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 22px 20px;
}

.auth-form > * + * {
  margin-top: 14px;
}

.auth-form .form-message {
  margin-bottom: 0;
}

/* ---------- dialogs and toasts ---------- */

.dialog {
  width: calc(100vw - 28px);
  max-width: 520px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.dialog::backdrop {
  background: rgba(5, 8, 12, 0.6);
}

.dialog-title {
  margin: 0;
  padding: 20px 20px 4px;
  font-size: 1.3rem;
}

.dialog-body {
  padding: 8px 20px;
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 20px;
}

.dialog-actions .btn {
  flex: 1 1 140px;
}

.toasts {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(520px, calc(100vw - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  font-weight: 650;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s ease;
  pointer-events: auto;
}

.toast-error {
  background: #991b1b;
}

.toast-success {
  background: #166534;
}

.toast-leaving {
  opacity: 0;
}

/* ---------- larger screens ---------- */

@media (min-width: 480px) {
  .m-call span {
    display: inline;
  }
}

@media (min-width: 640px) {
  main {
    padding: 22px 20px 48px;
  }

  .muster-toolbar {
    margin-left: 0;
    margin-right: 0;
    padding: 8px 0;
  }

  .muster-search {
    max-width: 560px;
  }

  .banners {
    padding: 14px 20px 0;
  }

  .card-pad {
    padding: 20px;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .stat-total {
    grid-column: auto;
    flex-direction: column;
    gap: 0;
  }

  .download-option {
    flex-direction: row;
    align-items: center;
    gap: 18px;
  }

  .download-option .btn {
    flex: none;
    width: 300px;
  }

  .download-option p {
    margin: 0;
  }

  .device-list {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }

  .pairing-grid {
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    align-items: start;
  }

  .auth-card {
    padding: 28px;
  }

  .page-auth {
    padding-top: 8vh;
  }
}

@media (min-width: 960px) {
  h1 {
    font-size: 1.85rem;
  }

  .groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .muster-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .brand-name {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .muster-stats .stat {
    padding: 10px;
  }

  .seg {
    padding: 10px 12px;
  }
}

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

/* ---------- print: muster roll (Print > Save as PDF) ---------- */

@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --surface-2: #fff;
    --text: #000;
    --text-2: #222;
    --muted: #444;
    --border: #999;
    --border-strong: #666;
    --in: #14532d;
    --danger: #7f1d1d;
    --ok-soft: #fff;
    --shadow: none;
  }

  @page {
    margin: 12mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
  }

  .topbar,
  .tabs,
  .banners,
  .footer,
  .toasts,
  .skip-link,
  .no-print,
  .progress,
  .dialog {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .page > * + * {
    margin-top: 4mm;
  }

  .print-only {
    display: block;
  }

  .print-head p {
    margin: 0 0 1mm;
  }

  .print-title {
    font-size: 15pt;
    font-weight: 800;
  }

  h1 {
    font-size: 14pt;
  }

  a {
    color: #000;
    text-decoration: none;
  }

  .card,
  .stat {
    border: 1px solid #999;
    box-shadow: none;
  }

  .stats,
  .muster-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 3mm;
  }

  .stat {
    padding: 2mm 3mm;
  }

  .stat-value {
    font-size: 16pt;
  }

  .groups,
  .muster-groups {
    display: block;
  }

  .group {
    margin-bottom: 4mm;
    border-left: 5pt solid var(--company, #666);
    break-inside: auto;
  }

  .page-muster .page-head,
  .page-muster .back-link {
    display: none;
  }

  .group-head {
    padding: 2mm 3mm;
    font-size: 11pt;
    break-after: avoid;
  }

  .m-row {
    align-items: center;
    break-inside: avoid;
  }

  .print-box {
    display: grid;
    flex: none;
    place-items: center;
    width: 13pt;
    height: 13pt;
    margin-left: 3mm;
    border: 1.5pt solid #000;
    font-size: 11pt;
    font-weight: 800;
    line-height: 1;
  }

  .is-accounted .print-box::after {
    content: "\2713";
  }

  .m-check {
    display: none;
  }

  .m-toggle {
    min-height: 0;
    padding: 1.5mm 3mm;
  }

  .m-name {
    font-size: 11pt;
  }

  .m-meta,
  .m-status {
    font-size: 9pt;
  }

  .is-accounted {
    background: none;
  }

  .m-call {
    border: 0;
    color: #000;
  }

  .m-call .icon {
    display: none;
  }

  .m-call span {
    display: inline;
  }

  .tag-danger {
    background: none;
    color: #000;
    border-color: #000;
  }
}

@media (max-width: 639px) {
  .btn-block-mobile {
    width: 100%;
  }
}

.filter-grid + .result-summary {
  margin-top: 12px;
}
