/* ── Welp Support Panel — Apple-style Dark Theme ── */

:root {
    --background: #0a0a0c;
    --foreground: #f5f5f7;
    --card: rgba(28, 28, 30, 0.65);
    --card-foreground: #f5f5f7;
    --card-hover: rgba(44, 44, 46, 0.75);
    --card-solid: #1c1c1e;
    --muted: rgba(28, 28, 30, 0.5);
    --muted-foreground: #98989d;
    --accent: #2eb872;
    --accent-hover: #3fc97e;
    --accent-glow: rgba(46, 184, 114, 0.20);
    --accent-soft: rgba(46, 184, 114, 0.08);
    --primary: #2eb872;
    --primary-foreground: #ffffff;
    --secondary: #1c1c1e;
    --secondary-foreground: #c7c7cc;
    --destructive: #ff453a;
    --destructive-foreground: #ffffff;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.14);
    --input: rgba(255, 255, 255, 0.10);
    --input-bg: rgba(28, 28, 30, 0.5);
    --ring: #2eb872;
    --success: #30d158;
    --success-soft: rgba(48, 209, 88, 0.10);
    --warning: #ff9f0a;
    --info: #64d2ff;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.24);
    --shadow: 0 4px 20px rgba(0,0,0,0.28);
    --shadow-md: 0 12px 40px rgba(0,0,0,0.38);
    --shadow-glow: 0 0 24px rgba(46, 184, 114, 0.15);
    --transition: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: 0.12s cubic-bezier(0.25, 0.8, 0.25, 1);
    --gradient-accent: linear-gradient(135deg, #2eb872, #3fc97e);

    --sidebar-bg: rgba(18, 18, 20, 0.85);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-fg: #f5f5f7;
    --sidebar-muted: #98989d;
    --sidebar-accent-bg: rgba(46, 184, 114, 0.10);

    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.01em;
}

/* Apple-style ambient background glow */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(1400px 600px at 5% -10%, rgba(46, 184, 114, 0.06), transparent 55%),
        radial-gradient(1000px 500px at 100% 110%, rgba(46, 184, 114, 0.03), transparent 50%);
}

a {
    color: var(--foreground);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--muted-foreground);
}

/* ── Layout ── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
    width: 256px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: 1px solid var(--sidebar-border);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 22px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(46, 184, 114, 0.3);
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--sidebar-fg);
    letter-spacing: -0.3px;
}

.sidebar-brand span {
    font-size: 11px;
    color: var(--sidebar-muted);
    display: block;
    margin-top: 1px;
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
}

.nav-section {
    margin-bottom: 16px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-muted);
    padding: 0 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--sidebar-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 1px;
    border: 1px solid transparent;
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--sidebar-fg);
}

.nav-link.active {
    background: var(--sidebar-accent-bg);
    color: var(--accent);
    font-weight: 600;
    border-color: rgba(46, 184, 114, 0.12);
}

.nav-link .icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-link .icon i,
.nav-link .icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.75;
}

/* ── Main content ── */

.main-content {
    margin-left: 256px;
    flex: 1;
    padding: 32px;
    min-width: 0;
    background: var(--background);
}

.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.6px;
    margin-bottom: 4px;
    color: var(--foreground);
}

.page-header p {
    color: var(--muted-foreground);
    font-size: 14px;
}

/* ── Stat Cards ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

/* ── Dashboard two-column row ── */

.dashboard-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card .card-body { padding: 16px 20px; }

.chart-legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--muted-foreground);
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot {
    width: 9px; height: 9px; border-radius: 50%;
    display: inline-block;
}
.legend-dot.created { background: var(--accent); }
.legend-dot.closed { background: var(--destructive); }

.chart-wrap {
    width: 100%;
    height: 200px;
}
.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 100%;
    gap: 8px;
    padding-top: 14px;
}
.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 0;
}
.chart-bar-pair {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    width: 100%;
    max-height: 170px;
}
.chart-bar {
    width: 10px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    justify-content: center;
}
.chart-bar.created { background: var(--accent); }
.chart-bar.closed { background: var(--destructive); opacity: 0.7; }
.bar-val {
    position: absolute;
    top: -16px;
    font-size: 10px;
    color: var(--muted-foreground);
    font-weight: 600;
}
.chart-label {
    font-size: 11px;
    color: var(--muted-foreground);
    margin-top: 6px;
    white-space: nowrap;
}

