/*
Design Read
- Direction: operational Material-inspired interface with matte orange brand accents.
- Design Variance: 2/5
- Motion Intensity: 2/5
- Visual Density: 4/5
- Chrome Weight: 3/5
*/
:root {
  --background: oklch(0.975 0.008 60);
  --foreground: oklch(0.245 0.025 45);
  --surface: oklch(0.997 0.004 70);
  --surface-subtle: oklch(0.956 0.012 62);
  --surface-strong: oklch(0.925 0.022 58);
  --muted: oklch(0.51 0.025 45);
  --muted-foreground: oklch(0.42 0.024 45);
  --border: oklch(0.875 0.025 58);
  --border-strong: oklch(0.79 0.045 55);
  --primary: oklch(0.64 0.145 50);
  --primary-hover: oklch(0.56 0.145 48);
  --primary-foreground: oklch(0.99 0.005 80);
  --primary-muted: oklch(0.935 0.055 55);
  --success: oklch(0.58 0.125 150);
  --success-foreground: oklch(0.985 0.01 145);
  --success-muted: oklch(0.93 0.045 150);
  --warning: oklch(0.67 0.145 78);
  --warning-foreground: oklch(0.27 0.05 70);
  --warning-muted: oklch(0.945 0.06 82);
  --info: oklch(0.59 0.11 240);
  --info-muted: oklch(0.93 0.04 240);
  --destructive: oklch(0.57 0.19 28);
  --destructive-foreground: oklch(0.985 0.005 30);
  --destructive-muted: oklch(0.93 0.055 28);
  --developer: oklch(0.57 0.13 305);
  --developer-muted: oklch(0.94 0.04 305);
  --administrator: oklch(0.56 0.11 245);
  --administrator-muted: oklch(0.94 0.035 245);
  --shadow-sm: 0 1px 2px oklch(0.25 0.02 45 / 0.06);
  --shadow-md: 0 12px 34px oklch(0.25 0.03 45 / 0.09);
  --shadow-lg: 0 24px 62px oklch(0.22 0.035 45 / 0.14);
  --radius-sm: 0.65rem;
  --radius-md: 0.9rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.65rem;
  --header-height: 4.25rem;
  --sidebar-width: 15.25rem;
  --z-base: 0;
  --z-sticky: 10;
  --z-dropdown: 30;
  --z-drawer: 40;
  --z-popover: 60;
  --z-toast: 70;
  --step-0: clamp(1rem, 0.97rem + 0.15vw, 1.075rem);
  --step-1: clamp(1.2rem, 1.08rem + 0.55vw, 1.45rem);
  --step-2: clamp(1.55rem, 1.35rem + 0.9vw, 2rem);
  --step-3: clamp(2rem, 1.55rem + 1.8vw, 2.8rem);
}

* { box-sizing: border-box; }
html { min-width: 20rem; background: var(--background); color: var(--foreground); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.5; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--foreground); }
body.nav-open { overflow: hidden; }
a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 0.18rem solid color-mix(in oklch, var(--primary) 45%, transparent); outline-offset: 0.16rem; }
svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: fixed; left: 1rem; top: 0.75rem; z-index: var(--z-toast); transform: translateY(-180%); padding: 0.65rem 0.9rem; border-radius: var(--radius-sm); background: var(--foreground); color: var(--surface); font-weight: 750; box-shadow: var(--shadow-md); }
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; }
.app-header { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; min-height: var(--header-height); padding: 0.65rem clamp(0.8rem, 2.4vw, 1.6rem); gap: 0.85rem; background: color-mix(in oklch, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(1rem); }
.app-brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--foreground); min-width: 0; }
.app-brand:hover { text-decoration: none; }
.app-brand-mark { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; flex: 0 0 auto; border-radius: 0.85rem; background: var(--primary); color: var(--primary-foreground); font-weight: 900; letter-spacing: -0.04em; box-shadow: 0 0.45rem 1rem color-mix(in oklch, var(--primary) 25%, transparent); }
.app-brand-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.08; }
.app-brand-copy strong { font-size: 1rem; letter-spacing: -0.025em; }
.app-brand-copy small { margin-top: 0.25rem; color: var(--muted); font-size: 0.72rem; }
.app-header-spacer { flex: 1; }
.live-indicator { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.25rem; padding: 0.45rem 0.75rem; border: 1px solid color-mix(in oklch, var(--success) 20%, var(--border)); border-radius: 999px; background: var(--success-muted); color: var(--success); font-size: 0.78rem; font-weight: 750; }
.live-indicator > span:first-child { width: 0.48rem; height: 0.48rem; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0.25rem color-mix(in oklch, var(--success) 16%, transparent); }
.session-user { display: flex; align-items: center; gap: 0.65rem; }
.session-user-copy { display: flex; flex-direction: column; max-width: 10rem; line-height: 1.1; }
.session-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.session-user-copy small { margin-top: 0.25rem; color: var(--muted); font-size: 0.7rem; }

