/* PixelOffice Staff
   Design language: Apple HIG translated for the web. System type with size-specific tracking,
   translucent materials for chrome, springs for motion (see app.js), instant press feedback,
   and full support for reduced motion, reduced transparency and increased contrast. */

/* ---- Tokens ------------------------------------------------------------------------------ */
:root {
  /* Backgrounds (grouped style) */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #e9e9ef;
  --fill: rgba(118, 118, 128, .12);
  --fill-strong: rgba(118, 118, 128, .2);
  --separator: rgba(60, 60, 67, .16);
  --separator-strong: rgba(60, 60, 67, .29);

  /* Labels */
  --text: #1d1d1f;
  --text-2: rgba(60, 60, 67, .72);
  --text-3: rgba(60, 60, 67, .5);

  /* Tints. *-text variants are darkened for 4.5:1 contrast on light surfaces. */
  --accent: #007aff;
  --accent-pressed: #0062cc;
  --accent-text: #0066d6;
  --accent-soft: rgba(0, 122, 255, .11);
  --ok: #248a3d;
  --ok-soft: rgba(52, 199, 89, .14);
  --warn: #b25000;
  --warn-tint: #ff9500;
  --warn-soft: rgba(255, 149, 0, .14);
  --bad: #d70015;
  --bad-tint: #ff3b30;
  --bad-soft: rgba(255, 59, 48, .11);

  /* Materials */
  --material-chrome: rgba(249, 249, 251, .72);
  --material-sidebar: rgba(242, 242, 247, .8);
  --material-thick: rgba(255, 255, 255, .82);
  --material-blur: blur(24px) saturate(180%);
  --scrim: rgba(0, 0, 0, .28);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .03);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .05);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, .18), 0 4px 16px rgba(0, 0, 0, .08);
  --ring: 0 0 0 4px rgba(0, 122, 255, .3);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-w: 264px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.64, 0, .78, 0);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --fill: rgba(118, 118, 128, .24);
    --fill-strong: rgba(118, 118, 128, .36);
    --separator: rgba(84, 84, 88, .55);
    --separator-strong: rgba(84, 84, 88, .8);
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, .68);
    --text-3: rgba(235, 235, 245, .42);
    --accent: #0a84ff;
    --accent-pressed: #409cff;
    --accent-text: #4aa3ff;
    --accent-soft: rgba(10, 132, 255, .2);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .16);
    --warn: #ffb340;
    --warn-tint: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, .16);
    --bad: #ff6961;
    --bad-tint: #ff453a;
    --bad-soft: rgba(255, 69, 58, .17);
    --material-chrome: rgba(22, 22, 24, .72);
    --material-sidebar: rgba(28, 28, 30, .78);
    --material-thick: rgba(36, 36, 38, .84);
    --scrim: rgba(0, 0, 0, .5);
    --shadow-1: none;
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-3: 0 24px 64px rgba(0, 0, 0, .6);
    --ring: 0 0 0 4px rgba(10, 132, 255, .45);
    color-scheme: dark;
  }
}

