/* ============================================================
   Zem Portal – Theme CSS
   ============================================================ */

:root {
    /* Background & surfaces */
    --bg: #f4f1e8;
    --surface: #fffdf9;
    --surface-alt: #f0e8d8;
    --surface-hover: #f8f4ec;

    /* Text */
    --text: #1f1d1a;
    --muted: #5a5347;          /* darkened for WCAG AA 4.5:1 */
    --line: #d8cebc;

    /* Accent */
    --accent: #0d5c63;
    --accent-hover: #094a50;
    --accent-strong: #083d41;

    /* Semantic */
    --danger: #9d2b2b;
    --danger-hover: #7e2222;
    --danger-bg: rgba(157, 43, 43, 0.10);
    --success: #1a7f50;
    --success-bg: rgba(26, 127, 80, 0.12);
    --warning: #b8860b;
    --warning-bg: rgba(184, 134, 11, 0.12);

    /* Typography scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(31, 29, 26, 0.06);
    --shadow-md: 0 8px 24px rgba(31, 29, 26, 0.08);
    --shadow-lg: 0 18px 36px rgba(31, 29, 26, 0.10);

    /* Background gradients */
    --bg-glow: rgba(13, 92, 99, 0.12);
    --bg-top: #efe6d3;

    /* Transitions */
    --transition: 0.2s ease;
}

/* ============================================================
   Color Schemes
   ============================================================ */

/* Ocean – cool blues */
body[data-color-scheme="ocean"] {
    --bg: #edf2f7;
    --bg-glow: rgba(43, 108, 176, 0.12);
    --bg-top: #dbe4ef;
    --surface: #ffffff;
    --surface-alt: #e2e8f0;
    --surface-hover: #edf2f7;
    --text: #1a202c;
    --muted: #4a5568;
    --line: #cbd5e0;
    --accent: #2b6cb0;
    --accent-hover: #2c5282;
    --accent-strong: #1a365d;
    --danger: #c53030;
    --danger-hover: #9b2c2c;
    --success: #276749;
    --warning: #b7791f;
}

/* Forest – natural greens */
body[data-color-scheme="forest"] {
    --bg: #f0f4f0;
    --bg-glow: rgba(45, 106, 79, 0.12);
    --bg-top: #dfe8df;
    --surface: #fafcfa;
    --surface-alt: #e2ebe2;
    --surface-hover: #edf3ed;
    --text: #1a2e1a;
    --muted: #4a6349;
    --line: #c1d4c0;
    --accent: #2d6a4f;
    --accent-hover: #245840;
    --accent-strong: #1b4332;
    --danger: #9d2b2b;
    --danger-hover: #7e2222;
    --success: #1a7f50;
    --warning: #b8860b;
}

/* Sunset – warm oranges/reds */
body[data-color-scheme="sunset"] {
    --bg: #fef5ed;
    --bg-glow: rgba(192, 86, 33, 0.12);
    --bg-top: #f5e4d2;
    --surface: #fffcf9;
    --surface-alt: #fde8d0;
    --surface-hover: #fef0e0;
    --text: #2d1b0e;
    --muted: #6b4c35;
    --line: #e8cdb0;
    --accent: #c05621;
    --accent-hover: #9c4221;
    --accent-strong: #7b341e;
    --danger: #c53030;
    --danger-hover: #9b2c2c;
    --success: #276749;
    --warning: #b7791f;
}

/* Slate – neutral grays */
body[data-color-scheme="slate"] {
    --bg: #f1f3f5;
    --bg-glow: rgba(55, 65, 81, 0.08);
    --bg-top: #e5e7eb;
    --surface: #ffffff;
    --surface-alt: #e5e7eb;
    --surface-hover: #f3f4f6;
    --text: #111827;
    --muted: #4b5563;
    --line: #d1d5db;
    --accent: #374151;
    --accent-hover: #1f2937;
    --accent-strong: #111827;
    --danger: #b91c1c;
    --danger-hover: #991b1b;
    --success: #15803d;
    --warning: #a16207;
}

