:root {
    --background-color: #1a1f36;
    --container-background: #2e3b5d;
    --text-color: #d0e1ff;
    --input-background: #3a4a6b;
    --input-border: #4a5a7b;
    --button-background: #4b5b7d;
    --button-hover: #0056b3;
    --error-color: #ff4d4d;
    --card-background: #2e3b5e;
    --header-bg: #1e2640;
    --header-border: rgba(255, 255, 255, 0.08);
    --header-height: 56px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Light theme overrides */
[data-theme="light"] {
    --background-color: #f0f2f5;
    --container-background: #ffffff;
    --text-color: #1a1a2e;
    --input-background: #e8ecf1;
    --input-border: #c5cdd8;
    --button-background: #4b7bec;
    --button-hover: #3867d6;
    --error-color: #e53e3e;
    --card-background: #ffffff;
    --header-bg: #ffffff;
    --header-border: #e5e7eb;
}

[data-theme="light"] a {
    color: #2563eb;
}

/* ===== APP HEADER ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    padding-top: var(--safe-area-top);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    max-width: 100%;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.app-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.app-hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .app-hamburger:hover {
    background: rgba(0, 0, 0, 0.06);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
}

.app-logo i {
    color: #4c9aff;
    font-size: 18px;
}

.app-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
    padding: 0 16px;
}

.app-tenant-select {
    background: var(--input-background);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    max-width: 200px;
}

.app-tenant-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    opacity: 0.8;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
}

.app-header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

[data-theme="light"] .app-header-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.app-admin-btn {
    color: #f59e0b;
}

[data-theme="light"] .app-admin-btn {
    color: #2563eb;
}

.app-logout-btn {
    color: #ef4444;
}

.app-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
}

.app-user-name {
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.7;
    white-space: nowrap;
}

/* Theme Toggle in header */
.app-theme-toggle {
    position: relative;
}

.app-theme-icon-light { display: none; }
.app-theme-icon-dark { display: inline; }
[data-theme="light"] .app-theme-icon-light { display: inline; color: #f59e0b; }
[data-theme="light"] .app-theme-icon-dark { display: none; }

/* ===== MOBILE SLIDE MENU ===== */
.app-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
    opacity: 0;
    transition: opacity 0.3s;
}

.app-mobile-overlay.open {
    display: block;
    opacity: 1;
}

.app-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--header-bg);
    z-index: 960;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    border-right: 1px solid var(--header-border);
}

.app-mobile-menu.open {
    transform: translateX(0);
}

.app-mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--header-border);
}

.app-mobile-menu-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-color);
}

.app-mobile-menu-title i {
    color: #4c9aff;
}

.app-mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--header-border);
}

.app-mobile-menu-user > i {
    font-size: 32px;
    color: #4c9aff;
}

.app-mobile-user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.app-mobile-user-tenant {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
}

.app-mobile-menu-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--header-border);
}

.app-mobile-menu-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color);
    opacity: 0.5;
    padding: 8px 16px 4px;
}

.app-mobile-tenant-select {
    width: 100%;
    background: var(--input-background);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.app-mobile-menu-items {
    flex: 1;
    padding: 8px 0;
}

.app-mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    min-height: 44px;
    transition: background 0.15s;
}

.app-mobile-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .app-mobile-menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.app-mobile-menu-item.active {
    color: #4c9aff;
    font-weight: 600;
}

.app-mobile-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.app-mobile-menu-divider {
    height: 1px;
    background: var(--header-border);
    margin: 8px 0;
}

.app-mobile-menu-footer {
    border-top: 1px solid var(--header-border);
    padding: 8px 0;
}

.app-mobile-menu-item.logout {
    color: #ef4444;
}

/* ===== SETTINGS PANEL ===== */
.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 970;
    opacity: 0;
    transition: opacity 0.3s;
}

.settings-overlay.open {
    display: block;
    opacity: 1;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--background-color);
    z-index: 980;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-top: var(--safe-area-top);
    border-left: 1px solid var(--header-border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--header-border);
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.settings-header h2 i {
    color: #4c9aff;
}

.settings-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-body {
    flex: 1;
    padding: 8px 0;
}

