/* staff.css - Streamlined admin console styling with panel grid, tokens, dark/light themes and responsive rail */

:root {
  /* Dark leather / bronze palette default */
  --ground: #130d08;
  --panel: rgba(26, 18, 12, 0.95);
  --panel-elevated: #241910;
  --panel-soft: rgba(38, 26, 17, 0.9);
  --scrim: rgba(0, 0, 0, 0.75);

  --text: #c7b48c;
  --text-bright: #e7d6b4;
  --text-dim: #9e8e70;
  --text-faint: #6e6049;
  --silver: #e7d6b4;

  --stone: #8a7050;
  --stone-dark: #3a2115;
  --stone-light: #c7b48c;

  --border: rgba(184, 134, 43, 0.38);
  --border-subtle: rgba(184, 134, 43, 0.2);
  --border-strong: rgba(184, 134, 43, 0.75);

  --glow: 0 0 16px rgba(184, 134, 43, 0.15);
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.75);
  --shadow-dropdown: 0 10px 24px rgba(0, 0, 0, 0.8);

  --gold: #d9b25a;
  --gold-fill: rgba(184, 134, 43, 0.14);
  --gold-fill-hover: rgba(184, 134, 43, 0.28);
  --gold-border: rgba(184, 134, 43, 0.5);
  --gold-border-strong: rgba(184, 134, 43, 0.85);

  --accent: #d9b25a;
  --accent-fill: rgba(184, 134, 43, 0.14);
  --accent-hover: #e8c676;

  --amber: #d9b25a;
  --red: #e0897f;
  --ok: #8fd3a0;
  --warn: #d9b25a;
  --bad: #e0897f;

  --title: 'Cinzel', Georgia, serif;
  --ui: 'Roboto Condensed', 'Roboto', 'Segoe UI', -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;

  /* Spacing 4px scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  --sidebar-w: 240px;
  --sidebar-rail-w: 64px;
  --topbar-h: 56px;
}

/* Light paper / parchment theme overrides */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #dfd1b5;
    --panel: #ebdcb9;
    --panel-elevated: #f4e8cc;
    --panel-soft: #e2d2ad;
    --scrim: rgba(43, 29, 18, 0.6);

    --text: #2b1d12;
    --text-bright: #140d08;
    --text-dim: #5a4632;
    --text-faint: #7a654d;
    --silver: #1a1008;

    --stone: #5e4930;
    --stone-dark: #b89e76;
    --stone-light: #5a4632;

    --border: #bfa677;
    --border-subtle: rgba(184, 134, 43, 0.25);
    --border-strong: #9e8455;

    --glow: none;
    --shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.2);
    --shadow-dropdown: 0 8px 20px rgba(0, 0, 0, 0.22);

    --gold: #7e2a1e;
    --gold-fill: rgba(190, 168, 126, 0.35);
    --gold-fill-hover: rgba(190, 168, 126, 0.55);
    --gold-border: #b89e76;
    --gold-border-strong: #5e4930;

    --accent: #7e2a1e;
    --accent-fill: rgba(126, 42, 30, 0.1);
    --accent-hover: #9c3628;

    --amber: #693f07;
    --red: #7e2a1e;
    --ok: #2d5424;
    --warn: #693f07;
    --bad: #7e2a1e;
  }
}

:root[data-theme="light"] {
  --ground: #dfd1b5;
  --panel: #ebdcb9;
  --panel-elevated: #f4e8cc;
  --panel-soft: #e2d2ad;
  --scrim: rgba(43, 29, 18, 0.6);

  --text: #2b1d12;
  --text-bright: #140d08;
  --text-dim: #5a4632;
  --text-faint: #7a654d;
  --silver: #1a1008;

  --stone: #5e4930;
  --stone-dark: #b89e76;
  --stone-light: #5a4632;

  --border: #bfa677;
  --border-subtle: rgba(184, 134, 43, 0.25);
  --border-strong: #9e8455;

  --glow: none;
  --shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.2);
  --shadow-dropdown: 0 8px 20px rgba(0, 0, 0, 0.22);

  --gold: #7e2a1e;
  --gold-fill: rgba(190, 168, 126, 0.35);
  --gold-fill-hover: rgba(190, 168, 126, 0.55);
  --gold-border: #b89e76;
  --gold-border-strong: #5e4930;

  --accent: #7e2a1e;
  --accent-fill: rgba(126, 42, 30, 0.1);
  --accent-hover: #9c3628;

  --amber: #693f07;
  --red: #7e2a1e;
  --ok: #2d5424;
  --warn: #693f07;
  --bad: #7e2a1e;
}

:root[data-theme="dark"] {
  --ground: #130d08;
  --panel: rgba(26, 18, 12, 0.95);
  --panel-elevated: #241910;
  --panel-soft: rgba(38, 26, 17, 0.9);
  --scrim: rgba(0, 0, 0, 0.75);

  --text: #c7b48c;
  --text-bright: #e7d6b4;
  --text-dim: #9e8e70;
  --text-faint: #6e6049;
  --silver: #e7d6b4;

  --stone: #8a7050;
  --stone-dark: #3a2115;
  --stone-light: #c7b48c;

  --border: rgba(184, 134, 43, 0.38);
  --border-subtle: rgba(184, 134, 43, 0.2);
  --border-strong: rgba(184, 134, 43, 0.75);

  --glow: 0 0 16px rgba(184, 134, 43, 0.15);
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.75);
  --shadow-dropdown: 0 10px 24px rgba(0, 0, 0, 0.8);

  --gold: #d9b25a;
  --gold-fill: rgba(184, 134, 43, 0.14);
  --gold-fill-hover: rgba(184, 134, 43, 0.28);
  --gold-border: rgba(184, 134, 43, 0.5);
  --gold-border-strong: rgba(184, 134, 43, 0.85);

  --accent: #d9b25a;
  --accent-fill: rgba(184, 134, 43, 0.14);
  --accent-hover: #e8c676;

  --amber: #d9b25a;
  --red: #e0897f;
  --ok: #8fd3a0;
  --warn: #d9b25a;
  --bad: #e0897f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(70% 50% at 50% 8%, rgba(184, 134, 43, 0.12), transparent 70%), var(--ground);
}

