@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── DPR Agent System — Premium Dark UI ─────────────────────────────── */

:root {
    --bg-topbar: rgba(12, 17, 29, 0.85);
    --bg-base: #090d16;
    --bg-card: #121824;
    --bg-card-hover: #1e2638;
    --bg-sidebar: #090d16;
    --bg-input: #1a2336;

    --border: rgba(255, 255, 255, 0.12);
    --border-focus: #10b981;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.3);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.25);
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    --radius: 14px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --calendar-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23cbd5e1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    --select-arrow: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23cbd5e1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
}

body.theme-light {
    --bg-base: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-input: #f1f5f9;
    --bg-topbar: rgba(255, 255, 255, 0.85);

    --border: #cbd5e1;
    --border-focus: #059669;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --accent: #059669;
    --accent-glow: rgba(5, 150, 105, 0.2);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.2);

    --calendar-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23334155" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    --select-arrow: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23334155" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
}

body.theme-cyberpunk {
    --bg-base: #02040a;
    --bg-card: #0b1120;
    --bg-card-hover: #16223d;
    --bg-sidebar: #02040a;
    --bg-input: #111a30;
    --bg-topbar: rgba(2, 4, 10, 0.85);

    --border: rgba(0, 242, 255, 0.35);
    --border-focus: #00f2ff;

    --text-primary: #ffffff;
    --text-secondary: #a5f3fc;
    --text-muted: #67e8f9;

    --accent: #00f2ff;
    --accent-glow: rgba(0, 242, 255, 0.4);
    --accent-green: #39ff14;
    --accent-green-glow: rgba(57, 255, 20, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    color-scheme: dark;
}

body.theme-light {
    color-scheme: light;
}

body {
    display: flex;
}


/* ─── Sidebar ──────────────────────────────────────────────────────── */

.sidebar {
    width: 240px;
    min-width: 240px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    transition: var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
    background: linear-gradient(135deg, #15803d, #059669);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #15803d, #059669);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(74, 144, 255, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(74, 144, 255, 0.12);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.project-selector label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.project-selector select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.project-selector select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}


/* ─── Main Content ─────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: 0;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
    letter-spacing: -0.5px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
}

.status-badge {
    padding: 6px 14px;
    background: rgba(74, 144, 255, 0.1);
    border: 1px solid rgba(74, 144, 255, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.section {
    display: none;
    padding: 24px 28px;
    animation: fadeIn 0.35s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ─── Stats Grid ───────────────────────────────────────────────────── */

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(8px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.accent::before {
    background: linear-gradient(90deg, var(--accent-green), #22c55e);
    opacity: 1;
}

.stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}


/* ─── Cards ────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
}

.card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}


/* ─── Charts ───────────────────────────────────────────────────────── */

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}


/* ─── Tables ───────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    background: rgba(74, 144, 255, 0.08);
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: rgba(74, 144, 255, 0.04);
}


/* ─── Progress Bars ────────────────────────────────────────────────── */

.progress-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(74, 144, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
    background: linear-gradient(90deg, var(--accent), #6366f1);
}

.progress-fill.complete {
    background: linear-gradient(90deg, var(--accent-green), #22c55e);
}

.progress-text {
    font-size: 12px;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
    color: var(--text-secondary);
}


/* ─── Forms ────────────────────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group.compact {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: var(--calendar-icon) !important;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
    width: 20px;
    height: 20px;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s ease;
    filter: none !important;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
    padding-right: 40px !important;
}

/* Ensure modern native form styling aligns with themes */
input, select, textarea {
    color-scheme: dark;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea,
.dpr-chat-wrapper input,
.dpr-chat-wrapper select,
.dpr-chat-wrapper textarea {
    color-scheme: light;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.helper-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}


/* ─── Buttons ──────────────────────────────────────────────────────── */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(74, 144, 255, 0.1);
    border: 1px solid rgba(74, 144, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(74, 144, 255, 0.18);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-green), #22c55e);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-green-glow);
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-green-glow);
}


/* ─── Filter Bar ───────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}


/* ─── Result Box ───────────────────────────────────────────────────── */

.result-box {
    margin-top: 20px;
    padding: 20px;
    background: rgba(10, 20, 40, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.result-box.hidden {
    display: none;
}

.result-box.success {
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(52, 211, 153, 0.05);
}

.result-box.error {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.05);
}

.result-header {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-box pre {
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}


/* ─── Team Grid ────────────────────────────────────────────────────── */

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.team-member {
    padding: 16px;
    background: rgba(74, 144, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.team-member:hover {
    background: rgba(74, 144, 255, 0.1);
    border-color: rgba(74, 144, 255, 0.2);
}

.team-member .name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.team-member .role {
    font-size: 12px;
    color: var(--text-secondary);
}

.team-member .crew {
    font-size: 11px;
    color: var(--accent);
    margin-top: 4px;
    font-weight: 600;
}


/* ─── Reports List ─────────────────────────────────────────────────── */

.reports-list .report-entry {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    background: rgba(74, 144, 255, 0.03);
    transition: var(--transition);
}

.reports-list .report-entry:hover {
    border-color: rgba(74, 144, 255, 0.2);
}

.report-date {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
}

.report-platforms {
    display: grid;
    gap: 8px;
}

.report-platform {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: rgba(10, 20, 40, 0.5);
    border-radius: var(--radius-sm);
}

.report-platform .pname {
    font-weight: 600;
    min-width: 180px;
}

.report-platform .pscans {
    color: var(--accent-green);
    font-weight: 600;
    min-width: 80px;
}

.report-platform .pprogress {
    flex: 1;
}


/* ─── Loading spinner ──────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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


/* ─── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -240px;
        transition: left var(--transition);
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .section {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .top-bar {
        padding: 12px 16px;
    }
}


/* ─── Detail Modal ─────────────────────────────────────────────────── */

.detail-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.detail-modal-overlay.active {
    display: flex;
}

.detail-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.detail-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(74, 144, 255, 0.05);
}

.detail-modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.detail-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.detail-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.detail-modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

.detail-modal-body ul {
    padding-left: 20px;
}

.detail-modal-body li {
    margin-bottom: 4px;
}


/* ─── Popup Tables ─────────────────────────────────────────────────── */

.popup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.popup-table th {
    text-align: left;
    padding: 10px 12px;
    background: rgba(74, 144, 255, 0.08);
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.popup-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.popup-table tr:hover {
    background: rgba(74, 144, 255, 0.04);
}


/* ─── Team Card (dashboard) ────────────────────────────────────────── */

.team-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(74, 144, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.team-card:hover {
    background: rgba(74, 144, 255, 0.1);
    border-color: rgba(74, 144, 255, 0.2);
}

.team-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.team-info {
    min-width: 0;
}

.team-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.team-crew {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    margin-top: 2px;
}


/* ─── Template Selector Modal ──────────────────────────────────────── */

.template-card {
    background: rgba(20, 28, 50, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.template-card:hover {
    background: rgba(74, 144, 255, 0.08);
    border-color: rgba(74, 144, 255, 0.3);
    transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* DPR Interactive Chat Widget — High-Fidelity UI Styling                  */
/* ═══════════════════════════════════════════════════════════════════════ */

.dpr-chat-wrapper {
    /* Scoped ChatGPT Light Theme Override */
    --bg-base: #ffffff;
    --bg-card: #f9f9f9;
    --bg-card-hover: #f0f0f0;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;

    --border: #e5e5e5;
    --border-focus: #10a37f;

    --text-primary: #0d0d0d;
    --text-secondary: #676767;
    --text-muted: #b4b4b4;

    --accent: #10a37f;
    --accent-glow: rgba(16, 163, 127, 0.15);
    --accent-green: #10a37f;
    --accent-green-glow: rgba(16, 163, 127, 0.1);
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    --calendar-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23676767" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    --select-arrow: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23676767" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');

    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    gap: 16px;
    padding: 10px 0;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.chat-stepper {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    background: rgba(17, 24, 42, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    flex-shrink: 0;
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(20, 28, 50, 0.4);
    border: 1px solid transparent;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
}

.step.active {
    color: #ffffff;
    background: rgba(74, 144, 255, 0.2);
    border-color: rgba(74, 144, 255, 0.5);
    box-shadow: 0 0 15px rgba(74, 144, 255, 0.2);
}

.step.completed {
    color: var(--accent-green);
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.3);
}

.step.completed:hover {
    background: rgba(52, 211, 153, 0.2);
    transform: translateY(-1px);
}

.step-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

.step.active .step-number {
    background: var(--accent);
    color: white;
}

.step.completed .step-number {
    background: var(--accent-green);
    color: white;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    min-height: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
    padding: 60px 40px;
}

.chat-welcome-icon {
    font-size: 80px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

.chat-welcome h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chat-welcome p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 500px;
    line-height: 1.6;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-bubble {
    display: flex;
    gap: 16px;
    max-width: 85%;
    width: fit-content;
    animation: chatSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-bubble.bot {
    align-self: flex-start;
}

.chat-bubble.user {
    align-self: flex-end;
}

.chat-bubble.system {
    align-self: center;
    max-width: 95%;
}

.chat-bubble.chat-card-interactive-wrapper {
    max-width: 100%;
    width: 100%;
    align-self: center;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.bot-avatar {
    background: #10a37f;
    color: white;
}

.user-avatar {
    background: #5436da;
    color: white;
}

.chat-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-primary);
}

.chat-bubble.bot .chat-content {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding-left: 0;
    max-width: 100%;
}

.chat-bubble.user .chat-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    border-top-right-radius: 4px;
    color: var(--text-primary);
}

.chat-system-content {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.chat-bullet {
    color: var(--accent);
    font-weight: 700;
    margin-right: 4px;
}

.chat-card-interactive {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    overflow: hidden;
    margin: 8px 0;
}

.chat-card-header {
    background: linear-gradient(90deg, var(--accent-green-glow), transparent);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-card-footer {
    padding: 16px 24px;
    background: var(--bg-card-hover);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Forms and Lists */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.form-group-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-inline label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group-inline input,
.form-group-inline select,
.form-group-inline textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13.5px;
    transition: var(--transition);
}

.form-group-inline input:focus,
.form-group-inline select:focus,
.form-group-inline textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 10px rgba(16, 163, 127, 0.15);
    outline: none;
    background: var(--bg-input);
}

/* Checklist and custom items style */
.checklist-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 6px;
}

.checklist-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.checklist-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.checklist-main-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.checklist-item-details {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

.roster-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.25s ease;
}

.roster-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
}

.roster-checkbox-wrapper {
    display: flex;
    align-items: center;
}

.roster-item-details {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

.item-main-name {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 180px;
}

.roster-role-select,
.roster-group-input,
.checklist-serial-input {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 13.5px !important;
    transition: all 0.2s ease !important;
}

.roster-role-select:focus,
.roster-group-input:focus,
.checklist-serial-input:focus {
    border-color: var(--border-focus) !important;
    outline: none !important;
}

.roster-delete-btn,
.checklist-delete-btn {
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 16px !important;
    padding: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--accent-red) !important;
    transition: transform 0.2s ease !important;
}

.roster-delete-btn:hover,
.checklist-delete-btn:hover {
    transform: scale(1.2) !important;
}

/* iOS Toggle switches */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .3s;
    border-radius: 24px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.switch-toggle input:checked+.switch-slider {
    background-color: var(--accent);
}

.switch-toggle input:checked+.switch-slider:before {
    transform: translateX(20px);
}

/* Collapsible Content */
.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
}

.collapsible-content.expanded {
    max-height: 600px;
    opacity: 1;
}

/* WBS Progress Table */
.interactive-table-container {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.interactive-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.interactive-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.interactive-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

/* Slider and Hours range styling */
.hours-slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.hours-slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.hours-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.hours-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.hours-slider-val {
    font-size: 12px;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* Roster / Equipment Add Area */
.add-item-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.add-item-row input {
    flex: 1;
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Input Styling */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-base);
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 52px;
    max-height: 140px;
    border-radius: 26px;
    padding: 14px 22px;
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font);
    transition: all 0.25s ease;
}

.chat-input-area textarea:focus {
    border-color: var(--border-focus);
    background: var(--bg-base);
    outline: none;
}

/* Chat Inline Report Download Card */
.chat-download-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 10px;
}

.chat-download-title {
    font-weight: 700;
    color: var(--accent-green);
    font-size: 15px;
}

.download-range-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-base);
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.download-range-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.download-range-row input[type="date"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
    min-width: 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   Project Setup — Tabbed Form & Summary Card
   ════════════════════════════════════════════════════════════════════════════ */

/* Tab Nav */
.setup-tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.setup-tab-btn {
    padding: 9px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: var(--transition);
    white-space: nowrap;
}

.setup-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.setup-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(16, 163, 127, 0.08);
}

.setup-tab-pane {
    display: none;
}

.setup-tab-pane.active {
    display: block;
}

/* Equipment Roster Table */
.equip-roster-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}

.equip-roster-table th {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.equip-roster-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.equip-roster-table input {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 13px;
}

.equip-roster-table .delete-btn {
    background: transparent;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background .15s;
}

.equip-roster-table .delete-btn:hover {
    background: rgba(229, 62, 62, .1);
}

/* Custom Sections */
.custom-section-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.custom-section-item {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.custom-section-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.custom-section-item-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
}

.custom-section-params {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.custom-section-param-row {
    display: flex;
    gap: 8px;
}

.custom-section-param-row input {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 13px;
}

/* Project Summary Card */
.project-summary-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.summary-project-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--accent), #0d7a5f);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.summary-project-title {
    flex: 1;
    min-width: 160px;
}

.summary-project-title h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 3px;
}

.summary-project-title p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.summary-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.summary-sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 14px;
}

.summary-section-panel {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    overflow: hidden;
}

.summary-section-panel.color-blue {
    border-left-color: #4299e1;
}

.summary-section-panel.color-green {
    border-left-color: #48bb78;
}

.summary-section-panel.color-amber {
    border-left-color: #ed8936;
}

.summary-section-panel.color-purple {
    border-left-color: #9f7aea;
}

.summary-section-panel.color-red {
    border-left-color: #fc8181;
}

.summary-section-panel.color-teal {
    border-left-color: #38b2ac;
}

.summary-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .03);
    border-bottom: 1px solid var(--border);
}

.summary-section-head-title {
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
}

.summary-section-edit-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
}

.summary-section-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.summary-section-delete-btn {
    background: transparent;
    border: 1px solid rgba(229, 62, 62, .4);
    color: #fc8181;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
    margin-left: 4px;
}

.summary-section-delete-btn:hover {
    background: rgba(229, 62, 62, .1);
}

.summary-section-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-field-row {
    display: flex;
    gap: 6px;
    font-size: 13px;
    align-items: baseline;
}

.summary-field-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 130px;
    flex-shrink: 0;
    font-size: 12px;
}

.summary-field-value {
    color: var(--text-primary);
    word-break: break-word;
}

.summary-section-empty {
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
}

.summary-equip-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(16, 163, 127, .12);
    color: var(--accent);
    border: 1px solid rgba(16, 163, 127, .25);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    margin: 2px 3px 2px 0;
}

.summary-danger-zone {
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px solid rgba(229, 62, 62, .35);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.summary-danger-zone p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* Section edit modal */
.setup-edit-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.setup-edit-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 30px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}

.setup-edit-modal h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 18px;
}

