/*
 * ITTS TicketSystem -- Design System
 * Blazor Server adaptation of the design prototype.
 *
 * Structure:
 *   1. Design tokens (CSS custom properties)
 *   2. Dark theme (default)
 *   3. Accent presets
 *   4. Density / radius variants
 *   5. Base reset
 *   6. App shell (sidebar, main, topbar)
 *   7. Navigation
 *   8. Buttons
 *   9. Cards
 *  10. Badges
 *  11. Tables
 *  12. Inputs
 *  13. KPI cards
 *  14. Utilities
 *  15. Blazor-specific (error UI, reconnect)
 *  16. Scrollbar
 */

/* ==========================================================
   1. DESIGN TOKENS
   ========================================================== */
:root {
  /* Canvas */
  --bg: oklch(0.985 0.004 90);
  --surface: #ffffff;
  --surface-2: oklch(0.975 0.005 90);
  --surface-3: oklch(0.955 0.006 90);

  /* Ink */
  --ink: oklch(0.18 0.012 260);
  --ink-2: oklch(0.36 0.011 260);
  --ink-3: oklch(0.55 0.010 260);
  --ink-4: oklch(0.72 0.008 260);

  /* Lines */
  --line: oklch(0.92 0.006 90);
  --line-2: oklch(0.88 0.008 90);
  --line-strong: oklch(0.80 0.010 90);

  /* Accents (fallback values; indigo preset applied below) */
  --accent: oklch(0.70 0.17 55);
  --accent-ink: oklch(0.30 0.12 50);
  --accent-wash: oklch(0.97 0.03 75);
  --accent-wash-2: oklch(0.93 0.06 75);

  /* Signals */
  --danger: oklch(0.58 0.18 25);
  --danger-wash: oklch(0.96 0.025 25);
  --warn: oklch(0.70 0.15 80);
  --warn-wash: oklch(0.97 0.03 85);
  --ok: oklch(0.62 0.12 155);
  --ok-wash: oklch(0.96 0.02 155);
  --info: oklch(0.60 0.12 240);
  --info-wash: oklch(0.96 0.02 240);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 0 oklch(0.88 0.01 90 / 0.5);
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 12px rgba(20, 20, 30, .04);
  --shadow-lg: 0 12px 32px rgba(20, 20, 30, .10), 0 2px 6px rgba(20, 20, 30, .06);

  /* Typography */
  --font-sans: Arial, Helvetica, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Courier New", ui-monospace, monospace;
  --font-serif: Georgia, "Times New Roman", ui-serif, serif;

  /* Layout */
  --sidebar-w: 232px;
  --sidebar-w-compact: 60px;
  --topbar-h: 56px;
  --row-h: 58px;
}

/* ==========================================================
   2. DARK THEME (default)
   ========================================================== */
[data-theme="dark"] {
  --bg: oklch(0.155 0.008 260);
  --surface: oklch(0.195 0.009 260);
  --surface-2: oklch(0.220 0.010 260);
  --surface-3: oklch(0.250 0.011 260);

  --ink: oklch(0.96 0.006 90);
  --ink-2: oklch(0.80 0.008 90);
  --ink-3: oklch(0.62 0.010 90);
  --ink-4: oklch(0.48 0.010 90);

  --line: oklch(0.28 0.010 260);
  --line-2: oklch(0.33 0.011 260);
  --line-strong: oklch(0.40 0.012 260);

  --accent-wash: oklch(0.30 0.06 75);
  --accent-wash-2: oklch(0.38 0.10 75);

  --danger-wash: oklch(0.30 0.08 25);
  --warn-wash: oklch(0.32 0.09 80);
  --ok-wash: oklch(0.30 0.06 155);
  --info-wash: oklch(0.30 0.06 240);

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .30);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .30);
}

/* ==========================================================
   3. ACCENT PRESETS
   ========================================================== */

/* Indigo (default) */
[data-accent="indigo"] {
  --accent: oklch(0.55 0.18 275);
  --accent-ink: oklch(0.35 0.14 275);
  --accent-wash: oklch(0.97 0.02 275);
  --accent-wash-2: oklch(0.92 0.05 275);
}