.app-layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); align-items: start; min-height: calc(100vh - var(--header-height)); }
.app-sidebar { position: sticky; top: var(--header-height); display: flex; flex-direction: column; min-height: calc(100vh - var(--header-height)); padding: 1.1rem 0.85rem; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar-section { display: grid; gap: 0.25rem; }
.sidebar-section + .sidebar-section { margin-top: 1.35rem; }
.sidebar-label { margin: 0 0 0.35rem; padding: 0 0.65rem; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.sidebar-link { display: flex; align-items: center; gap: 0.75rem; min-height: 2.8rem; width: 100%; padding: 0.65rem 0.75rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted-foreground); font-weight: 720; text-align: left; cursor: pointer; }
.sidebar-link svg { width: 1.18rem; height: 1.18rem; flex: 0 0 auto; }
.sidebar-link:hover { background: var(--surface-subtle); color: var(--foreground); text-decoration: none; }
.sidebar-link.active { background: var(--primary-muted); color: var(--primary-hover); }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar-account { display: none; align-items: center; gap: 0.65rem; margin-bottom: 0.75rem; padding: 0.45rem 0.55rem; }
.sidebar-account > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-account strong { font-size: 0.82rem; }
.sidebar-account small { margin-top: 0.25rem; color: var(--muted); font-size: 0.7rem; }
.logout-link { color: var(--destructive); }
.sidebar-backdrop { display: none; }
.nav-toggle { display: none; }

.app-main { min-width: 0; min-height: calc(100vh - var(--header-height)); }
.content-shell { width: min(100% - 2.25rem, 74rem); margin: 0 auto; padding: clamp(1.4rem, 3vw, 2.7rem) 0 4rem; }
.content-shell.wide { width: min(100% - 2rem, 88rem); }
.content-shell.content-narrow { width: min(100% - 2rem, 54rem); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.6rem; }
.page-heading.compact { align-items: center; }
.page-heading h1 { margin: 0.25rem 0 0.45rem; font-size: var(--step-3); line-height: 1.05; letter-spacing: -0.045em; }
.eyebrow { margin: 0; color: var(--primary-hover); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.13em; text-transform: uppercase; }
.muted { margin: 0; max-width: 65ch; color: var(--muted); }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.65rem; }

.button, button:not(.icon-button):not(.sidebar-link):not(.sidebar-backdrop) { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.65rem 1rem; border: 1px solid transparent; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-foreground); font-weight: 780; line-height: 1.2; cursor: pointer; box-shadow: var(--shadow-sm); }
.button:hover, button:not(.icon-button):not(.sidebar-link):not(.sidebar-backdrop):hover { background: var(--primary-hover); text-decoration: none; }
.button.secondary, button.secondary { border-color: var(--border); background: var(--surface); color: var(--foreground); box-shadow: none; }
.button.secondary:hover, button.secondary:hover { border-color: var(--border-strong); background: var(--surface-subtle); }
.button svg, button svg { flex: 0 0 auto; }
button:disabled { cursor: wait; opacity: 0.62; }
.icon-button { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-foreground); cursor: pointer; }
.icon-button:hover { background: var(--primary-hover); }
.icon-button.secondary { border-color: var(--border); background: var(--surface); color: var(--foreground); }
.icon-button.secondary:hover, .icon-button.ghost:hover { background: var(--surface-subtle); }
.icon-button.ghost { background: transparent; color: var(--muted-foreground); }