/* ─── Premium Flash Visible Transitions for Clickable Elements ─── */
button,
.btn-primary,
.btn-secondary,
.btn-accent,
.sidebar-tab,
.action-btn,
.nav-btn,
.tab-btn,
[role="button"] {
    transition: all 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

button:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-accent:hover,
.sidebar-tab:hover,
.action-btn:hover,
.nav-btn:hover,
.tab-btn:hover,
[role="button"]:hover {
    filter: brightness(1.25) contrast(1.1) !important;
    animation: button-flash 0.35s ease-out;
}

button:active,
.btn-primary:active,
.btn-secondary:active,
.btn-accent:active,
.sidebar-tab:active,
.action-btn:active,
.nav-btn:active,
.tab-btn:active,
[role="button"]:active {
    transform: scale(0.96) !important;
    filter: brightness(0.9) !important;
}

@keyframes button-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45);
        filter: brightness(1.5) contrast(1.2);
    }

    30% {
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
        filter: brightness(1.3) contrast(1.1);
    }

    100% {
        filter: brightness(1.25) contrast(1.1);
    }
}

/* Custom placeholder and scrollbars */
::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.95 !important;
    font-weight: 500 !important;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

body.theme-light ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}


/* ─── DPR Analytics Styles ─── */
.ai-search-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#analyticsChartWrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0;
    min-height: 200px;
}