/* Amber */
[data-accent="amber"] {
  --accent: oklch(0.72 0.17 55);
  --accent-ink: oklch(0.32 0.12 50);
  --accent-wash: oklch(0.975 0.03 75);
  --accent-wash-2: oklch(0.93 0.07 75);
}

/* Emerald */
[data-accent="emerald"] {
  --accent: oklch(0.62 0.15 160);
  --accent-ink: oklch(0.38 0.11 160);
  --accent-wash: oklch(0.97 0.02 155);
  --accent-wash-2: oklch(0.92 0.05 155);
}

/* Rose */
[data-accent="rose"] {
  --accent: oklch(0.64 0.19 15);
  --accent-ink: oklch(0.38 0.14 15);
  --accent-wash: oklch(0.97 0.02 15);
  --accent-wash-2: oklch(0.93 0.06 15);
}

/* Ink */
[data-accent="ink"] {
  --accent: oklch(0.22 0.015 260);
  --accent-ink: oklch(0.10 0.01 260);
  --accent-wash: oklch(0.965 0.005 260);
  --accent-wash-2: oklch(0.92 0.008 260);
}

/* -- Dark theme accent overrides (MUST come after presets for specificity) -- */
[data-theme="dark"][data-accent="indigo"] {
  --accent-ink: oklch(0.78 0.12 275);
  --accent-wash: oklch(0.25 0.06 275);
  --accent-wash-2: oklch(0.32 0.09 275);
}
[data-theme="dark"][data-accent="amber"] {
  --accent-ink: oklch(0.82 0.10 50);
  --accent-wash: oklch(0.28 0.06 55);
  --accent-wash-2: oklch(0.35 0.09 55);
}
[data-theme="dark"][data-accent="emerald"] {
  --accent-ink: oklch(0.78 0.10 160);
  --accent-wash: oklch(0.25 0.05 155);
  --accent-wash-2: oklch(0.32 0.08 155);
}
[data-theme="dark"][data-accent="rose"] {
  --accent-ink: oklch(0.80 0.12 15);
  --accent-wash: oklch(0.28 0.06 15);
  --accent-wash-2: oklch(0.35 0.09 15);
}
[data-theme="dark"][data-accent="ink"] {
  --accent: oklch(0.92 0.01 90);
  --accent-ink: oklch(0.98 0.01 90);
  --accent-wash: oklch(0.30 0.01 260);
  --accent-wash-2: oklch(0.45 0.02 260);
}

/* ==========================================================
   4. DENSITY / RADIUS VARIANTS
   ========================================================== */

[data-density="compact"] {
  --row-h: 46px;
}

[data-radius="sharp"] {
  --radius-sm: 2px;
  --radius: 4px;
  --radius-lg: 6px;
}

/* ==========================================================
   5. BASE RESET
   ========================================================== */

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================
   6. APP SHELL
   ========================================================== */

/* Grid layout --
   In Blazor Server the sidebar is rendered as a fixed-position element
   so the main content uses margin-left rather than a CSS grid column. */
.app {
  min-height: 100vh;
}

/* -- Sidebar (fixed in Blazor) -- */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px 10px;
  gap: 14px;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
}

.app[data-sidebar="compact"] .sidebar {
  width: var(--sidebar-w-compact);
}

/* -- Main area -- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

.app[data-sidebar="compact"] .main {
  margin-left: var(--sidebar-w-compact);
}

/* -- Topbar -- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.crumbs .sep { color: var(--ink-4); }
.crumbs .cur { color: var(--ink); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* -- Page content area -- */
.page {
  padding: 26px 32px 60px 32px;
  max-width: 1440px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-sub {
  color: var(--ink-3);
  font-size: 13.5px;
  margin-top: 4px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================
   7. NAVIGATION
   ========================================================== */

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Nav search */
.nav-search {
  margin: 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 12.5px;
  cursor: pointer;
}

.nav-search:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.nav-search .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink-3);
}