.wm {
  position: fixed;
  right: -70px;
  top: 50%;
  transform: translateY(-50%);
  width: min(640px, 58vw);
  opacity: 0.035;
  z-index: -1;
  pointer-events: none;
  filter: drop-shadow(0 0 40px rgba(184, 134, 43, 0.25));
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* SVG icon utility */
.icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  stroke-width: 2;
  flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* Top Header Bar */
.top-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-bar {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--silver);
  font-family: var(--title);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  white-space: nowrap;
}

/* Breadcrumb in top bar */
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  padding-left: 0.45rem;
  border-left: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.bc-root { font-weight: 500; }
.bc-sep { opacity: 0.5; }
.bc-current { color: var(--text-bright); font-weight: 600; }

/* Workspace Switcher Staff | Analytics */
.workspace-switch {
  display: inline-flex;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}
.ws-tab {
  display: inline-block;
  padding: 0.25rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: all 140ms ease;
}
.ws-tab:hover { color: var(--text-bright); }
.ws-tab.active {
  background: var(--gold-fill-hover);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

/* Header Right items */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.env-pill {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.env-pill.prod {
  color: var(--ok);
  background: rgba(143, 211, 160, 0.12);
  border: 1px solid currentColor;
}

/* Theme toggle button */
.btn-theme {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 140ms, border-color 140ms;
}
.btn-theme:hover { color: var(--gold); border-color: var(--gold-border); }

/* User Menu button & dropdown */
.user-menu-wrap {
  position: relative;
}
.user-menu-btn {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.65rem 0.2rem 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-bright);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 140ms;
}
.user-menu-btn:hover { border-color: var(--gold-border); }
.user-avatar {
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}
.user-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tier-badge {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-border);
  background: var(--gold-fill);
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-sm);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  min-width: 160px;
  padding: 0.35rem 0;
  z-index: 150;
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.85rem;
  color: var(--text);
  font-size: 0.86rem;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background 120ms;
}
.dropdown-item:hover {
  background: var(--gold-fill);
  color: var(--text-bright);
}
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(224, 137, 127, 0.15); }
.user-dropdown hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 0.35rem 0;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--silver);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
}

/* Page Layout */
.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

.staff-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  transition: grid-template-columns 200ms ease;
}

/* Collapsible rail mode */
.staff-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-rail-w) minmax(0, 1fr);
}

/* Sidebar navigation */
.staff-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 1rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.6rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: width 200ms ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-title {
  font-family: var(--title);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--silver);
  white-space: nowrap;
}
.rail-toggle {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
}
.rail-toggle:hover { color: var(--gold); background: var(--gold-fill); }

.staff-layout.sidebar-collapsed .sidebar-title { display: none; }
.staff-layout.sidebar-collapsed .rail-toggle svg { transform: rotate(180deg); }

.staff-nav {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-group-title {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.2rem 0.6rem;
  font-weight: 600;
  white-space: nowrap;
}

.staff-layout.sidebar-collapsed .nav-group-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: all 140ms ease;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--gold-fill);
  color: var(--text-bright);
}

.nav-item.active {
  background: var(--gold-fill-hover);
  color: var(--gold);
  border-left-color: var(--gold);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.staff-layout.sidebar-collapsed .nav-label {
  display: none;
}

.staff-layout.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.55rem 0.2rem;
  border-left: 0;
}
.staff-layout.sidebar-collapsed .nav-item.active {
  background: var(--gold-fill-hover);
  border-radius: var(--radius-md);
}

/* Staff Content & Section Header */
.staff-content {
  min-width: 0;
}

.staff-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sec-title-wrap h2 {
  font-family: var(--title);
  color: var(--silver);
  font-size: 1.45rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.sec-desc {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.sec-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.sec-updated {
  font-size: 0.82rem;
  margin: 0 0.25rem;
}

/* 12-Column Panel Grid System */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  align-items: start;
}

/* Panel Widths */
.panel-card[data-width="s"] { grid-column: span 4; }
.panel-card[data-width="m"] { grid-column: span 6; }
.panel-card[data-width="l"] { grid-column: span 12; }

/* Panel card styling */
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow 160ms, border-color 160ms;
}

.panel-card:hover {
  border-color: var(--border-strong);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  gap: 0.45rem 0.6rem;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}

// Wrap header controls onto their own row in customize mode when width is tight
body.is-customizing .panel-header-left {
  min-width: min(100%, max-content);
}

.panel-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  flex-shrink: 0;
}
.panel-status-dot.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.panel-status-dot.bad { background: var(--red); box-shadow: 0 0 6px var(--red); }

.panel-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-title {
  font-family: var(--title);
  color: var(--silver);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Drag Handle */
.panel-drag-handle {
  display: none;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  cursor: grab;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  touch-action: none;
  align-items: center;
  justify-content: center;
}
.panel-drag-handle:hover { color: var(--gold); border-color: var(--gold); }
.panel-drag-handle:active { cursor: grabbing; }

/* Show Drag handles and customize actions ONLY in customize mode */
body.is-customizing .panel-drag-handle { display: inline-flex; }
body.is-customizing .panel-width-select { display: inline-flex; }
body.is-customizing .btn-panel-hide { display: inline-flex; }

/* Panel Width buttons (S/M/L) */
.panel-width-select {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-soft);
}
.btn-width {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}
.btn-width:hover { color: var(--text-bright); }
.btn-width.active {
  background: var(--gold-fill-hover);
  color: var(--gold);
}

/* Panel action icon buttons */
.btn-panel-action {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-panel-action:hover { color: var(--gold); background: var(--gold-fill); }

.btn-panel-hide { display: none; }

/* Collapse toggle icon rotation */
.panel-card.is-collapsed .btn-panel-collapse svg {
  transform: rotate(-90deg);
}

/* Overflow Menu */
.panel-menu-wrap {
  position: relative;
}
.panel-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  min-width: 170px;
  padding: 0.35rem 0;
  z-index: 120;
}
.panel-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.85rem;
  color: var(--text);
  font-size: 0.82rem;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.panel-menu-dropdown button:hover {
  background: var(--gold-fill);
  color: var(--text-bright);
}
.panel-menu-dropdown hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 0.3rem 0;
}

/* Panel Body */
.panel-body {
  padding: 1rem 1.2rem;
}

/* Collapsed state */
.panel-card.is-collapsed .panel-body {
  display: none !important;
}

