/* CHIIRP Design System - Professional AI Agent Platform Theme */

/* Import Components */
@import url('components.css');

:root {
    /* HSL Component Values (for use with hsl() function and alpha) */
    --primary-component: 34 100% 51%;
    --primary-blue-component: 193 70% 39%;
    --primary-blue-hover: 193 75% 34%;
    --primary-blue-ring: 193 70% 39%;
    --secondary-component: 210 7% 97%;
    --muted-component: 210 7% 97%;
    /* Accent component is the canonical theme value. The head script in layout.html
       overrides this from cached settings before <body> parses, so all
       hsl(var(--accent-component)) usages recolor immediately. */
    --accent-component: 193 70% 39%;
    --success-component: 193 70% 39%;
    --warning-component: 43 96% 56%;
    --destructive-component: 0 84% 60%;
    --border-component: 210 7% 90%;
    --background-component: 0 0% 100%;
    --foreground-component: 210 11% 15%;
    --accent-light: 193 40% 92%;
    --accent-dark: 193 25% 12%;

    /* Sidebar text (defaults for dark accent backgrounds — head script overrides for light accents) */
    --sidebar-text: rgba(255, 255, 255, 0.8);
    --sidebar-text-active: #fff;
    --sidebar-text-muted: rgba(255, 255, 255, 0.4);
    --sidebar-text-faded: rgba(255, 255, 255, 0.55);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(255, 255, 255, 0.18);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-active-border: #fff;
    --sidebar-logo-filter: brightness(0) invert(1);

    /* Core Colors */
    --background: hsl(0, 0%, 100%);
    --foreground: hsl(210, 11%, 15%);

    /* Card System */
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(210, 11%, 15%);

    /* Popover */
    --popover: hsl(0, 0%, 100%);
    --popover-foreground: hsl(210, 11%, 15%);

    /* Primary - CHIIRP Orange */
    --primary: hsl(34, 100%, 51%);
    /* #ff9103 */
    --primary-foreground: hsl(0, 0%, 100%);
    --primary-hover: hsl(34, 95%, 46%);

    /* Secondary - Subtle Gray */
    --secondary: hsl(210, 7%, 97%);
    --secondary-foreground: hsl(210, 11%, 15%);

    /* Muted Elements */
    --muted: hsl(210, 7%, 97%);
    --muted-foreground: hsl(210, 6%, 46%);

    /* Accent - themeable. Most code uses hsl(var(--accent-component)) so we keep
       --accent as a real color for the few sites that use it directly (background,
       gradients). The head script in layout.html overrides --accent-component on
       page load — when that happens, hsl(var(--accent-component)) recolors but
       --accent itself does not (it's a static fallback color). For dynamic theming,
       prefer hsl(var(--accent-component)). */
    --accent: hsl(var(--accent-component));
    --accent-foreground: hsl(0, 0%, 100%);
    --accent-hover: hsl(193, 75%, 34%);

    /* Status Colors */
    --success: hsl(var(--success-component));
    --success-foreground: hsl(0, 0%, 100%);
    --warning: hsl(43, 96%, 56%);
    --warning-foreground: hsl(0, 0%, 100%);
    --destructive: hsl(0, 84%, 60%);
    --destructive-foreground: hsl(0, 0%, 100%);

    /* Borders & Inputs */
    --border: hsl(210, 7%, 90%);
    --input: hsl(210, 7%, 90%);
    --ring: hsl(34, 100%, 51%);
    /* CHIIRP Orange for focus rings */

    /* Agent Category Colors - Expanded palette with complementary colors */
    --agent-speed: hsl(34, 100%, 51%);
    /* CHIIRP Orange */
    --agent-nurture: hsl(193, 70%, 39%);
    /* CHIIRP Blue */
    --agent-review: hsl(250, 84%, 54%);
    /* Deep Purple */
    --agent-support: hsl(210, 100%, 56%);
    /* Rich Blue */
    --agent-concierge: hsl(335, 78%, 42%);
    /* Deep Rose */
    --agent-broadcast: hsl(193 70% 39%);
    /* Forest Green */
    --agent-voice: hsl(280, 65%, 50%);
    /* Purple for voice agents */

    /* Label Colors - Variety for better visual distinction */
    --label-blue: hsl(214, 95%, 93%);
    --label-blue-text: hsl(214, 95%, 45%);
    --label-green: hsl(143, 85%, 96%);
    --label-green-text: hsl(143, 85%, 41%);
    --label-yellow: hsl(48, 100%, 96%);
    --label-yellow-text: hsl(48, 100%, 47%);
    --label-purple: hsl(262, 87%, 96%);
    --label-purple-text: hsl(262, 87%, 47%);
    --label-pink: hsl(330, 81%, 96%);
    --label-pink-text: hsl(330, 81%, 47%);
    --label-red: hsl(0, 93%, 94%);
    --label-red-text: hsl(0, 93%, 50%);
    --label-orange: hsl(25, 95%, 95%);
    --label-orange-text: hsl(25, 95%, 53%);
    --label-teal: hsl(173, 80%, 96%);
    --label-teal-text: hsl(173, 80%, 36%);

    /* Channel Colors - Variety for different communication types */
    --channel-sms: hsl(214, 95%, 45%);
    --channel-email: hsl(143, 85%, 41%);
    --channel-voice: hsl(25, 95%, 53%);
    --channel-chat: hsl(262, 87%, 47%);
    --channel-video: hsl(330, 81%, 47%);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(34, 100%, 51%), hsl(193, 70%, 39%));
    --gradient-card: linear-gradient(145deg, hsl(0, 0%, 100%), hsl(34, 20%, 98%));
    --gradient-hero: linear-gradient(135deg, hsl(34, 100%, 51%) 0%, hsl(193, 70%, 39%) 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 hsl(210, 7%, 46%, 0.05);
    --shadow-md: 0 4px 6px -1px hsl(210, 7%, 46%, 0.1), 0 2px 4px -1px hsl(210, 7%, 46%, 0.06);
    --shadow-lg: 0 10px 15px -3px hsl(210, 7%, 46%, 0.1), 0 4px 6px -2px hsl(210, 7%, 46%, 0.05);
    --shadow-card: 0 1px 3px 0 hsl(210, 7%, 46%, 0.1), 0 1px 2px 0 hsl(210, 7%, 46%, 0.06);

    /* Animations */
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-exit: cubic-bezier(0.4, 0, 1, 1);         /* speeds up as it leaves */
    --ease-enter: cubic-bezier(0.2, 0.6, 0.2, 1);    /* fast start, soft landing */
    --ease-out: cubic-bezier(0, 0, 0.2, 1);          /* decelerating fade */
    --ease-pop: cubic-bezier(0.34, 1.45, 0.64, 1);   /* overshoots, then settles */

    --radius: 0.75rem;

    --sidebar-background: hsl(0, 0%, 98%);
    --sidebar-foreground: hsl(240, 5.3%, 26.1%);
    --sidebar-primary: hsl(240, 5.9%, 10%);
    --sidebar-primary-foreground: hsl(0, 0%, 98%);
    --sidebar-accent: hsl(240, 4.8%, 95.9%);
    --sidebar-accent-foreground: hsl(240, 5.9%, 10%);
    --sidebar-border: hsl(220, 13%, 91%);
    --sidebar-ring: hsl(217.2, 91.2%, 59.8%);
}