#analyticsChartImg {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #111b2d;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition);
}

#analyticsChartImg:hover {
    transform: scale(1.01);
}

#analyticsTableContainer table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13.5px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

#analyticsTableContainer th {
    background: rgba(74, 144, 255, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
}

#analyticsTableContainer td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

#analyticsTableContainer tr:last-child td {
    border-bottom: none;
}

#analyticsTableContainer tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* AI Analytics Chat Interface */
#analyticsChatFeed::-webkit-scrollbar {
    width: 6px;
}

#analyticsChatFeed::-webkit-scrollbar-track {
    background: transparent;
}

#analyticsChatFeed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#analyticsChatFeed::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent) 0%, #3a7bd5 100%);
    color: #fff;
    padding: 12px 18px;
    border-radius: 18px 18px 2px 18px;
    max-width: 75%;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(74, 144, 255, 0.25);
    word-wrap: break-word;
}

.chat-bubble-bot {
    align-self: flex-start;
    background: #161b26;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #e3e3e3;
    padding: 16px 20px;
    border-radius: 12px;
    max-width: 85%;
    width: 100%;
    font-size: 15px;
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.chat-bot-avatar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes pulse {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 1;
    }
}

/* ─── Analytics Chat Bubbles ─────────────────────────────────────── */