/* Dragging & Placeholder states */
.panel-card.is-dragging {
  position: fixed !important;
  pointer-events: none !important;
  z-index: 1000 !important;
  opacity: 0.92;
  box-shadow: var(--shadow-lg);
  border-color: var(--gold-border-strong);
  cursor: grabbing;
}

.panel-placeholder {
  border: 2px dashed var(--gold);
  background: rgba(184, 134, 43, 0.08);
  border-radius: var(--radius-lg);
  min-height: 80px;
}

/* Hidden Panels dropdown in section header */
.hidden-panels-wrap {
  position: relative;
}
.hidden-panels-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  min-width: 200px;
  padding: 0.4rem 0;
  z-index: 120;
}
.dropdown-header {
  padding: 0.3rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.25rem;
}

/* KPI Tiles Grid */
.kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-tile {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--glow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.kpi-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}
.kpi-val {
  font-family: var(--title);
  color: var(--gold);
  font-size: 1.75rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.kpi-tile.ok .kpi-val { color: var(--ok); }
.kpi-tile.warn .kpi-val { color: var(--warn); }
.kpi-tile.bad .kpi-val { color: var(--bad); }

/* Sparkline SVG */
.spark {
  display: block;
  width: 100%;
  height: 60px;
}

/* Quick Links Grid */
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
}
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: all 140ms ease;
}
.quick-link-card:hover {
  border-color: var(--gold-border);
  background: var(--gold-fill);
  color: var(--text-bright);
}
.quick-link-card strong { display: block; font-size: 0.9rem; color: var(--silver); }
.quick-link-card .dim { font-size: 0.78rem; }

/* Tables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  max-height: 480px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-elevated);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  z-index: 2;
}

tbody tr:hover {
  background: var(--gold-fill);
}

th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.num { color: var(--silver); }

/* Common controls & forms */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=range]),
select,
textarea {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-bright);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  box-sizing: border-box;
}
input.search { min-width: 240px; }

input:not([type=checkbox]):not([type=radio]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-border-strong);
  box-shadow: 0 0 0 2px var(--gold-fill-hover);
  background: var(--panel-elevated);
}

select option {
  background: var(--panel-elevated);
  color: var(--text-bright);
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Buttons */
button, a.btn {
  font-family: var(--ui);
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--gold-fill);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 140ms ease, border-color 140ms ease;
  line-height: 1.25;
}

button:hover:not(:disabled), a.btn:hover {
  background: var(--gold-fill-hover);
  border-color: var(--gold-border-strong);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.ghost, a.ghost {
  background: var(--gold-fill);
  color: var(--silver);
  border-color: var(--border);
}
button.ghost:hover:not(:disabled), a.ghost:hover {
  background: var(--gold-fill-hover);
  border-color: var(--border-strong);
}

button.btn-sm, a.btn-sm {
  font-size: 0.76rem;
  padding: 0.3rem 0.65rem;
}

button.active, a.btn.active {
  background: var(--gold-fill-hover);
  border-color: var(--gold-border-strong);
  color: var(--gold);
}

button.danger {
  background: rgba(201, 70, 58, 0.15);
  color: #e58b80;
  border-color: rgba(201, 70, 58, 0.65);
}
button.danger:hover:not(:disabled) {
  background: rgba(201, 70, 58, 0.28);
  border-color: var(--red);
}

a.dl {
  font-size: 0.95rem;
  padding: 0.75rem 1.6rem;
}

/* Common panels & gates */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
}

.gate {
  text-align: center;
  padding: 2.5rem 1rem;
}

.dim { color: var(--text-dim); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.denied-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 0.8rem 0;
}
.denied-state h3 {
  font-family: var(--title);
  color: var(--silver);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
}
.denied-state p {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.94rem;
}

/* Skeleton Loading bars */
.skeleton {
  background: linear-gradient(90deg, rgba(184, 134, 43, 0.08) 25%, rgba(184, 134, 43, 0.18) 50%, rgba(184, 134, 43, 0.08) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 1.2rem;
  margin: 0.4rem 0;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Server component styles */
.srv {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.3rem 1rem;
  box-shadow: var(--shadow);
  margin: 0.4rem 0 1rem;
  overflow-wrap: anywhere;
}

.blk {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.15rem 1rem;
  padding: 0.65rem 0;
  font-size: 0.9rem;
}
.blk + .blk { border-top: 1px solid var(--border-subtle); }

.lbl {
  font-family: var(--title);
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding-top: 0.1rem;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-full);
  padding: 0 0.6rem;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.flag {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.4rem;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--gold);
  background: var(--gold-fill);
  margin: 0.1rem 0.3rem 0.1rem 0;
  white-space: nowrap;
}
.flag.warn {
  color: var(--amber);
  border-color: rgba(201, 138, 58, 0.6);
  background: rgba(201, 138, 58, 0.12);
}

.grp { margin: 0.3rem 0; }
.grp > summary { cursor: pointer; color: var(--silver); }
.qi { padding: 0.3rem 0 0.3rem 1rem; border-bottom: 1px solid rgba(184, 134, 43, 0.12); }
.qm { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.7rem; font-size: 0.82rem; }
.sha { font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); margin-right: 0.5rem; }
.stop { color: var(--amber); font-size: 0.78rem; letter-spacing: 0.06em; text-align: center; border-top: 1px dashed var(--amber); margin: 0.4rem 0 0.2rem; }
.srv button { font-size: 0.78rem; padding: 0.35rem 0.9rem; margin-top: 0.4rem; }

/* Status dot & live indicator */
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.live {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  display: inline-block;
}
.live.stale {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
}