/* Agent workload */
.workload-list {
    max-height: 260px;
    overflow-y: auto;
}
.workload-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.workload-item:hover { background: var(--accent-soft); }
.workload-item:last-child { border-bottom: none; }
.workload-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.workload-info { flex: 1; min-width: 0; }
.workload-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.workload-login { font-size: 12px; }
.workload-count {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}
.workload-count .count-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.workload-count.busy .count-value { color: var(--warning); }
.workload-count .count-label {
    font-size: 10px;
    color: var(--muted-foreground);
    margin-top: 2px;
}

.stat-card {
    background: var(--card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.stat-card:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    margin-bottom: 10px;
    color: var(--muted-foreground);
}

.stat-card .stat-icon i,
.stat-card .stat-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
}

.stat-card.accent .stat-icon { color: var(--accent); }
.stat-card.success .stat-icon { color: var(--success); }
.stat-card.warning .stat-icon { color: var(--warning); }
.stat-card.danger .stat-icon { color: var(--destructive); }
.stat-card.info .stat-icon { color: var(--info); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
    color: var(--foreground);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--muted-foreground);
    margin-top: 4px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--destructive); }
.stat-card.info .stat-value { color: var(--info); }

/* ── Card / Table ── */

.card {
    background: var(--card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.2px;
}

.card-body {
    padding: 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted-foreground);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--foreground);
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: var(--accent-soft);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Status badges ── */

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    letter-spacing: 0.1px;
}

.badge-status.open {
    background: rgba(48, 209, 88, 0.10);
    color: var(--success);
    border-color: rgba(48, 209, 88, 0.20);
}

.badge-status.claimed {
    background: rgba(255, 159, 10, 0.10);
    color: var(--warning);
    border-color: rgba(255, 159, 10, 0.20);
}

.badge-status.escalated {
    background: rgba(100, 210, 255, 0.10);
    color: var(--info);
    border-color: rgba(100, 210, 255, 0.20);
}

.badge-status.closed {
    background: rgba(255, 69, 58, 0.10);
    color: var(--destructive);
    border-color: rgba(255, 69, 58, 0.20);
}

/* ── Ticket cards list ── */

.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ticket-card {
    display: flex;
    background: var(--card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--foreground);
    transition: transform var(--transition-fast), background var(--transition), border-color var(--transition), box-shadow var(--transition);
    position: relative;
}
.ticket-card:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    color: var(--foreground);
}
.ticket-card:active {
    transform: translateY(0) scale(0.99);
}

.ticket-card-strip {
    width: 4px;
    flex-shrink: 0;
    background: var(--border-light);
}
.ticket-card.open .ticket-card-strip { background: var(--success); }
.ticket-card.claimed .ticket-card-strip { background: var(--warning); }
.ticket-card.escalated .ticket-card-strip { background: var(--info); }
.ticket-card.closed .ticket-card-strip { background: var(--muted-foreground); }

.ticket-card-body {
    flex: 1;
    padding: 12px 16px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticket-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ticket-card-number {
    font-size: 14px;
    font-weight: 700;
}
.ticket-card-cat {
    font-size: 12px;
    color: var(--muted-foreground);
}
.ticket-card-date {
    margin-left: auto;
    white-space: nowrap;
}

.ticket-card-preview {
    font-size: 13px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    opacity: 0.7;
}

.ticket-card-bottom {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.ticket-card-meta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--muted-foreground);
}
.ticket-card-meta svg {
    color: var(--muted-foreground);
}