/* Dark Mode */
.dark {
    /* HSL Component Values (for use with hsl() function and alpha) */
    --primary-component: 217 91% 70%;
    --primary-blue-component: 193 78% 60%;
    --primary-blue-hover: 193 75% 55%;
    --primary-blue-ring: 193 70% 60%;
    --secondary-component: 210 11% 18%;
    --muted-component: 210 11% 18%;
    --accent-component: 193 78% 60%;
    --success-component: 193 78% 60%;
    --warning-component: 43 96% 70%;
    --destructive-component: 0 84% 68%;
    --border-component: 210 15% 32%;
    --background-component: 210 11% 7%;
    --foreground-component: 0 0% 100%;

    /* Core Colors */
    --background: hsl(210, 11%, 7%);
    --foreground: hsl(0, 0%, 100%);

    /* Card System */
    --card: hsl(210, 11%, 10%);
    --card-foreground: hsl(0, 0%, 100%);

    /* Popover */
    --popover: hsl(210, 11%, 10%);
    --popover-foreground: hsl(0, 0%, 100%);

    /* Primary */
    --primary: hsl(217, 91%, 70%);
    --primary-foreground: hsl(0, 0%, 100%);
    --primary-hover: hsl(217, 91%, 65%);

    /* Secondary */
    --secondary: hsl(210, 11%, 18%);
    --secondary-foreground: hsl(0, 0%, 100%);

    /* Muted Elements */
    --muted: hsl(210, 11%, 18%);
    --muted-foreground: hsl(210, 8%, 70%);

    /* Accent — flows through --accent-component (head script overrides this) */
    --accent: hsl(var(--accent-component));
    --accent-foreground: hsl(0, 0%, 100%);
    --accent-hover: hsl(193, 75%, 55%);

    /* Status Colors */
    --success: hsl(var(--success-component));
    --success-foreground: hsl(0, 0%, 100%);
    --warning: hsl(43, 96%, 70%);
    --warning-foreground: hsl(0, 0%, 100%);
    --destructive: hsl(0, 84%, 68%);
    --destructive-foreground: hsl(0, 0%, 100%);

    /* Borders & Inputs */
    --border: hsl(210, 15%, 30%);
    --input: hsl(210, 15%, 30%);
    --ring: hsl(217, 91%, 70%);

    /* Agent Category Colors */
    --agent-speed: hsl(34, 95%, 65%);
    --agent-nurture: hsl(193, 78%, 55%);
    --agent-review: hsl(250, 75%, 65%);
    --agent-support: hsl(210, 85%, 70%);
    --agent-concierge: hsl(335, 65%, 60%);
    --agent-broadcast: hsl(142, 60%, 60%);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(217, 91%, 65%), hsl(262, 83%, 65%));
    --gradient-card: linear-gradient(145deg, hsl(210, 11%, 9%), hsl(210, 11%, 11%));
    --gradient-hero: linear-gradient(135deg, hsl(217, 91%, 65%) 0%, hsl(262, 83%, 65%) 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 hsl(0, 0%, 0%, 0.3);
    --shadow-md: 0 4px 6px -1px hsl(0, 0%, 0%, 0.4), 0 2px 4px -1px hsl(0, 0%, 0%, 0.3);
    --shadow-lg: 0 10px 15px -3px hsl(0, 0%, 0%, 0.4), 0 4px 6px -2px hsl(0, 0%, 0%, 0.3);
    --shadow-card: 0 1px 3px 0 hsl(0, 0%, 0%, 0.4), 0 1px 2px 0 hsl(0, 0%, 0%, 0.3);

    /* Sidebar Dark Theme */
    --sidebar-background: hsl(210, 11%, 5%);
    --sidebar-foreground: hsl(0, 0%, 95%);
    --sidebar-primary: hsl(217, 91%, 65%);
    --sidebar-primary-foreground: hsl(0, 0%, 100%);
    --sidebar-accent: hsl(210, 11%, 12%);
    --sidebar-accent-foreground: hsl(0, 0%, 95%);
    --sidebar-border: hsl(210, 11%, 18%);
    --sidebar-ring: hsl(217, 91%, 65%);

    /* Label Colors - Dark theme variants */
    --label-blue: hsl(214, 50%, 25%);
    --label-blue-text: hsl(214, 95%, 70%);
    --label-green: hsl(143, 50%, 25%);
    --label-green-text: hsl(143, 85%, 65%);
    --label-yellow: hsl(48, 50%, 25%);
    --label-yellow-text: hsl(48, 100%, 70%);
    --label-purple: hsl(262, 50%, 25%);
    --label-purple-text: hsl(262, 87%, 70%);
    --label-pink: hsl(330, 50%, 25%);
    --label-pink-text: hsl(330, 81%, 70%);
    --label-red: hsl(0, 50%, 25%);
    --label-red-text: hsl(0, 93%, 70%);
    --label-orange: hsl(25, 50%, 25%);
    --label-orange-text: hsl(25, 95%, 70%);
    --label-teal: hsl(173, 50%, 25%);
    --label-teal-text: hsl(173, 80%, 60%);

    /* Channel Colors - Dark theme variants */
    --channel-sms: hsl(214, 95%, 70%);
    --channel-email: hsl(143, 85%, 65%);
    --channel-voice: hsl(25, 95%, 70%);
    --channel-chat: hsl(262, 87%, 70%);
    --channel-video: hsl(330, 81%, 70%);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
}
html {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.security-notice {
    background: hsl(var(--primary-blue-component) / .05);
    border: 1px solid rgba(72, 185, 175, 0.2);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: start;
    gap: 0.75rem;
}

.security-notice i {
    color: var(--chiirp-blue);
    font-size: 1rem;
    margin-top: 0.125rem;
}

.security-notice-content {
    flex: 1;
    font-size: 0.8rem;
    color: #6B7280;
}

.security-notice-content strong {
    color: #1A1A1A;
    font-weight: 600;
}

.auth-button {
    width: 100%;
    height: 3rem;
    padding: 0.75rem 1rem;
    background: hsl(var(--primary-blue-component));
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(72, 185, 175, 0.2);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-button:hover {
    background: hsl(var(--primary-blue-hover));
    box-shadow: 0 4px 8px rgba(72, 185, 175, 0.3);
    transform: translateY(-1px);
}

.auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Density Settings */
.density-compact {
    --spacing-unit: 0.75rem;
}

.density-comfortable {
    --spacing-unit: 1rem;
}

.density-spacious {
    --spacing-unit: 1.5rem;
}

.density-compact .space-y-4>*+* {
    margin-top: 0.5rem;
}

.density-spacious .space-y-4>*+* {
    margin-top: 1.5rem;
}

.density-compact .space-y-6>*+* {
    margin-top: 1rem;
}

.density-spacious .space-y-6>*+* {
    margin-top: 2rem;
}

/* Animation Settings */
.reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    /* Themed gradient shell — sidebar floats transparently on top */
    background: hsl(var(--accent-component));
}

/* Sidebar — themed accent shell, white-on-color text by default */
.sidebar {
    width: 16rem;
    background: transparent;
    border-right: none;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    height: 100vh;
    height: 100dvh; /* iOS Safari: 100vh runs under the bottom URL bar */
    position: fixed;
    left: 0;
    top: 0;
    overflow: hidden;
    z-index: 20;
}

/* Animation enabled only on user click — see toggleSidebarCollapse in main.js.
   The IIFE that restores collapsed state on load does NOT add .animate, so
   first paint is instant. */
.sidebar.animate {
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-container.animate .main-content {
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed (desktop) */
.sidebar.collapsed {
    width: 4.5rem;
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .sidebar-logo h1,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item > span:not(.notif-icon-wrap),
.sidebar.collapsed .powered-by-chiirp {
    display: none;
}

/* ── Collapsed rail: groups ──────────────────────────────────────────────
   Section headers are the only thing separating groups in the expanded rail,
   and the rule above hides them here — which left the collapsed rail as one
   undifferentiated column of icons. Redraw each boundary as a hairline, the
   same divider idiom .sidebar-footer already uses.

   `~` rather than `+`, and :has() rather than a bare sibling selector, so the
   line is drawn only between sections that ACTUALLY render rows: a section
   whose items are all user-hidden, or one gated off entirely (Agency/Admin),
   no longer leaves a stray divider behind it. Where :has() is unsupported the
   whole rule drops and the rail simply has no dividers — never wrong ones. */
.sidebar.collapsed .nav-section:has(.nav-item:not(.nav-hidden)) ~ .nav-section:has(.nav-item:not(.nav-hidden)) {
    border-top: 1px solid var(--sidebar-border);
    margin-top: 0.4rem;
    padding-top: 0.4rem;
}

/* A FOLDED section is the exception the divider rule needs. Its rows are
   display:none, so without this it collapsed to a 7px sliver that still drew
   its border — fold two sections and the rail showed a stack of horizontal
   lines with nothing between them, and no way to unfold from the rail.

   Show the section header instead, reduced to its chevron and centred: a
   right-pointing arrow that reads as "open this". The label is hidden but the
   button keeps its accessible name from .section-label's text. */
.sidebar.collapsed .nav-section.section-folded:has(.nav-item:not(.nav-hidden)) .nav-section-title {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.3rem 0;
    margin: 0;
    border-radius: 0.5rem;
}
.sidebar.collapsed .nav-section.section-folded:has(.nav-item:not(.nav-hidden)) .nav-section-title:hover {
    background: var(--sidebar-hover-bg);
}
.sidebar.collapsed .section-label {
    display: none;
}
/* Overrides the blanket `.sidebar.collapsed .section-chevron { display:none }`
   in sidebar-customize.css — for a folded section the chevron IS the control,
   so it is sized up from the 13px decorative caret it is in the expanded rail.
   The rotation is deliberately NOT set here: the existing
   `.nav-section.section-folded .section-chevron { transform: rotate(-90deg) }`
   already points it right, and inheriting that keeps the rail and the expanded
   header showing the same direction for the same state. */
.sidebar.collapsed .nav-section.section-folded:has(.nav-item:not(.nav-hidden)) .section-chevron {
    display: block !important;
    margin-left: 0;
    width: 16px;
    height: 16px;
    opacity: 1;
}

/* Pinned rows are clones sitting above every section and .pinned-head is
   hidden here too, so close the group — otherwise they read as part of Core. */
.sidebar.collapsed .pinned-block:not(.pinned-empty) {
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 0.4rem;
}

.sidebar.collapsed .account-details,
.sidebar.collapsed .account-chevron-well {
    display: none;
}

/* Switch-account reads as one more icon in the rail, so it has to BE one:
   same insets as .nav-section, same padding and radius as a collapsed
   .nav-item, same 20px glyph. It was a 12px icon in a full-width 49px box,
   which left it visibly smaller than everything under it and off the column
   the nav icons share. */
.sidebar.collapsed .account-switcher {
    /* 8px to match .nav-section, plus 4px on the right for the scrollbar
       gutter .sidebar-nav reserves — the switcher sits OUTSIDE that scroller,
       so without it the trigger runs 4px wider than every row beneath it. */
    padding: 0 12px 0 8px;
    margin: 0.5rem 0;
}

.sidebar.collapsed .account-switcher-trigger {
    padding: 0.35rem;
    justify-content: center;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0.5rem;
}

.sidebar.collapsed .account-switcher-trigger:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar.collapsed .account-info {
    justify-content: center;
    gap: 0;
}

/* The initials tile stands in for the whole switcher, centred on the icon column. */
.sidebar.collapsed .account-mark {
    margin: 0;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed #sidebar-logo-client {
    display: none !important;
}

/* When sidebar is collapsed AND the runtime JS has hidden #sidebar-logo-default
   (because a client logo loaded), force the default Chiirp icon back into view
   so the collapsed bar shows something. The wordmark stays hidden so just the
   icon fits in the 4.5rem strip. */
.sidebar.collapsed #sidebar-logo-default {
    display: flex !important;
    justify-content: center;
}

.sidebar.collapsed #sidebar-logo-default h1 {
    display: none;
}

.sidebar.collapsed #sidebar-logo-default img {
    height: 1.75rem;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.5rem;
}

.sidebar.collapsed .nav-item i,
.sidebar.collapsed .nav-item svg {
    margin: 0;
}

.sidebar.collapsed .nav-item.active {
    border-left: none;
}

.sidebar.collapsed .sidebar-footer .nav-item {
    justify-content: center;
}

.sidebar.collapsed .notif-icon-wrap {
    margin: 0 auto;
}

.app-container.sidebar-collapsed .main-content {
    margin-left: 4.5rem;
}

/* Pre-paint collapsed state (set by head script before <body> parses) — prevents
   one-frame flicker of the expanded layout on navigation. */
html.sidebar-pre-collapsed .sidebar {
    width: 4.5rem;
    padding: 1rem 0.5rem;
}

html.sidebar-pre-collapsed .app-container .main-content {
    margin-left: 4.5rem;
}

/* ── Collapse toggle — half-disc notch on the sidebar seam ───────────────
   Anchored to the rail's RIGHT EDGE at mid-height rather than to the top, so
   it cannot land on the logo row or the admin account switcher the way the
   old top-corner puck did (that one overlapped the collapsed switcher by 4px
   and, at z-index 30 over the rail's 20, swallowed its clicks).

   Between states the ONLY thing that changes is `left` — the rail width
   carries the notch — so there is one coordinate per side to keep in sync
   instead of the four the puck needed.

   Filled with the raw accent so it reads as the rail growing a thumb. There
   is deliberately NO border or inset highlight on its flat edge: any line
   there cuts the notch off from the sidebar it belongs to. The drop shadow is
   offset rightward so it falls on .main-content only, never back on the rail. */
.sidebar-collapse-btn {
    position: fixed;
    /* Dead centre of the viewport. This was 75%, clamped by a min() so the
       notch never drifted into the collapsed footer's stacked icon band on a
       short viewport. At 50% it sits mid-nav on every height there is, so the
       clamp went with it — one coordinate, no viewport arithmetic. */
    top: 50%;
    left: 16rem;
    transform: translateY(-50%);
    width: 15px;
    height: 46px;
    /* Flat against the rail, round into the panel. */
    border-radius: 0 23px 23px 0;
    background: hsl(var(--accent-component));
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
    color: var(--sidebar-text);
    box-shadow: 2px 0 6px -2px rgba(0, 0, 0, 0.35);
}

/* At rest the notch is a chip of accent parked on .main-content, right on
   the edge the eye tracks while reading — a blocker on a control that is only
   wanted at the moment it is reached for. Fade it out until the pointer is on
   the rail, on the notch itself (so the trip from one to the other never
   blanks it mid-reach), or the notch has keyboard focus.

   `:has()` rather than a sibling combinator: the button is written BEFORE
   .sidebar inside .app-container, and no combinator selects backwards.

   Gated on (hover: hover). A touch screen never fires the reveal, and an
   invisible button that still takes taps is a control nobody can find — so
   coarse pointers keep the notch permanently visible.

   Also gated on @supports selector(:has(a)), and the :has() reveal is its own
   rule: a selector list containing a selector the browser can't parse is
   dropped WHOLE (Firefox < 121, Safari < 15.4), so the hide would apply with
   no reveal and the notch would never appear. Without :has() the notch simply
   stays visible. */
@media (hover: hover) {
    @supports selector(:has(a)) {
        .sidebar-collapse-btn {
            opacity: 0;
            transition: opacity 0.15s ease;
        }
        .app-container:has(.sidebar:hover) .sidebar-collapse-btn {
            opacity: 1;
        }
        .sidebar-collapse-btn:hover,
        .sidebar-collapse-btn:focus-visible {
            opacity: 1;
        }
    }
}

/* The account switcher's dropdown opens out of the rail and across the notch,
   but it lives inside .sidebar, whose z-index of 20 caps it below the notch's
   30 whatever its own z-index says. Hovering the dropdown is hovering the rail,
   so the reveal above painted the notch over the menu, and even faded out the
   notch still took the clicks meant for the rows beneath it. Stand it down
   while the dropdown is open: `visibility` rather than opacity, because nothing
   else sets it (no specificity race with the reveal) and a hidden element takes
   no clicks. Outside the hover gate since touch screens show the notch always;
   its own rule, so a browser without :has() drops only this. */
.app-container:has(.account-switcher-dropdown.open) .sidebar-collapse-btn {
    visibility: hidden;
}

/* The same for the profile row's menu, which opens out of the rail too. */
.app-container:has(.sidebar-user-menu:not([hidden])) .sidebar-collapse-btn {
    visibility: hidden;
}

/* Brighten the notch itself. --sidebar-hover-bg is a white overlay meant for
   use ON the accent rail; over .main-content it reads as a translucent smear
   instead of a solid thumb. */
.sidebar-collapse-btn:hover {
    filter: brightness(1.18);
    color: var(--sidebar-text-active);
}

/* The notch bulges right, so optical centre is left of geometric centre. */
.sidebar-collapse-btn i,
.sidebar-collapse-btn svg {
    margin-left: -1px;
}

.app-container.sidebar-collapsed .sidebar-collapse-btn,
html.sidebar-pre-collapsed .sidebar-collapse-btn {
    left: 4.5rem;
}

/* `top` no longer differs between states, so it is out of the transition.
   Opacity is restated here because this rule out-specifies the hover-reveal
   transition above; without it the fade would cut out for the 250ms a collapse
   toggle holds .animate — exactly when the pointer is on the notch. */
.sidebar-collapse-btn.animate {
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
}

.app-container.sidebar-collapsed .sidebar-collapse-btn i,
.app-container.sidebar-collapsed .sidebar-collapse-btn svg,
html.sidebar-pre-collapsed .sidebar-collapse-btn i,
html.sidebar-pre-collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

/* ─── Sidebar Position: Right (html.sidebar-right) ─── */
/* Mirrors the entire sidebar/main-content layout. The body class is set by
   the head script in layout.html before <body> parses, so there is no flash. */
html.sidebar-right .sidebar {
    left: auto;
    right: 0;
}

html.sidebar-right .main-content {
    margin-left: 10px;
    margin-right: calc(16rem + 10px);
}

html.sidebar-right .app-container.sidebar-collapsed .main-content,
html.sidebar-right html.sidebar-pre-collapsed .app-container .main-content {
    margin-left: 10px;
    margin-right: 4.5rem;
}

/* Mirror: the flat edge still faces the rail, so the radius flips and the
   shadow falls leftward onto .main-content. */
html.sidebar-right .sidebar-collapse-btn {
    left: auto;
    right: 16rem;
    border-radius: 23px 0 0 23px;
    box-shadow: -2px 0 6px -2px rgba(0, 0, 0, 0.35);
}

/* `html.sidebar-right html.sidebar-pre-collapsed` — an <html> descending from
   an <html> — could never match, so the right-hand rail's collapsed position
   silently did nothing on a pre-paint load. Both classes land on the SAME
   element; they have to be written as a compound selector. */
html.sidebar-right .app-container.sidebar-collapsed .sidebar-collapse-btn,
html.sidebar-right.sidebar-pre-collapsed .sidebar-collapse-btn {
    left: auto;
    right: 4.5rem;
}

html.sidebar-right .sidebar-collapse-btn i,
html.sidebar-right .sidebar-collapse-btn svg {
    margin-left: 0;
    margin-right: -1px;
    transform: rotate(180deg);
}

html.sidebar-right .app-container.sidebar-collapsed .sidebar-collapse-btn i,
html.sidebar-right .app-container.sidebar-collapsed .sidebar-collapse-btn svg,
html.sidebar-right.sidebar-pre-collapsed .sidebar-collapse-btn i,
html.sidebar-right.sidebar-pre-collapsed .sidebar-collapse-btn svg {
    transform: rotate(0deg);
}

/* Active nav-item indicator flips to the right edge so it points toward the
   sidebar's anchored side. */
html.sidebar-right .nav-item.active {
    border-left: none;
    border-right: 3px solid var(--sidebar-active-border);
}

/* Mobile: right-anchored slide-in instead of left. */
@media (max-width: 768px) {
    html.sidebar-right .sidebar {
        right: 0 !important;
        left: auto !important;
        transform: translateX(100%) !important;
    }
    html.sidebar-right .sidebar.open {
        transform: translateX(0) !important;
    }
    html.sidebar-right .main-content {
        margin-right: 0;
    }
}

/* ─── Squared Corners (html.squared-corners) ───
   Removes the rounded look on cards, buttons, inputs, modals, badges, etc.
   Wide selector list so every common shape flattens. The accent gradient,
   avatar circles, and pill-shaped status badges are intentionally exempt
   so we don't break visual hierarchy. */
html.squared-corners .main-content,
html.squared-corners .card,
html.squared-corners .btn,
html.squared-corners .btn-primary,
html.squared-corners .btn-secondary,
html.squared-corners .btn-outline,
html.squared-corners .btn-ghost,
html.squared-corners .btn-icon,
html.squared-corners .btn-sm,
html.squared-corners .btn-md,
html.squared-corners .btn-lg,
html.squared-corners .form-input,
html.squared-corners input[type="text"],
html.squared-corners input[type="email"],
html.squared-corners input[type="password"],
html.squared-corners input[type="number"],
html.squared-corners input[type="search"],
html.squared-corners input[type="tel"],
html.squared-corners input[type="url"],
html.squared-corners select,
html.squared-corners textarea,
html.squared-corners .modal-content,
html.squared-corners .modal-card,
html.squared-corners .settings-section,
html.squared-corners .nav-item,
html.squared-corners .dropdown-menu,
html.squared-corners .table-wrapper,
html.squared-corners .audience-card,
html.squared-corners .config-card {
    border-radius: 2px !important;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 25%;
}

/* Default Chiirp logo gets the brightness/invert filter so it renders white on
   the accent-colored sidebar. Client-uploaded logos are full color brand assets
   and must NOT be filtered — without this scoping, white-bg client logos would
   render as solid white tiles. */
.sidebar-logo #sidebar-logo-default img {
    height: 2rem;
    width: auto;
    filter: var(--sidebar-logo-filter);
}