/* Dialogs */
dialog.ctl {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 1.2rem 1.4rem;
  width: min(520px, calc(100vw - 32px));
}
dialog.ctl::backdrop { background: var(--scrim); }
dialog.ctl h3 { font-family: var(--title); font-weight: 400; color: var(--silver); letter-spacing: 0.1em; margin: 0 0 0.5rem; }
dialog.ctl p { margin: 0.4rem 0; font-size: 0.9rem; }
dialog.ctl label { display: block; color: var(--text-dim); font-size: 0.8rem; margin: 0.7rem 0 0.2rem; }
dialog.ctl input, dialog.ctl select, dialog.ctl textarea {
  width: 100%;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  font: inherit;
}
dialog.ctl textarea { min-height: 4.6rem; resize: vertical; }
dialog.ctl .acts { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
dialog.ctl button { font-size: 0.82rem; padding: 0.45rem 1rem; }

/* Bot Features components */
.ft-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; padding: 0.3rem 0; }
.ft-row .k { min-width: 6.5rem; font-family: var(--title); color: var(--gold); font-size: 0.82rem; }
.ft-row .v { min-width: 4rem; font-weight: 600; }
.ft-row select { font-size: 0.8rem; min-height: 30px; }
.ft-row .why { flex: 1 1 100%; font-size: 0.8rem; }
.ft-tbl { border-collapse: collapse; font-size: 0.82rem; width: 100%; }
.ft-tbl td, .ft-tbl th { padding: 0.25rem 0.6rem 0.25rem 0; text-align: left; vertical-align: top; }
.ft-on { color: var(--ok); }
.ft-off { color: var(--text-dim); }
.ft-mid { color: var(--amber); }

/* Staff Console components */
.con-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.con-form input { flex: 1 1 260px; min-width: 0; font-family: var(--mono); }
.con-entry { border-top: 1px solid var(--border-subtle); padding: 0.45rem 0; }
.con-entry pre {
  margin: 0.3rem 0 0;
  padding: 0.4rem 0.6rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.con-help { font-size: 0.8rem; margin: 0.2rem 0 0.4rem; }

/* Player Directory components */
.who { display: flex; gap: 0.55rem; align-items: center; }
.who img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); }
.chars div + div { margin-top: 0.25rem; }
.chip {
  display: inline-block;
  border: 1px solid var(--gold-border);
  background: var(--gold-fill);
  border-radius: var(--radius-full);
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
  color: var(--gold);
}

