[hidden] { display: none !important; }
/* Layout: a working directory — header, department tape tabs, company chips, then one dense contacts table. */
:root {
  --bg: #f3f4f2;
  --surface: #ffffff;
  --fg: #1d2124;
  --muted: #5d666c;
  --line: #d9ddda;
  --line-strong: #b9bfbb;
  --accent: #e8a317;          /* gaffer-tape amber */
  --accent-ink: #1d2124;
  --accent-soft: #fbf0d4;
  --danger: #b3261e;
  --gear: #3b7dd8;
  --gens: #d2662b;
  --lights: #e8a317;
  --studies: #1f8a7a;
  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181a; --surface: #1d2124; --fg: #e8eae8; --muted: #9aa3a8;
    --line: #2e3438; --line-strong: #444c51; --accent: #f0b232; --accent-ink: #15181a;
    --accent-soft: #3a3020; --danger: #f28b82; --gear: #6ea2ee; --gens: #ee8a55; --lights: #f0b232; --studies: #4fb8a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181a; --surface: #1d2124; --fg: #e8eae8; --muted: #9aa3a8;
  --line: #2e3438; --line-strong: #444c51; --accent: #f0b232; --accent-ink: #15181a;
  --accent-soft: #3a3020; --danger: #f28b82; --gear: #6ea2ee; --gens: #ee8a55; --lights: #f0b232; --studies: #4fb8a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 48px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; }

header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 2px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 5vw, 44px); line-height: 1; margin: 0; letter-spacing: .01em; text-wrap: balance; }
.search { position: relative; width: min(320px, 100%); }
.search input { width: 100%; }

input, select {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 9px 12px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 6px; padding: 9px 14px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
}
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Department tabs — tape strips */
.depts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dept {
  position: relative; text-align: left; padding: 14px 16px 12px 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--fg);
  display: grid; gap: 2px;
}
.dept::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 6px; border-radius: 0 3px 3px 0; background: var(--c); }
.dept .name { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .04em; text-transform: uppercase; line-height: 1.1; }
.dept .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dept:hover { border-color: var(--line-strong); }
.dept[aria-selected="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }

/* Company chips */
.companies { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--fg);
  border-radius: 999px; padding: 7px 14px; font-weight: 500; font-size: 14px;
  display: inline-flex; gap: 8px; align-items: center;
}
.chip .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--fg); }
.chip[aria-selected="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip[aria-selected="true"] .n { color: var(--bg); opacity: .7; }
.chip.add { border-style: dashed; color: var(--muted); }

/* Panel */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: .01em; }
.panel-head .sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--fg); margin-right: 6px; vertical-align: 2px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
.ptype { font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; }
.phones { display: grid; gap: 4px; justify-items: start; }
td.notes { color: var(--muted); font-size: 14px; min-width: 220px; }
tr.featured td { background: var(--accent-soft); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--bg); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
td.name { font-weight: 600; }
td.mono, .mono { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted { color: var(--muted); }
.cell { display: inline-flex; align-items: center; gap: 6px; }
.copy {
  border: 0; background: transparent; color: var(--muted); padding: 2px 6px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
}
.copy:hover { color: var(--fg); background: var(--bg); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.icon-btn { border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 6px; padding: 5px 9px; font-size: 13px; font-weight: 600; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--fg); }
.icon-btn.del:hover { color: var(--danger); border-color: var(--danger); }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty strong { color: var(--fg); font-size: 16px; }
.notice { padding: 12px 16px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; }

/* Dialog */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, #000 45%, transparent); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(560px, 100%); max-height: calc(100% - 32px); overflow: auto; }
.dialog form { display: grid; gap: 14px; padding: 20px; }
.dialog h3 { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field input, .field select { width: 100%; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.err { color: var(--danger); font-size: 14px; margin: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 30; }

@media (max-width: 640px) {
  .depts { grid-template-columns: 1fr; }
  .dept { grid-template-columns: 1fr auto; align-items: center; }
  .fields { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* Access screen */
.gate { min-height: 72vh; display: grid; place-items: center; }
.gate-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-top: 6px solid var(--accent); border-radius: 12px; padding: 28px 24px 24px;
  display: grid; gap: 18px;
}
.gate-card h1 { font-size: 40px; }
.gate-card form { display: grid; gap: 14px; }
.gate-card p { margin: 0; }
.gate-lead { color: var(--muted); font-size: 14px; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; min-width: 0; }
.warn { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); }
.gate-card .btn.primary { justify-content: center; padding-block: 11px; }
.lock-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); display: grid; place-items: center; }
.lock-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.header-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.header-right .search { width: min(280px, 100%); }
.btn.small { padding: 8px 12px; font-size: 13px; }


.code-box { font-family: var(--font-mono); font-size: 20px; letter-spacing: .06em; padding: 14px; border-radius: 8px; border: 1px dashed var(--line-strong); background: var(--bg); text-align: center; user-select: all; word-break: break-all; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 14px; justify-self: start; }
.link-btn:hover { color: var(--fg); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.users { display: grid; gap: 0; }
.user-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.user-info { flex: 1 1 200px; min-width: 0; display: grid; }
.user-info strong { overflow-wrap: anywhere; }
.user-info span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.status { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--muted); }
.status.pending { background: var(--accent-soft); color: var(--fg); border-color: transparent; }
.status.ok { color: var(--fg); }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.section-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 8px 0 0; }
.dialog.wide { width: min(640px, 100%); }

/* ---- standalone additions ---- */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
.dept.gear { --c: var(--gear); }
.dept.generators { --c: var(--gens); }
.dept.lights { --c: var(--lights); }
.dialog-sub { margin: -8px 0 0; color: var(--muted); font-size: 14px; }
.dialog-text { margin: 0; }
.actions .push-left { margin-right: auto; }
.whoami { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.gate-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.noscript { padding: 24px; text-align: center; }
.pw-hint { font-size: 13px; color: var(--muted); margin: 0; }
.ok-note { font-size: 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); margin: 0; }
.muted { color: var(--muted); }
header { display: grid; gap: 14px; align-items: start; }
header .header-right { justify-content: flex-start; }

/* ---- two-step sign-in ---- */
.otp-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.otp-row { display: flex; gap: 8px; }
.otp-box { width: 44px; height: 52px; padding: 0; text-align: center; font-family: var(--font-mono); font-size: 22px; font-variant-numeric: tabular-nums; }
.otp-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sec-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 10px; }
.sec-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.sec-head h4, .dialog h4 { margin: 0; font-size: 16px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.on { background: #1f7a4d; color: #fff; }
.pill.off { background: var(--bg); color: var(--muted); border: 1px solid var(--line-strong); }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 220px; overflow: auto; }
.events li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-size: 13px; }
.qr-wrap { display: flex; justify-content: center; }
.qr { width: 200px; height: 200px; max-width: 100%; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
.manual-key { flex-wrap: wrap; }
.manual-key code, .rc-list code { font-family: var(--font-mono); font-size: 15px; letter-spacing: .04em; overflow-wrap: anywhere; }
.rc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; margin: 0; padding: 12px 12px 12px 32px; background: var(--bg); border-radius: 8px; }
@media (max-width: 420px) { .rc-list { grid-template-columns: 1fr; } .otp-box { width: 40px; height: 48px; } .otp-row { gap: 6px; } }
.field .otp-row .otp-box { width: 44px; flex: none; }
@media (max-width: 420px) { .field .otp-row .otp-box { width: 40px; } }