.panel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin: 0.2rem 0 0; font-size: var(--step-1); line-height: 1.2; }
.alert { display: flex; align-items: flex-start; gap: 0.7rem; margin-bottom: 1rem; padding: 0.85rem 1rem; border: 1px solid transparent; border-radius: var(--radius-md); font-weight: 680; }
.alert.success { border-color: color-mix(in oklch, var(--success) 24%, transparent); background: var(--success-muted); color: var(--success); }
.alert.danger { border-color: color-mix(in oklch, var(--destructive) 22%, transparent); background: var(--destructive-muted); color: var(--destructive); }
.alert.protected { flex-direction: column; gap: 0.15rem; border-color: color-mix(in oklch, var(--developer) 22%, transparent); background: var(--developer-muted); color: var(--developer); }
.alert.protected span { font-weight: 550; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; margin-bottom: 1rem; }
.metric-card { display: flex; align-items: center; gap: 1rem; min-width: 0; padding: 1.15rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.metric-card > div { min-width: 0; }
.metric-card span:not(.metric-icon), .metric-card small { display: block; color: var(--muted); }
.metric-card > div > span { font-size: 0.78rem; font-weight: 760; }
.metric-card strong { display: block; margin: 0.1rem 0; font-size: clamp(1.75rem, 3vw, 2.4rem); line-height: 1; font-variant-numeric: tabular-nums; }
.metric-card small { font-size: 0.72rem; }
.metric-icon { display: grid; place-items: center; width: 2.85rem; height: 2.85rem; flex: 0 0 auto; border-radius: 1rem; background: var(--surface-subtle); color: var(--muted-foreground); }
.metric-icon.brand { background: var(--primary-muted); color: var(--primary-hover); }
.metric-card.success .metric-icon { background: var(--success-muted); color: var(--success); }
.metric-card.destructive .metric-icon { background: var(--destructive-muted); color: var(--destructive); }
.metric-card.warning .metric-icon { background: var(--warning-muted); color: var(--warning); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(17rem, 0.55fr); gap: 1rem; }
.action-panel { padding: 1.25rem; }
.action-list { display: grid; gap: 0.35rem; margin-top: 1rem; }
.action-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.85rem; min-height: 4.6rem; padding: 0.75rem; border-radius: var(--radius-md); color: var(--foreground); }
.action-row:hover { background: var(--surface-subtle); text-decoration: none; }
.action-row-icon { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border-radius: 0.85rem; background: var(--primary-muted); color: var(--primary-hover); }
.action-row > span:nth-child(2) { min-width: 0; }
.action-row strong, .action-row small { display: block; }
.action-row small { margin-top: 0.2rem; color: var(--muted); }
.action-arrow { color: var(--muted); }
.safety-panel { display: flex; flex-direction: column; align-items: flex-start; padding: 1.4rem; background: linear-gradient(145deg, var(--surface), var(--primary-muted)); }
.safety-panel h2 { margin: 0.35rem 0 0.45rem; }
.safety-panel p:not(.eyebrow) { color: var(--muted-foreground); }
.safety-panel a { margin-top: auto; padding-top: 1rem; font-weight: 780; }
.safety-icon { display: grid; place-items: center; width: 3.1rem; height: 3.1rem; margin-bottom: 1.15rem; border-radius: 1rem; background: var(--primary); color: var(--primary-foreground); }
.safety-icon svg { width: 1.55rem; height: 1.55rem; }