/* Nav groups */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-label {
  padding: 12px 10px 4px 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Nav items -- works with <a href> in Blazor */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
  position: relative;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* Active state: aria-current for Blazor NavLink, .active as fallback */
.nav-item[aria-current="page"],
.nav-item.active {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.nav-item .nav-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: .85;
}

.nav-item[aria-current="page"] .nav-ico,
.nav-item.active .nav-ico {
  opacity: 1;
  color: var(--accent);
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
}

.nav-dot {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-wash-2);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-name {
  font-size: 12.5px;
  font-weight: 500;
}

.user-role {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Compact sidebar -- hide labels, text, counts.
   Supports both the data attribute on .sidebar itself
   and the data attribute on the .app wrapper. */
.sidebar[data-compact="true"] .brand-name,
.sidebar[data-compact="true"] .brand-sub,
.sidebar[data-compact="true"] .nav-label,
.sidebar[data-compact="true"] .nav-item span:not(.nav-ico-wrap),
.sidebar[data-compact="true"] .nav-search span,
.sidebar[data-compact="true"] .nav-count,
.sidebar[data-compact="true"] .user-info,
.app[data-sidebar="compact"] .brand-name,
.app[data-sidebar="compact"] .brand-sub,
.app[data-sidebar="compact"] .nav-label,
.app[data-sidebar="compact"] .nav-item span:not(.nav-ico-wrap),
.app[data-sidebar="compact"] .nav-search span,
.app[data-sidebar="compact"] .nav-count,
.app[data-sidebar="compact"] .user-info {
  display: none;
}

.sidebar[data-compact="true"] .nav-item,
.app[data-sidebar="compact"] .nav-item {
  justify-content: center;
}

.sidebar[data-compact="true"] .nav-search,
.app[data-sidebar="compact"] .nav-search {
  justify-content: center;
  padding: 7px;
}

/* ==========================================================
   8. BUTTONS
   ========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(0.5px);
}

/* Primary */
.btn[data-variant="primary"],
.btn.btn-primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.btn[data-variant="primary"]:hover,
.btn.btn-primary:hover {
  background: oklch(from var(--ink) calc(l + 0.06) c h);
}

/* Accent */
.btn[data-variant="accent"],
.btn.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

[data-theme="dark"] .btn[data-variant="accent"],
[data-theme="dark"] .btn.btn-accent {
  color: var(--ink);
}

/* Ghost */
.btn[data-variant="ghost"],
.btn.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn[data-variant="ghost"]:hover,
.btn.btn-ghost:hover {
  background: var(--surface-2);
}

/* Button icon */
.btn-ico {
  width: 14px;
  height: 14px;
}

/* Keyboard hint inside button */
.btn .kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--ink-3);
  margin-left: 2px;
}

.btn[data-variant="primary"] .kbd,
.btn[data-variant="accent"] .kbd,
.btn.btn-primary .kbd,
.btn.btn-accent .kbd {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .2);
  color: rgba(255, 255, 255, .75);
}

/* Icon-only button */
.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  cursor: pointer;
  border: 0;
  background: transparent;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ==========================================================
   9. CARDS
   ========================================================== */

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

.card-hd {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.card-hd h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}