/* Punishments & Moderation components */
#punish { padding: 0.8rem 1rem 1rem; border: 0; box-shadow: none; background: transparent; }
#punish button { margin: 0; }
.pu-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
#punish .pu-add { margin-left: auto; font-size: 0.85rem; padding: 0.45rem 1.1rem; }
.pu-rule { margin: 0.45rem 0 0; font-size: 0.92rem; }
.pu-rule .dim { font-size: 0.86rem; }
.pu-alert {
  border-left: 3px solid var(--amber);
  background: rgba(201, 138, 58, 0.1);
  color: var(--amber);
  padding: 0.35rem 0.8rem;
  margin: 0.5rem 0 0;
  font-size: 0.86rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.pu-tabs { display: flex; border-bottom: 1px solid var(--border); margin: 0.9rem 0 1rem; overflow-x: auto; }
#punish .pu-tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-dim);
  padding: 0.6rem 1.05rem;
  margin: 0 0 -1px;
  font-size: 0.82rem;
  white-space: nowrap;
}
#punish .pu-tabs button:hover { color: var(--text); background: var(--gold-fill); }
#punish .pu-tabs button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
#punish #puTabPlayer { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; }
.pu-n {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(201, 138, 58, 0.22);
  color: #f3d2a4;
  font-size: 0.72rem;
  line-height: 1.5;
}
.pu-h { font-family: var(--title); font-weight: 400; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); margin: 0 0 0.5rem; }
.pu-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; margin: 0 0 0.6rem; font-size: 0.86rem; }
.pu-filters label { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-dim); }
#punish select, #punish input[type=date] {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.86rem;
  min-height: 2.2rem;
}
#punish .pu-filters button, #punish .pu-empty button { font-size: 0.75rem; padding: 0.4rem 0.9rem; }
#punish button.linkish {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: var(--gold);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pu-list { margin: 0 0 0.6rem; }
.pu-row { display: grid; gap: 0.15rem 1rem; align-items: start; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--border-subtle); font-size: 0.9rem; }
.pu-row.pu-hd { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.15rem 0.4rem 0.35rem; }
.pu-run .pu-row { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 0.85fr) minmax(0, 1.5fr); }
.pu-rec .pu-row { grid-template-columns: 5.6rem minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1.1fr) minmax(0, 1.5fr); }
.pu-his .pu-row { grid-template-columns: 5.6rem minmax(0, 1.4fr) minmax(0, 1.1fr) minmax(0, 0.85fr) minmax(0, 1.5fr); }
.pu-sub { display: block; color: var(--text-dim); font-size: 0.8rem; line-height: 1.45; }
.pu-left { font-family: var(--title); color: var(--silver); font-size: 1.02rem; letter-spacing: 0.02em; line-height: 1.35; }
.pu-kb { display: inline-block; border: 1px solid; border-radius: var(--radius-sm); padding: 0 0.45rem; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; line-height: 1.6; margin: 0 0.45rem 0.15rem 0; }
.pu-kb.bad { background: rgba(201, 70, 58, 0.3); border-color: rgba(229, 139, 128, 0.85); color: #f6c1ba; }
.pu-kb.warn { background: rgba(201, 138, 58, 0.28); border-color: rgba(232, 184, 120, 0.85); color: #f3d2a4; }
.pu-kb.strike { border-color: var(--amber); color: #e8b878; }
.pu-kb.plain { border-color: var(--border); color: var(--gold); }
.pu-kb.undo { border-color: var(--border); color: var(--gold); border-style: dashed; }
.pu-kb.over { border-color: rgba(215, 227, 227, 0.3); color: var(--text-dim); }
.pu-kb.void { text-decoration: line-through; }
.pu-st.on { color: var(--amber); }
.pu-st.on::before { content: "\25CF  "; font-size: 0.75em; }
.pu-st.strike { color: #e8b878; }
.pu-st.off { color: var(--text-dim); }
.pu-prog { display: block; width: 100%; max-width: 11rem; height: 4px; margin-top: 0.3rem; border: 0; border-radius: 2px; background: rgba(184, 134, 43, 0.18); appearance: none; }
.pu-prog::-webkit-progress-bar { background: rgba(184, 134, 43, 0.18); border-radius: 2px; }
.pu-prog::-webkit-progress-value { background: var(--amber); border-radius: 2px; }
.pu-prog::-moz-progress-bar { background: var(--amber); border-radius: 2px; }
.pu-empty { padding: 1.1rem; text-align: center; color: var(--text-dim); border: 1px dashed var(--border); border-radius: var(--radius-lg); margin: 0.2rem 0 0.6rem; }
.pu-empty button { display: block; margin: 0.6rem auto 0 !important; }
.pu-strikes { border: 1px solid rgba(201, 138, 58, 0.35); border-radius: var(--radius-lg); padding: 0.55rem 0.9rem; margin: 0 0 1rem; }
.pu-strikes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.6rem; }
.pu-strikes li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; font-size: 0.88rem; margin: 0; }
.pu-pips { display: inline-flex; gap: 0.2rem; }
.pu-pips i { display: block; width: 1.1rem; height: 0.5rem; border: 1px solid var(--amber); border-radius: 2px; }
.pu-pips i.f { background: var(--amber); }
.pu-foot { font-size: 0.8rem; color: var(--text-dim); margin: 0.3rem 0 0; }
.pu-find { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.8rem; }
#punish .pu-find input { flex: 1 1 260px; min-width: 0; font: inherit; }
#punish .pu-find button { font-size: 0.8rem; padding: 0.45rem 1.2rem; }
.pu-acct { display: flex; flex-wrap: wrap; gap: 0.15rem 0.8rem; align-items: baseline; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--border-subtle); }
#punish .pu-back { font-size: 0.86rem; margin: 0 0 0.7rem; }
.pu-pcard { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.8rem 1.5rem; align-items: start; background: var(--panel-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.2rem; margin: 0 0 1rem; }
.pu-pname { font-family: var(--title); font-size: 1.5rem; color: var(--silver); letter-spacing: 0.04em; line-height: 1.25; }
.pu-pmeta { color: var(--text-dim); font-size: 0.86rem; }
.pu-meter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.7rem; margin-top: 0.6rem; }
.pu-acts { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
#punish .pu-acts button { font-size: 0.82rem; padding: 0.6rem 1.15rem; }
.pu-hint { font-size: 0.8rem; color: var(--text-dim); margin: 0.5rem 0 0; text-align: right; }
.pu-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.75rem 1rem; margin: 0 0 1rem; }
.pu-card.pu-running { border-color: rgba(201, 138, 58, 0.6); background: linear-gradient(180deg, rgba(201, 138, 58, 0.12), rgba(201, 70, 58, 0.05)); }
.pu-card.pu-running .pu-h { color: #f3d2a4; }
.pu-item { display: grid; grid-template-columns: 9.5rem 12rem minmax(0, 1fr); gap: 0.2rem 1rem; padding: 0.55rem 0; border-top: 1px solid rgba(201, 138, 58, 0.25); }
.pu-item.first { border-top: 0; }
.pu-none { color: var(--text-dim); margin: 0.2rem 0; }
.pu-sources { margin: 0.9rem 0 0; font-size: 0.8rem; color: var(--text-dim); }
.pu-sources summary { cursor: pointer; }
.pu-sources .flag { white-space: normal; }

/* Moderation Dialog */
dialog.pu-dlg { width: min(560px, calc(100vw - 32px)); }
.pu-dlg .pu-who { color: var(--silver); margin: 0 0 0.2rem; }
.pu-dlg .pu-small { font-size: 0.8rem; margin: 0.25rem 0; }
.pu-cmd {
  display: block;
  margin: 0.2rem 0 0.4rem;
  padding: 0.5rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.pu-confirm { border: 1px solid rgba(201, 138, 58, 0.6); background: rgba(201, 138, 58, 0.08); border-radius: var(--radius-lg); padding: 0.5rem 0.8rem; margin: 0.6rem 0; }
.pu-confirm .acts { margin-top: 0.4rem; }
#puDlgResult { white-space: pre-line; }

/* Scrim for mobile drawer */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 180;
  backdrop-filter: blur(2px);
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 3.5rem;
  letter-spacing: 0.08em;
}

/* Responsiveness & Phone layout (375px+) */
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .staff-layout { grid-template-columns: 1fr; }
  .staff-layout.sidebar-collapsed { grid-template-columns: 1fr; }

  /* Sidebar becomes fixed slide-over drawer */
  .staff-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -290px;
    width: 280px;
    z-index: 200;
    border-radius: 0;
    border-top: 0;
    border-bottom: 0;
    transition: transform 220ms ease;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .staff-sidebar.open {
    transform: translateX(290px);
  }
  .rail-toggle { display: none; }
  .staff-layout.sidebar-collapsed .nav-label { display: inline; }
  .staff-layout.sidebar-collapsed .nav-group-title { display: block; }
  .staff-layout.sidebar-collapsed .sidebar-title { display: inline; }
  .staff-layout.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0.55rem 0.65rem; }

  .two { grid-template-columns: 1fr; }
  .blk { grid-template-columns: minmax(0, 1fr); }
  .ft-row .k { min-width: 100%; }
}

@media (max-width: 768px) {
  /* On mobile every panel is full width (12 columns) */
  .panel-card[data-width="s"],
  .panel-card[data-width="m"],
  .panel-card[data-width="l"] {
    grid-column: span 12 !important;
  }

  .panel-header {
    flex-wrap: wrap;
  }
  .panel-header-actions {
    margin-left: auto;
  }

  #punish { padding: 0.8rem 0.75rem; }
  #punish .pu-add { margin-left: 0; flex: 1 1 100%; min-height: 44px; }
  #punish .pu-tabs button { flex: 1 1 0; min-width: 0; white-space: normal; padding: 0.55rem 0.25rem; min-height: 44px; font-size: 0.72rem; }
  .pu-n { margin-left: 0.25rem; }
  .pu-row.pu-hd { display: none; }
  .pu-run .pu-row, .pu-rec .pu-row, .pu-his .pu-row {
    grid-template-columns: minmax(0, 1fr);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 0 0 0.5rem;
    padding: 0.6rem 0.75rem;
  }
  .pu-item { grid-template-columns: minmax(0, 1fr); }
  .pu-pcard { grid-template-columns: minmax(0, 1fr); }
  .pu-acts { justify-content: stretch; }
  #punish .pu-acts button { flex: 1 1 40%; min-height: 44px; }
  .pu-hint { text-align: left; }
  .pu-filters > * { flex: 1 1 40%; }
  .pu-filters label { flex-direction: column; align-items: stretch; gap: 0.1rem; }
  #punish select, #punish input[type=date] { min-height: 40px; width: 100%; }
  #punish .pu-find input, #punish .pu-find button { min-height: 44px; }
  #punish .pu-filters button { min-height: 40px; }
  #punish .pu-back { min-height: 40px; }
  dialog.pu-dlg button, dialog.pu-dlg select { min-height: 44px; }
  dialog.pu-dlg .acts button { flex: 1 1 40%; }
}