.ticket-card.is-new {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.ticket-card.is-new:hover {
    background: var(--accent-glow);
}

/* "New" badge */
.new-badge {
    display: inline-block;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #fff;
    background: var(--accent);
    border-radius: 999px;
    vertical-align: middle;
}

/* SLA badge — response time indicator */
.sla-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    font-variant-numeric: tabular-nums;
}
.sla-badge svg { stroke-width: 2; }
.sla-ok {
    background: rgba(48, 209, 88, 0.10);
    color: var(--success);
    border-color: rgba(48, 209, 88, 0.22);
}
.sla-warn {
    background: rgba(255, 159, 10, 0.12);
    color: var(--warning);
    border-color: rgba(255, 159, 10, 0.25);
}
.sla-over {
    background: rgba(255, 59, 48, 0.12);
    color: var(--destructive);
    border-color: rgba(255, 59, 48, 0.25);
    animation: sla-pulse 2s ease-in-out infinite;
}
@keyframes sla-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.pagination-wrap {
    margin-top: 16px;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition), border-color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    user-select: none;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(46, 184, 114, 0.2);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--primary-foreground);
    box-shadow: 0 4px 16px rgba(46, 184, 114, 0.3);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    color: var(--secondary-foreground);
    border-color: var(--border-light);
}
.btn-outline:hover {
    background: var(--accent-soft);
    color: var(--foreground);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
    box-shadow: 0 2px 8px rgba(255, 69, 58, 0.15);
}
.btn-danger:hover {
    opacity: 0.92;
    box-shadow: 0 4px 16px rgba(255, 69, 58, 0.25);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
    box-shadow: 0 2px 8px rgba(48, 209, 88, 0.15);
}
.btn-success:hover {
    opacity: 0.92;
    box-shadow: 0 4px 16px rgba(48, 209, 88, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--muted-foreground);
}
.btn-ghost:hover {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.05);
}
.theme-btn.active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ── Forms ── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 14px;
    background: var(--input-bg);
    border: 1px solid var(--input);
    border-radius: 10px;
    color: var(--foreground);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--muted-foreground);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7194' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 36px;
}

/* ── Filters ── */

.filters {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 13px;
    font-weight: 500;
    background: var(--card);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.filter-btn:hover {
    background: var(--accent-soft);
    color: var(--foreground);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(46, 184, 114, 0.2);
}

/* ── Category dropdown ── */

.cat-dropdown {
    position: relative;
}
.cat-toggle i:last-child {
    transition: transform var(--transition);
}
.cat-dropdown.open .cat-toggle i:last-child {
    transform: rotate(180deg);
}
.cat-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--card-solid);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 5px;
    z-index: 200;
    animation: catDropdownIn 0.15s ease;
}
.cat-dropdown.open .cat-dropdown-menu {
    display: block;
}
.cat-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--foreground);
    transition: background var(--transition-fast);
}
.cat-dropdown-menu a:hover {
    background: var(--accent-soft);
    color: var(--foreground);
}
.cat-dropdown-menu a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.cat-dropdown-menu a i {
    color: var(--muted-foreground);
}
.cat-dropdown-menu a.active i {
    color: var(--accent);
}
@keyframes catDropdownIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Pagination ── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 16px;
}

.pagination .page-dots {
    border: none;
    padding: 6px 6px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--muted-foreground);
    transition: all var(--transition);
}

.pagination a:hover {
    background: var(--accent-soft);
    color: var(--foreground);
}