.sidebar-logo #sidebar-logo-client img {
    filter: none;
}

.sidebar-logo .powered-by-chiirp img {
    filter: var(--sidebar-logo-filter);
}

.sidebar-logo h1 {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--sidebar-text-active);
    letter-spacing: -0.01em;
    padding-left: 4px;
}

/* Client logo in sidebar — "Powered by Chiirp" */
.powered-by-chiirp {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.5625rem;
    font-weight: 500;
    color: var(--sidebar-text-faded);
    margin-top: 4px;
    letter-spacing: 0.02em;
    opacity: 0.85;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-text-muted);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-text-faded);
}

.nav-section {
    margin-bottom: 0.25rem;
    padding: 0 8px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    margin-bottom: 0.25rem;
    padding: 0 0.75rem;
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
}

.nav-section:first-child .nav-section-title {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0.125rem 0;
    position: relative;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
    border-left: 3px solid var(--sidebar-active-border);
    border-right: none;
    border-top: none;
    border-bottom: none;
    box-shadow: none;
}

.nav-item i,
.nav-item svg {
    font-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    color: inherit;
}

.nav-item.active::after {
    display: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 2vh;
}

.sidebar-footer .nav-item {
    border: none;
    background: transparent;
    color: var(--sidebar-text-faded);
    font-size: 0.8rem;
}

