/* =====================================================================
 * GENESIS DASHBOARD — shared styles for dashboard, history and insights
 * Colours come only from the tokens below; components never hard-code
 * theme colours, so light and dark mode stay consistent.
 * ===================================================================== */

/* ---------- 1. DESIGN TOKENS ---------- */
:root,
:root[data-theme="dark"] {
    --bg: #0b1622;
    --surface: #111f2e;
    --surface-2: #172a3d;
    --surface-hover: #1b3148;
    --border: #22384e;
    --text: #e6edf5;
    --text-muted: #8ea3b9;
    --accent: #00aeef;          /* brand cyan */
    --accent-strong: #0096d1;
    --accent-soft: rgba(0, 174, 239, 0.14);
    --brand-2: #e6007e;         /* brand magenta — used sparingly */
    --success: #2ecc71;
    --warning: #f1c40f;
    --info: #4aa3f0;
    --danger: #ff5a5f;
    --success-soft: rgba(46, 204, 113, 0.14);
    --warning-soft: rgba(241, 196, 15, 0.14);
    --info-soft: rgba(74, 163, 240, 0.14);
    --danger-soft: rgba(255, 90, 95, 0.14);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --overlay: rgba(3, 10, 18, 0.72);
    --glow: rgba(0, 174, 239, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --surface-2: #f5f8fb;
    --surface-hover: #edf2f7;
    --border: #dde5ee;
    --text: #0d2640;
    --text-muted: #5b7089;
    --accent: #0096d1;
    --accent-strong: #007fb3;
    --accent-soft: rgba(0, 150, 209, 0.10);
    --success: #1e9e55;
    --warning: #b7860b;
    --info: #2475c7;
    --danger: #d93a3f;
    --success-soft: rgba(30, 158, 85, 0.10);
    --warning-soft: rgba(183, 134, 11, 0.12);
    --info-soft: rgba(36, 117, 199, 0.10);
    --danger-soft: rgba(217, 58, 63, 0.10);
    --shadow: 0 8px 24px rgba(13, 38, 64, 0.10);
    --overlay: rgba(13, 38, 64, 0.45);
    --glow: rgba(0, 150, 209, 0.10);
    color-scheme: light;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

/* Soft static glow instead of the old animated gradient */
body::before {
    content: '';
    position: fixed;
    inset: 0 0 auto 0;
    height: 320px;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(ellipse at top, var(--glow), transparent 70%);
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 3. TOP BAR ---------- */
.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 10px 16px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.brand { font-family: 'Montserrat', 'Inter', sans-serif; font-size: 1.05rem; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.brand span { color: var(--accent); }

.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    color: var(--text-muted);
    font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); }

.icon-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.is-on { color: var(--success); border-color: var(--success); }
.icon-btn-danger:hover { color: var(--danger); border-color: var(--danger); }

/* language dropdown built by i18n.js inside [data-lang-dropdown] */
.lang-picker {
    height: 36px;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}
.lang-picker select { color: var(--text) !important; font-weight: 600 !important; }

/* ---------- 4. PAGE HEADER / VIEW SWITCH ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.seg {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px;
    border: none; border-radius: 8px;
    background: transparent; color: var(--text-muted);
    font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
    cursor: pointer;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--accent); color: #fff; }

.sync-status { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
#updateStatus { display: none; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; }

/* ---------- 5. BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, filter 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success:hover:not(:disabled), .btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary, .btn-gray, .btn-info, .btn-warning { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled), .btn-gray:hover:not(:disabled), .btn-info:hover:not(:disabled), .btn-warning:hover:not(:disabled) { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-lg { height: 44px; }

/* small preset buttons (Today / Yesterday / 7D) */
.btn-xs {
    height: 30px; padding: 0 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 12px; font-weight: 600;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer;
}
.btn-xs:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 6. PANELS ---------- */
.panel, .glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.panel-title { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; color: var(--text-muted); text-transform: uppercase; margin-bottom: 14px; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.main-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.insights-grid .span-all { grid-column: 1 / -1; }

.map-box { height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
/* dark theme: tint the light OSM tiles instead of loading a second tile set */
:root[data-theme="dark"] .map-box .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.map-box .leaflet-control-attribution { font-size: 10px; background: var(--surface); color: var(--text-muted); }
.map-box .leaflet-control-attribution a { color: var(--accent); }
.map-box .leaflet-container, .map-box.leaflet-container { background: var(--surface-2); font-family: inherit; }
.big-count { margin-top: 24px; text-align: center; }
.big-count .value { font-size: 2.6rem; font-weight: 700; color: var(--accent); }
.big-count .label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.05em; }

/* ---------- 7. STAT CARDS ---------- */
.stats-ribbon { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 14px 16px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--tone, var(--accent));
    border-radius: var(--radius);
    color: var(--text);
}
button.stat-card { cursor: pointer; transition: transform 0.15s, border-color 0.15s, background 0.15s; }
button.stat-card:hover { transform: translateY(-2px); background: var(--surface-2); }
button.stat-card.active { background: var(--surface-2); border-color: var(--tone, var(--accent)); box-shadow: 0 0 0 1px var(--tone, var(--accent)) inset; }
.stat-card h4 { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.stat-card .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 11px; color: var(--text-muted); min-height: 1em; }
.tone-success { --tone: var(--success); }
.tone-warning { --tone: var(--warning); }
.tone-info { --tone: var(--info); }
.tone-danger { --tone: var(--danger); }

/* line capacity */
.pbx-card { --tone: var(--text-muted); }
.pbx-wrapper { width: 100%; margin-top: 6px; }
.pbx-bar-bg { width: 100%; height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.pbx-bar-fill { width: 0; height: 100%; background: var(--success); transition: width 0.4s, background-color 0.4s; }
.pbx-text { margin-top: 6px; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 95, 0.6); } 70% { box-shadow: 0 0 0 10px rgba(255, 90, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 90, 95, 0); } }
.pbx-critical { animation: pulse-red 2s infinite; --tone: var(--danger); }

/* ---------- 8. FILTERS ---------- */
.filters-bar {
    position: sticky; top: 10px; z-index: 50;
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; }
.filter-group.narrow { flex: 0 0 auto; min-width: 140px; }
.filter-label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.preset-group { display: flex; gap: 6px; padding-bottom: 4px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

.input-box, .form-input, .page-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-box:focus, .form-input:focus, .page-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-box::placeholder, .form-input::placeholder { color: var(--text-muted); }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-chips:empty { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 6px 0 12px;
    background: var(--accent-soft); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px;
    font-size: 12px;
}
.chip b { font-weight: 600; color: var(--accent); }
.chip button {
    width: 20px; height: 20px; border-radius: 50%;
    border: none; background: transparent; color: var(--text-muted);
    cursor: pointer; line-height: 1;
}
.chip button:hover { background: var(--surface-hover); color: var(--text); }
.chip-clear { background: transparent; border-style: dashed; padding-right: 12px; cursor: pointer; color: var(--text-muted); }

/* dropdowns (export menu, column picker) */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 1000;
    min-width: 170px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: none; border-radius: 6px;
    background: transparent; color: var(--text); text-align: left;
    font-size: 13px; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-title { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; color: var(--text-muted); text-transform: uppercase; padding: 4px 6px 8px; }
.column-picker { top: 52px; right: 12px; width: 220px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 6px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.check-row:hover { background: var(--surface-2); }
.check-row input { accent-color: var(--accent); }

/* ---------- 9. TABLE ---------- */
.table-panel { position: relative; }
.table-wrap {
    max-height: 560px; overflow: auto;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface);
    transition: opacity 0.2s;
}
.table-wrap.is-loading { opacity: 0.55; pointer-events: none; }

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th {
    position: sticky; top: 0; z-index: 2;
    padding: 11px 12px;
    text-align: left; white-space: nowrap;
    font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
th .sort-icon { margin-left: 6px; opacity: 0.35; font-size: 0.9em; }
th .sort-icon.on { opacity: 1; color: var(--accent); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr.main-row:nth-child(4n+1) { background: transparent; }
tbody tr.main-row:nth-child(4n+3) { background: rgba(127, 127, 127, 0.04); }
.main-row { cursor: pointer; }
.main-row:hover { background: var(--accent-soft) !important; }
td.table-empty { text-align: center; padding: 28px; color: var(--text-muted); }
td time { cursor: help; }

.details-row > td { background: var(--surface-2); white-space: normal; }
.details-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; padding: 6px 4px; }
.detail-item label { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.detail-item span { font-size: 13px; word-break: break-all; }

.copy-wrapper { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.copy-wrapper:hover { background: var(--surface-hover); color: var(--accent); }

/* status pill: dot + label, no blinking */
.status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    white-space: nowrap;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-success { color: var(--success); background: var(--success-soft); }
.status-warning { color: var(--warning); background: var(--warning-soft); }
.status-info { color: var(--info); background: var(--info-soft); }
.status-danger { color: var(--danger); background: var(--danger-soft); }

/* pagination */
.pagination-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 13px; }
.page-summary { color: var(--text-muted); }
.page-info { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--border); }
.page-numbers { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.page-ellipsis { padding: 0 4px; color: var(--text-muted); }
.btn-page {
    min-width: 32px; height: 32px; padding: 0 8px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.btn-page:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-page.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-page:disabled { opacity: 0.35; cursor: not-allowed; }
.goto-box { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.page-input { width: 70px; height: 32px; text-align: center; }

/* skeleton loading */
.skeleton {
    display: inline-block; width: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
.skeleton-text { height: 1em; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- 10. CAMPAIGN MONITOR ---------- */
.monitor-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.monitor-head h3 { font-size: 1rem; display: flex; align-items: center; gap: 10px; }
.monitor-head .actions { display: flex; gap: 8px; }
.health-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; font-size: 12px; color: var(--text-muted); }
.health-legend span { display: inline-flex; align-items: center; gap: 6px; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.health-ok { background: var(--success); }
.health-low { background: var(--warning); }
.health-idle { background: var(--danger); }

.campaign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: stretch; }
.campaign-card {
    position: relative;
    display: flex; flex-direction: column; gap: 14px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--card-color, var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.campaign-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.campaign-card[data-health="ok"] { box-shadow: 0 0 0 2px var(--success) inset; }
.campaign-card[data-health="low"] { box-shadow: 0 0 0 2px var(--warning) inset; }
.campaign-card[data-health="idle"] { box-shadow: 0 0 0 2px var(--danger) inset; }
.card-state { --card-color: var(--danger); }
.card-state.state-active { --card-color: var(--success); }
.card-state.state-paused { --card-color: var(--warning); }
.card-state.state-outside { --card-color: #9b59b6; }
.card-badge {
    position: absolute; top: 0; right: 0;
    padding: 4px 12px;
    background: var(--card-color); color: #fff;
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    border-bottom-left-radius: 8px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-top: 6px; }
.card-title { font-size: 1.1rem; color: var(--accent); }
.card-sub { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.card-actions { display: flex; gap: 6px; }
.card-actions .icon-btn { width: 32px; height: 32px; }
.card-actions .icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius-sm); }
.card-stat { padding: 10px; text-align: center; }
.card-stat + .card-stat { border-left: 1px solid var(--border); }
.card-stat label, .mini-metric label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; color: var(--text-muted); }
.card-stat .val { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-stat .val small { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.card-metrics { display: flex; justify-content: space-between; gap: 8px; }
.mini-metric { flex: 1; text-align: center; }
.mini-metric .val { font-size: 1rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.empty-state { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--text-muted); }

/* ---------- 11. MODALS & FORMS ---------- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 10000;
    justify-content: center; align-items: center;
    padding: 16px;
    background: var(--overlay);
}
.modal-content {
    width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.modal-content.wide { max-width: 600px; }
.modal-content.narrow { max-width: 400px; text-align: center; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.05rem; color: var(--accent); letter-spacing: 0.02em; }
.modal-close {
    width: 32px; height: 32px; border-radius: 8px;
    border: none; background: transparent; color: var(--text-muted);
    font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-icon { display: block; font-size: 3rem; margin-bottom: 14px; }
.modal-message { margin: 12px 0 22px; color: var(--text-muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
.modal-section { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { display: flex; flex-direction: column; }
.form-field.full { grid-column: 1 / -1; }
.form-label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-muted); }
.form-input[type="time"]::-webkit-calendar-picker-indicator { cursor: pointer; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(1); }

.day-toggle-group { display: flex; gap: 6px; }
.day-btn {
    flex: 1; height: 38px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.day-btn:hover { border-color: var(--accent); }
.day-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.info-box { margin-bottom: 18px; padding: 14px 16px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-size: 13px; }
.info-box strong { display: block; margin-bottom: 4px; color: var(--accent); }
.info-box ul { margin: 0; padding-left: 18px; line-height: 1.7; }
.dropzone { padding: 36px; text-align: center; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone i { font-size: 2rem; color: var(--accent); margin-bottom: 10px; }
#importProgress { display: none; margin-top: 18px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; color: var(--text-muted); }
.progress-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
#progressBar { width: 0; height: 100%; background: var(--success); transition: width 0.2s; }

@keyframes icon-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.pulse-warning { color: var(--brand-2); animation: icon-pulse 1.6s infinite ease-in-out; }

/* ---------- 12. FEEDBACK: banner, toasts, loader ---------- */
.broadcast-banner {
    display: none;
    position: relative;
    margin-bottom: 16px;
    padding: 10px 44px;
    border-radius: var(--radius-sm);
    text-align: center; font-weight: 600;
    background: var(--info); color: #fff;
}
.broadcast-banner[data-type="warning"] { background: var(--warning); color: #1a1a1a; }
.broadcast-banner[data-type="danger"] { background: var(--danger); }
.broadcast-banner i.fa-bullhorn { margin-right: 8px; }
.banner-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: none; color: inherit; font-size: 1.1rem; opacity: 0.8; cursor: pointer; }

#toast-container { position: fixed; top: 20px; right: 20px; z-index: 100000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 12px;
    min-width: 260px; max-width: 380px;
    padding: 12px 16px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    animation: toastSlideIn 0.25s ease-out;
}
@keyframes toastSlideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.global-loader {
    display: none;
    position: fixed; inset: 0; z-index: 99999;
    flex-direction: column; justify-content: center; align-items: center; gap: 14px;
    background: var(--overlay); color: #fff;
}
.global-loader i { font-size: 2.6rem; color: var(--accent); }

/* ---------- 13. TV MODE ---------- */
#tvExitBtn { display: none; }
body.tv-mode .topbar, body.tv-mode .page-head, body.tv-mode .filters-bar, body.tv-mode .filter-chips,
body.tv-mode .charts-row, body.tv-mode .main-grid, body.tv-mode .broadcast-banner { display: none !important; }
body.tv-mode #queueView { display: block !important; }
body.tv-mode .stats-ribbon { grid-template-columns: repeat(3, 1fr); gap: 32px; min-height: calc(100vh - 40px); margin: 0; }
body.tv-mode .stat-card { justify-content: center; align-items: center; text-align: center; padding: 24px; pointer-events: none; }
body.tv-mode .stat-card h4 { font-size: 2.2rem; }
body.tv-mode .stat-card .value { font-size: 7rem; }
body.tv-mode .stat-card .sub { font-size: 1.4rem; }
body.tv-mode .pbx-card { grid-column: 1 / -1; }
body.tv-mode .pbx-bar-bg { height: 26px; }
body.tv-mode .pbx-text { font-size: 2rem; }
body.tv-mode #tvExitBtn { display: inline-flex; position: fixed; top: 24px; right: 24px; z-index: 9999; opacity: 0.6; }
body.tv-mode #tvExitBtn:hover { opacity: 1; }

/* ---------- 14. RESPONSIVE ---------- */
@media (max-width: 1100px) {
    .main-grid, .charts-row, .insights-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    body { padding: 12px; }
    /* top bar: brand, then icon actions, then full-width page tabs */
    .brand { flex-basis: 100%; }
    .tabs { order: 3; flex-basis: 100%; }
    .tab { flex: 1; justify-content: center; padding: 8px 6px; }
    .icon-actions { margin-left: 0; flex-wrap: wrap; }
    .filter-actions { margin-left: 0; width: 100%; }
    .form-grid { grid-template-columns: 1fr; }

    /* table rows become cards */
    table, thead, tbody, th, td, tr { display: block; }
    table { min-width: 0; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tbody tr.main-row { margin: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2) !important; }
    td { position: relative; padding: 8px 10px 8px 45%; border: none; border-bottom: 1px solid var(--border); text-align: right; white-space: normal; }
    td:last-child { border-bottom: 0; }
    td::before { content: attr(data-label); position: absolute; left: 10px; top: 8px; width: 40%; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
    td.table-empty { padding-left: 10px; text-align: center; }
    td.table-empty::before, .details-row > td::before { content: none; }
    .details-row > td { padding: 10px; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