@media (max-width: 480px) {
  .header-bar { padding: 0.45rem 0.5rem; gap: 0.4rem; }
  .header-left { gap: 0.4rem; min-width: 0; }
  .brand span { display: none; }
  .breadcrumb { font-size: 0.8rem; padding-left: 0.25rem; }
  .header-right { gap: 0.4rem; }
  .env-pill { display: none; }
  .user-name { display: none; }
  .page-wrap { padding: 0.75rem 0.5rem 3rem; }
  .kpi-grid { grid-template-columns: 1fr; gap: 0.6rem; }
  .kpi-val { font-size: 1.45rem; }
  input.search { min-width: 0; width: 100%; }
  .search-wrap { width: 100%; }
}

// Management merged component styling in unified staff theme
.tag {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  font-size: 0.72rem;
  line-height: 1.35;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--panel-soft);
  white-space: nowrap;
}
.tag.locked, .tag.danger {
  color: var(--bad);
  border-color: rgba(224, 112, 112, 0.45);
  background: rgba(224, 112, 112, 0.12);
}
.tag.muted {
  color: var(--text-dim);
  border-color: var(--border-subtle);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.stat-box {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
}
.stat-box strong {
  font-family: var(--title);
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1.2;
}
.stat-box .muted {
  font-size: 0.74rem;
  color: var(--text-dim);
}

.manage-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.manage-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.manage-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
}
.manage-form .check-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text);
}
.manage-form .check-row input[type=checkbox] {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  margin: 0;
}
.manage-form input:not([type=checkbox]):not([type=radio]),
.manage-form select,
.manage-form textarea {
  width: 100%;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-bright);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  box-sizing: border-box;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.manage-form input:not([type=checkbox]):not([type=radio]):focus,
.manage-form select:focus,
.manage-form textarea:focus {
  outline: none;
  border-color: var(--gold-border-strong);
  box-shadow: 0 0 0 2px var(--gold-fill-hover);
  background: var(--panel-elevated);
}
.manage-form input:disabled,
.manage-form select:disabled,
.manage-form textarea:disabled,
.manage-form input[readonly] {
  opacity: 0.6;
  background: var(--panel);
  cursor: not-allowed;
}
.manage-form textarea {
  resize: vertical;
  min-height: 60px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

button.mini, .btn.mini {
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  line-height: 1.4;
}
button.danger, .btn.danger {
  color: var(--bad);
  border-color: rgba(224, 112, 112, 0.5);
  background: rgba(224, 112, 112, 0.1);
}
button.danger:hover, .btn.danger:hover {
  background: rgba(224, 112, 112, 0.22);
}

.ticket-reply-box {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-elevated);
}
.ticket-reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.ticket-reply-head h4 {
  margin: 0;
  font-family: var(--title);
  color: var(--gold);
  font-size: 0.92rem;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.compact-table table th, .compact-table table td {
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
}

tr.selected {
  background: var(--gold-fill-hover);
  border-left: 3px solid var(--gold);
}

.empty-row {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.live-builds-list {
  display: flex;
  flex-direction: column;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--text-bright);
  color: var(--ground);
  font-family: var(--ui);
  font-weight: 500;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.hidden {
  display: none !important;
}

:root {
  color-scheme: dark;
  --series-1: #d9b25a;
  --series-2: #6ba4d9;
  --series-3: #8fd3a0;
  --series-4: #e0897f;
  --series-5: #c590d9;
  --series-6: #e8a860;
  --series-7: #5ec4b6;
  --series-8: #d4789c;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --series-1: #8c3b28;
    --series-2: #245b8a;
    --series-3: #2d6b38;
    --series-4: #8a571d;
    --series-5: #653b82;
    --series-6: #a05a18;
    --series-7: #186b68;
    --series-8: #8f2d5e;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --series-1: #8c3b28;
  --series-2: #245b8a;
  --series-3: #2d6b38;
  --series-4: #8a571d;
  --series-5: #653b82;
  --series-6: #a05a18;
  --series-7: #186b68;
  --series-8: #8f2d5e;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --series-1: #d9b25a;
  --series-2: #6ba4d9;
  --series-3: #8fd3a0;
  --series-4: #e0897f;
  --series-5: #c590d9;
  --series-6: #e8a860;
  --series-7: #5ec4b6;
  --series-8: #d4789c;
}

.explorer-root {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  width: 100%;
}

.explorer-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-dim);
  padding: 2px 0 6px 0;
}

.bc-crumb {
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--gold);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-transform: none;
  letter-spacing: normal;
}

.bc-crumb:hover {
  background: var(--gold-fill);
  color: var(--accent-hover);
}

.bc-crumb.current {
  color: var(--text-bright);
  font-weight: 600;
  cursor: default;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
}

.bc-crumb.current:hover {
  background: none;
}

.bc-sep {
  color: var(--text-faint);
  user-select: none;
}

.explorer-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}

.explorer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-3);
}

.explorer-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 130px;
}

.explorer-field.grow {
  flex: 1 1 200px;
}

.explorer-label {
  font-family: var(--ui);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.explorer-select,
.explorer-input {
  font-family: var(--ui);
  font-size: 0.88rem;
  color: var(--text-bright);
  background: var(--panel-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  height: 32px;
  box-sizing: border-box;
  outline: none;
}

.explorer-select:focus,
.explorer-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-fill);
}