.settings-section {
    padding: 8px 20px 16px;
}

.settings-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-color);
    opacity: 0.5;
    margin-bottom: 12px;
    padding-top: 8px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    gap: 12px;
    border-bottom: 1px solid var(--header-border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.settings-row-label > i {
    font-size: 16px;
    color: #4c9aff;
    width: 20px;
    text-align: center;
}

.settings-row-label div {
    font-size: 14px;
    color: var(--text-color);
}

.settings-row-hint {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.5;
    margin-top: 2px;
}

/* Toggle Switch */
.settings-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.settings-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #4a5568;
    border-radius: 28px;
    transition: background 0.3s;
}

.settings-switch-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.settings-switch input:checked + .settings-switch-slider {
    background: #4c9aff;
}

.settings-switch input:checked + .settings-switch-slider::before {
    transform: translateX(20px);
}

/* Toggle Button Group */
.settings-toggle-group {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--input-border);
}

.settings-toggle-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
    white-space: nowrap;
}

.settings-toggle-btn.active {
    background: #4c9aff;
    color: #fff;
}

.settings-toggle-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .settings-toggle-btn:not(.active):hover {
    background: rgba(0, 0, 0, 0.04);
}

.settings-select {
    background: var(--input-background);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.settings-about {
    padding: 12px;
    background: var(--input-background);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-color);
}

.settings-dev-btn {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.settings-dev-btn:hover {
    background: rgba(139, 92, 246, 0.25);
}

/* ===== DEV TOOLS MODAL ===== */
.devtools-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 990;
}

.devtools-overlay.open {
    display: block;
}

.devtools-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    background: var(--background-color);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    z-index: 995;
    overflow: hidden;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.devtools-modal.open {
    display: flex;
}

.devtools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--header-border);
    background: rgba(139, 92, 246, 0.08);
}

.devtools-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #a78bfa;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.devtools-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.devtools-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.devtools-body {
    overflow-y: auto;
    padding: 12px 18px 18px;
    flex: 1;
}

.devtools-section {
    margin-bottom: 16px;
}

.devtools-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a78bfa;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.devtools-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.devtools-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: var(--input-background);
    border-radius: 6px;
    font-size: 11px;
}

.devtools-status-label {
    color: var(--text-color);
    opacity: 0.7;
}

.devtools-status-value {
    font-weight: 600;
    font-family: monospace;
    font-size: 11px;
}