.chat-bubble-user {
    align-self: flex-end;
    max-width: 75%;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    border-radius: 16px 16px 4px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    font-family: var(--font);
    word-wrap: break-word;
    animation: chatSlideIn 0.25s ease both;
}

.chat-bubble-bot {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
    font-family: var(--font);
    animation: chatSlideIn 0.25s ease both;
}

.chat-bot-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.chat-bot-header .bot-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}



/* ─── Bot Text Content — compact ChatGPT typography ──────────── */

.bot-text-content {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.55;
    font-family: var(--font);
}

.bot-text-content p {
    margin: 0 0 10px 0;
}

.bot-text-content p:last-child {
    margin-bottom: 0;
}

.bot-text-content ul,
.bot-text-content ol {
    margin: 6px 0 10px 0;
    padding-left: 18px;
}

.bot-text-content li {
    margin-bottom: 4px;
    line-height: 1.5;
    color: var(--text-primary);
}

.bot-text-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.bot-text-content h1,
.bot-text-content h2,
.bot-text-content h3 {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 6px;
}

.bot-text-content h1 {
    font-size: 1.15em;
}

.bot-text-content h2 {
    font-size: 1.08em;
}

.bot-text-content h3 {
    font-size: 1.0em;
}

.bot-text-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin: 8px 0;
}

.bot-text-content th {
    background: var(--bg-input);
    color: var(--text-primary);
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.bot-text-content td {
    padding: 6px 10px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.bot-text-content code {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
}

.bot-text-content pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
    overflow-x: auto;
    margin: 8px 0;
}

/* ─── Bot Media / Dashboard iframes ──────────────────────────── */

.bot-media-content iframe {
    border-radius: 6px;
    border: 1px solid var(--border);
}

.bot-details-content {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

/* ─── Thinking dots animation ────────────────────────────────── */

.thinking-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.thinking-dots .dot {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 0.8s infinite alternate;
}

.thinking-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ==========================================================================
   DPR Analytics Chatboard Premium White/Light Theme Overrides
   ========================================================================== */

body.theme-light .analytics-chatboard,
.analytics-chatboard {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;

    /* Lock theme CSS custom variables to light values inside the analytics container */
    --bg-base: #f8fafc !important;
    --bg-card: #ffffff !important;
    --bg-card-hover: #f1f5f9 !important;
    --bg-sidebar: #ffffff !important;
    --bg-input: #f1f5f9 !important;
    --bg-topbar: rgba(255, 255, 255, 0.85) !important;

    --border: #cbd5e1 !important;
    --border-focus: #059669 !important;

    --text-primary: #0f172a !important;
    --text-secondary: #334155 !important;
    --text-muted: #64748b !important;

    --accent: #059669 !important;
    --accent-glow: rgba(5, 150, 105, 0.2) !important;
    --accent-green: #10b981 !important;
    --accent-green-glow: rgba(16, 185, 129, 0.2) !important;
}

body.theme-light .analytics-chatboard .analytics-header,
.analytics-chatboard .analytics-header {
    background: #f9fafb !important;
    border-bottom: 1px solid #e5e7eb !important;
}

body.theme-light .analytics-chatboard .analytics-header h2,
.analytics-chatboard .analytics-header h2 {
    color: #111827 !important;
}

body.theme-light .analytics-chatboard #analyticsChatFeed,
.analytics-chatboard #analyticsChatFeed {
    background: transparent !important;
    position: relative !important;
    z-index: 1 !important;
}

body.theme-light .analytics-chatboard #analyticsWelcomeMessage h3,
.analytics-chatboard #analyticsWelcomeMessage h3 {
    color: #111827 !important;
}

body.theme-light .analytics-chatboard #analyticsWelcomeMessage p,
.analytics-chatboard #analyticsWelcomeMessage p {
    color: #4b5563 !important;
}

body.theme-light .analytics-chatboard #analyticsTypingIndicator,
.analytics-chatboard #analyticsTypingIndicator {
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
    color: #4b5563 !important;
}

body.theme-light .analytics-chatboard .analytics-input-footer,
.analytics-chatboard .analytics-input-footer {
    background: #ffffff !important;
    border-top: 1px solid #e5e7eb !important;
}

body.theme-light .analytics-chatboard #aiAnalyticsQueryInput,
.analytics-chatboard #aiAnalyticsQueryInput {
    background: #f9fafb !important;
    border: 1px solid #d1d5db !important;
    color: #111827 !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

body.theme-light .analytics-chatboard #aiAnalyticsQueryInput::placeholder,
.analytics-chatboard #aiAnalyticsQueryInput::placeholder {
    color: #9ca3af !important;
}

body.theme-light .analytics-chatboard #aiAnalyticsQueryInput:focus,
.analytics-chatboard #aiAnalyticsQueryInput:focus {
    border-color: #10a37f !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.15) !important;
}