.sidebar-footer .nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
    border-color: transparent;
}

/* ── Sidebar notification badge ─────────────────────── */
.notif-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.sidebar-notif-badge {
    position: absolute;
    top: -5px;
    right: -6px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    background: var(--success);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid hsl(var(--sidebar-background));
    pointer-events: none;
    z-index: 1;
}

.dark .sidebar-notif-badge {
    border-color: hsl(220 13% 12%);
}

/* Bell ring animation */
@keyframes notif-bell-ring {
    0%   { transform: rotate(0deg); }
    15%  { transform: rotate(18deg); }
    35%  { transform: rotate(-16deg); }
    55%  { transform: rotate(12deg); }
    70%  { transform: rotate(-8deg); }
    85%  { transform: rotate(4deg); }
    100% { transform: rotate(0deg); }
}
.notif-bell-ring .notif-icon-wrap {
    animation: notif-bell-ring 0.55s ease;
    transform-origin: top center;
}

/* Badge pop animation */
@keyframes notif-badge-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.45); }
    70%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.notif-badge-pop {
    animation: notif-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Confetti pieces */
.notif-confetti-piece {
    position: fixed;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 99999;
}

/* ── Notification drawer ──────────────────────────────────────────────────
   The shell is the shared Aura UI drawer (.cui-drawer in css/ui/page-frame.css,
   inside a .cui-page wrapper in layout.html). Only what the list adds is here. */
body.notif-open { overflow: hidden; }
.notif-drawer .cui-drawer-head h3 { display: flex; align-items: center; gap: 0.45rem; }
.notif-drawer-tools { padding: 0.8rem 0.85rem 0.2rem; flex-shrink: 0; }
.notif-drawer .cui-drawer-body.notif-list { padding: 0.5rem 0.85rem 1rem; }
.notif-drawer .cui-empty { margin: 1.25rem 0.5rem; }

/* Scrollable list */
.notif-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.625rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--border-component)) transparent;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }

/* Date group label */
.notif-date-group {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    opacity: 0.7;
    padding: 0.75rem 0.25rem 0.375rem;
}
.notif-date-group:first-child { padding-top: 0.25rem; }

/* Individual notification item */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.875rem 0.75rem;
    border-radius: 0.75rem;
    margin-bottom: 0.125rem;
    transition: background 0.15s;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.notif-item:hover { background: var(--muted); }
.notif-item.unread { background: hsl(var(--accent-component) / 0.06); }
.notif-item.unread:hover { background: hsl(var(--accent-component) / 0.11); }
.notif-item.unread::before {
    content: '';
    position: absolute;
    left: -0.125rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 40%;
    min-height: 20px;
    border-radius: 9999px;
    background: hsl(var(--accent-component));
}
/* Type-specific unread bar + background */
.notif-item.unread.ntype-message  { background: hsla(205, 100%, 50%, 0.06); }
.notif-item.unread.ntype-message:hover  { background: hsla(205, 100%, 50%, 0.10); }
.notif-item.unread.ntype-message::before  { background: hsl(205, 90%, 42%); }
.notif-item.unread.ntype-agent   { background: hsla(28, 100%, 53%, 0.06); }
.notif-item.unread.ntype-agent:hover   { background: hsla(28, 100%, 53%, 0.10); }
.notif-item.unread.ntype-agent::before   { background: hsl(28, 95%, 40%); }
.notif-item.unread.ntype-campaign { background: hsla(152, 75%, 38%, 0.06); }
.notif-item.unread.ntype-campaign:hover { background: hsla(152, 75%, 38%, 0.10); }
.notif-item.unread.ntype-campaign::before { background: hsl(152, 68%, 30%); }
.notif-item.unread.ntype-pipeline { background: hsla(258, 80%, 58%, 0.06); }
.notif-item.unread.ntype-pipeline:hover { background: hsla(258, 80%, 58%, 0.10); }
.notif-item.unread.ntype-pipeline::before { background: hsl(258, 70%, 50%); }
.notif-item.unread.ntype-billing  { background: hsla(0, 85%, 58%, 0.06); }
.notif-item.unread.ntype-billing:hover  { background: hsla(0, 85%, 58%, 0.10); }
.notif-item.unread.ntype-billing::before  { background: hsl(0, 78%, 48%); }
.notif-item.unread.ntype-system   { background: hsl(var(--accent-component) / 0.06); }
.notif-item.unread.ntype-system:hover   { background: hsl(var(--accent-component) / 0.11); }
.notif-item.unread.ntype-system::before   { background: hsl(var(--accent-component)); }

/* Icon */
.notif-icon-cell {
    width: 40px;
    height: 40px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.0625rem;
}
.notif-icon-cell svg { width: 1.0625rem; height: 1.0625rem; }

/* Per-type icon colours — more vibrant */
.ni-blue   { background: hsla(205, 100%, 50%, 0.13); color: hsl(205, 90%, 42%); }
.ni-orange { background: hsla(28,  100%, 53%, 0.14); color: hsl(28,  95%, 40%); }
.ni-green  { background: hsla(152,  75%, 38%, 0.14); color: hsl(152, 68%, 30%); }
.ni-purple { background: hsla(258,  80%, 58%, 0.14); color: hsl(258, 70%, 50%); }
.ni-red    { background: hsla(0,    85%, 58%, 0.14); color: hsl(0,   78%, 48%); }
.ni-teal   { background: hsl(var(--accent-component) / 0.13); color: hsl(var(--accent-component)); }

/* Body */
.notif-body-cell { flex: 1; min-width: 0; }

.notif-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.notif-type-chip {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.125rem 0.4375rem;
    border-radius: 9999px;
    flex-shrink: 0;
}
.chip-message  { background: hsla(205, 100%, 50%, 0.13); color: hsl(205, 90%, 42%); }
.chip-agent    { background: hsla(28,  100%, 53%, 0.14); color: hsl(28,  95%, 40%); }
.chip-campaign { background: hsla(152,  75%, 38%, 0.14); color: hsl(152, 68%, 30%); }
.chip-pipeline { background: hsla(258,  80%, 58%, 0.14); color: hsl(258, 70%, 50%); }
.chip-billing  { background: hsla(0,    85%, 58%, 0.14); color: hsl(0,   78%, 48%); }
.chip-system   { background: hsl(var(--accent-component) / 0.13); color: hsl(var(--accent-component)); }

.notif-time {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    flex-shrink: 0;
}

.notif-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 0.1875rem;
    line-height: 1.4;
    /* allow up to 2 lines, ellipsis after */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-desc {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin: 0;
    line-height: 1.45;
}

/* Dismiss button */
.notif-dismiss-btn {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.25rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: all 0.15s;
    margin-top: 0.0625rem;
}
.notif-item:hover .notif-dismiss-btn { opacity: 1; }
.notif-dismiss-btn:hover { background: var(--muted); color: var(--foreground); }
.notif-dismiss-btn svg { width: 0.75rem; height: 0.75rem; }

/* Chevron expand button */
.notif-chevron-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.25rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: all 0.2s;
    margin-top: 0.0625rem;
}
.notif-chevron-btn:hover { background: var(--muted); color: var(--foreground); }
.notif-chevron-btn svg { width: 1rem; height: 1rem; transition: transform 0.2s ease; }
.notif-chevron-btn.open svg { transform: rotate(180deg); }

/* Navigation affordance for clickable (deep-linked) notification rows */
.notif-nav-arrow {
    opacity: 0;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-top: 0.0625rem;
    transition: opacity 0.15s, transform 0.15s;
}
.notif-item:hover .notif-nav-arrow { opacity: 0.9; transform: translateX(2px); }
.notif-nav-arrow svg { width: 0.875rem; height: 0.875rem; }

/* Expand panel — Option 3 bubble style */
.notif-expand-panel {
    display: grid;
    grid-template-rows: 0fr;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    transition: grid-template-rows 0.28s ease, padding-bottom 0.28s ease, opacity 0.25s ease;
    opacity: 0;
    overflow: hidden;
}
.notif-expand-panel > * { min-height: 0; }
.notif-expand-content { display: flex; gap: 0; }
.notif-expand-panel.open {
    display: grid;
    grid-template-rows: 1fr;
    padding-bottom: 0.875rem;
    opacity: 1;
}
.notif-expand-thread-line {
    width: 48px;
    flex-shrink: 0;
    position: relative;
}
.notif-expand-thread-line::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0.5rem;
    width: 2px;
    background: var(--border);
    transform: translateX(-50%);
    border-radius: 2px;
}
.notif-expand-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.notif-expand-bubble {
    background: var(--muted);
    border-radius: 4px 14px 14px 14px;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--foreground);
    position: relative;
}
.notif-expand-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--primary-blue-component));
    text-decoration: none;
    padding: 0.25rem 0.625rem;
    background: hsl(var(--primary-blue-component) / 0.08);
    border-radius: 999px;
    transition: background 0.15s;
}
.notif-expand-view-btn:hover { background: hsl(var(--primary-blue-component) / 0.16); }
.notif-expand-view-btn svg { width: 0.7rem; height: 0.7rem; }