.explorer-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.explorer-metric-help {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 2px;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  background: var(--panel-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  max-width: 100%;
}

.btn-segment {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-segment:hover {
  color: var(--text-bright);
  background: var(--gold-fill);
}

.btn-segment.active {
  background: var(--gold);
  color: var(--ground);
  font-weight: 600;
}

.date-presets {
  display: inline-flex;
  gap: 4px;
}

.btn-preset {
  background: var(--panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  height: 32px;
  box-sizing: border-box;
}

.btn-preset:hover {
  color: var(--text-bright);
  border-color: var(--border);
}

.btn-preset.active {
  background: var(--gold-fill-hover);
  border-color: var(--gold);
  color: var(--gold);
}

.date-inputs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-inputs span {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.filter-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  position: relative;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  background: var(--gold-fill);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-bright);
  padding: 2px 8px 2px 10px;
  gap: 6px;
}

.chip-label {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chip-label:hover {
  text-decoration: underline;
}

.chip-dim {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.chip-val {
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-bright);
}

.chip-remove {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip-remove:hover {
  color: var(--bad);
}

.btn-add-filter {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-full);
  color: var(--text-dim);
  font-family: var(--ui);
  font-size: 0.8rem;
  padding: 3px 10px;
  cursor: pointer;
}

.btn-add-filter:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.filter-popover {
  position: absolute;
  z-index: 1000;
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: var(--sp-3);
  min-width: 240px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.filter-popover-title {
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-bright);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

.filter-values-scroll {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.filter-value-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  text-transform: none;
  letter-spacing: normal;
}

.filter-value-item input[type="checkbox"] {
  accent-color: var(--gold);
  cursor: pointer;
}

.filter-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}

.explorer-result {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
  min-height: 32px;
}

.result-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 180px;
  box-sizing: border-box;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  overflow: visible;
  font-family: var(--ui);
}

.chart-grid-line {
  stroke: var(--border-subtle);
  stroke-dasharray: 3 3;
  stroke-width: 1;
}

.chart-zero-line {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.chart-axis-text {
  fill: var(--text-dim);
  font-size: 11px;
  text-transform: none;
}

.chart-label {
  fill: var(--text-bright);
  font-size: 12px;
  text-transform: none;
}

.chart-val-text {
  fill: var(--text-dim);
  font-size: 11px;
  font-feature-settings: 'tnum';
  text-transform: none;
}

.chart-faint {
  fill: var(--text-faint);
  font-size: 11px;
  font-style: italic;
}

.chart-drillable {
  cursor: pointer;
  outline: none;
}

.chart-drillable:hover .chart-bar,
.chart-drillable:focus .chart-bar {
  filter: brightness(1.2);
  stroke: var(--gold);
  stroke-width: 1.5;
}

.chart-drillable:hover .chart-label,
.chart-drillable:focus .chart-label {
  fill: var(--gold);
  font-weight: 600;
}

.chart-marker {
  cursor: pointer;
  transition: r 0.15s ease;
  outline: none;
}

.chart-marker:hover,
.chart-marker:focus {
  r: 5px;
  stroke: var(--text-bright);
  stroke-width: 1.5;
}

.chart-marker-hidden {
  cursor: help;
  outline: none;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--ui);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
}

.legend-label {
  text-transform: none;
  letter-spacing: normal;
}

.legend-btn:hover,
.legend-btn:focus {
  background: var(--gold-fill);
  color: var(--text-bright);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.percentile-key {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.pct-key-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pct-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.result-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: var(--sp-2);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.result-note-item {
  color: var(--warn);
}

.result-stamp {
  margin-left: auto;
}

.chart-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 12px;
  width: 100%;
  box-sizing: border-box;
}

.skeleton-line {
  height: 20px;
  background: linear-gradient(90deg, var(--panel-soft) 25%, var(--panel-elevated) 50%, var(--panel-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.chart-error-box {
  padding: var(--sp-4);
  background: rgba(224, 137, 127, 0.12);
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  color: var(--text-bright);
  font-size: 0.88rem;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--ui);
  font-size: 0.78rem;
  color: var(--text-bright);
  box-shadow: var(--shadow);
  white-space: nowrap;
  transform: translate(-50%, -120%);
}

.preset-chart-root {
  width: 100%;
}

.table-scroll {
  color-scheme: inherit;
}

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

.result-table th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  user-select: none;
}

.result-table th.num {
  text-align: right;
}

.result-table th.sortable {
  cursor: pointer;
}

.result-table th.sortable:hover {
  color: var(--gold);
}

.result-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  text-transform: none;
}

.result-table td.num {
  text-align: right;
  font-feature-settings: 'tnum';
}

.result-table tr.clickable {
  cursor: pointer;
}

.result-table tr.clickable:hover {
  background: var(--gold-fill-hover);
}

@media (max-width: 600px) {
  .explorer-toolbar {
    gap: 10px;
    padding: 10px;
  }
  .explorer-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .explorer-field {
    width: 100%;
    min-width: 0;
    flex: none;
    gap: 4px;
  }
  .explorer-field.grow {
    flex: none;
    width: 100%;
  }
  .filter-chips-wrap {
    min-height: 0;
  }
  .date-inputs {
    flex-direction: column;
    align-items: stretch;
  }
  .segmented-control {
    width: 100%;
    flex-wrap: wrap;
  }
  .btn-segment {
    flex: 1 1 auto;
    text-align: center;
    padding: 5px 8px;
  }
}

@media (max-width: 480px) {
  .btn-segment {
    min-width: calc(33.333% - 4px);
    font-size: 0.78rem;
    padding: 6px 6px;
  }
}

/* Stage 3: Records tier and timeline styling */
.records-root {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
}

.records-audit-notice {
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}

.records-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.records-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.records-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.records-field.grow {
  flex: 1 1 auto;
}

.records-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pid-input {
  width: 110px;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.records-select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--ui);
  font-size: 0.84rem;
}

.range-inputs-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.range-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.range-item span {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.range-input {
  width: 72px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.btn-list-records {
  background: var(--gold);
  color: #1a120c;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--ui);
  font-size: 0.84rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-list-records:hover {
  opacity: 0.9;
}

.records-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
  margin-top: 4px;
}

.records-more-note {
  color: var(--warn);
  font-weight: 500;
}

.records-count {
  color: var(--text-dim);
}

.records-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 0.88rem;
}

.records-table th,
.records-table td {
  white-space: nowrap;
}

.records-table .col-extra {
  display: none;
}

.records-table.show-more-cols .col-extra {
  display: table-cell;
}

.chip-pid {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  color: var(--gold);
  cursor: pointer;
  margin: 1px 2px;
  vertical-align: middle;
}

.chip-pid:hover,
.chip-pid:focus {
  background: var(--gold-fill);
  border-color: var(--gold);
  color: var(--text-bright);
}

.timeline-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
}

.timeline-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 14px;
  background: var(--panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
}

.timeline-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.timeline-summary-label {
  color: var(--text-dim);
}

.timeline-summary-val {
  color: var(--text-bright);
  font-weight: 500;
}

.timeline-members-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.track-container {
  width: 100%;
  background: var(--panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-sizing: border-box;
}

.track-svg {
  width: 100%;
  height: 64px;
  overflow: visible;
  display: block;
}

.track-axis {
  stroke: var(--border-subtle);
  stroke-width: 2;
}

.track-tick {
  stroke: var(--border);
  stroke-width: 1;
}

.track-tick-text {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-dim);
}

.track-marker {
  cursor: pointer;
  outline: none;
  transition: transform 0.1s ease;
}

.track-marker:hover,
.track-marker:focus {
  stroke: var(--text-bright);
  stroke-width: 1.5;
}

.track-guide {
  stroke: var(--text-dim);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  pointer-events: none;
}

.timeline-events-wrap {
  width: 100%;
  max-height: 480px;
  overflow-y: auto;
}

.event-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-dungeon {
  background: rgba(184, 134, 43, 0.2);
  color: var(--gold);
}

.badge-economy {
  background: rgba(143, 211, 160, 0.2);
  color: var(--ok);
}

.badge-session {
  background: rgba(138, 180, 248, 0.2);
  color: #8ab4f8;
}

.event-coords {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.bin-click-popover {
  position: absolute;
  z-index: 1050;
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: var(--shadow-dropdown);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--ui);
  min-width: 170px;
}

.bin-popover-title {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 2px;
}

@keyframes recordsHighlight {
  0% {
    box-shadow: 0 0 0 3px var(--gold);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.panel-card.panel-highlight {
  animation: recordsHighlight 1.6s ease-out;
}

@media (max-width: 600px) {
  .records-toolbar {
    padding: 10px;
    gap: 10px;
  }
  .records-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .records-field {
    width: 100%;
  }
  .range-inputs-group {
    flex-direction: column;
    align-items: stretch;
  }
  .pid-input {
    width: 100%;
  }
}

/* Stage 4: heat maps, compare and funnels */
.heatmap-block { margin: 4px 0 14px; }
.heatmap-title { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; }
.heatmap-scroll { overflow: auto; max-width: 100%; max-height: 520px; color-scheme: inherit; }
.heatmap-svg { display: block; }
.heat-tile { fill: var(--series-1); }
/* Stage 6: the terrain under the tiles, muted so the heat stays readable in both themes */
.heat-terrain { opacity: 0.5; image-rendering: pixelated; }
.heat-tile.heat-hidden { fill-opacity: 1; stroke: var(--border); stroke-width: 0.5; }
.heatmap-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.75rem; margin-top: 6px; }
.heat-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--series-1); }
.heat-swatch.heat-low { opacity: 0.2; }
.heat-swatch.heat-hidden-swatch { background: repeating-linear-gradient(45deg, var(--border-strong) 0 2px, transparent 2px 6px); border: 1px solid var(--border); }
.compare-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.compare-wrap { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); }
.compare-title { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; }
.funnel-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.funnel-steps-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.funnel-step-item { display: flex; align-items: center; gap: 4px; min-width: 0; }
.funnel-step-item .explorer-select { max-width: 220px; }
.funnel-step-n { font-size: 0.75rem; }
.funnel-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.funnel-result { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; grid-template-areas: 'label bar' 'num num'; gap: 2px 10px; align-items: center; }
.funnel-label { grid-area: label; font-size: 0.85rem; color: var(--text-bright); }
.funnel-bar-box { grid-area: bar; height: 14px; background: var(--panel-soft); border-radius: var(--radius-sm); overflow: hidden; }
.funnel-bar { height: 100%; background: var(--series-1); }
.funnel-bar.hidden-bar { background: repeating-linear-gradient(45deg, var(--border-strong) 0 2px, transparent 2px 6px); }
.funnel-num { grid-area: num; font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .funnel-row { grid-template-columns: 1fr; grid-template-areas: 'label' 'bar' 'num'; }
  .funnel-step-item .explorer-select { max-width: 100%; }
}