.filter-bar { display: grid; grid-template-columns: auto minmax(11rem, 16rem) auto auto; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; padding: 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.filter-bar label { padding-left: 0.35rem; color: var(--muted); font-size: 0.78rem; font-weight: 780; }
.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 48rem; border-collapse: collapse; }
th, td { padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-subtle); color: var(--muted-foreground); font-size: 0.7rem; font-weight: 820; letter-spacing: 0.08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklch, var(--primary-muted) 35%, var(--surface)); }
td small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.75rem; }
.table-secondary { color: var(--muted-foreground); font-size: 0.86rem; }
.user-cell { display: flex; align-items: center; gap: 0.7rem; min-width: 12rem; }
.user-cell > span:last-child { min-width: 0; }
.user-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.protected-note { color: var(--developer) !important; font-weight: 760; }
.actions-heading { text-align: right; }
.actions { display: flex; justify-content: flex-end; gap: 0.35rem; white-space: nowrap; }
.empty-state { padding: 2.5rem 1rem; color: var(--muted); text-align: center; }
.empty-state svg { display: block; width: 2rem; height: 2rem; margin: 0 auto 0.65rem; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 0.25rem; font-size: 0.84rem; }

.badge { display: inline-flex; align-items: center; gap: 0.38rem; min-height: 1.75rem; padding: 0.3rem 0.62rem; border-radius: 999px; font-size: 0.7rem; font-weight: 820; white-space: nowrap; }
.badge-dot { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; }
.badge.online { background: var(--success-muted); color: var(--success); }
.badge.disconnected { background: var(--destructive-muted); color: var(--destructive); }
.badge.warning { background: var(--warning-muted); color: var(--warning-foreground); }
.badge.inactive { background: var(--surface-strong); color: var(--muted-foreground); }
.badge.role-developer { background: var(--developer-muted); color: var(--developer); }
.badge.role-administrator { background: var(--administrator-muted); color: var(--administrator); }
.badge.role-adjuster { background: var(--primary-muted); color: var(--primary-hover); }