/* Daily digest: Aura mini stats beside the Aura score ring (layout.html _notifDigestStats) */
.notif-drawer .notif-digest { display: flex; gap: 0.5rem; }
.notif-drawer .notif-digest .cui-mini-stats { flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.notif-drawer .notif-digest .cui-mini-stat { padding: 0.5rem 0.65rem; }
.notif-drawer .notif-digest .cui-mini-stat-v { font-size: 1.1rem; }
.notif-drawer .notif-digest-score {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.45rem; flex-shrink: 0;
    padding: 0.6rem 0.85rem; border-radius: var(--cui-r-md); background: hsl(var(--muted-component) / 0.7);
}
.notif-drawer .notif-digest-score .cui-ring-lbl b { font-size: 1rem; }
.notif-drawer .notif-digest-score-text { display: flex; flex-direction: column; align-items: center; font-size: 0.8125rem; line-height: 1.3; }
.notif-drawer .notif-digest-score-text span { font-size: 0.75rem; font-weight: 650; color: var(--muted-foreground); }
.notif-drawer .notif-digest-score-text b { text-transform: capitalize; }

/* First-load placeholders: the rows' own classes with main.css's .sk bars */
.notif-drawer .notif-item.sk-item { cursor: default; }
.notif-drawer .notif-icon-cell.sk { height: 40px; border-radius: 0.625rem; }
.notif-drawer .notif-sk-chip { width: 4.25rem; height: 1rem; border-radius: 999px; }

/* Footer */
/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    margin-left: 16rem;
    margin-top: 10px;
    margin-right: 10px;
    margin-bottom: 10px;
    border-radius: 14px;
    overflow: hidden;
    /* Shrinks to the viewport even where a page swaps hidden for clip (no longer a scroll container). */
    min-width: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 1px 0 0 hsl(var(--accent-light));
}

/* Header */
.header {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: hsl(var(--background));
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Search Bar */
.search-bar {
    position: relative;
    width: 280px;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: hsl(var(--background));
    color: var(--foreground);
    transition: var(--transition-smooth);
}

.search-bar input::placeholder {
    color: var(--muted-foreground);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--border);
    box-shadow: 0 0 0 1px var(--border);
}

.search-bar i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    /* NOTE: padding is intentionally NOT set here. The base padding already
       comes from components.css `.btn`; re-declaring it here loads *after*
       components.css and clobbered the `.btn-sm`/`.btn-lg` size modifiers'
       padding (equal specificity, later wins). Leave it out so size
       modifiers keep their compact/wide padding. */
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Primary Button - Blue with good contrast */
.btn-primary {
    background: hsl(var(--accent-component));
    color: hsl(0, 0%, 100%);
}

.btn-primary:hover {
    background: hsl(var(--accent-component));
}

/* Secondary Button - Visible on white */
.btn-secondary {
    background: hsl(210, 7%, 95%);
    color: hsl(210, 11%, 25%);
    border: 1px solid hsl(210, 7%, 80%);
}

.btn-secondary:hover {
    background: hsl(210, 7%, 90%);
    border-color: hsl(210, 7%, 70%);
}

/* Icon Button - Visible on white */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    background: hsl(210, 7%, 95%);
    border: 1px solid hsl(210, 7%, 85%);
    cursor: pointer;
    transition: var(--transition-smooth);
    color: hsl(210, 11%, 40%);
    font-size: 1rem;
}

.btn-icon:hover {
    background: hsl(210, 7%, 90%);
    color: hsl(210, 11%, 25%);
    border-color: hsl(210, 7%, 75%);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    /* max-height: calc(100vh - 60px); */
    background: linear-gradient(145deg, hsl(var(--background)), hsl(210, 7%, 99%));
}

/* ── Page transitions (driven by spa.js window.chiirpPageTransition) ── */
/* Selectors keep the class rightmost so each restyles only its element; never select #page-content.spa-leaving. */
#page-content > .page-leave {
    opacity: 0;
    transition: opacity 130ms var(--ease-exit);
    pointer-events: none;
}
/* Domino pop: hidden 14px low at 96%, then fades, rises and settles after --pt-d; translate/scale leave transform alone. */
#page-content .page-enter {
    opacity: 0;
    translate: 0 14px;
    scale: 0.96;
    transition: none; /* hide instantly, even items with their own transition */
}
/* Frames (contents pop inside) and data filling in place fade without the rise. */
#page-content .page-enter.pt-frame { translate: none; scale: 0.985; }
#page-content .page-enter.pt-fade { translate: none; scale: none; }
/* A transition, not a keyframe: it ends at the element's own opacity, so a scrim resting at 0 never flashes. */
#page-content .page-enter-go {
    transition:
        opacity 200ms var(--ease-enter),
        translate 300ms var(--ease-pop),
        scale 300ms var(--ease-pop);
    transition-delay: var(--pt-d, 0ms);
}
/* Backstops for reduced motion and Appearance → animations off (spa.js adds no classes then). */
@media (prefers-reduced-motion: reduce) {
    #page-content > .page-leave { opacity: 1; transition: none; pointer-events: auto; }
    #page-content .page-enter { opacity: 1; translate: none; scale: none; }
    #page-content .page-enter-go { transition: none; }
}
html.no-animations #page-content > .page-leave { opacity: 1; pointer-events: auto; }
html.no-animations #page-content .page-enter { opacity: 1; translate: none; scale: none; }
/* Until a swapped-in page's stylesheets apply: no transitions from unstyled values. */
#page-content.spa-styling *,
#page-content.spa-styling *::before,
#page-content.spa-styling *::after { transition: none !important; }
/* Hidden while styling, and after a full-reload sidebar link until spa.js pops the page in (layout.html <head>). */
@media (prefers-reduced-motion: no-preference) {
    html:not(.no-animations) #page-content.spa-styling,
    html:not(.no-animations).page-entering #page-content { opacity: 0; }
}

/* ── Loading placeholders: .sk-item (a row/card, same classes as the real one) and .sk (a bar) inside [data-reveal] ── */
/* A rolling shimmer like the dashboard's; colours mix theme tokens (never hsl(var(--muted)): main.css redefines it as a full colour). */
.sk, .sk-shimmer {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--border) 70%, var(--background)) 25%,
        color-mix(in srgb, var(--border) 30%, var(--background)) 50%,
        color-mix(in srgb, var(--border) 70%, var(--background)) 75%);
    background-size: 200% 100%;
    animation: chiirp-sk-shimmer 1.4s ease-in-out infinite;
}
.sk {
    display: block;
    height: 0.75em;
    max-width: 100%;
    border-radius: 6px;
}
.sk.sk-inline { display: inline-block; vertical-align: -0.1em; } /* inside a line of text, keeping its line box */
.sk.sk-word { width: 2.2em; }
.sk.sk-num { display: inline-block; vertical-align: -0.08em; height: 0.85em; width: 2.2em; border-radius: 6px; }
.sk.sk-title { height: 1em; }
.sk.sk-circle { border-radius: 50%; }
.sk:not(.sk-inline):not(.sk-num) + .sk:not(.sk-inline):not(.sk-num) { margin-top: 0.5em; }
.sk.sk-w-30 { width: 30%; }
.sk.sk-w-40 { width: 40%; }
.sk.sk-w-50 { width: 50%; }
.sk.sk-w-60 { width: 60%; }
.sk.sk-w-70 { width: 70%; }
.sk.sk-w-80 { width: 80%; }
.sk.sk-w-100 { width: 100%; }
.sk-item { pointer-events: none; }
/* Data arriving: the placeholders it replaced fade out over it (spa.js _ghost). */
.sk-ghost-host { position: relative; }
.sk-ghost { position: absolute; top: 0; left: 0; right: 0; z-index: 1; box-sizing: border-box; transition: opacity 120ms var(--ease-out); }
.sk-ghost.sk-ghost-out { opacity: 0; }
@keyframes chiirp-sk-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .sk, .sk-shimmer { animation: none; }
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    background: hsl(var(--card));
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    border-left: 3px solid hsl(var(--accent-component));
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    background: hsl(var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: hsl(var(--accent-component));
}

.section-header-icon i,
.section-header-icon svg {
    width: 1.125rem;
    height: 1.125rem;
}

.section-header-text {
    display: flex;
    flex-direction: column;
}

.section-header-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: hsl(var(--foreground));
    letter-spacing: -0.01em;
}

.section-header-description {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    margin: 0.125rem 0 0 0;
}