/* Berry – purple/pink tones */
body[data-color-scheme="berry"] {
    --bg: #f5f0f7;
    --bg-glow: rgba(124, 58, 237, 0.10);
    --bg-top: #e8ddf0;
    --surface: #fcfafd;
    --surface-alt: #ede4f2;
    --surface-hover: #f3ecf7;
    --text: #1e1226;
    --muted: #5e4a6b;
    --line: #d4c3de;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-strong: #5b21b6;
    --danger: #be123c;
    --danger-hover: #9f1239;
    --success: #15803d;
    --warning: #a16207;
}

/* Mediateknik – corporate purple/magenta */
body[data-color-scheme="mediateknik"] {
    --bg: #f0f1f3;
    --bg-glow: rgba(55, 42, 64, 0.10);
    --bg-top: #e4e0e8;
    --surface: #ffffff;
    --surface-alt: #e8e5ec;
    --surface-hover: #f3f1f5;
    --text: #212326;
    --muted: #55505c;
    --line: #d4d0d8;
    --accent: #372a40;
    --accent-hover: #4a3b55;
    --accent-strong: #2a1f32;
    --danger: #e51147;
    --danger-hover: #c40e3d;
    --danger-bg: rgba(229, 17, 71, 0.10);
    --success: #1a7f50;
    --success-bg: rgba(26, 127, 80, 0.12);
    --warning: #b8860b;
    --warning-bg: rgba(184, 134, 11, 0.12);
}

/* ---- Dark mode ---- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1816;
        --surface: #252220;
        --surface-alt: #2e2a27;
        --surface-hover: #353130;
        --text: #e8e4de;
        --muted: #a09889;
        --line: #3d3835;
        --accent: #3daab3;
        --accent-hover: #4dbfc9;
        --accent-strong: #5dd0da;
        --danger: #e05555;
        --danger-hover: #c94444;
        --danger-bg: rgba(224, 85, 85, 0.15);
        --success: #3cb878;
        --success-bg: rgba(60, 184, 120, 0.15);
        --warning: #d4a017;
        --warning-bg: rgba(212, 160, 23, 0.15);
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.3);
    }

    body {
        background: linear-gradient(180deg, #1e1b18 0%, var(--bg) 100%);
    }

    input, textarea, select {
        background: var(--surface-alt);
        color: var(--text);
        border-color: var(--line);
    }

    /* Dark mode per color scheme */
    body[data-color-scheme="ocean"] {
        --bg: #141a22;
        --surface: #1c2430;
        --surface-alt: #243040;
        --surface-hover: #2a3848;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --line: #334155;
        --accent: #63b3ed;
        --accent-hover: #90cdf4;
        --accent-strong: #bee3f8;
    }

    body[data-color-scheme="forest"] {
        --bg: #141e14;
        --surface: #1a2a1a;
        --surface-alt: #243424;
        --surface-hover: #2a3c2a;
        --text: #e0ede0;
        --muted: #8aaa89;
        --line: #2d4a2d;
        --accent: #4ade80;
        --accent-hover: #6ee7a0;
        --accent-strong: #86efac;
    }

    body[data-color-scheme="sunset"] {
        --bg: #1e1410;
        --surface: #2a1e16;
        --surface-alt: #362818;
        --surface-hover: #3e3020;
        --text: #f5e6d8;
        --muted: #b8977a;
        --line: #4a3525;
        --accent: #f6ad55;
        --accent-hover: #f9c87c;
        --accent-strong: #fbd38d;
    }

    body[data-color-scheme="slate"] {
        --bg: #111214;
        --surface: #1a1b1e;
        --surface-alt: #242528;
        --surface-hover: #2c2d32;
        --text: #e5e7eb;
        --muted: #9ca3af;
        --line: #333438;
        --accent: #9ca3af;
        --accent-hover: #d1d5db;
        --accent-strong: #e5e7eb;
    }

    body[data-color-scheme="berry"] {
        --bg: #18101e;
        --surface: #221628;
        --surface-alt: #2e1c38;
        --surface-hover: #382442;
        --text: #ede4f2;
        --muted: #b09cc0;
        --line: #3e2d50;
        --accent: #a78bfa;
        --accent-hover: #c4b5fd;
        --accent-strong: #ddd6fe;
    }

    body[data-color-scheme="mediateknik"] {
        --bg: #1a181c;
        --surface: #252228;
        --surface-alt: #302c34;
        --surface-hover: #3a353e;
        --text: #e8e5ec;
        --muted: #a89db2;
        --line: #3e3844;
        --accent: #c49ed0;
        --accent-hover: #d8b8e2;
        --accent-strong: #e8d0f0;
        --danger: #f05a82;
        --danger-hover: #e04070;
    }
}