/* Button overrides in White Theme Chatboard */
body.theme-light .analytics-chatboard .btn-secondary,
.analytics-chatboard .btn-secondary {
    background: #f3f4f6 !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

body.theme-light .analytics-chatboard .btn-secondary:hover,
.analytics-chatboard .btn-secondary:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
    border-color: #9ca3af !important;
}

body.theme-light .analytics-chatboard .btn-accent,
.analytics-chatboard .btn-accent {
    background: #10a37f !important;
    /* ChatGPT style green accent */
    border: 1px solid #0e8f6d !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}

body.theme-light .analytics-chatboard .btn-accent:hover,
.analytics-chatboard .btn-accent:hover {
    background: #0e8f6d !important;
    border-color: #0c7c5f !important;
}

/* User Bubble in Analytics White Chatboard */
body.theme-light .analytics-chatboard .chat-bubble-user,
.analytics-chatboard .chat-bubble-user {
    background: #007bff !important;
    /* Premium blue */
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1) !important;
    border-radius: 16px 16px 4px 16px !important;
    font-size: 14px !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

/* ChatGPT style Bot Bubble in Analytics White Chatboard */
body.theme-light .analytics-chatboard .chat-bubble-bot,
.analytics-chatboard .chat-bubble-bot {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
    padding: 16px 20px !important;
    border-radius: 12px !important;
    color: #1f2328 !important;
    max-width: 100% !important;
    width: 100% !important;
}

body.theme-light .analytics-chatboard .chat-bot-header,
.analytics-chatboard .chat-bot-header {
    color: #4b5563 !important;
}

body.theme-light .analytics-chatboard .chat-bot-header .bot-icon,
.analytics-chatboard .chat-bot-header .bot-icon {
    background: #10a37f !important;
    /* ChatGPT style green icon */
    color: #ffffff !important;
}

/* LLM response ChatGPT typography overrides */
body.theme-light .analytics-chatboard .bot-text-content,
.analytics-chatboard .bot-text-content {
    color: #0d0d0d !important;
    font-family: circular, 'segoe ui', sans-serif !important;
    font-size: 14.5px !important;
    line-height: 1.62 !important;
    font-weight: 400 !important;
    letter-spacing: -0.01em !important;
}

body.theme-light .analytics-chatboard .bot-text-content p,
.analytics-chatboard .bot-text-content p {
    margin: 0 0 16px 0 !important;
    color: #0d0d0d !important;
}

body.theme-light .analytics-chatboard .bot-text-content p:last-child,
.analytics-chatboard .bot-text-content p:last-child {
    margin-bottom: 0 !important;
}

body.theme-light .analytics-chatboard .bot-text-content strong,
.analytics-chatboard .bot-text-content strong {
    color: #000000 !important;
    font-weight: 600 !important;
}

body.theme-light .analytics-chatboard .bot-text-content ul,
body.theme-light .analytics-chatboard .bot-text-content ol,
.analytics-chatboard .bot-text-content ul,
.analytics-chatboard .bot-text-content ol {
    margin: 8px 0 16px 0 !important;
    padding-left: 20px !important;
}

body.theme-light .analytics-chatboard .bot-text-content li,
.analytics-chatboard .bot-text-content li {
    margin-bottom: 6px !important;
    color: #0d0d0d !important;
    line-height: 1.6 !important;
}

body.theme-light .analytics-chatboard .bot-text-content h1,
body.theme-light .analytics-chatboard .bot-text-content h2,
body.theme-light .analytics-chatboard .bot-text-content h3,
.analytics-chatboard .bot-text-content h1,
.analytics-chatboard .bot-text-content h2,
.analytics-chatboard .bot-text-content h3 {
    color: #000000 !important;
    font-weight: 600 !important;
    margin-top: 24px !important;
    margin-bottom: 8px !important;
}

/* Code and block styling */
body.theme-light .analytics-chatboard .bot-text-content code,
.analytics-chatboard .bot-text-content code {
    background: #f3f4f6 !important;
    color: #ea580c !important;
    /* Premium orange-red for inline code */
    padding: 2px 5px !important;
    border-radius: 4px !important;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace !important;
    font-size: 0.85em !important;
    font-weight: 500 !important;
}

body.theme-light .analytics-chatboard .bot-text-content pre,
.analytics-chatboard .bot-text-content pre {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    padding: 12px 16px !important;
    border-radius: 8px !important;
    overflow-x: auto !important;
    margin: 12px 0 !important;
}

body.theme-light .analytics-chatboard .bot-text-content pre code,
.analytics-chatboard .bot-text-content pre code {
    background: transparent !important;
    color: #1f2328 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    font-size: 13px !important;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace !important;
    font-weight: 400 !important;
}

body.theme-light .analytics-chatboard .bot-text-content table,
.analytics-chatboard .bot-text-content table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 13px !important;
    border: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    margin: 12px 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

body.theme-light .analytics-chatboard .bot-text-content th,
.analytics-chatboard .bot-text-content th {
    background: #f9fafb !important;
    color: #111827 !important;
    font-weight: 600 !important;
    padding: 10px 12px !important;
    border-bottom: 2px solid #e5e7eb !important;
}

body.theme-light .analytics-chatboard .bot-text-content td,
.analytics-chatboard .bot-text-content td {
    padding: 8px 12px !important;
    color: #374151 !important;
    border-bottom: 1px solid #f3f4f6 !important;
}

body.theme-light .analytics-chatboard .bot-text-content tr:last-child td,
.analytics-chatboard .bot-text-content tr:last-child td {
    border-bottom: none !important;
}




/* ─── T-08 Issue Management Log Styling ─────────────────────────────────────── */

.badge-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-status.status-open {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-status.status-inprogress {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-status.status-closed {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-priority.priority-high {
    background: #ef4444;
    color: white;
}

.badge-priority.priority-medium {
    background: #f59e0b;
    color: #1e1e2d;
}

.badge-priority.priority-low {
    background: #3b82f6;
    color: white;
}

body.theme-light .badge-status.status-open {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

body.theme-light .badge-status.status-inprogress {
    background: rgba(217, 119, 6, 0.1);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.2);
}

body.theme-light .badge-status.status-closed {
    background: rgba(5, 150, 105, 0.1);
    color: #047857;
    border: 1px solid rgba(5, 150, 105, 0.2);
}

body.theme-light .badge-priority.priority-high {
    background: #dc2626;
}

body.theme-light .badge-priority.priority-medium {
    background: #d97706;
    color: white;
}

body.theme-light .badge-priority.priority-low {
    background: #2563eb;
}

/* ══════════════════════════════════════════════════════════════════════
   PROFESSIONAL REDESIGN LAYER (v2)
   Appended last so it refines the visual language without disturbing the
   existing structure/selectors. All 3 themes still drive off variables.
   ══════════════════════════════════════════════════════════════════════ */

:root {
    --elev-1: 0 1px 2px rgba(0,0,0,0.25), 0 1px 1px rgba(0,0,0,0.15);
    --elev-2: 0 4px 12px rgba(0,0,0,0.30), 0 2px 4px rgba(0,0,0,0.18);
    --elev-3: 0 12px 32px rgba(0,0,0,0.40), 0 4px 10px rgba(0,0,0,0.22);
    --ring: 0 0 0 3px var(--accent-glow);
    --grad-accent: linear-gradient(135deg, var(--accent) 0%, var(--accent-green) 100%);
    --radius-lg: 18px;
    --sp: 8px;
}

body.theme-light {
    --elev-1: 0 1px 2px rgba(16,24,40,0.06), 0 1px 3px rgba(16,24,40,0.10);
    --elev-2: 0 4px 12px rgba(16,24,40,0.08), 0 2px 6px rgba(16,24,40,0.06);
    --elev-3: 0 16px 40px rgba(16,24,40,0.14), 0 6px 14px rgba(16,24,40,0.08);
}

/* Layered, subtly-lit background for depth */
body {
    background:
        radial-gradient(1200px 600px at 82% -8%, var(--accent-glow), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(74,144,255,0.10), transparent 55%),
        var(--bg-base);
    background-attachment: fixed;
}

/* ─── Sidebar ─── */
.sidebar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-sidebar) 92%, var(--accent) 8%), var(--bg-sidebar));
    box-shadow: var(--elev-2);
}
.logo-icon {
    background: var(--grad-accent);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 8px var(--accent-glow));
    font-size: 26px;
}
.nav-item {
    position: relative;
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
}
.nav-item::before {
    content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%) scaleY(0);
    width: 3px; height: 60%; border-radius: 3px; background: var(--grad-accent);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.nav-item:hover { background: var(--bg-card-hover); transform: translateX(2px); }