.pagination .current {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* ── Chat / Messages ── */

.chat-card {
    display: flex;
    flex-direction: column;
    min-height: 480px;
    height: calc(100vh - 280px);
    max-height: 800px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 24px 8px;
    background: transparent;
    margin: 0;
    flex: 1 1 auto;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 78%;
}

.chat-message.client {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-message.agent {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message .msg-sender {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted-foreground);
    padding: 0 4px;
}

.chat-message.agent .msg-sender {
    color: var(--accent);
    flex-direction: row-reverse;
}

.chat-message.client .msg-sender {
    color: var(--success);
}

.chat-message .msg-sender .msg-time {
    font-weight: 400;
    font-size: 11px;
    color: var(--muted-foreground);
}

.chat-message .msg-content {
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--foreground);
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.client .msg-content {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 18px 18px 18px 4px;
    border: 1px solid var(--border);
}

.chat-message.agent .msg-content {
    background: var(--primary);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 12px rgba(46, 184, 114, 0.2);
}

.chat-message .msg-media {
    margin: 6px 4px 0;
    max-width: 100%;
}

/* Slide-in animation for new chat messages */
@keyframes msg-slide-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.chat-message.msg-new {
    animation: msg-slide-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chat-message.client.msg-new {
    animation-name: msg-slide-in-left;
}
.chat-message.agent.msg-new {
    animation-name: msg-slide-in-right;
}
@keyframes msg-slide-in-left {
    from { opacity: 0; transform: translateX(-16px) scale(0.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes msg-slide-in-right {
    from { opacity: 0; transform: translateX(16px) scale(0.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
.chat-message.agent .msg-media {
    display: flex;
    justify-content: flex-end;
}
.chat-message.client .msg-media {
    display: flex;
    justify-content: flex-start;
}

/* ── Ticket detail header ── */

.ticket-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.ticket-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.ticket-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.meta-item {
    background: var(--card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}

.meta-item .meta-label {
    font-size: 12px;
    color: var(--muted-foreground);
    margin-bottom: 4px;
    font-weight: 500;
}

.meta-item .meta-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
}

/* ── Modal ── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.modal-box {
    background: var(--card-solid);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    min-width: 320px;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 12px;
}

.modal-message {
    font-size: 14px;
    color: var(--muted-foreground);
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ── Empty state ── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted-foreground);
}

.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--muted-foreground);
    font-weight: 500;
    margin-bottom: 4px;
}

/* ── Utility ── */

.text-muted { color: var(--muted-foreground); }
.text-success { color: var(--success); }
.text-danger { color: var(--destructive); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ── Scrollbar ── */

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ── Reply form ── */

.reply-form {
    border-top: 1px solid var(--border);
    padding: 12px 20px 14px;
    background: var(--card-solid);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    flex-shrink: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.reply-form-inner {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.reply-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: vertical;
}

.reply-btn {
    height: 42px;
    width: 42px;
    padding: 0;
    flex-shrink: 0;
    border-radius: 50%;
}

/* ── Reply toolbar ── */

.reply-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.reply-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.reply-tool-btn:hover {
    color: var(--foreground);
    background: var(--accent-soft);
    border-color: var(--accent);
}
.reply-tool-btn:active {
    transform: scale(0.96);
}

/* ── Slide-out panels ── */

.slideout-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.slideout-overlay.open {
    display: block;
    opacity: 1;
}

.slideout-panel {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    z-index: 9001;
    background: var(--card-solid);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-left: 1px solid var(--border-light);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.slideout-panel.open {
    right: 0;
}

.slideout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.slideout-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--foreground);
}

.slideout-close {
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: all var(--transition);
}
.slideout-close:hover {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.06);
}

.slideout-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.slideout-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    color: var(--foreground);
    font-family: inherit;
    transition: background var(--transition-fast);
    margin-bottom: 4px;
}
.slideout-item:hover {
    background: var(--accent-soft);
}
.slideout-item:active {
    transform: scale(0.98);
}

.slideout-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 8px;
}

.slideout-item-preview {
    font-size: 12px;
    color: var(--muted-foreground);
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.slideout-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted-foreground);
}
.slideout-empty i,
.slideout-empty svg {
    color: var(--muted-foreground);
    margin-bottom: 12px;
}
.slideout-empty p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Agent avatar in transfer panel */
.agent-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Media in chat ── */

.msg-media {
    margin: 4px 0 2px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 320px;
}

.msg-media img {
    display: block;
    max-width: 100%;
    border-radius: 8px;
}

.msg-media video {
    display: block;
    max-width: 100%;
    border-radius: 8px;
}

.msg-media a.file-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    transition: background var(--transition);
}

.msg-media a.file-download:hover {
    background: var(--accent-soft);
}

.pdf-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 520px;
}

.pdf-preview iframe {
    background: var(--bg-secondary);
    border-radius: 8px;
    min-height: 420px;
}

/* ── Category icon in table cells ── */

.cat-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cat-label svg,
.cat-label i {
    width: 14px;
    height: 14px;
    color: var(--muted-foreground);
    stroke-width: 1.75;
}

/* ── Sidebar footer / user ── */

.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--sidebar-fg);
}

.sidebar-role {
    margin-left: auto;
    font-size: 11px;
    color: var(--sidebar-muted);
    background: var(--sidebar-accent-bg);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ── Toast notifications ── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    background: var(--card-solid);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    min-width: 280px;
    max-width: 420px;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transition: opacity 0.3s, transform 0.3s;
}

/* New-ticket toast — accent border + glow */
.toast-new-ticket {
    border-color: rgba(46, 184, 114, 0.3);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 24px rgba(46, 184, 114, 0.15);
}
.toast-new-ticket .toast-icon {
    color: var(--accent);
}

/* Toast action button */
.toast-action {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform var(--transition-fast), background var(--transition);
    align-self: center;
    flex-shrink: 0;
    margin-left: 4px;
}
.toast-action:hover {
    background: var(--accent-hover);
}
.toast-action:active {
    transform: scale(0.95);
}

.toast.toast-out {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-icon svg { width: 18px; height: 18px; }

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error .toast-icon { color: var(--destructive); }
.toast.toast-info .toast-icon { color: var(--accent); }
.toast.toast-transfer .toast-icon { color: var(--warning); }
.toast.toast-transfer { border-color: rgba(245, 158, 11, 0.3); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--foreground);
}

.toast-message {
    font-size: 12px;
    color: var(--muted-foreground);
    margin-top: 2px;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0;
}

.toast-close svg { width: 14px; height: 14px; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Light theme (auto) ── */

[data-theme="light"] {
    --background: #f5f5f7;
    --foreground: #1c1c1e;
    --card: rgba(255, 255, 255, 0.72);
    --card-foreground: #1c1c1e;
    --card-hover: rgba(255, 255, 255, 0.92);
    --card-solid: #ffffff;
    --muted: rgba(0, 0, 0, 0.04);
    --muted-foreground: #6e6e73;
    --accent: #1a9d5c;
    --accent-hover: #2eb872;
    --accent-glow: rgba(26, 157, 92, 0.14);
    --accent-soft: rgba(26, 157, 92, 0.07);
    --primary: #1a9d5c;
    --primary-foreground: #ffffff;
    --secondary: rgba(0, 0, 0, 0.05);
    --secondary-foreground: #3a3a3c;
    --destructive: #ff3b30;
    --destructive-foreground: #ffffff;
    --border: rgba(0, 0, 0, 0.07);
    --border-light: rgba(0, 0, 0, 0.10);
    --input: rgba(0, 0, 0, 0.07);
    --input-bg: rgba(255, 255, 255, 0.7);
    --ring: #1a9d5c;
    --success: #248a3d;
    --success-soft: rgba(36, 138, 61, 0.08);
    --warning: #ff9500;
    --info: #007aff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-md: 0 12px 40px rgba(0,0,0,0.10);
    --shadow-glow: 0 0 24px rgba(26, 157, 92, 0.10);

    --sidebar-bg: rgba(245, 245, 247, 0.75);
    --sidebar-border: rgba(0, 0, 0, 0.05);
    --sidebar-fg: #1c1c1e;
    --sidebar-muted: #6e6e73;
    --sidebar-accent-bg: rgba(26, 157, 92, 0.08);
}

/* ── Responsive ── */

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 56px;
        overflow: hidden;
    }
    .sidebar-brand h1,
    .sidebar-brand span,
    .nav-section-title,
    .nav-link span:not(.icon),
    .sidebar-footer {
        display: none;
    }
    .sidebar-brand {
        justify-content: center;
        padding: 16px 10px;
    }
    .nav-link {
        justify-content: center;
        padding: 10px;
        min-height: 44px; /* touch target */
    }
    .main-content {
        margin-left: 56px;
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Filters stack and take full width */
    .filters {
        flex-wrap: wrap;
    }
    .filters .search-input {
        min-width: 0;
        flex: 1 1 100%;
        order: -1;
    }
    /* Wide tables scroll horizontally instead of breaking layout */
    .card:has(> table) {
        overflow-x: auto;
    }
    .card > table {
        min-width: 620px;
    }
    /* Chat fills the viewport on phones/tablets */
    .chat-card {
        height: calc(100dvh - 170px);
        max-height: none;
        min-height: 0;
    }
    /* Buttons get comfortable touch targets */
    .btn, .filter-btn {
        min-height: 36px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px 10px;
    }
    .page-header h2 {
        font-size: 20px;
    }
    .stats-grid {
        gap: 8px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
    .ticket-card-body {
        padding: 12px;
    }
    .pagination a, .pagination span {
        padding: 8px 11px; /* touch target */
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Consistency fixes ───────────────────────────────────────── */
.filter-btn .filter-count {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}
.filter-btn.active .filter-count {
    background: rgba(255,255,255,0.2);
    color: var(--primary-foreground);
}
.search-input {
    min-width: 280px;
    padding: 7px 14px 7px 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--foreground);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2398989d' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M9 17a8 8 0 100-16 8 8 0 000 16zM21 21l-5-5'/%3e%3c/svg%3e");
    background-position: 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input::placeholder {
    color: var(--muted-foreground);
}
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
/* Unify control heights so buttons/inputs align on the same line. */
.filters .btn,
.filters .filter-btn,
.filters input[type="search"] {
    height: 34px;
    box-sizing: border-box;
}
.filters input[type="search"] {
    display: inline-flex;
    margin: 0;
}
input[type="search"] {
    font-family: inherit;
}
.btn {
    box-sizing: border-box;
}
/* Row hover feedback on tables for better UX. */
table tbody tr {
    transition: background var(--transition);
}
table tbody tr:hover {
    background: var(--accent-soft);
}
/* Consistent focus ring across interactive elements. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}