.avatar { position: relative; display: grid; place-items: center; width: 2.35rem; height: 2.35rem; flex: 0 0 auto; overflow: hidden; border: 2px solid var(--surface); border-radius: 50%; background: var(--primary-muted); color: var(--primary-hover); font-weight: 850; object-fit: cover; box-shadow: 0 0 0 1px var(--border); }
img.avatar { object-fit: cover; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-with-image > span { position: relative; z-index: 0; }
.avatar-preview.is-removed { opacity: 0.45; filter: grayscale(1); }
.avatar-small { width: 2.1rem; height: 2.1rem; }
.avatar-large { width: 3.3rem; height: 3.3rem; font-size: 1.15rem; }

input, select { width: 100%; min-height: 2.8rem; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--foreground); }
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem color-mix(in oklch, var(--primary) 15%, transparent); outline: none; }
input[readonly], input:disabled, select:disabled { background: var(--surface-subtle); color: var(--muted); }
label { color: var(--foreground); font-size: 0.84rem; font-weight: 760; }
label small, .form-help { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.account-form { padding: 0; overflow: hidden; }
.form-section { padding: clamp(1.1rem, 3vw, 1.55rem); border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-heading { display: flex; align-items: flex-start; gap: 0.8rem; margin-bottom: 1.1rem; }
.form-section-heading > span { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; flex: 0 0 auto; border-radius: 50%; background: var(--primary-muted); color: var(--primary-hover); font-size: 0.75rem; font-weight: 850; }
.form-section-heading h2 { margin: 0; font-size: 1rem; }
.form-section-heading p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.78rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid label { display: flex; flex-direction: column; gap: 0.38rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.65rem; padding: 1rem 1.3rem; background: var(--surface-subtle); }
.avatar-upload { display: flex; align-items: center; gap: 1.2rem; padding: 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-subtle); }
.avatar-preview { position: relative; display: grid; place-items: center; width: 6.4rem; height: 6.4rem; flex: 0 0 auto; overflow: hidden; border: 0.3rem solid var(--surface); border-radius: 50%; background: var(--primary-muted); color: var(--primary-hover); font-size: 2rem; font-weight: 900; box-shadow: var(--shadow-sm); }
.avatar-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-preview [data-avatar-fallback] { position: relative; z-index: 0; }
.avatar-upload-copy { min-width: 0; }
.avatar-upload-copy p { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.76rem; }
.file-button { cursor: pointer; }
.file-status { font-weight: 680; }
.remove-avatar { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; color: var(--destructive); }
.remove-avatar input { width: 1rem; min-height: 1rem; accent-color: var(--destructive); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; margin-top: 1rem; padding: 1rem 1.15rem; border: 1px solid color-mix(in oklch, var(--destructive) 22%, var(--border)); border-radius: var(--radius-lg); background: var(--destructive-muted); }
.danger-zone strong { color: var(--destructive); }
.danger-zone p { margin: 0.2rem 0 0; color: var(--muted-foreground); font-size: 0.78rem; }
.danger-button { background: var(--destructive) !important; color: var(--destructive-foreground) !important; }
.danger-button:hover { background: color-mix(in oklch, var(--destructive) 84%, var(--foreground)) !important; }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 1rem; background: radial-gradient(circle at 15% 10%, var(--primary-muted), transparent 36%), var(--background); }
.auth-shell { width: min(100%, 27rem); }
.setup-shell { width: min(100%, 31rem); }
.auth-card { padding: clamp(1.35rem, 5vw, 2rem); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.6rem; }
.auth-brand > div { display: flex; flex-direction: column; line-height: 1.1; }
.auth-brand small { margin-top: 0.2rem; color: var(--muted); font-size: 0.72rem; }
.auth-card h1 { margin: 0.35rem 0 0.55rem; font-size: var(--step-2); line-height: 1.1; letter-spacing: -0.035em; }
.stack { display: grid; gap: 0.9rem; margin-top: 1.3rem; }
.stack label { display: grid; gap: 0.38rem; }
.stack button { width: 100%; margin-top: 0.2rem; }
.auth-footnote, .form-progress { margin: 1.15rem 0 0; color: var(--muted); font-size: 0.75rem; text-align: center; }