/* ---- Reset & base ---- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--bg-glow), transparent 30%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 100%);
    min-height: 100vh;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent);
    text-decoration: underline;
}

h1, h2, h3 {
    margin-top: 0;
    line-height: 1.3;
}

h1 { font-size: var(--text-3xl); font-weight: 700; }
h2 { font-size: var(--text-2xl); font-weight: 700; }
h3 { font-size: var(--text-xl); font-weight: 600; }

/* ---- Skip to content ---- */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    background: var(--accent);
    color: #fff;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    z-index: 1000;
    font-weight: 700;
    transition: top var(--transition);
}

.skip-link:focus {
    top: var(--space-sm);
    text-decoration: none;
    color: #fff;
}

/* ---- Shell ---- */
.shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md) 4rem;
}

/* ---- Topbar ---- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-md) 1.25rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(8px);
}


.brand {
    font-size: var(--text-lg);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.brand img {
    height: 88px;
    width: auto;
}

/* ---- Nav ---- */
.nav {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}

.nav a {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav a:hover {
    background: var(--surface-alt);
    text-decoration: none;
}

.nav a.active {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.nav a.active:hover {
    background: var(--accent-hover);
}

/* Nav dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-arrow {
    font-size: 0.7em;
    margin-left: 0.15em;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 180px;
    margin-top: var(--space-xs);
    padding: var(--space-xs) 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    flex-direction: column;
}

.nav-dropdown-menu a {
    display: block;
    width: 100%;
    padding: var(--space-xs) var(--space-md) !important;
    border-radius: 0 !important;
    white-space: nowrap;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: flex;
}

/* Hamburger toggle */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    color: var(--text);
    font-size: var(--text-lg);
    line-height: 1;
}

.nav-toggle:hover {
    background: var(--surface-alt);
}

/* Customer switcher in topbar */
.topbar-customer-switcher {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.topbar-customer-switcher select {
    width: auto;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

.topbar-customer-switcher button {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
}

/* ---- Breadcrumbs ---- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    font-size: var(--text-sm);
    color: var(--muted);
}

.breadcrumbs a {
    color: var(--muted);
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.breadcrumbs .separator {
    margin: 0 var(--space-xs);
    opacity: 0.5;
}

.breadcrumbs .current {
    color: var(--text);
    font-weight: 600;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-static {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.card-service {
    background: var(--surface-hover);
}

/* ---- Modal overlay ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* ---- Settings tabs ---- */
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    border-bottom: 2px solid var(--line);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.settings-tabs button {
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--muted);
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.settings-tabs button:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.settings-tabs button.active {
    background: var(--accent);
    color: #fff;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.hero {
    display: grid;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

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

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid.three {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ---- Form fields ---- */
.field {
    display: grid;
    gap: 0.45rem;
    margin-bottom: var(--space-md);
}

label {
    font-weight: 700;
    font-size: var(--text-sm);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.95rem;
    font: inherit;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 92, 99, 0.15);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.checkbox input {
    width: auto;
}

.field-error {
    color: var(--danger);
    font-size: var(--text-sm);
    margin-top: var(--space-xs);
}

/* Password field with toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: var(--space-xs);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

.password-toggle:hover {
    color: var(--text);
    background: var(--surface-alt);
}

/* ---- Buttons ---- */
.button,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    border: 0;
    border-radius: var(--radius-full);
    padding: 0.85rem 1.5rem;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    background: var(--accent);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.button:hover,
button[type="submit"]:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: #fff;
}

.button:active,
button[type="submit"]:active {
    transform: translateY(0);
}

.button:disabled,
button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.button.secondary {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
}

.button.secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.button.danger {
    background: var(--danger);
    color: #fff;
}

.button.danger:hover {
    background: var(--danger-hover);
    color: #fff;
}

.button.small {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
}

/* Loading state */
.button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.button.loading::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: var(--space-sm);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Flash / Toast ---- */
.flash {
    padding: 0.85rem var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    animation: slideDown 0.3s ease;
}

.flash.success {
    background: var(--success-bg);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.flash.error {
    background: var(--danger-bg);
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Muted ---- */
.muted {
    color: var(--muted);
}

/* ---- Stack ---- */
.stack > * + * {
    margin-top: var(--space-md);
}

/* ---- Section gap (replaces inline margin-top) ---- */
.section-gap {
    margin-top: 1.25rem;
}

/* ---- Tags / Badges ---- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.65rem;
    background: var(--surface-alt);
    color: var(--accent-strong);
    font-size: var(--text-xs);
    font-weight: 600;
    margin-right: 0.35rem;
}

.tag-success {
    background: var(--success-bg);
    color: var(--success);
}

.tag-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.tag-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.tag-muted {
    background: rgba(109, 102, 91, 0.14);
    color: var(--muted);
}

/* ---- Lists ---- */
ul {
    padding-left: 1.25rem;
}

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

th, td {
    text-align: left;
    padding: 0.75rem var(--space-sm);
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

/* Responsive table wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.4;
}

.empty-state p {
    margin-bottom: var(--space-md);
    font-size: var(--text-lg);
}

.empty-state .button {
    margin-top: var(--space-sm);
}

/* ---- Dashboard widgets ---- */
.widget {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow var(--transition), transform var(--transition);
}

.widget:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.widget-icon {
    font-size: var(--text-2xl);
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    flex-shrink: 0;
}

.widget-body h3 {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--muted);
    font-weight: 600;
}

.widget-body .widget-value {
    font-size: var(--text-2xl);
    font-weight: 700;
}

/* ---- Tickets ---- */
.ticket-list {
    gap: var(--space-md);
}

.ticket-thread {
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    transition: box-shadow var(--transition);
}

.ticket-thread:hover {
    box-shadow: var(--shadow-sm);
}

.ticket-thread-open {
    background: linear-gradient(180deg, #f9f9f7 0%, #f3f1eb 100%);
}

.ticket-thread-closed {
    background: linear-gradient(180deg, #ebe6dc 0%, #e2dccf 100%);
    border-color: #c7bdac;
}

@media (prefers-color-scheme: dark) {
    .ticket-thread-open {
        background: linear-gradient(180deg, var(--surface) 0%, var(--surface-alt) 100%);
    }
    .ticket-thread-closed {
        background: linear-gradient(180deg, var(--surface-alt) 0%, #252220 100%);
        border-color: var(--line);
    }
}

.ticket-toggle {
    list-style: none;
    display: grid;
    grid-template-columns: 2.2rem minmax(120px, 0.8fr) minmax(180px, 1.15fr) minmax(140px, 0.8fr) minmax(140px, 0.8fr) auto auto;
    align-items: center;
    gap: 0.9rem 1.15rem;
    padding: var(--space-md) 1.35rem;
    cursor: pointer;
    transition: background var(--transition);
}

.ticket-toggle:hover {
    background: rgba(13, 92, 99, 0.04);
}

.ticket-toggle::-webkit-details-marker {
    display: none;
}

.ticket-toggle-icon {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, #ffffff 0%, #f3efe7 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent);
    transition: transform var(--transition);
}

.ticket-toggle-icon::before {
    content: "+";
}

.ticket-thread[open] .ticket-toggle-icon {
    transform: rotate(45deg);
}

.ticket-number {
    min-width: 0;
    font-size: var(--text-sm);
    font-weight: 700;
}

.ticket-title {
    min-width: 0;
    font-size: var(--text-sm);
}

.ticket-meta-item {
    min-width: 0;
    font-size: var(--text-sm);
    white-space: nowrap;
    color: var(--muted);
}

.ticket-status {
    justify-self: end;
    font-size: var(--text-xs);
    padding: 0.2rem 0.55rem;
}

.ticket-status-open {
    background: var(--success-bg);
    color: var(--success);
}

.ticket-status-closed {
    background: rgba(109, 102, 91, 0.14);
    color: var(--muted);
}

.ticket-count {
    justify-self: end;
    font-size: var(--text-xs);
    padding: 0.2rem 0.55rem;
}

.ticket-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--line);
}

.ticket-comment-admin {
    background: #f6ead1;
    border-left: 3px solid var(--warning);
}

.ticket-comment-customer {
    background: #eef8fb;
    border-left: 3px solid var(--accent);
}

@media (prefers-color-scheme: dark) {
    .ticket-comment-admin {
        background: rgba(184, 134, 11, 0.1);
    }
    .ticket-comment-customer {
        background: rgba(13, 92, 99, 0.1);
    }
}

/* ---- Confirm dialog ---- */
.confirm-delete {
    display: inline;
}

.confirm-delete .confirm-step-1 { display: inline; }
.confirm-delete .confirm-step-2 { display: none; }

.confirm-delete.confirming .confirm-step-1 { display: none; }
.confirm-delete.confirming .confirm-step-2 { display: inline; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
    .settings-tabs {
        flex-direction: column;
        gap: 0;
        border-bottom: none;
    }

    .settings-tabs button {
        border-radius: 0;
        border-bottom: 1px solid var(--line);
        text-align: left;
        padding: var(--space-sm) var(--space-md);
    }

    .settings-tabs button.active {
        border-bottom-color: var(--accent);
    }

    .shell {
        padding-inline: 0.75rem;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-toggle {
        display: block;
        align-self: flex-end;
        margin-top: calc(var(--space-md) * -1);
    }

    .nav {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: var(--space-xs);
    }

    .nav.open {
        display: flex;
    }

    .nav a {
        width: 100%;
        padding: var(--space-sm);
    }

    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-menu {
        position: static;
        border: none;
        box-shadow: none;
        margin-top: 0;
        padding: 0 0 0 var(--space-md);
        background: transparent;
    }

    .nav-dropdown-menu a {
        padding: var(--space-sm) !important;
    }

    .ticket-toggle {
        grid-template-columns: 2rem minmax(0, 1fr);
        align-items: flex-start;
    }

    .ticket-number,
    .ticket-title,
    .ticket-meta-item,
    .ticket-status,
    .ticket-count {
        grid-column: 2;
        justify-self: start;
    }

    .ticket-meta-item {
        white-space: normal;
    }

    .breadcrumbs {
        flex-wrap: wrap;
    }

    .topbar-customer-switcher {
        width: 100%;
    }

    .topbar-customer-switcher select {
        width: 100%;
    }
}

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

.max-w-form {
    max-width: 480px;
}

/* ---- Color scheme picker ---- */
.color-scheme-picker {
    width: auto;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

/* ============================================================
   Multi-select dropdown (admin settings)
   ============================================================ */

.multi-dropdown {
    position: relative;
}

.multi-dropdown-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.6rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.multi-dropdown-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.multi-dropdown-summary {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-dropdown-menu {
    display: none;
    position: absolute;
    z-index: 60;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-xs);
}

.multi-dropdown.open .multi-dropdown-menu {
    display: block;
}

.multi-dropdown-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin: 0;
    font-weight: 400;
}

.multi-dropdown-option:hover {
    background: var(--surface-hover);
}

.multi-dropdown-option input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

/* ============================================================
   Processing overlay (long-running actions)
   ============================================================ */

.processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: rgba(31, 29, 26, 0.55);
    backdrop-filter: blur(3px);
}

.processing-overlay.visible {
    display: flex;
}

.processing-card {
    display: grid;
    justify-items: center;
    gap: var(--space-md);
    max-width: 420px;
    padding: var(--space-xl);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.processing-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid var(--surface-alt);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