/* ---- Base & typography ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 .9375rem/1.47 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -.006em;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
.sprite { display: none; }
/* Tracking tightens and leading closes up as type grows. */
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 2rem; line-height: 1.12; letter-spacing: -.022em; font-weight: 700; }
h2 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -.017em; }
h3 { font-size: 1.0625rem; line-height: 1.3; letter-spacing: -.012em; }
small, .hint, .table th, .nav-heading { letter-spacing: .005em; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
code, .mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; font-size: .88em; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pre { white-space: pre-line; }
.text-warn { color: var(--warn); font-weight: 600; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.icon { width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Page-to-page continuity: the active nav pill and segmented thumb glide between pages. */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .32s; animation-timing-function: var(--ease-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }

/* ---- Shell -------------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* Structural region: heavier material. */
.sidebar {
  width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px; padding: 20px 12px 14px;
  background: var(--material-sidebar);
  -webkit-backdrop-filter: var(--material-blur); backdrop-filter: var(--material-blur);
  border-right: .5px solid var(--separator);
  overflow-y: auto; overscroll-behavior: contain; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.015em; color: var(--text); padding: 2px 10px 18px; }
.brand:hover { text-decoration: none; }
.brand .icon { width: 1.75rem; height: 1.75rem; color: var(--accent); }
.brand small { font-weight: 500; color: var(--text-3); }
.brand-center { justify-content: center; padding-bottom: 6px; }
.nav-section { margin-bottom: 18px; display: grid; gap: 1px; }
.nav-heading { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 4px 12px 6px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 7px 12px; min-height: 36px;
  border-radius: var(--radius-sm); color: var(--text); font-weight: 500;
  transition: background-color .2s var(--ease-out), transform .25s var(--ease-out);
}
.nav-link .icon { color: var(--accent); }
.nav-link:hover { background: var(--fill); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; view-transition-name: nav-pill; }
.nav-link.active .icon { color: #fff; }
.nav-link span:not(.badge) { flex: 1; }
.nav-link.active .badge { background: #fff; color: var(--accent); }
.badge {
  min-width: 1.25rem; height: 1.25rem; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--bad-tint); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.badge.bump { animation: bump .5s var(--ease-out); }
@keyframes bump { 30% { transform: scale(1.35); } }
.sidebar-foot { margin-top: auto; padding-top: 12px; display: grid; gap: 4px; position: relative; }
.sidebar-foot::before { content: ""; position: absolute; top: 0; left: 12px; right: 12px; border-top: .5px solid var(--separator); }
.me { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); }
.me:hover { background: var(--fill); text-decoration: none; }
.me strong, .me small { display: block; }
.me strong { font-weight: 600; }
.me small { color: var(--text-2); font-size: .8125rem; }
.avatar {
  width: 2.125rem; height: 2.125rem; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(160deg, #8e8e93, #636366); color: #fff; font-weight: 600; font-size: .875rem;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Floating chrome: lighter material, content scrolls underneath. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 0 28px; min-height: 52px;
  background: var(--material-chrome);
  -webkit-backdrop-filter: var(--material-blur); backdrop-filter: var(--material-blur);
}
/* Scroll edge effect instead of a permanent divider: appears only once content is underneath. */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: .5px; background: var(--separator);
  opacity: 0; transition: opacity .2s;
}
.scrolled .topbar::after { opacity: 1; }
.topbar-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 1.0625rem; letter-spacing: -.015em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.js .topbar-title { opacity: 0; transform: translateY(6px); transition: opacity .2s var(--ease-out), transform .3s var(--ease-out); }
.js.title-collapsed .topbar-title { opacity: 1; transform: none; }
.topbar .menu-toggle { display: none; }
.bell { position: relative; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; color: var(--accent); transition: background-color .15s, transform .25s var(--ease-out); }
.bell:hover { background: var(--fill); }
.bell:active { transform: scale(.9); transition-duration: .08s; }
.bell .icon { width: 1.375rem; height: 1.375rem; }
.bell .badge { position: absolute; top: 1px; right: -1px; box-shadow: 0 0 0 2px var(--surface); }

.content { padding: 6px 28px 56px; max-width: 900px; width: 100%; display: grid; gap: 20px; align-content: start; }
.content.wide { max-width: 1280px; }
.large-title { padding: 10px 0 2px; }

/* ---- Auth --------------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; padding: 32px 16px; gap: 18px;
  background:
    radial-gradient(60vmax 60vmax at 15% 10%, rgba(0, 122, 255, .16), transparent 60%),
    radial-gradient(50vmax 50vmax at 90% 90%, rgba(175, 82, 222, .13), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(400px, calc(100vw - 32px)); padding: 34px 30px 30px; display: grid; gap: 18px;
  background: var(--material-thick);
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  border: .5px solid var(--separator); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  animation: materialize .5s var(--ease-out) both;
}
.auth-title { font-size: 1.625rem; letter-spacing: -.02em; text-align: center; }
.auth-card > .muted { text-align: center; margin: -6px 0 0; }
.auth-foot { text-align: center; color: var(--text-3); font-size: .8125rem; margin: 0; }
.qr { display: grid; place-items: center; background: #fff; border-radius: var(--radius); padding: 14px; justify-self: center; box-shadow: var(--shadow-2); }
.qr svg { width: 188px; height: 188px; display: block; }
.manual-key { text-align: center; }
.manual-key summary { cursor: pointer; color: var(--accent-text); font-size: .875rem; }
.secret { display: inline-block; margin-top: 8px; padding: 8px 12px; background: var(--fill); border-radius: var(--radius-xs); letter-spacing: .08em; user-select: all; word-break: break-all; cursor: copy; }
.code-input { font-size: 1.5rem !important; letter-spacing: .32em !important; text-align: center; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.center-row { display: flex; justify-content: center; }

@keyframes materialize {
  from { opacity: 0; transform: scale(.96); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ---- Surfaces ----------------------------------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 24px; display: grid; gap: 20px; }
.card.narrow { max-width: 580px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.split > div { display: grid; gap: 12px; align-content: start; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filters { justify-content: flex-start; }
.actions, .button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.push-right { margin-left: auto; }

/* ---- Forms (filled iOS-style fields) ---------------------------------------------------------- */
.field { display: grid; gap: 7px; }
label { font-weight: 600; font-size: .875rem; letter-spacing: -.003em; }
.optional { font-weight: 400; color: var(--text-3); font-size: .8125rem; margin-left: 4px; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--fill);
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 14px; min-height: 44px;
  transition: background-color .2s, box-shadow .2s var(--ease-out), border-color .2s;
  -webkit-appearance: none; appearance: none;
}
select {
  padding-right: 38px; cursor: pointer;
  background-image: url("/static/chevron.svg");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
input:disabled, select:disabled { color: var(--text-2); opacity: .7; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: var(--ring); }
input[type=file] { font: inherit; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; margin-right: 12px; padding: 8px 16px; border-radius: 999px;
  border: 0; background: var(--accent-soft); color: var(--accent-text); cursor: pointer;
}
input[type=checkbox] { width: 1.125rem; height: 1.125rem; accent-color: var(--accent); }
.has-error input, .has-error select, .has-error textarea { background: var(--bad-soft); border-color: var(--bad-tint); }
.hint { margin: 0; color: var(--text-2); font-size: .8125rem; line-height: 1.4; }
.error { margin: 0; color: var(--bad); font-size: .8125rem; font-weight: 500; animation: rise .3s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(-3px); } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-top: 8px; }
.photo-field { display: flex; gap: 18px; align-items: center; }
.photo-field > div { display: grid; gap: 8px; min-width: 0; }
.search { position: relative; flex: 1; max-width: 440px; min-width: 200px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 1rem; height: 1rem; pointer-events: none; }
.search input { padding-left: 36px !important; min-height: 38px !important; border-radius: var(--radius-sm); }
.filters select { width: auto; min-width: 180px; min-height: 38px; }
.filters input:not([type=search]) { width: auto; min-height: 38px; }

/* ---- Buttons: feedback on press, instantly ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 18px;
  border-radius: var(--radius-sm); border: 0; font: inherit; font-weight: 600; letter-spacing: -.005em; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; user-select: none;
  transition: background-color .2s var(--ease-out), transform .3s var(--ease-out), opacity .2s;
}
.btn:active:not(:disabled), .btn.pressed { transform: scale(.96); transition-duration: .08s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-pressed); }
.btn-ghost { background: var(--fill); color: var(--accent-text); }
.btn-ghost:hover { background: var(--fill-strong); }
.btn-danger-ghost { background: var(--bad-soft); color: var(--bad); }
.btn-danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--bad-tint) 20%, transparent); }
.btn-danger { background: var(--bad-tint); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 5px 13px; font-size: .875rem; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.btn .icon { width: 1rem; height: 1rem; }
.sidebar-foot .btn-ghost { background: transparent; color: var(--text-2); justify-content: flex-start; font-weight: 500; padding: 8px 12px; }
.sidebar-foot .btn-ghost:hover { background: var(--fill); color: var(--text); }
.nav-link:active, .me:active { transform: scale(.98); transition-duration: .08s; }

/* ---- Alerts --------------------------------------------------------------------------------- */
.alert { display: flex; gap: 11px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius); font-weight: 500; line-height: 1.4; animation: materialize .45s var(--ease-out) both; }
.alert .icon { margin-top: 1px; width: 1.25rem; height: 1.25rem; }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }
.alert p { margin: 6px 0 0; font-weight: 400; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-error a { color: inherit; text-decoration: underline; }
.alert-info { background: var(--accent-soft); color: var(--text); }
.alert-info .icon { color: var(--accent); }
.alert-link { color: var(--warn); transition: transform .3s var(--ease-out), filter .2s; }
.alert-link:hover { text-decoration: none; filter: brightness(.98); }
.alert-link:active { transform: scale(.985); transition-duration: .08s; }
.pulse { animation: pulse 1.4s var(--ease-out) 2; }
@keyframes pulse { 40% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn-tint) 22%, transparent); } }