.card-hd .eyebrow {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card-bd {
  padding: 14px 16px;
}

/* ==========================================================
   10. BADGES
   ========================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge[data-tone="danger"] {
  background: var(--danger-wash);
  border-color: color-mix(in oklab, var(--danger) 40%, transparent);
  color: var(--danger);
}

.badge[data-tone="warn"] {
  background: var(--warn-wash);
  border-color: color-mix(in oklab, var(--warn) 40%, transparent);
  color: oklch(0.45 0.12 70);
}

.badge[data-tone="ok"] {
  background: var(--ok-wash);
  border-color: color-mix(in oklab, var(--ok) 40%, transparent);
  color: oklch(0.38 0.10 155);
}

.badge[data-tone="info"] {
  background: var(--info-wash);
  border-color: color-mix(in oklab, var(--info) 40%, transparent);
  color: oklch(0.40 0.11 240);
}

.badge[data-tone="accent"] {
  background: var(--accent-wash);
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  color: var(--accent-ink);
}

/* Dark mode: wash backgrounds are L≈0.30, so text needs to be light (L≈0.78+) */
[data-theme="dark"] .badge[data-tone="danger"] {
  color: oklch(0.80 0.14 25);
}
[data-theme="dark"] .badge[data-tone="warn"] {
  color: oklch(0.84 0.12 70);
}
[data-theme="dark"] .badge[data-tone="ok"] {
  color: oklch(0.80 0.12 155);
}
[data-theme="dark"] .badge[data-tone="info"] {
  color: oklch(0.80 0.10 240);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ==========================================================
   11. TABLES
   ========================================================== */

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

.tbl th {
  text-align: left;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 500;
}

.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.tbl tr:hover td {
  background: var(--surface-2);
}

/* ==========================================================
   12. INPUTS
   ========================================================== */

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

/* Field layout (form groups) */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ==========================================================
   13. KPI CARDS
   ========================================================== */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px 16px;
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
}

.kpi-value .n {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-value .u {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-sans);
}

.kpi-delta {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-delta[data-dir="up"]   { color: var(--danger); }
.kpi-delta[data-dir="down"] { color: var(--ok); }

.kpi-spark {
  height: 28px;
  margin-top: 4px;
}

/* ==========================================================
   14. UTILITY CLASSES
   ========================================================== */

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "ss01";
}

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

.spacer {
  flex: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row.gap-sm  { gap: 6px; }
.row.wrap    { flex-wrap: wrap; }

.hairline {
  height: 1px;
  background: var(--line);
}

.grow {
  flex: 1;
}

.tight {
  letter-spacing: -0.01em;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.segmented button {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-2);
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--ink);
}

/* Filter chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  color: var(--ink-2);
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

/* Split layouts */
.split-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.split-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Activity feed */
.activity {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-ico {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.activity .when {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.activity .who {
  font-weight: 500;
}

/* Modal (generic) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: color-mix(in oklab, var(--ink) 40%, transparent);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
}

.modal {
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-hd {
  position: sticky;
  top: 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.modal-hd h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.modal-bd {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-label {
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.section-label::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* Mandanten cards */
.mandanten-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.mandant-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.mandant-hd {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mandant-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid var(--line);
}

.mandant-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mandant-meta .m-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mandant-rate {
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
}

.mandant-rate .val {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
}

.mandant-rate .lbl {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-sans);
}

/* Time bars (mini chart) */
.time-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 120px;
  padding: 6px 0;
}

.time-bars .col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.time-bars .bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.time-bars .bar {
  width: 100%;
  background: var(--surface-3);
  border-radius: 3px 3px 0 0;
  border-top: 3px solid var(--accent);
}

.time-bars .col[data-today="true"] .bar {
  background: var(--accent-wash-2);
}

.time-bars .label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
}

/* Spark area (mini inline chart) */
.area-spark {
  width: 100%;
  height: 54px;
}

/* ==========================================================
   15. BLAZOR-SPECIFIC
   ========================================================== */

/* Blazor error UI */
#blazor-error-ui {
  background: var(--danger-wash);
  border-top: 2px solid var(--danger);
  color: var(--danger);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 12px 22px;
  font-size: 13px;
  font-family: var(--font-sans);
  display: none;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  margin-left: 16px;
  padding: 4px 10px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
}

#blazor-error-ui .dismiss:hover {
  background: var(--danger);
  color: white;
}

/* Blazor reconnect modal */
#components-reconnect-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(4px);
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
  display: grid;
  place-items: center;
}

#components-reconnect-modal::after {
  content: "Verbindung wird wiederhergestellt...";
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink-2);
  padding: 20px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

#components-reconnect-modal.components-reconnect-failed::after {
  content: "Verbindung verloren. Bitte Seite neu laden.";
  border-color: var(--danger);
  color: var(--danger);
}

#components-reconnect-modal.components-reconnect-rejected::after {
  content: "Sitzung abgelaufen. Bitte Seite neu laden.";
  border-color: var(--warn);
  color: var(--warn);
}

/* Blazor validation messages */
.validation-message {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.invalid,
.input-validation-error {
  border-color: var(--danger) !important;
}

.valid,
.modified.valid {
  border-color: var(--ok);
}

/* ==========================================================
   16. SCROLLBAR
   ========================================================== */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 2px solid var(--bg);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
}

/* ==========================================================
   17. SIDEBAR ICON BUTTONS
   ========================================================== */

.sidebar .icon-btn { color: var(--ink-3); }
.sidebar .icon-btn:hover { color: var(--ink); background: var(--surface-3); }
.icon-btn svg { width: 16px; height: 16px; }

/* ==========================================================
   18. HERO HEADER
   ========================================================== */

