:root {
    --bg: #0b1020;
    --panel: #151c2f;
    --panel-alt: #1b2440;
    --line: #2a3558;
    --text: #e8ecf8;
    --muted: #a2aecf;
    --accent: #6ea8fe;
    --accent-2: #3dd9b4;
    --warning: #f5b85a;
    --danger: #ff7373;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(110, 168, 254, 0.18), transparent 25%),
        linear-gradient(180deg, #0a0f1d, #10172a 60%, #0d1322);
    color: var(--text);
}

.app-shell {
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px;
}

.hero,
.panel,
.stat-card {
    background: rgba(21, 28, 47, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.hero {
    border-radius: 24px;
    padding: 28px 30px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-2);
    font-size: 0.78rem;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2rem, 4vw, 3.1rem);
}

.hero-copy,
.panel p,
.stat-card p,
.hint,
.queue-item-sub,
.queue-item-meta,
.history-entry,
.detail-empty,
.import-summary,
.status-strip {
    color: var(--muted);
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary-btn {
    background: linear-gradient(135deg, #4d8dff, #2b60ff);
    color: white;
    font-weight: 700;
}

.secondary-btn,
.filter-chip,
.quick-action,
.queue-item {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--line);
}

.danger-btn {
    background: rgba(255, 115, 115, 0.12);
    color: #ffd0d0;
    border: 1px solid rgba(255, 115, 115, 0.35);
}

.panel {
    border-radius: 22px;
    padding: 22px;
}

.import-panel {
    margin-bottom: 24px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.hint-badge,
.queue-badge,
.status-pill,
.mini-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hint-badge {
    background: rgba(61, 217, 180, 0.12);
    color: var(--accent-2);
}

.import-grid {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: 14px;
    align-items: end;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #0e1426;
    color: var(--text);
    padding: 12px 14px;
}

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

.status-strip {
    margin-top: 16px;
    background: rgba(110, 168, 254, 0.08);
    border: 1px solid rgba(110, 168, 254, 0.2);
    border-radius: 14px;
    padding: 12px 14px;
}

.import-summary {
    margin-top: 14px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.08);
}

.import-summary.empty,
.queue-list.empty,
.detail-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border-radius: 18px;
    padding: 18px;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    margin-top: 4px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.queue-panel,
.detail-panel {
    min-height: 780px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-chip.active {
    background: rgba(110, 168, 254, 0.16);
    border-color: rgba(110, 168, 254, 0.45);
    color: white;
}

.queue-list {
    display: grid;
    gap: 12px;
}

.queue-item {
    width: 100%;
    padding: 16px;
    text-align: left;
    border-radius: 16px;
}

.queue-item.active {
    border-color: rgba(110, 168, 254, 0.8);
    box-shadow: 0 0 0 1px rgba(110, 168, 254, 0.3);
}

.queue-item-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.queue-item-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.stat-chip {
    display: flex;
    gap: 6px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.queue-item-meta,
.queue-item-sub {
    font-size: 0.9rem;
    line-height: 1.45;
}

.queue-badge.first-touch,
.status-pill.first-touch {
    background: rgba(110, 168, 254, 0.18);
    color: #cfe0ff;
}

.queue-badge.retry,
.status-pill.retry {
    background: rgba(245, 184, 90, 0.15);
    color: #ffd897;
}

.queue-badge.completed,
.status-pill.completed {
    background: rgba(61, 217, 180, 0.14);
    color: #b2f7e7;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
}

.detail-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px;
}

.detail-top {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.detail-top h3 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.keyfacts,
.field-grid,
.history-list,
.quick-actions,
.script-list,
.summary-grid {
    display: grid;
    gap: 12px;
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 12px;
}

.summary-box,
.fact-box {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    padding: 14px;
}

.summary-box strong,
.fact-box strong {
    display: block;
    margin-top: 6px;
    font-size: 1.2rem;
}

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

.field-grid .full {
    grid-column: 1 / -1;
}

.quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-action.active {
    background: rgba(61, 217, 180, 0.16);
    border-color: rgba(61, 217, 180, 0.32);
}

.action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.history-list {
    margin-top: 12px;
}

.history-entry {
    border-left: 3px solid rgba(110, 168, 254, 0.4);
    padding-left: 12px;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    background: linear-gradient(135deg, #2858db, #2037a8);
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
}

.warning-text {
    color: #ffd897;
}

.good-text {
    color: #9ef5d8;
}

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

@media (max-width: 1180px) {
    .stats-grid,
    .workspace-grid,
    .detail-layout,
    .import-grid,
    .field-grid,
    .quick-actions,
    .analytics-grid,
    .analytics-compare {
        grid-template-columns: 1fr;
    }

    .hero,
    .panel-header,
    .detail-top {
        flex-direction: column;
    }

    .queue-panel,
    .detail-panel {
        min-height: auto;
    }
}

/* ─── QUEUE CONTROLS ─── */

.queue-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.search-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #0e1426;
    color: var(--text);
    padding: 10px 14px;
    font: inherit;
}

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

.sort-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
}

.sort-btn {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    transition: all 200ms ease;
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.sort-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ─── ANALYTICS PANEL ─── */

.analytics-panel {
    margin-top: 24px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 4px;
}

.analytics-section h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.analytics-bars {
    display: grid;
    gap: 10px;
}

.analytics-bar-row {
    display: grid;
    grid-template-columns: 180px 1fr 90px;
    align-items: center;
    gap: 12px;
}

.analytics-label {
    font-size: 0.88rem;
    color: var(--text);
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-bar-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.analytics-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4d8dff, #3dd9b4);
    min-width: 2px;
    transition: width 0.4s ease;
}

.analytics-count {
    font-size: 0.82rem;
    color: var(--muted);
    text-align: right;
}

/* Analytics table */

.table-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.analytics-table th,
.analytics-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.analytics-table th {
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.025);
}

.analytics-table tbody tr:last-child td {
    border-bottom: none;
}

.analytics-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Compare cards */

.analytics-compare {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.compare-card {
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.025);
    padding: 16px;
}

.compare-card strong {
    display: block;
    font-size: 2rem;
    margin: 6px 0 4px;
}

.compare-card p {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0;
}

/* ─── CONTACT GROUP CYCLE BUTTON ─── */
.group-filter-row {
    margin-bottom: 8px;
}

.group-cycle-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.group-cycle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.group-cycle-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(110, 168, 254, 0.1);
}

/* ─── CALL BUTTON ─── */
.call-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(110, 168, 254, 0.4);
    background: rgba(110, 168, 254, 0.1);
    color: var(--primary);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 200ms ease, opacity 200ms ease;
}
.call-btn:hover { background: rgba(110, 168, 254, 0.2); }
.call-btn.is-dialing { opacity: 0.6; cursor: not-allowed; }
.call-btn.is-dialing::after { content: ' — Calling\2026'; font-style: italic; }

/* ─── CALL CONFIG PANEL ─── */
.config-panel { margin-top: 0; }

.config-body { padding-top: 4px; }

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.config-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}

.config-grid input[type="tel"] {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #0e1426;
    color: var(--text);
    padding: 10px 14px;
    font: inherit;
    font-size: 0.95rem;
}

.config-grid input[type="tel"]:focus {
    outline: none;
    border-color: var(--primary);
}

@media (max-width: 680px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}