/* Stage 5: patch markers on line charts */
.chart-marker { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-marker:hover { stroke: var(--accent); stroke-width: 2; }

/* Stage 7: Insights (alerts, the weekly report, saved views, exploit leads) */
.insights-note { font-size: 0.78rem; margin: 0 0 8px; }
.alert-list, .view-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.alert-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 6px 8px; border-left: 3px solid var(--border-strong); background: var(--panel-soft); border-radius: var(--radius-sm); }
.alert-item.alert-up { border-left-color: var(--amber); }
.alert-item.alert-down { border-left-color: var(--accent); }
.alert-day { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: 0.8rem; }
.alert-patch { font-size: 0.75rem; color: var(--text-bright); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 0 6px; }
.weekly-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.weekly-h { font-size: 0.85rem; margin: 12px 0 6px; color: var(--text-bright); }
.view-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.view-badge { font-size: 0.7rem; border: 1px solid var(--gold-border); border-radius: var(--radius-sm); padding: 0 6px; color: var(--gold); }
.save-view-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }
.save-view-form .explorer-input { min-width: 0; flex: 1 1 160px; }
.save-view-check { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; }
.save-view-msg { font-size: 0.78rem; }
.lead-timeline { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }

/* Analytics stage 8: Server growth (analytics/growth.js) */
.growth-controls { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.growth-kpis { margin-bottom: var(--sp-3); }
.growth-notes p { margin: 0 0 var(--sp-1); font-size: 0.82rem; }
.growth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--sp-4); margin: var(--sp-3) 0; }
.growth-chart { min-width: 0; }
.growth-chart-title { margin: 0; font-size: 0.92rem; color: var(--text-bright); }
.growth-chart-sub { margin: 2px 0 var(--sp-2); font-size: 0.78rem; }
.growth-chart-box { min-width: 0; }
.growth-short { fill: var(--text-faint); fill-opacity: 0.08; }
.growth-cohorts { margin-top: var(--sp-3); }
.growth-details { margin-top: var(--sp-3); }
.growth-details summary { cursor: pointer; color: var(--text-dim); font-size: 0.85rem; }
.growth-gaps { margin-top: var(--sp-3); font-size: 0.8rem; }