.map-body { overflow: hidden; }
.map-main { height: calc(100dvh - var(--header-height)); min-height: 32rem; overflow: hidden; }
.map-page { position: relative; width: 100%; height: 100%; background: var(--surface-strong); }
#map { width: 100%; height: 100%; background: var(--surface-strong); }
.map-controls { position: absolute; top: 1rem; left: 1rem; z-index: var(--z-dropdown); display: flex; align-items: flex-end; gap: 0.55rem; max-width: calc(100% - 2rem); padding: 0.55rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: color-mix(in oklch, var(--surface) 94%, transparent); box-shadow: var(--shadow-md); backdrop-filter: blur(0.9rem); }
.map-user-control { display: grid; gap: 0.22rem; min-width: min(21rem, 46vw); }
.map-user-control label { padding-left: 0.15rem; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.map-user-control select { min-height: 2.65rem; border: 0; background: var(--surface-subtle); font-weight: 720; }
.map-control-button { width: 2.65rem; height: 2.65rem; }
.map-live-state { align-self: center; min-height: 2.65rem; }
.map-popover { position: absolute; top: 5.7rem; left: 1rem; z-index: var(--z-popover); width: min(23rem, calc(100% - 2rem)); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.popover-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.7rem; margin-bottom: 0.9rem; }
.popover-heading strong, .popover-heading small { display: block; }
.popover-heading small { margin-top: 0.15rem; color: var(--muted); font-size: 0.75rem; }
.map-popover label { display: grid; gap: 0.35rem; margin-top: 0.7rem; }
.popover-actions { display: flex; justify-content: flex-end; gap: 0.55rem; margin-top: 0.9rem; }
.location-card { position: absolute; left: 1rem; bottom: 1rem; z-index: var(--z-dropdown); width: min(27rem, calc(100% - 2rem)); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: color-mix(in oklch, var(--surface) 96%, transparent); box-shadow: var(--shadow-lg); backdrop-filter: blur(1rem); }
.location-card-close { position: absolute; top: 0.55rem; right: 0.55rem; width: 2.35rem; height: 2.35rem; }
.location-card-profile { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.8rem; padding-right: 2.4rem; }
.location-card-title { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; }
.location-card-title h2 { margin: 0; font-size: 1.05rem; }
.location-card-profile p { margin-top: 0.15rem; font-size: 0.75rem; }
.written-location { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.7rem; margin-top: 0.9rem; padding: 0.8rem; border-radius: var(--radius-md); background: var(--primary-muted); }
.written-location-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 0.7rem; background: var(--primary); color: var(--primary-foreground); }
.written-location small, .written-location strong, .written-location span { display: block; }
.written-location small { color: var(--primary-hover); font-size: 0.68rem; font-weight: 820; letter-spacing: 0.06em; text-transform: uppercase; }
.written-location strong { margin-top: 0.2rem; font-size: 0.86rem; line-height: 1.35; }
.written-location span { margin-top: 0.25rem; color: var(--muted-foreground); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.location-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; margin: 0.8rem 0; }
.location-facts div { padding: 0.55rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.location-facts dt { color: var(--muted); font-size: 0.65rem; font-weight: 760; }
.location-facts dd { margin: 0.15rem 0 0; font-size: 0.78rem; font-weight: 780; }
.location-history { width: 100%; }
.map-empty { position: absolute; inset: 50% auto auto 50%; z-index: var(--z-dropdown); display: grid; justify-items: center; width: min(22rem, calc(100% - 2rem)); transform: translate(-50%, -50%); padding: 1.3rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-md); text-align: center; }
.map-empty svg { width: 2rem; height: 2rem; margin-bottom: 0.55rem; color: var(--primary); }
.map-empty span { margin-top: 0.25rem; color: var(--muted); font-size: 0.8rem; }
.jsecure-marker-shell { background: transparent; border: 0; }
.person-pin { position: relative; display: grid; place-items: center; width: 3.15rem; height: 3.7rem; filter: drop-shadow(0 0.35rem 0.45rem oklch(0.22 0.03 45 / 0.24)); }
.person-pin::before { content: ""; position: absolute; inset: 0.05rem 0.08rem 0.55rem; border: 0.2rem solid var(--surface); border-radius: 50% 50% 50% 0.45rem; background: var(--destructive); transform: rotate(-45deg); }
.person-pin.online::before { background: var(--success); }
.person-pin-avatar { position: relative; z-index: 1; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin-top: -0.45rem; overflow: hidden; border: 0.15rem solid var(--surface); border-radius: 50%; background: var(--primary-muted); color: var(--primary-hover); font-size: 0.78rem; font-weight: 900; }
.person-pin-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.person-pin.selected { transform: scale(1.12); transform-origin: bottom center; }
.leaflet-control-zoom a { color: var(--foreground); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--foreground); }
.leaflet-popup-content { margin: 0.8rem 0.9rem; }

.history-filter-panel { padding: 0.85rem; margin-bottom: 1rem; }
.history-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; gap: 0.7rem; }
.history-filters label { display: grid; gap: 0.35rem; }
.history-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(17rem, 0.45fr); gap: 1rem; margin-bottom: 1rem; }
#history-map { min-height: 31rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-strong); box-shadow: var(--shadow-sm); }
.event-panel { padding: 1rem; }
.timeline { display: grid; gap: 0.7rem; margin-top: 1rem; }
.timeline article { padding: 0.75rem 0.8rem; border-left: 0.22rem solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-subtle); }
.timeline h3 { margin: 0; font-size: 0.84rem; }
.timeline p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.75rem; }
.table-title { padding: 1rem 1rem 0.75rem; }