.devtools-status-value.ok { color: #48bb78; }
.devtools-status-value.warn { color: #f6ad55; }
.devtools-status-value.err { color: #fc8181; }
.devtools-status-value.na { color: #888; }

.devtools-btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.devtools-btn {
    padding: 7px 12px;
    background: var(--input-background);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
    white-space: nowrap;
}

.devtools-btn:hover {
    background: var(--button-background);
}

.devtools-btn.warn {
    color: #fc8181;
    border-color: rgba(252, 129, 129, 0.3);
}

.devtools-btn.warn:hover {
    background: rgba(252, 129, 129, 0.15);
}

.devtools-log {
    background: #0a0e1a;
    color: #68d391;
    font-family: monospace;
    font-size: 11px;
    padding: 10px;
    border-radius: 6px;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 6px;
    display: none;
}

.devtools-log.visible {
    display: block;
}

[data-theme="light"] .devtools-log {
    background: #f3f4f6;
    color: #065f46;
}

[data-theme="light"] .devtools-header {
    background: rgba(139, 92, 246, 0.05);
}

@media (max-width: 768px) {
    .devtools-modal {
        top: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .devtools-status-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== MAIN CONTENT ===== */
.app-content {
    padding-top: calc(var(--header-height) + var(--safe-area-top));
    min-height: 100vh;
}

.app-content-inner {
    padding: 0 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    max-width: 100%;
}

.app-debug-banner {
    padding: 20px;
    background: #1a1f2b;
    color: #ff6b6b;
    margin: calc(var(--header-height) + var(--safe-area-top) + 8px) 16px 0;
}

.app-debug-banner pre {
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

/* Compact mode */
.compact-mode .ch-call {
    padding: 6px 8px;
    gap: 6px;
}

.compact-mode .ch-call-name {
    font-size: 13px;
}

.compact-mode .ch-call-name-btn {
    font-size: 13px;
}

.compact-mode .ch-call-sub {
    font-size: 10px;
    gap: 4px;
    margin-top: 1px;
}

.compact-mode .ch-call-agent {
    font-size: 11px;
    min-width: 70px;
}

.compact-mode .ch-call-agent-name {
    font-size: 12px;
}

.compact-mode .ch-call-queue {
    font-size: 10px;
}

.compact-mode .ch-call-meta {
    font-size: 11px;
}

.compact-mode .ch-call-time {
    font-size: 11px;
}

.compact-mode .ch-call-dur {
    font-size: 10px;
}

.compact-mode .ch-hint {
    display: none;
}

.compact-mode .ch-header {
    padding: 8px 0;
    margin-bottom: 6px;
    gap: 6px;
}

.compact-mode .ch-title {
    font-size: 15px;
    gap: 6px;
}

.compact-mode .ch-nav-btn {
    padding: 5px 10px;
    font-size: 12px;
}

.compact-mode .ch-date-input {
    padding: 5px 8px;
    font-size: 12px;
}

.compact-mode .ch-stats {
    padding: 4px 0;
    gap: 10px;
    font-size: 12px;
}

.compact-mode .ch-stat {
    gap: 3px;
    font-size: 12px;
}

.compact-mode .ch-stat-num {
    font-size: 12px;
}

.compact-mode .ch-search {
    margin-bottom: 6px;
    gap: 6px;
}

.compact-mode .ch-search-input {
    padding: 6px 10px;
    font-size: 13px;
}

.compact-mode .ch-filter-btn {
    padding: 6px 10px;
}

.compact-mode .ch-list {
    gap: 6px;
}

.compact-mode .ch-callflow-panel {
    margin-bottom: 6px;
}

.compact-mode .ch-callflow-toggle {
    padding: 8px 10px;
    font-size: 12px;
}

.compact-mode .ch-call-flow-summary {
    margin-top: 4px;
}

.compact-mode .ch-flow-toggle {
    padding: 6px 10px;
    font-size: 11px;
}

.compact-mode .ch-flow-event {
    padding: 4px 8px;
    font-size: 11px;
}

.compact-mode .active-call-card {
    padding: 10px;
}

.compact-mode .active-calls-container {
    gap: 8px;
    padding-top: 10px;
}

.compact-mode #reloadTimer {
    font-size: 10px !important;
    padding: 4px 8px !important;
}

/* Mobile compact — additional tightening for mobile screens */
@media (max-width: 768px) {
    .compact-mode .ch-call {
        padding: 5px 6px;
        gap: 5px;
    }

    .compact-mode .ch-call-main {
        padding-right: 48px;
        gap: 2px;
    }

    .compact-mode .ch-call-name {
        font-size: 12px;
    }

    .compact-mode .ch-call-name-btn {
        font-size: 12px;
    }

    .compact-mode .ch-call-sub {
        font-size: 10px;
    }

    .compact-mode .ch-mobile-agent {
        margin-top: 2px;
        padding-top: 3px;
        gap: 4px;
        font-size: 10px;
    }

    .compact-mode .ch-call-agent-name {
        font-size: 10px;
    }

    .compact-mode .ch-call-queue {
        font-size: 9px;
    }

    .compact-mode .ch-call-meta {
        top: 5px;
        right: 6px;
    }

    .compact-mode .ch-call-time {
        font-size: 10px;
    }

    .compact-mode .ch-call-dur {
        font-size: 9px;
    }

    .compact-mode .ch-header {
        padding: 12px 0;
        margin-bottom: 4px;
        gap: 4px;
    }

    .compact-mode .ch-title {
        font-size: 14px;
    }

    .compact-mode .ch-nav {
        gap: 3px;
    }

    .compact-mode .ch-nav-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .compact-mode .ch-stats {
        padding: 6px 0;
        gap: 24px;
    }

    .compact-mode .ch-stat {
        font-size: 11px;
    }

    .compact-mode .ch-search {
        margin-bottom: 4px;
        gap: 4px;
    }

    .compact-mode .ch-search-input {
        padding: 5px 8px;
        font-size: 12px;
    }

    .compact-mode .ch-filter-btn {
        padding: 5px 8px;
    }

    .compact-mode .ch-callflow-toggle {
        padding: 6px 8px;
        font-size: 11px;
    }

    .compact-mode .active-calls-container {
        padding-top: 6px;
        gap: 6px;
    }

    .compact-mode .active-call-card {
        padding: 8px;
    }
}

/* ===== EXISTING STYLES (updated) ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
    color: #007bff;
}

body {
    font-family: monospace;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.centered-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container form {
    display: flex;
    flex-direction: column;
}

.login-container {
    background-color: var(--container-background);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    width: 300px;
    text-align: center;
}

.login-container h1 {
    margin-bottom: 10px;
    font-size: 24px;
}

.login-container label {
    display: block;
    margin-bottom: 5px;
    text-align: left;
}

.login-container input {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    background-color: var(--input-background);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-color);
}

.login-container input::placeholder {
    color: #b0b0b0;
}

.login-container button {
    width: 100%;
    padding: 10px;
    background-color: var(--button-background);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.login-container button:hover {
    background-color: var(--button-hover);
}

.error-message {
    color: var(--error-color);
    margin-bottom: 15px;
}

.details {
    margin: 10px;
    background-color: var(--container-background);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Legacy details-grid - kept for backward compat */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background-color: var(--container-background);
    padding: 20px;
    margin-bottom: 15px;
}

.grid-item {
    background-color: var(--input-background);
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status {
    padding: 5px 10px;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
}

.status.enabled {
    background-color: #28a745;
}

.status.disabled {
    background-color: #dc3545;
}

.logout-button {
    text-align: center;
    padding: 10px;
    background-color: var(--button-background);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.logout-button:hover {
    background-color: var(--button-hover);
}

[data-theme="light"] .logout-button {
    color: #fff;
}

.queue-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 5px;
    padding: 2px;
}

.queue-card {
    background-color: var(--card-background);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    text-align: left;
}

.queue-card h3 {
    margin-bottom: 10px;
    font-size: 20px;
    color: var(--text-color);
}

.queue-card p {
    margin: 5px 0;
    font-size: 14px;
    color: var(--text-color);
}

.call-history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: var(--container-background);
    color: var(--text-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.call-history-table th, .call-history-table td {
    padding: 10px;
    text-align: left;
}

.call-history-table th {
    background-color: var(--input-background);
    font-weight: bold;
}

.call-history-table tr:nth-child(even) {
    background-color: var(--input-background);
}

.status-button {
    padding: 8px 12px;
    margin: 2px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    width: 40px;
    height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
}

.status-button.done {
    background-color: #28a745;
}

.status-button.undefined {
    background-color: #ffc107;
}

.status-button.incomplete {
    background-color: #dc3545;
}

.status-button:hover {
    opacity: 0.9;
    transform: scale(1.1);
    transition: transform 0.2s ease-in-out;
}

.incoming-call {
    color: limegreen;
}

.outgoing-call {
    color: #007bff;
}

.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: wait;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top: 4px solid #4c5c7e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

[data-theme="light"] .spinner {
    border-color: #d1d5db;
    border-top-color: #4b7bec;
}

.pagination-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    background: #2e3b5d;
    padding: 5px 10px;
    border: 1px solid #3a4a6b;
    border-radius: 5px;
}

[data-theme="light"] .pagination-container {
    background: #ffffff;
    border-color: #d1d5db;
}

.pagination-buttons {
    display: flex;
    gap: 10px;
}

.pagination-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 15px;
    background: var(--button-background);
    color: var(--text-color);
    border-radius: 5px;
    font-size: 14px;
    transition: background 0.3s ease, transform 0.2s ease;
    cursor: pointer;
    border: none;
}

.pagination-button:hover {
    background: var(--button-hover);
    transform: scale(1.1);
}

.today-button {
    font-size: 14px;
    font-weight: bold;
    padding: 4px 15px;
    background: #4b5b7d;
    border-radius: 5px;
}

.today-button:hover {
    background: #218838;
}

.pagination-stats {
    font-size: 14px;
    color: var(--text-color);
    font-weight: bold;
}

.day-picker {
    padding: 5px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-background);
    color: var(--text-color);
}

a[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.active-calls-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding-top: 20px;
}

.active-call-card {
    background-color: var(--card-background);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: 100%;
    max-width: 300px;
}

.active-call-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--text-color);
}

.duration {
    font-weight: bold;
    color: #28a745;
}

/* ===== Active Call Cards Light Theme ===== */
[data-theme="light"] .active-call-card {
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .active-call-card div[style*="background: #1e2836"],
[data-theme="light"] .active-call-card div[style*="background:#1e2836"] {
    background: #f3f4f6 !important;
}

[data-theme="light"] .active-call-card div[style*="color: #fff"],
[data-theme="light"] .active-call-card span[style*="color: #fff"],
[data-theme="light"] .active-call-card strong[style*="color: #fff"] {
    color: #111827 !important;
}

[data-theme="light"] .active-call-card div[style*="color: #aaa"] {
    color: #6b7280 !important;
}

[data-theme="light"] .active-call-card div[style*="color: #888"] {
    color: #6b7280 !important;
}

[data-theme="light"] .active-call-card .duration-counter {
    color: #111827 !important;
}

[data-theme="light"] .active-call-card span[style*="font-size: 20px"] {
    color: #111827 !important;
}

[data-theme="light"] .active-call-card div[style*="border-top: 1px solid #3d4a5c"] {
    border-top-color: #e5e7eb !important;
}

/* Yellow text → amber on light theme (global fix) */
[data-theme="light"] .active-call-card span[style*="color: #ffcc00"],
[data-theme="light"] .active-call-card div[style*="color: #ffcc00"],
[data-theme="light"] .active-call-card strong[style*="color: #ffcc00"] {
    color: #b45309 !important;
}

[data-theme="light"] .active-call-card i[style*="color: #ffcc00"] {
    color: #d97706 !important;
}

[data-theme="light"] .active-call-card[style*="border-left: 3px solid #ffcc00"] {
    border-left-color: #d97706 !important;
}

/* Global yellow text fix for light theme */
[data-theme="light"] span[style*="color: #ffcc00"],
[data-theme="light"] div[style*="color: #ffcc00"],
[data-theme="light"] strong[style*="color: #ffcc00"],
[data-theme="light"] a[style*="color: #ffcc00"] {
    color: #b45309 !important;
}

/* Active calls summary bar */
[data-theme="light"] div[style*="background: #1e2836"] {
    background: #f3f4f6 !important;
}

[data-theme="light"] div[style*="color: #e0e0e0"] {
    color: #374151 !important;
}

[data-theme="light"] div[style*="color: #ccc"] {
    color: #4b5563 !important;
}

/* Diversion Banner */
[data-theme="light"] .callflow-diversion-banner div[style*="background: linear-gradient"] {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(234, 88, 12, 0.05)) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

[data-theme="light"] .callflow-diversion-banner div[style*="color: #e0e0e0"] {
    color: #374151 !important;
}

[data-theme="light"] .callflow-diversion-banner strong[style*="color: #fff"] {
    color: #111827 !important;
}

[data-theme="light"] .callflow-diversion-banner div[style*="color: #999"] {
    color: #6b7280 !important;
}

[data-theme="light"] .callflow-diversion-banner span[style*="color: #777"] {
    color: #6b7280 !important;
}

[data-theme="light"] .callflow-diversion-banner span[style*="color: #aaa"] {
    color: #6b7280 !important;
}

/* Class-based active call light theme */
[data-theme="light"] .ac-ext-name { color: #111827 !important; }
[data-theme="light"] .ac-ext-sub { color: #6b7280 !important; }
[data-theme="light"] .ac-external-panel { background: #f3f4f6 !important; }
[data-theme="light"] .ac-party-label { color: #6b7280 !important; }
[data-theme="light"] .ac-contact-name { color: #111827 !important; }
[data-theme="light"] .ac-company { color: #6b7280 !important; }
[data-theme="light"] .ac-phone-num { color: #6b7280 !important; }
[data-theme="light"] .ac-unknown-num { color: #111827 !important; }
[data-theme="light"] .ac-dialing-text { color: #b45309 !important; }
[data-theme="light"] .ac-dialing-icon { color: #d97706 !important; }
[data-theme="light"] .ac-duration-bar { border-top-color: #e5e7eb !important; }
[data-theme="light"] .ac-duration-text { color: #111827 !important; }
[data-theme="light"] .ac-summary { background: #f3f4f6 !important; color: #6b7280 !important; }

[data-theme="light"] .active-call-card span[style*="color: limegreen"] { color: #059669 !important; }
[data-theme="light"] .active-call-card span[style*="color: cyan"] { color: #0891b2 !important; }
[data-theme="light"] .active-call-card span[style*="color: lime"] { color: #059669 !important; }
[data-theme="light"] .active-call-card span[style*="color: #aaa"] { color: #6b7280 !important; }

/* Global inline white text on light */
[data-theme="light"] span[style*="color: #fff"],
[data-theme="light"] div[style*="color: #fff"],
[data-theme="light"] strong[style*="color: #fff"] {
    color: #111827 !important;
}

/* Global inline #aaa text on light */
[data-theme="light"] span[style*="color: #aaa"],
[data-theme="light"] div[style*="color: #aaa"] {
    color: #6b7280 !important;
}

/* Global inline #888 text on light */
[data-theme="light"] span[style*="color: #888"],
[data-theme="light"] div[style*="color: #888"] {
    color: #6b7280 !important;
}

/* Global inline #666 text on light */
[data-theme="light"] span[style*="color: #666"],
[data-theme="light"] div[style*="color: #666"] {
    color: #9ca3af !important;
}

/* Inline background overrides for light */
[data-theme="light"] div[style*="background: #1a1f2b"],
[data-theme="light"] div[style*="background:#1a1f2b"],
[data-theme="light"] div[style*="background: #252d3a"],
[data-theme="light"] div[style*="background:#252d3a"] {
    background: #f3f4f6 !important;
}

[data-theme="light"] div[style*="background: #2d3748"],
[data-theme="light"] span[style*="background: #2d3748"] {
    background: #e5e7eb !important;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    :root {
        --header-height: 48px;
    }

    .hide_on_mobile,
    .hide-mobile {
        display: none !important;
    }

    .app-hamburger {
        display: flex;
    }

    .app-logo-text {
        display: none;
    }

    .app-header-center {
        padding: 0 4px;
    }

    .app-tenant-select {
        max-width: 140px;
        font-size: 12px;
        padding: 4px 8px;
    }

    .app-header-right .app-admin-btn {
        display: none;
    }

    .app-header-btn {
        width: 32px;
        height: 32px;
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
        border-radius: 8px;
    }

    .app-header-right {
        gap: 1px;
    }

    .app-content-inner {
        padding: 0 6px;
    }

    .active-calls-container {
        grid-template-columns: 1fr;
    }

    .active-call-card {
        max-width: 100%;
    }

    /* Settings panel full width on small screens */
    .settings-panel {
        width: 100%;
        max-width: 100vw;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 44px;
    }

    .app-header-inner {
        padding: 0 4px;
    }

    .app-tenant-select {
        max-width: 100px;
        font-size: 11px;
        padding: 3px 6px;
    }

    .app-header-btn {
        width: 30px;
        height: 30px;
        min-width: 36px;
        min-height: 36px;
        font-size: 13px;
    }

    .app-content-inner {
        padding: 0 4px;
    }
}

/* PWA standalone mode adjustments */
@media (display-mode: standalone) {
    .app-header {
        padding-top: var(--safe-area-top);
    }
}

/* ===== LIGHT THEME: Header-specific ===== */
[data-theme="light"] .app-header {
    background: var(--header-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .details-grid {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .details-grid select {
    background: #e8ecf1 !important;
    color: #1a1a2e !important;
    border-color: #c5cdd8 !important;
}

[data-theme="light"] .admin-link {
    color: #2563eb !important;
}

[data-theme="light"] .grid-item a[style*="color: #ffcc00"] {
    color: #2563eb !important;
}