.dark .section-header {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 15%, 20%);
    border-left-color: hsl(var(--accent-component));
}

.dark .section-header-icon {
    background: hsl(210, 15%, 20%);
    color: hsl(var(--accent-component));
}

.dark .section-header-title {
    color: hsl(0 0% 95%);
}

.dark .section-header-description {
    color: hsl(0 0% 65%);
}

/* Cards */
.card {
    background: hsl(var(--card));
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 hsl(210 7% 46% / 0.1), 0 1px 2px 0 hsl(210 7% 46% / 0.06);
}

.card-header {
    margin-bottom: 0;
    padding-bottom: 1rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
    color: var(--foreground);
}

.card-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 400;
}

/* Grid System */
.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive Grid - Tablet and up (768px) */
@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .md\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 769px) {
    .header {
        display: none;
    }
}

/* Responsive Grid - Desktop and up (1280px) */
@media (min-width: 1280px) {
    .xl\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .xl\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .xl\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.form-input,
select.form-input,
textarea.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--background);
    color: var(--foreground);
    transition: var(--transition-smooth);
}

.form-input:focus,
select.form-input:focus,
textarea.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px hsla(34, 100%, 51%, 0.1);
}

/* Stats Card */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--foreground);
    letter-spacing: -0.02em;
}

.stat-change {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--destructive);
}

/* Agent Badge */
.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.agent-badge.speed {
    background: hsla(34, 100%, 51%, 0.1);
    color: var(--agent-speed);
}

.agent-badge.nurture {
    background: hsl(var(--accent-component) / 0.1);
    color: var(--agent-nurture);
}

.agent-badge.review {
    background: hsla(250, 84%, 54%, 0.1);
    color: var(--agent-review);
}

.agent-badge.support {
    background: hsla(210, 100%, 56%, 0.1);
    color: var(--agent-support);
}

.agent-badge.concierge {
    background: hsla(335, 78%, 42%, 0.1);
    color: var(--agent-concierge);
}

.agent-badge.broadcast {
    background: hsla(142, 71%, 45%, 0.1);
    color: var(--agent-broadcast);
}

.agent-ai-icon-wrapper {
    position: relative;
    display: inline-flex;
    overflow: hidden;
    margin-left: 0.25rem;
    flex-shrink: 0;
    border-radius: 2px;
}

.agent-ai-icon-wrapper::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -100%;
    width: 100%;
    height: calc(100% + 4px);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.6) 50%,
        transparent 100%
    );
    animation: icon-shimmer 2.5s ease-in-out infinite;
}

@keyframes icon-shimmer {
    0%, 100% { left: -100%; }
    50%, 60% { left: 100%; }
}

.agent-ai-icon {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    color: hsl(262, 83%, 58%) !important;
    display: block;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: hsl(var(--accent-component) / 0.1);
    color: var(--success);
}

.status-badge.paused {
    background: hsla(43, 96%, 56%, 0.1);
    color: hsl(43, 96%, 40%);
}

.status-badge.inactive {
    background: hsla(210, 6%, 46%, 0.1);
    color: var(--muted-foreground);
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted-foreground);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.table tbody tr {
    transition: var(--transition-smooth);
}

.table tbody tr:hover {
    background: var(--secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem;
    width: auto;
}

.modal-content {
    background: var(--card);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 65vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* Utility Classes */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-xs {
    gap: 0.25rem;
}

.gap-sm {
    gap: 0.5rem;
}

.gap-md {
    gap: 1rem;
}

.gap-lg {
    gap: 1.5rem;
}

.mt-xs {
    margin-top: 0.25rem;
}

.mt-sm {
    margin-top: 0.5rem;
}

.mt-md {
    margin-top: 1rem;
}

.mt-lg {
    margin-top: 1.5rem;
}

.mt-xl {
    margin-top: 2rem;
}

.mb-xs {
    margin-bottom: 0.25rem;
}

.mb-sm {
    margin-bottom: 0.5rem;
}

.mb-md {
    margin-bottom: 1rem;
}

.mb-lg {
    margin-bottom: 1.5rem;
}

.mb-xl {
    margin-bottom: 2rem;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-base {
    font-size: 1rem;
    line-height: 1.5rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.text-muted {
    color: var(--muted-foreground);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-destructive {
    color: var(--destructive);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: background 0.2s;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: hsl(210, 7%, 95%);
}

.mobile-menu-toggle:active {
    background: hsl(210, 7%, 90%);
}

.mobile-menu-toggle i {
    font-size: 1.25rem;
    color: hsl(210, 11%, 15%);
    pointer-events: none;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 40px !important;
        height: 40px !important;
        background: hsl(210, 7%, 95%) !important;
        border: 2px solid hsl(var(--accent-component)) !important;
        border-radius: 0.5rem !important;
        cursor: pointer !important;
    }

    .mobile-menu-toggle i {
        font-size: 1.25rem !important;
        color: hsl(210, 11%, 15%) !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 16rem !important;
        height: 100vh !important;
        height: 100dvh !important; /* the visible height, above Safari's URL bar */
        z-index: 1000 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15) !important;
        background: hsl(var(--accent-component)) !important;
        overflow-y: auto !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    .sidebar.collapsed {
        width: 16rem !important;
        padding: 1rem !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.3) !important;
        pointer-events: auto !important;
        opacity: 1 !important;
    }
    .sidebar-logo {
        padding: 0px 3.75rem !important;
    }
    body.sidebar-open {
        overflow: hidden;
    }
    /* Open, the toggle is the drawer's close button: it keeps the slot .sidebar-logo's
       padding leaves for it, where an unpushed header puts it, even when a banner above
       the header (setup, impersonation) or a scrolled page has moved the header down. */
    body.sidebar-open .mobile-menu-toggle {
        position: fixed;
        top: 10px;
        left: 1rem;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .mobile-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        margin-top: 0;
        margin-right: 0;
        margin-bottom: 0;
        border-radius: 0;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(1, 1fr);
    }

    .search-bar {
        width: 150px;
    }

    .page-content {
        padding: 1rem;
    }

    .header {
        padding: 0 1rem;
    }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media (max-width: 576px) {
    .search-bar {
        display: none;
    }

    .header-right {
        gap: 0.5rem;
    }

    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }
}

/* ========================================
   DARK MODE - Global Text & Component Overrides
   ======================================== */

/* Sidebar Dark Mode — keeps the themed accent gradient (darker variant via --accent-dark).
   Sidebar-text vars already provide the white/dark contrast — no per-element overrides needed. */
.dark .app-container {
    background: hsl(var(--accent-dark));
}

.dark .sidebar {
    background: transparent;
    border-right: none;
}

.dark .sidebar-footer {
    border-top-color: var(--sidebar-border);
}

.dark .sidebar-footer .nav-item {
    border-color: transparent;
    background: transparent;
}

/* Page Content Dark Mode */
.dark .page-content {
    background: linear-gradient(145deg, hsl(210, 11%, 7%), hsl(210, 11%, 9%));
}

/* Card Dark Mode */
.dark .card {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 10%, 16%);
}

.dark .card-title {
    color: hsl(0 0% 90%);
}

.dark .card-description {
    color: hsl(0 0% 70%);
}

/* Text Utilities Dark Mode */
.dark .text-muted {
    color: hsl(0 0% 60%);
}

.dark .text-foreground {
    color: hsl(0 0% 90%);
}

/* Security Notice Dark Mode */
.dark .security-notice {
    background: hsl(195 42% 20% / 0.15);
    border-color: rgba(72, 185, 175, 0.3);
}

.dark .security-notice-content {
    color: hsl(0 0% 70%);
}

.dark .security-notice-content strong {
    color: hsl(0 0% 90%);
}

/* Form Elements Dark Mode */
.dark .form-input,
.dark select.form-input,
.dark textarea.form-input {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 15%, 22%);
    color: hsl(0 0% 90%);
}

.dark .form-input::placeholder {
    color: hsl(0 0% 50%);
}

.dark .form-label,
.dark .label {
    color: hsl(0 0% 90%);
}

/* Input Dark Mode */
.dark .input {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 15%, 22%);
    color: hsl(0 0% 90%);
}