@media (prefers-reduced-motion: no-preference) {
  .sidebar-link, .button, button, .action-row, .person-pin { transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease; }
}

@media (max-width: 74rem) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 61.99rem) {
  .app-header { padding-inline: 0.75rem; }
  .nav-toggle { display: inline-grid; }
  .app-brand-copy small, .live-indicator-label, .session-user-copy { display: none; }
  .app-layout { display: block; }
  .app-sidebar { position: fixed; z-index: var(--z-drawer); top: var(--header-height); left: 0; bottom: 0; width: min(var(--sidebar-width), calc(100% - 3.5rem)); min-height: 0; transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: transform 180ms ease; }
  .nav-open .app-sidebar { transform: translateX(0); }
  .sidebar-account { display: flex; }
  .sidebar-backdrop { position: fixed; inset: var(--header-height) 0 0; z-index: calc(var(--z-drawer) - 1); display: block; border: 0; background: oklch(0.18 0.02 45 / 0.48); opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
  .nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .dashboard-grid, .history-layout { grid-template-columns: 1fr; }
  .safety-panel { min-height: 14rem; }
  .map-main { height: calc(100dvh - var(--header-height)); }
}

@media (max-width: 47.99rem) {
  .content-shell, .content-shell.wide, .content-shell.content-narrow { width: min(100% - 1.25rem, 74rem); padding-top: 1.15rem; }
  .page-heading, .page-heading.compact { align-items: flex-start; flex-direction: column; gap: 0.9rem; }
  .heading-actions { width: 100%; justify-content: stretch; }
  .heading-actions .button { flex: 1; }
  .filter-bar { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .avatar-upload { align-items: flex-start; flex-direction: column; }
  .avatar-preview { width: 5.4rem; height: 5.4rem; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .danger-zone .button { width: 100%; }
  .history-filters { grid-template-columns: 1fr; }
  .history-filters button { width: 100%; }
  #history-map { min-height: 24rem; }
  table { min-width: 42rem; }
  .map-controls { right: 0.65rem; left: 0.65rem; top: 0.65rem; max-width: none; }
  .map-user-control { min-width: 0; flex: 1; }
  .map-controls { display: flex; }
  .map-live-state { width: 2.65rem; padding: 0; justify-content: center; font-size: 0; }
  .map-live-state .badge-dot { width: 0.58rem; height: 0.58rem; }
  .map-popover { top: 5.15rem; left: 0.65rem; width: calc(100% - 1.3rem); }
  .location-card { right: 0.65rem; bottom: max(0.65rem, env(safe-area-inset-bottom)); left: 0.65rem; width: auto; max-height: min(49dvh, 25rem); overflow-y: auto; }
  .location-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 35.99rem) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 5.5rem; }
  .live-indicator { display: none; }
  .session-user { margin-left: auto; }
  .page-heading h1 { font-size: clamp(1.85rem, 10vw, 2.35rem); }
  .heading-actions { display: grid; grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr auto auto; }
  .filter-bar label { display: none; }
  .filter-bar select { min-width: 0; }
  .form-actions { position: sticky; bottom: 0; z-index: var(--z-sticky); display: grid; grid-template-columns: 1fr 1fr; }
  .location-card-profile { padding-right: 2.1rem; }
  .location-facts { gap: 0.35rem; }
  .location-facts div { padding: 0.45rem; }
  .location-facts dt { font-size: 0.6rem; }
  .location-facts dd { font-size: 0.7rem; }
}

@media (forced-colors: active) {
  .person-pin::before, .metric-icon, .written-location-icon, .app-brand-mark { border: 1px solid CanvasText; }
  .badge-dot { forced-color-adjust: none; }
}