/* ---- Tables as inset grouped lists ---------------------------------------------------------- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow-x: auto; overscroll-behavior-x: contain; }
.card .table-wrap { box-shadow: none; border: .5px solid var(--separator); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 12px 18px 8px; white-space: nowrap; }
.table td { padding: 11px 18px; vertical-align: middle; position: relative; }
/* Hairline separators, inset from the left edge like iOS lists. */
.table tbody tr + tr td { box-shadow: inset 0 .5px 0 var(--separator); }
.table tbody tr + tr td:first-child { box-shadow: none; }
.table tbody tr + tr td:first-child::before { content: ""; position: absolute; top: 0; left: 18px; right: 0; border-top: .5px solid var(--separator); }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--fill) 50%, transparent); }
.table-compact td { padding: 8px 16px; font-size: .8438rem; }
.row-actions { text-align: right; white-space: nowrap; }
.table td.mono { white-space: nowrap; }
.row-warn td { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }
.details-cell { color: var(--text-3); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .75rem; max-width: 320px; overflow-wrap: anywhere; }
.person { display: flex; align-items: center; gap: 12px; color: var(--text); }
.person:hover { text-decoration: none; }
a.person:hover strong { color: var(--accent-text); }
.person strong, .person small { display: block; }
.person strong { font-weight: 600; }
.person small { color: var(--text-2); font-size: .8125rem; }