.nav-item.active {
    background: linear-gradient(90deg, var(--accent-glow), transparent 90%);
    color: var(--text-primary); font-weight: 600;
}
.nav-item.active::before { transform: translateY(-50%) scaleY(1); }
.nav-item.active .nav-icon { filter: drop-shadow(0 0 6px var(--accent-glow)); }

/* ─── Top bar ─── */
.top-bar {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg-topbar);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    box-shadow: var(--elev-1);
}
.top-bar h1 { letter-spacing: -0.02em; font-weight: 700; }
.status-badge {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--text-primary); font-weight: 600;
    box-shadow: var(--elev-1);
}

/* ─── Cards ─── */
.card, .chart-card {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 96%, #fff 4%), var(--bg-card));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-2);
    transition: var(--transition);
}
.card:hover, .chart-card:hover { box-shadow: var(--elev-3); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.card h2, .card h3, .chart-card h3 { letter-spacing: -0.01em; }

/* ─── Stat tiles ─── */
.stat-card {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 94%, #fff 6%), var(--bg-card));
    border-radius: 16px;
    box-shadow: var(--elev-2);
}
.stat-card:hover { box-shadow: var(--elev-3); }
.stat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 13px;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
    margin-bottom: 10px;
}
.stat-value { font-weight: 800; letter-spacing: -0.03em; }
.stat-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }

/* ─── Buttons ─── */
.btn-primary, .btn-accent {
    background: var(--grad-accent);
    border: none; color: #04120c; font-weight: 700;
    border-radius: 10px;
    box-shadow: var(--elev-1), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:hover, .btn-accent:hover { filter: brightness(1.06); box-shadow: var(--elev-2), 0 0 0 3px var(--accent-glow); }
.btn-secondary {
    background: color-mix(in srgb, var(--bg-input) 70%, transparent);
    border: 1px solid var(--border); color: var(--text-primary); font-weight: 600;
    border-radius: 10px;
}
.btn-secondary:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--bg-card-hover); }
button:focus-visible, a.nav-item:focus-visible { outline: none; box-shadow: var(--ring); }

/* ─── Inputs ─── */
input[type="text"], input[type="date"], input[type="number"], input[type="email"],
textarea, select {
    border-radius: 10px !important;
    transition: var(--transition);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--border-focus) !important;
    box-shadow: var(--ring) !important; outline: none !important;
}

/* ─── Tables ─── */
table thead th {
    text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px;
    color: var(--text-muted);
}
table tbody tr { transition: background .15s ease; }
table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* ─── Scrollbars ─── */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 40%, transparent) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent) 55%, transparent); background-clip: content-box; }