.hero-head {
  position: relative;
  margin: -26px -32px 22px -32px;
  padding: 44px 32px 28px 32px;
  background:
    radial-gradient(1200px 300px at 12% -20%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(800px 260px at 96% -10%, color-mix(in oklab, var(--accent) 10%, transparent), transparent 60%),
    linear-gradient(180deg, color-mix(in oklab, var(--accent-wash) 40%, var(--bg)) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero-title {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1.1;
}
.hero-title em { font-style: italic; color: var(--accent-ink); font-weight: 500; }
.hero-sub { font-size: 14px; color: var(--ink-2); margin-top: 8px; max-width: 680px; }
.eyebrow-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink);
  padding: 4px 10px; border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line));
  margin-bottom: 12px;
}
.eyebrow-pill .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 50%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ==========================================================
   19. TICKET ROWS & SLA
   ========================================================== */

.ticket-row {
  display: grid;
  grid-template-columns: 4px auto 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.ticket-row:hover { background: var(--surface-2); }
.rail {
  width: 3px;
  height: 60%;
  min-height: 20px;
  border-radius: 2px;
  background: var(--line-2);
  align-self: center;
}
.ticket-row[data-urgency="overdue"] .rail { background: var(--danger); }
.ticket-row[data-urgency="soon"] .rail { background: var(--warn); }
.ticket-row[data-urgency="waiting"] .rail { background: var(--info); }
.t-id { font-family: var(--font-sans); font-size: 11.5px; color: var(--ink-3); }
.t-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.t-mandant { font-size: 11.5px; color: var(--ink-2); padding: 2px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }
.t-due { font-family: var(--font-sans); font-size: 11.5px; color: var(--ink-3); }
.ticket-row[data-urgency="overdue"] .t-due { color: var(--danger); font-weight: 500; }
.ticket-row[data-urgency="soon"] .t-due { color: var(--warn); }

.sla { display: flex; align-items: center; gap: 6px; font-family: var(--font-sans); font-size: 11px; }
.sla-bar { width: 60px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.sla-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), var(--warn) 60%, var(--danger)); border-radius: 2px; }

.list-head {
  display: grid;
  grid-template-columns: 4px auto 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--surface-2);
}

.t-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-wash-2);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ==========================================================
   20. TICKET DETAIL
   ========================================================== */

.detail-wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.detail-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-block h4 {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}

.side-block .side-bd {
  padding: 12px 14px;
}

.side-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.side-kv .side-label {
  color: var(--ink-3);
  font-size: 12px;
}

/* Thread / messages */
.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.msg[data-internal="true"] {
  background: var(--accent-wash);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
}

.msg-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.msg-bd {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.msg-bd a { color: var(--accent-ink); text-decoration: underline; }
.msg-bd p { margin: 0 0 8px 0; }
.msg-bd p:last-child { margin-bottom: 0; }
.msg-bd img { max-width: 100%; height: auto; border-radius: 4px; }
.msg-bd hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.msg-bd * { font-size: inherit !important; }

/* Composer */
.composer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.composer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.composer-tab {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.composer-tab[aria-selected="true"],
.composer-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.composer-bd {
  padding: 14px 16px;
}

.composer-bd textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
}

.composer-bd textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.composer-ft {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

/* Inline email content styling */
.email-body {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.55;
}

.email-body * { font-size: inherit !important; }
.email-body p { margin: 0 0 12px 0; }
.email-body p:last-child { margin-bottom: 0; }
.email-body a { color: var(--accent-ink); text-decoration: underline; }
.email-body img { max-width: 100%; height: auto; }
.email-body table { max-width: 100%; border-collapse: collapse; }
.email-body ul, .email-body ol { margin: 8px 0; padding-left: 24px; }
.email-body li { margin: 4px 0; }

/* Pasted images preview */
.paste-preview {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface-2);
}

/* Signature preview */
.sig-preview {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  opacity: 0.85;
  font-size: 12.5px;
}

/* Time entry in side block */
.time-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  position: relative;
}

.time-row:last-child { border-bottom: none; }

/* Edit form inside side block */
.side-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

.side-form .field-row {
  display: flex;
  gap: 8px;
}

.side-form .field-row > * { flex: 1; }

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