.dark .input::placeholder {
    color: hsl(0 0% 50%);
}

/* Search Bar Dark Mode */
.dark .search-bar input {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 15%, 22%);
    color: hsl(0 0% 90%);
}

.dark .search-bar input::placeholder {
    color: hsl(0 0% 50%);
}

/* Table Dark Mode */
.dark .table th {
    color: hsl(0 0% 75%);
    border-bottom-color: hsl(210, 15%, 20%);
}

.dark .table td {
    color: hsl(0 0% 90%);
    border-bottom-color: hsl(210, 15%, 20%);
}

.dark .table tbody tr:hover {
    background: hsl(210, 11%, 15%);
}

/* Stat Card Dark Mode */
.dark .stat-card {
    background: hsl(210, 11%, 12%);
    border-color: hsl(210, 15%, 20%);
}

.dark .stat-label {
    color: hsl(0 0% 70%);
}

.dark .stat-value {
    color: hsl(0 0% 90%);
}

/* Modal Dark Mode */
.dark .modal-content {
    background: hsl(210, 11%, 10%);
}

.dark .modal-body .card {
    background: hsl(210, 11%, 15%);
    border-color: hsl(210, 15%, 20%);
}

/* Header Dark Mode */
.dark .header {
    background: hsl(210, 11%, 8%);
    border-bottom-color: hsl(210, 15%, 20%);
}

/* Mobile Menu Dark Mode */
.dark .mobile-menu-toggle {
    background: hsl(210, 11%, 15%) !important;
    border-color: hsl(195, 50%, 50%) !important;
}

.dark .mobile-menu-toggle i {
    color: hsl(0 0% 90%) !important;
}

@media (max-width: 768px) {
    .dark .sidebar {
        background: hsl(var(--accent-dark)) !important;
    }
}

/* ============================================================================
   DARK MODE - Button Styles
   Comprehensive dark mode for all button variants
   ============================================================================ */

/* Base button text visibility */
.dark .btn {
    color: hsl(0 0% 90%);
}

/* Primary Button - Blue accent, black text for contrast */
.dark .btn-primary {
    background: hsl(195, 42%, 42%);
    color: hsl(0 0% 5%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark .btn-primary:hover {
    background: hsl(195, 42%, 52%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Secondary Button - Subtle dark background */
.dark .btn-secondary {
    background: hsl(210, 11%, 18%);
    color: hsl(0 0% 90%);
    border: 1px solid hsl(210, 15%, 25%);
}

.dark .btn-secondary:hover {
    background: hsl(210, 11%, 24%);
    border-color: hsl(210, 15%, 35%);
}

/* Outline Button - Visible border on dark */
.dark .btn-outline {
    background: transparent;
    border: 1px solid hsl(210, 15%, 35%);
    color: hsl(0 0% 85%);
}

.dark .btn-outline:hover {
    background: hsl(210, 11%, 18%);
    border-color: hsl(195, 42%, 45%);
    color: hsl(195, 45%, 65%);
}

/* Destructive Button - Bright red visible on dark */
.dark .btn-destructive {
    background: hsl(0, 65%, 48%);
    color: hsl(0 0% 95%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark .btn-destructive:hover {
    background: hsl(0, 72%, 58%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Ghost Button - Transparent with visible text */
.dark .btn-ghost {
    background: transparent;
    color: hsl(0 0% 75%);
}

.dark .btn-ghost:hover {
    background: hsl(210, 11%, 18%);
    color: hsl(0 0% 90%);
}

/* Link Button - Visible link color */
.dark .btn-link {
    background: transparent;
    color: hsl(195, 45%, 55%);
}

.dark .btn-link:hover {
    color: hsl(195, 45%, 65%);
}

/* Gradient Button - Visible gradient on dark */
.dark .btn-gradient {
    background: linear-gradient(135deg, hsl(195, 42%, 42%), hsl(34, 85%, 50%));
    color: hsl(0 0% 95%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.dark .btn-gradient:hover {
    background: linear-gradient(135deg, hsl(195, 42%, 50%), hsl(34, 85%, 55%));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* Icon Button - Visible on dark */
.dark .btn-icon {
    background: hsl(210, 11%, 18%);
    color: hsl(0 0% 75%);
    border: 1px solid hsl(210, 15%, 25%);
}

.dark .btn-icon:hover {
    background: hsl(210, 11%, 24%);
    color: hsl(0 0% 90%);
    border-color: hsl(210, 15%, 35%);
}

/* Disabled buttons in dark mode */
.dark .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Focus visible state for dark mode */
.dark .btn:focus-visible {
    outline: 2px solid hsl(195, 45%, 45%);
    outline-offset: 2px;
}

/* Inline Style Overrides for Hardcoded Colors */
.dark [style*="color: #64748b"],
.dark [style*="color:#64748b"],
.dark [style*="color: #6b7280"],
.dark [style*="color:#6b7280"],
.dark [style*="color: #374151"],
.dark [style*="color:#374151"] {
    color: hsl(0 0% 70%) !important;
}

.dark [style*="color: #1A1A1A"],
.dark [style*="color:#1A1A1A"],
.dark [style*="color: #1a1a1a"],
.dark [style*="color:#1a1a1a"],
.dark [style*="color: #111827"],
.dark [style*="color:#111827"] {
    color: hsl(0 0% 90%) !important;
}

/* Hardcoded White Background Overrides */
.dark [style*="background: white"],
.dark [style*="background:white"],
.dark [style*="background-color: white"],
.dark [style*="background-color:white"],
.dark [style*="background: #ffffff"],
.dark [style*="background:#ffffff"],
.dark [style*="background: #fff"],
.dark [style*="background:#fff"] {
    background: hsl(210, 11%, 12%) !important;
}

/* ============================================================================
   Static Modal Pattern (reusable)
   Use for any modal in CHIIRP 2.0 instead of window.chiirp.showModal().
   Reference: .claude/skills/modals-ui/index.md
   ============================================================================ */
.agency-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    backdrop-filter: blur(5px) saturate(10%) brightness(0.95);
    -webkit-backdrop-filter: blur(3px) saturate(1.2) brightness(0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.15s;
}

.agency-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.agency-modal {
    position: relative;
    z-index: 9999;
    width: 90%;
    max-width: 32rem;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid hsl(var(--border-component) / 0.5);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px hsl(var(--border-component) / 0.1),
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 20px 25px -5px rgba(0, 0, 0, 0.2),
        0 0 60px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.agency-modal-overlay.active .agency-modal {
    opacity: 1;
}

.agency-modal.md { max-width: 36rem; }
.agency-modal.lg { max-width: 42rem; }
/* Wide variant for modals laying out a multi-column grid (contacts filters). */
.agency-modal.xl { max-width: 58rem; }
/* Side-nav settings modals (integrations with four or more sections). */
.agency-modal.xxl { max-width: 68rem; }

.agency-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border-component) / 0.5);
    flex-shrink: 0;
}

.agency-modal-header-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.agency-modal-header-info h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
}

.agency-modal-header-info p {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin: 0.125rem 0 0 0;
}

.agency-modal-close {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 0.375rem;
    line-height: 1;
    border-radius: 0.5rem;
    transition: color 0.15s, background 0.15s;
}

.agency-modal-close:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--muted) / 0.15);
}

.agency-modal-close i { width: 1.125rem; height: 1.125rem; }

.agency-modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
}

.agency-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid hsl(var(--border-component) / 0.5);
    flex-shrink: 0;
}

/* Compact variant: slimmer header, body and footer for dense data modals. */
.agency-modal.compact .agency-modal-header { padding: 0.75rem 1rem 0.75rem 1.125rem; }
.agency-modal.compact .agency-modal-header-info h3 { font-size: 0.9375rem; }
.agency-modal.compact .agency-modal-body { padding: 0.875rem 1.125rem; }
.agency-modal.compact .agency-modal-footer { padding: 0.625rem 1.125rem; }
/* Footer carrying left-aligned meta (a count, a hint) beside its actions. */
.agency-modal-footer.with-meta {
    justify-content: space-between;
    align-items: center;
}