/* ─── Analytics chat ─── */
.analytics-chatboard { box-shadow: var(--elev-3) !important; border-radius: var(--radius-lg) !important; }
#analyticsChatFeed {
    background:
        radial-gradient(600px 300px at 100% 0%, var(--accent-glow), transparent 70%),
        transparent !important;
}
.chat-bubble-user {
    background: var(--grad-accent) !important;
    color: #04120c !important; font-weight: 500;
    border-radius: 16px 16px 4px 16px !important;
    box-shadow: var(--elev-2) !important; border: none !important;
}
.chat-bubble-bot {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 92%, #fff 8%), var(--bg-card)) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px 16px 16px 4px !important;
    box-shadow: var(--elev-2) !important;
}
.chat-bot-header .bot-icon, .bot-icon {
    background: var(--grad-accent);
    color: #04120c; border-radius: 9px;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ══════ AI-generated charts / dashboards (in-page Chart.js) ══════ */
.ai-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px; width: 100%;
}
.ai-chart-card {
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 94%, #fff 6%), var(--bg-card));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 16px 12px;
    box-shadow: var(--elev-2);
    transition: var(--transition);
}
.ai-chart-card:hover { box-shadow: var(--elev-3); border-color: color-mix(in srgb, var(--accent) 26%, var(--border)); }
.ai-chart-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.01em; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.ai-chart-title::before {
    content: ""; width: 4px; height: 16px; border-radius: 3px; background: var(--grad-accent);
}
.ai-chart-canvas-wrap { position: relative; width: 100%; height: 300px; }
.ai-chart-card.single .ai-chart-canvas-wrap, .bot-media-content > .ai-chart-card .ai-chart-canvas-wrap { height: 340px; }
.ai-chart-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }
.ai-chart-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.ai-chart-btn {
    background: color-mix(in srgb, var(--bg-input) 70%, transparent);
    border: 1px solid var(--border); color: var(--text-secondary);
    padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600;
    transition: var(--transition);
}
.ai-chart-btn:hover { color: var(--text-primary); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--bg-card-hover); }

.ai-dashboard { display: flex; flex-direction: column; gap: 16px; width: 100%; }
.ai-dashboard-title {
    font-size: 17px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary);
    display: flex; align-items: center; gap: 10px;
}
.ai-dashboard-title::before { content: "📊"; font-size: 18px; }
.ai-kpi-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
}
.ai-kpi-tile {
    position: relative; overflow: hidden;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 90%, var(--accent) 10%), var(--bg-card));
    border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
    box-shadow: var(--elev-1);
}
.ai-kpi-tile::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--grad-accent);
}
.ai-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.ai-kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-primary); margin-top: 4px; line-height: 1.1; }
.ai-kpi-unit { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.ai-kpi-change { font-size: 12px; font-weight: 700; margin-top: 4px; }
.ai-kpi-change.up { color: var(--accent-green); }
.ai-kpi-change.down { color: var(--accent-red); }
.ai-kpi-progress { margin-top: 10px; height: 6px; border-radius: 6px; background: color-mix(in srgb, var(--text-muted) 22%, transparent); overflow: hidden; }
.ai-kpi-progress-fill { height: 100%; border-radius: 6px; background: var(--grad-accent); transition: width .6s cubic-bezier(.4,0,.2,1); }

@media (max-width: 640px) {
    .ai-chart-grid { grid-template-columns: 1fr; }
    .ai-chart-canvas-wrap { height: 260px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PHASE 2 — ChatGPT-style DPR AI Analyst
   ══════════════════════════════════════════════════════════════════════ */
#sec-analytics { padding: 0; }
/* Fill the viewport below the ~57px sticky top bar — no grey gap, no inner cap */
.gpt-chat {
    display: flex; flex-direction: column;
    height: calc(100vh - 57px);
    background: var(--bg-card);
    border: none;
    border-radius: 0;
    overflow: hidden;
}

/* Header */
.gpt-chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    z-index: 5;
}
.gpt-chat-title { display: flex; align-items: center; gap: 11px; }
.gpt-chat-badge {
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    font-size: 16px; border-radius: 10px; background: var(--grad-accent);
    box-shadow: 0 3px 12px var(--accent-glow); flex-shrink: 0;
}
.gpt-chat-title h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }
.gpt-chat-sub { font-size: 12px; color: var(--text-muted); }
.gpt-icon-btn {
    display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
    padding: 7px 14px; border-radius: 10px;
    background: color-mix(in srgb, var(--bg-input) 70%, transparent);
    border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer;
    transition: var(--transition);
}
.gpt-icon-btn:hover { color: var(--text-primary); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--bg-card-hover); }

/* Feed — centered conversation column (flex so the empty state centers vertically) */
.gpt-chat-feed { flex: 1; overflow-y: auto; padding: 18px 0 4px; scroll-behavior: smooth; display: flex; flex-direction: column; }
.gpt-row { max-width: 780px; width: 100%; margin: 0 auto; padding: 9px 24px; box-sizing: border-box; }
.gpt-row-user { display: flex; justify-content: flex-end; }

/* User bubble (right) */
.gpt-chat-feed .chat-bubble-user {
    max-width: 78%; width: fit-content;
    background: var(--grad-accent); color: #04120c;
    padding: 11px 16px; border-radius: 16px 16px 5px 16px;
    font-size: 14.5px; line-height: 1.55; font-weight: 500;
    box-shadow: var(--elev-2); border: none;
    white-space: pre-wrap; word-break: break-word;
}