.photo { width: 2.5rem; height: 2.5rem; border-radius: 50%; object-fit: cover; flex: none; background: var(--fill); }
.photo.sm { width: 2.25rem; height: 2.25rem; }
.photo.lg { width: 4.5rem; height: 4.5rem; }
.photo.xl { width: 5.5rem; height: 5.5rem; }
.photo-empty { display: grid; place-items: center; background: linear-gradient(160deg, #a2a2a8, #6e6e73); color: #fff; font-weight: 600; font-size: .8125rem; letter-spacing: .02em; text-transform: uppercase; }
.photo-empty.lg, .photo-empty.xl { font-size: 1.5rem; letter-spacing: 0; }
.photo-empty .icon { width: 1.75rem; height: 1.75rem; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; letter-spacing: .005em; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-role-admin, .tag-role-dispatcher, .tag-role-hr { background: var(--fill); color: var(--text); }
.tag-role-admin::before { background: var(--accent); }
.tag-role-dispatcher::before { background: #af52de; }
.tag-role-hr::before { background: #ff2d55; }

/* ---- Details & profile ------------------------------------------------------------------------ */
.details { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; margin: 0; border-radius: var(--radius-sm); }
.details dt, .details dd { padding: 11px 0; margin: 0; }
.details dt { color: var(--text-2); font-size: .875rem; padding-right: 24px; }
.details dd { overflow-wrap: anywhere; }
.details dt + dd ~ dt, .details dt + dd ~ dt + dd { border-top: .5px solid var(--separator); }
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-head h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.profile-head p { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.danger-zone { border-top: .5px solid var(--separator); padding-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.error-code { font-size: 3.5rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; margin: 0; color: var(--text-3); }

/* ---- Segmented control ------------------------------------------------------------------------ */
.segmented { display: inline-flex; gap: 2px; padding: 2px; background: var(--fill); border-radius: 10px; justify-self: start; }
.segment {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 18px; min-height: 32px;
  border-radius: 8px; color: var(--text); font-weight: 500; font-size: .875rem;
  transition: transform .3s var(--ease-out), color .2s;
}
.segment:hover { text-decoration: none; color: var(--text); }
.segment:active { transform: scale(.96); transition-duration: .08s; }
.segment.active { background: var(--surface); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); view-transition-name: segment-thumb; }
@media (prefers-color-scheme: dark) { .segment.active { background: #636366; } }
.count { background: var(--fill); border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.count-warn { background: var(--warn-tint); color: #fff; }

/* ---- Easy view: contact cards ------------------------------------------------------------ */
.view-switch .segment { padding: 6px 12px; gap: 6px; }
.view-switch .icon { width: 1rem; height: 1rem; }
.people-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.person-tile { min-width: 0;
  position: relative; display: grid; justify-items: center; gap: 6px; text-align: center;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 24px 18px 14px;
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
  animation: materialize .4s var(--ease-out) both;
}
.person-tile:hover { box-shadow: var(--shadow-2); }
.person-tile:has(.stretched:active) { transform: scale(.98); transition-duration: .08s; }
.person-tile .photo { margin-bottom: 6px; }
.tile-name { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.012em; color: var(--text); line-height: 1.3; }
.tile-name:hover { text-decoration: none; color: var(--accent-text); }
/* The name link covers the whole card; the Edit button sits above it. */
.stretched::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.stretched:focus-visible { box-shadow: none; }
.stretched:focus-visible::after { box-shadow: var(--ring); border-radius: var(--radius-lg); }
.above { position: relative; z-index: 1; }
.tile-working { font-size: .875rem; color: var(--text-2); font-style: italic; margin-top: -4px; }
.tile-working .muted { font-style: normal; color: var(--text-3); }
/* Label above value, like Contacts, so details always fit however narrow the card is. */
.tile-facts { min-width: 0; width: 100%; margin: 8px 0 0; display: grid; gap: 7px; border-top: .5px solid var(--separator); padding-top: 12px; }
.tile-facts dt { color: var(--text-3); font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: -6px; }
.tile-facts dd { margin: 0; font-size: .875rem; overflow-wrap: anywhere; }
.tile-facts dd.mono { white-space: nowrap; font-size: .8125rem; }
.tile-foot { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.tile-foot small { color: var(--text-3); font-size: .75rem; }
.people-grid li:nth-child(2) { animation-delay: .02s; }
.people-grid li:nth-child(3) { animation-delay: .04s; }
.people-grid li:nth-child(n+4) { animation-delay: .06s; }

/* ---- Lists, cards, stats ---------------------------------------------------------------------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.person-card {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px 14px 18px; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
  animation: materialize .4s var(--ease-out) both;
}
.person-card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--warn-tint); }
.cards li:nth-child(2) { animation-delay: .03s; }
.cards li:nth-child(3) { animation-delay: .06s; }
.cards li:nth-child(n+4) { animation-delay: .09s; }
.person-card strong, .person-card small { display: block; }
.person-card strong { font-weight: 600; }
.person-card small { color: var(--text-2); font-size: .8125rem; }

.notif-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.notif { display: flex; gap: 14px; align-items: center; padding: 14px 18px; color: var(--text-2); position: relative; }
.notif + .notif::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; border-top: .5px solid var(--separator); }
.notif.unread { color: var(--text); }
.notif.unread::after { content: ""; position: absolute; left: 6px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--accent); }
.notif small { display: block; color: var(--text-3); font-size: .8125rem; margin-top: 2px; }
.notif-icon { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--fill); flex: none; color: var(--text-2); }
.notif.unread .notif-icon { background: var(--accent); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-1); color: var(--text);
  display: grid; gap: 2px; transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.stat:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.stat:active { transform: scale(.98); transition-duration: .08s; }
.stat span { color: var(--text-2); font-size: .8125rem; font-weight: 500; }
.stat strong { font-size: 2.125rem; line-height: 1.15; letter-spacing: -.03em; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-warn strong { color: var(--warn-tint); }

.empty { text-align: center; padding: 56px 24px; color: var(--text-2); display: grid; justify-items: center; gap: 4px; animation: materialize .45s var(--ease-out) both; }
.empty .icon { width: 2.75rem; height: 2.75rem; color: var(--text-3); stroke-width: 1.5; margin-bottom: 8px; }
.empty h3 { margin: 0; color: var(--text); font-size: 1.25rem; letter-spacing: -.017em; }
.empty p { margin: 0; max-width: 40ch; }
.pagination { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: .875rem; }

/* ---- Confirmation alert (modal: dims and pushes content back) ---------------------------------- */
.alert-dialog {
  width: min(300px, calc(100vw - 48px)); padding: 0; border: 0; border-radius: var(--radius); color: var(--text);
  background: var(--material-thick);
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  box-shadow: var(--shadow-3); overflow: hidden; text-align: center;
}
.alert-dialog[open] { animation: alert-in .34s var(--ease-out); }
.alert-dialog.closing { animation: alert-out .18s var(--ease-in) forwards; }
.alert-dialog::backdrop { background: var(--scrim); animation: fade-in .25s var(--ease-out); }
.alert-dialog.closing::backdrop { animation: fade-out .18s forwards; }
.alert-dialog h2 { font-size: 1.0625rem; letter-spacing: -.012em; padding: 20px 18px 4px; }
.alert-dialog p { margin: 0; padding: 0 18px 20px; font-size: .875rem; color: var(--text); line-height: 1.4; }
.alert-dialog .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: .5px solid var(--separator-strong); }
.alert-dialog .dialog-actions button { font: inherit; font-size: 1.0625rem; padding: 12px; min-height: 44px; border: 0; background: transparent; color: var(--accent-text); cursor: pointer; transition: background-color .1s; }
.alert-dialog .dialog-actions button + button { border-left: .5px solid var(--separator-strong); font-weight: 600; }
.alert-dialog .dialog-actions button:active { background: var(--fill); }
.alert-dialog .dialog-actions .destructive { color: var(--bad-tint); }
@keyframes alert-in { from { opacity: 0; transform: scale(1.12); } }
@keyframes alert-out { to { opacity: 0; transform: scale(.96); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.dialog-open .shell { transform: scale(.992); filter: saturate(.9); transition: transform .35s var(--ease-out), filter .35s; }
.shell { transition: transform .3s var(--ease-out), filter .3s; }

/* ---- Mobile: the sidebar becomes a drawer you can drag (driven by springs in app.js) ------------ */
.scrim, .edge-swipe { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translate3d(-100%, 0, 0); box-shadow: none;
    width: min(var(--sidebar-w), 84vw); touch-action: pan-y; will-change: transform;
    background: var(--material-thick);
  }
  /* The solid offset shadow fills the sliver revealed when a flicked drawer overshoots. */
  .sidebar-open .sidebar { box-shadow: -32px 0 0 var(--surface), var(--shadow-3); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: var(--scrim); opacity: 0; pointer-events: none; touch-action: none; }
  .sidebar-open .scrim { pointer-events: auto; }
  .edge-swipe { display: block; position: fixed; left: 0; top: 0; bottom: 0; width: 18px; z-index: 24; touch-action: none; }
  .sidebar-open .edge-swipe { display: none; }
  .topbar .menu-toggle { display: inline-flex; padding: 0; width: 2.5rem; height: 2.5rem; min-height: 0; border-radius: 50%; background: transparent; color: var(--accent); }
  .topbar .menu-toggle .icon { width: 1.375rem; height: 1.375rem; }
  .topbar { padding: 0 8px 0 6px; min-height: 48px; }
  .content { padding: 4px 16px 44px; }
  h1 { font-size: 1.75rem; }
  .grid-2, .split { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .details { grid-template-columns: 1fr; }
  .details dt { padding: 10px 0 0; border-top: .5px solid var(--separator); }
  .details dd { padding: 2px 0 10px; border-top: 0 !important; }
  .details dt:first-of-type { border-top: 0; }
  .push-right { margin-left: 0; }
  .topbar [data-enable-desktop] { font-size: 0; gap: 0; padding: 0; width: 2.5rem; height: 2.5rem; border-radius: 50%; }
  .topbar [data-enable-desktop] .icon { width: 1.25rem; height: 1.25rem; }
  .segmented { justify-self: stretch; }
  .toolbar > .actions { width: 100%; justify-content: space-between; }
  .people-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
  .person-tile { padding: 18px 12px 12px; }
  .person-tile .photo.xl { width: 4rem; height: 4rem; }
  .segment { flex: 1; justify-content: center; }
}

/* ---- Accessibility preferences ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; transition-property: opacity, background-color, color, border-color, box-shadow !important; }
  @view-transition { navigation: none; }
  .btn:active, .nav-link:active, .stat:active, .segment:active, .bell:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --material-chrome: var(--bg); --material-sidebar: var(--surface); --material-thick: var(--surface); }
  .sidebar, .topbar, .auth-card, .alert-dialog { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: rgba(60, 60, 67, .5); --text-2: rgba(60, 60, 67, .9); --text-3: rgba(60, 60, 67, .75); --fill: rgba(118, 118, 128, .18); }
  input:not([type=checkbox]):not([type=file]), select, textarea, .card, .table-wrap, .stat, .person-card, .notif-list { border: 1px solid var(--separator-strong); }
  .topbar::after { opacity: 1; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --text-2: rgba(235, 235, 245, .88); --text-3: rgba(235, 235, 245, .7); }
}
@media (forced-colors: active) {
  .nav-link.active, .segment.active { outline: 2px solid CanvasText; }
}

/* ---- Admin delete controls ------------------------------------------------------------------ */
.inline-form { display: inline-flex; margin: 0; }
.row-buttons { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-buttons .btn-danger-ghost.btn-sm, .row-actions .btn-danger-ghost.btn-sm { padding: 5px 9px; }
.danger-card .card-head { align-items: center; flex-wrap: wrap; }
.danger-card h2 { color: var(--bad); font-size: 1.0625rem; }
.danger-card .hint { margin-top: 4px; max-width: 52ch; }
/* Keep Edit/Delete visible: the actions column stays pinned when a wide table scrolls sideways. */
.table .row-actions { position: sticky; right: 0; z-index: 1; background: var(--surface); }
.table td.row-actions { box-shadow: -10px 0 10px -10px rgba(0, 0, 0, .35); }
.table tbody tr + tr td.row-actions { box-shadow: inset 0 .5px 0 var(--separator), -10px 0 10px -10px rgba(0, 0, 0, .35); }