/* Assistant message (full-width, avatar + content) */
.gpt-chat-feed .chat-bubble-bot {
    width: 100%; max-width: 100%;
    background: transparent !important; border: none !important;
    box-shadow: none !important; padding: 0 !important;
    color: var(--text-primary); font-size: 14.5px; line-height: 1.65;
}
.gpt-chat-feed .chat-bot-header { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.gpt-chat-feed .chat-bot-header > span { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.gpt-chat-feed .bot-icon {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; border-radius: 8px; background: var(--grad-accent); color: #fff;
    box-shadow: 0 0 12px var(--accent-glow); flex-shrink: 0;
}
.gpt-chat-feed .bot-text-content { color: var(--text-primary); }
.gpt-chat-feed .bot-text-content h1,
.gpt-chat-feed .bot-text-content h2,
.gpt-chat-feed .bot-text-content h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; letter-spacing: -0.01em; }
.gpt-chat-feed .bot-text-content p { margin: 8px 0; }
.gpt-chat-feed .bot-text-content ul,
.gpt-chat-feed .bot-text-content ol { margin: 8px 0 8px 4px; padding-left: 20px; }
.gpt-chat-feed .bot-text-content li { margin: 4px 0; }
.gpt-chat-feed .bot-text-content strong { color: var(--text-primary); font-weight: 700; }
.gpt-chat-feed .bot-text-content table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.gpt-chat-feed .bot-text-content th { background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 9px 12px; text-align: left; font-weight: 700; }
.gpt-chat-feed .bot-text-content td { padding: 8px 12px; border-top: 1px solid var(--border); color: var(--text-secondary); }

/* Welcome / empty state — vertically centered in the feed */
.gpt-welcome { max-width: 680px; margin: auto; text-align: center; padding: 24px; }
.gpt-welcome-logo {
    width: 52px; height: 52px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
    font-size: 26px; border-radius: 16px; background: var(--grad-accent); color: #fff;
    box-shadow: 0 8px 26px var(--accent-glow);
}
.gpt-welcome h3 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); margin: 0 0 8px; }
.gpt-welcome p { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; margin: 0 auto 20px; max-width: 500px; }
.gpt-suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 620px; margin: 0 auto; }
.gpt-suggestion {
    display: flex; align-items: center; gap: 11px; text-align: left;
    padding: 14px 16px; border-radius: 14px; cursor: pointer;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 90%, #fff 6%), var(--bg-card));
    border: 1px solid var(--border); color: var(--text-secondary);
    font-size: 13.5px; font-weight: 500; font-family: var(--font); line-height: 1.4;
    transition: var(--transition);
}
.gpt-suggestion:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--elev-2); color: var(--text-primary); }
.gpt-suggestion-ic { font-size: 18px; flex-shrink: 0; }

/* Typing indicator */
.gpt-typing { display: none; align-items: center; gap: 7px; max-width: 840px; margin: 0 auto; padding: 4px 24px 10px; }
.gpt-typing.show { display: flex; }
.gpt-typing-avatar { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 15px; border-radius: 8px; background: var(--grad-accent); color: #04120c; }
.gpt-typing .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite alternate; }
.gpt-typing .dot:nth-child(3) { animation-delay: .2s; }
.gpt-typing .dot:nth-child(4) { animation-delay: .4s; }
.gpt-typing-text { font-size: 13px; color: var(--text-muted); margin-left: 4px; }

/* Composer */
.gpt-composer-wrap { padding: 10px 24px 16px; border-top: 1px solid var(--border); background: var(--bg-card); }
.gpt-composer {
    display: flex; align-items: flex-end; gap: 8px;
    max-width: 840px; margin: 0 auto; padding: 8px 8px 8px 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 20px; transition: var(--transition);
    box-shadow: var(--elev-1);
}
.gpt-composer:focus-within { border-color: var(--border-focus); box-shadow: var(--ring); }
.gpt-composer textarea {
    flex: 1; border: none !important; background: transparent !important; resize: none;
    color: var(--text-primary); font-family: var(--font); font-size: 15px; line-height: 1.5;
    padding: 7px 2px; outline: none !important; box-shadow: none !important;
    /* override the global `textarea { min-height:120px }` so the bar is one line */
    min-height: 24px !important; height: 24px; max-height: 200px; overflow-y: auto;
}
.gpt-send {
    width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%; cursor: pointer; font-size: 15px; font-weight: 700;
    background: var(--grad-accent); color: #ffffff; transition: var(--transition);
    box-shadow: 0 2px 10px var(--accent-glow);
}
.gpt-send:hover { filter: brightness(1.08); transform: scale(1.05); }
.gpt-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.gpt-composer-hint { max-width: 840px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--text-muted); }

@media (max-width: 680px) {
    .gpt-suggestions { grid-template-columns: 1fr; }
    .gpt-row { padding: 8px 14px; }
    .gpt-chat-feed .chat-bubble-user { max-width: 88%; }
}


/* ── Result table (compact, capped) + stop button + tighter rows ── */
.gpt-table-scroll { overflow-x: auto; margin: 4px 0; border: 1px solid var(--border); border-radius: 10px; }
.gpt-result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gpt-result-table th {
    background: color-mix(in srgb, var(--accent) 9%, transparent);
    color: var(--text-secondary); text-align: left; font-weight: 700;
    padding: 8px 12px; white-space: nowrap; text-transform: none; letter-spacing: 0;
    border-bottom: 1px solid var(--border);
}
.gpt-result-table td { padding: 7px 12px; color: var(--text-secondary); border-top: 1px solid var(--border); vertical-align: top; }
.gpt-result-table tbody tr:hover, .gpt-result-table tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.gpt-table-note { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; font-style: italic; }

/* Stop state for the send button */
.gpt-send.stop { background: var(--accent-red); box-shadow: 0 2px 10px rgba(239,68,68,0.4); color: #fff; }
.gpt-send.stop:hover { filter: brightness(1.05); }

/* Tighten conversation spacing */
.gpt-chat-feed .gpt-row:first-child { padding-top: 2px; }
.gpt-composer-wrap { padding: 8px 24px 12px !important; }
.gpt-composer-hint { margin-top: 6px !important; }
