/* ================================================================
   Brahm Homeopathy CRM — Theme System
   Light + Dark Mode | Responsive Mobile
================================================================ */

/* ── Light Theme Variables ───────────────────────────────────── */
:root {
    --primary:        #005B70;
    --primary-dark:   #003d4f;
    --primary-light:  #006d87;
    --secondary:      #78C2AD;
    --secondary-light:#a0d4c5;
    --tertiary:       #4A90E2;

    --bg:             #F0F4F8;
    --bg-alt:         #E8EEF4;
    --surface:        #ffffff;
    --surface-raised: #ffffff;
    --neutral:        #F8FAFB;

    --border:         #d1dbe8;
    --border-focus:   #78C2AD;

    --text-primary:   #1a2332;
    --text-secondary: #4a5568;
    --text-muted:     #7a8a9a;

    --gray-100:       #f1f5f9;
    --gray-200:       #d1dbe8;
    --gray-400:       #8fa0b4;
    --gray-600:       #4a5568;
    --gray-800:       #1a2332;

    --success:        #22c55e;
    --danger:         #ef4444;
    --warning:        #f59e0b;
    --info:           #3b82f6;

    --shadow:         0 2px 8px rgba(0,60,90,0.08), 0 1px 3px rgba(0,60,90,0.05);
    --shadow-md:      0 4px 16px rgba(0,60,90,0.1), 0 2px 6px rgba(0,60,90,0.06);
    --shadow-lg:      0 8px 32px rgba(0,60,90,0.13), 0 4px 12px rgba(0,60,90,0.08);

    --sidebar-width:  260px;
    --topbar-height:  64px;
    --radius:         10px;
    --transition:     all 0.22s ease;

    --input-bg:       #ffffff;
    --input-border:   #c2cfe0;
    --input-shadow:   0 1px 4px rgba(0,60,90,0.07);
    --input-shadow-focus: 0 0 0 3px rgba(120,194,173,0.22), 0 1px 4px rgba(0,60,90,0.08);
}

/* ── Dark Theme Variables ────────────────────────────────────── */
[data-theme="dark"] {
    --primary:        #4db8d4;
    --primary-dark:   #2a9ab8;
    --primary-light:  #6ecde6;
    --secondary:      #78C2AD;
    --secondary-light:#9dd4c3;
    --tertiary:       #6ba8f0;

    --bg:             #0d1117;
    --bg-alt:         #161b22;
    --surface:        #1c2333;
    --surface-raised: #212c3f;
    --neutral:        #161b22;

    --border:         #2d3748;
    --border-focus:   #78C2AD;

    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #6e7681;

    --gray-100:       #1c2333;
    --gray-200:       #2d3748;
    --gray-400:       #6e7681;
    --gray-600:       #8b949e;
    --gray-800:       #e6edf3;

    --shadow:         0 2px 8px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg:      0 8px 32px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.35);

    --input-bg:       #161b22;
    --input-border:   #30363d;
    --input-shadow:   0 1px 4px rgba(0,0,0,0.3);
    --input-shadow-focus: 0 0 0 3px rgba(120,194,173,0.2), 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; background: var(--bg); }
html[data-theme="dark"] { background: var(--bg); }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--tertiary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: #003d4f;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
}

[data-theme="dark"] .sidebar {
    background: #0d1117;
    border-right: 1px solid #21262d;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}

.sidebar-brand {
    padding: 1.4rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    background: rgba(0,0,0,0.12);
}
[data-theme="dark"] .sidebar-brand { background: rgba(255,255,255,0.02); }

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #78C2AD, #4db8d4);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(120,194,173,0.4);
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; }
.sidebar-brand .brand-name { color: #fff; font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.sidebar-brand .brand-sub  { color: rgba(255,255,255,0.45); font-size: 0.7rem; }

.sidebar-section-title {
    padding: 0.9rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.32);
}

.sidebar-nav { list-style: none; padding: 0.35rem 0; }
.sidebar-nav .nav-item { margin: 1px 0.75rem; }

.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.65);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.95); }
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(120,194,173,0.25), rgba(120,194,173,0.12));
    color: #78C2AD;
    font-weight: 600;
    border-left: 3px solid #78C2AD;
    padding-left: calc(0.85rem - 3px);
}
[data-theme="dark"] .sidebar-nav .nav-link.active {
    background: rgba(120,194,173,0.12);
    border-left-color: #78C2AD;
    box-shadow: inset 0 0 20px rgba(120,194,173,0.05);
}

.sidebar-nav .nav-link .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    margin-top: auto;
    padding: 0.85rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-width); right: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 999;
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.topbar .page-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

.hamburger-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 7px; color: var(--text-muted);
    font-size: 1.1rem; border-radius: 8px;
    transition: var(--transition);
}
.hamburger-btn:hover { background: var(--gray-100); color: var(--text-primary); }

/* Theme Toggle Button */
.theme-toggle {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: scale(1.05); }
[data-theme="dark"] .theme-toggle { background: #21262d; border-color: #30363d; color: #e6edf3; }
[data-theme="dark"] .theme-toggle:hover { background: #4db8d4; border-color: #4db8d4; color: #0d1117; }

.topbar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #78C2AD, #005B70);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0,91,112,0.3);
}
.topbar-avatar:hover { box-shadow: 0 0 0 3px rgba(120,194,173,0.4); transform: scale(1.05); }

/* User Dropdown */
.user-menu {
    display: none;
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 200px;
    overflow: hidden;
    z-index: 1000;
}
.user-menu-header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--neutral);
}
.user-menu-header .name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); }
.user-menu-header .role { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.user-menu-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    color: var(--danger);
    background: none; border: none;
    width: 100%; cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}
.user-menu-btn:hover { background: var(--gray-100); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 1.75rem;
    min-height: calc(100vh - var(--topbar-height));
    background: var(--bg);
    transition: background 0.3s ease;
}

.grid-sidebar-right {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
}
@media (max-width: 1100px) {
    .grid-sidebar-right {
        grid-template-columns: 1fr;
    }
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: background 0.3s ease, border-color 0.3s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface);
}
[data-theme="dark"] .card-header { background: rgba(255,255,255,0.02); }

.card-title { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 1.25rem; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
[data-theme="dark"] .stat-card:hover { border-color: rgba(120,194,173,0.3); }

.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-info { flex: 1; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 12px rgba(0,91,112,0.35); }
[data-theme="dark"] .btn-primary { background: #1a7a96; border-color: #1a7a96; }
[data-theme="dark"] .btn-primary:hover { background: #4db8d4; border-color: #4db8d4; color: #0d1117; }
.btn-secondary { background: var(--secondary); color: var(--primary-dark); border-color: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-light); box-shadow: 0 4px 12px rgba(120,194,173,0.4); }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .btn-outline { color: var(--text-secondary); }
[data-theme="dark"] .btn-outline:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.35); }
.btn-sm { padding: 0.28rem 0.7rem; font-size: 0.8rem; border-radius: 6px; }
.btn-lg { padding: 0.72rem 1.5rem; font-size: 0.95rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 20px;
    font-size: 0.71rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-new       { background: #dcfce7; color: #15803d; }
.badge-followup  { background: #dbeafe; color: #1d4ed8; }
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-cured     { background: #dbeafe; color: #1d4ed8; }
.badge-stopped   { background: var(--gray-100); color: var(--text-muted); }
.badge-delayed   { background: #fee2e2; color: #dc2626; }
.badge-primary   { background: var(--primary); color: white; }
.badge-secondary { background: var(--secondary); color: var(--primary-dark); }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #dc2626; }
.badge-inactive  { background: #f1f5f9; color: #64748b; }
[data-theme="dark"] .badge-new      { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .badge-followup { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .badge-active   { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .badge-cured    { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .badge-stopped  { background: rgba(100,116,139,0.15); color: #94a3b8; }
[data-theme="dark"] .badge-inactive { background: rgba(100,116,139,0.15); color: #94a3b8; }
[data-theme="dark"] .badge-delayed  { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .badge-warning  { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .badge-danger   { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .badge-primary  { background: rgba(77,184,212,0.2); color: #4db8d4; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.brahm-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.brahm-table thead tr { background: var(--primary); color: white; }
[data-theme="dark"] .brahm-table thead tr { background: #1a3a4a; }
.brahm-table thead th { padding: 0.85rem 1rem; font-weight: 600; text-align: left; white-space: nowrap; font-size: 0.82rem; letter-spacing: 0.02em; }
.brahm-table tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
.brahm-table tbody tr:hover { background: var(--neutral); }
[data-theme="dark"] .brahm-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.brahm-table tbody td { padding: 0.75rem 1rem; vertical-align: middle; color: var(--text-primary); }
.brahm-table tbody tr:last-child { border-bottom: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block; font-size: 0.83rem; font-weight: 600;
    margin-bottom: 0.4rem; color: var(--text-secondary);
    letter-spacing: 0.01em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    display: block; width: 100%;
    padding: 0.58rem 0.9rem;
    font-size: 0.88rem;
    border: 1.5px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
    font-family: 'Inter', sans-serif;
    box-shadow: var(--input-shadow);
}
.form-control:hover { border-color: var(--secondary); }
.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: var(--input-shadow-focus);
    background: var(--surface);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.8; }
.form-control.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }
.form-text { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.invalid-feedback { color: var(--danger); font-size: 0.78rem; margin-top: 4px; display: block; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Filter Chips ────────────────────────────────────────────── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,91,112,0.3); }
[data-theme="dark"] .filter-chip.active { background: #1a7a96; border-color: #1a7a96; box-shadow: 0 2px 8px rgba(77,184,212,0.3); }
.filter-chip.secondary.active { background: var(--secondary); color: var(--primary-dark); border-color: var(--secondary); }

/* ── Scrumboard ──────────────────────────────────────────────── */
.scrumboard-container { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; min-height: 70vh; }
.scrumboard-column {
    flex: 0 0 260px;
    display: flex; flex-direction: column;
    background: var(--bg-alt);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-height: calc(100vh - 180px);
}
[data-theme="dark"] .scrumboard-column { background: #161b22; border-color: #21262d; }

.column-header {
    padding: 0.85rem 1rem;
    border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
    display: flex; align-items: center; gap: 0.5rem;
}
.column-header .col-title { font-weight: 700; color: white; font-size: 0.88rem; flex: 1; }
.column-header .col-count { background: rgba(255,255,255,0.22); color: white; border-radius: 12px; padding: 2px 8px; font-size: 0.75rem; font-weight: 600; }

.column-cards { padding: 0.75rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; }
.column-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.82rem; }

.patient-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 0.85rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    cursor: grab;
    transition: var(--transition);
    position: relative;
}
.patient-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
[data-theme="dark"] .patient-card:hover { border-color: rgba(120,194,173,0.3); }
.patient-card:active { cursor: grabbing; }
.patient-card.sortable-ghost { opacity: 0.4; }
.patient-card.sortable-chosen { box-shadow: var(--shadow-lg); }

.card-num { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.card-brahm { font-size: 0.78rem; color: var(--primary); font-weight: 600; }
.card-name { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); margin: 3px 0; }
.card-time { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
.drag-handle { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.75rem; opacity: 0; transition: var(--transition); }
.patient-card:hover .drag-handle { opacity: 1; }

/* ── Timeline ────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); border-radius: 2px; }
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-dot {
    position: absolute; left: -2rem; top: 4px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--secondary); border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--secondary);
}
.timeline-content { background: var(--surface); border-radius: 8px; padding: 0.85rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.timeline-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.87rem; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-danger  { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
[data-theme="dark"] .alert-success { background: rgba(34,197,94,0.12); color: #4ade80; border-color: rgba(34,197,94,0.25); }
[data-theme="dark"] .alert-danger  { background: rgba(239,68,68,0.12); color: #f87171; border-color: rgba(239,68,68,0.25); }
[data-theme="dark"] .alert-warning { background: rgba(245,158,11,0.12); color: #fbbf24; border-color: rgba(245,158,11,0.25); }
[data-theme="dark"] .alert-info    { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(59,130,246,0.25); }

/* ── Improvement Bar ─────────────────────────────────────────── */
.improvement-bar { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.improvement-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--secondary), var(--primary)); transition: width 0.8s ease; }

/* ── AI Box ──────────────────────────────────────────────────── */
.ai-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px; padding: 1.25rem; color: white;
}
[data-theme="dark"] .ai-box { background: linear-gradient(135deg, #1a3a4a, #1a5a70); border: 1px solid rgba(77,184,212,0.2); }
.ai-box h6 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.ai-medicine-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.1); font-size: 0.83rem; }
.ai-medicine-item:last-child { border-bottom: none; }
.ai-num { background: var(--secondary); color: var(--primary-dark); width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-wrapper { min-height: 100vh; display: flex; }
.login-brand {
    width: 45%; background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 3rem; position: relative; overflow: hidden;
}
[data-theme="dark"] .login-brand { background: linear-gradient(135deg, #0d1117 0%, #1a3a4a 60%, #1a5a70 100%); }
.login-brand .brand-watermark { position: absolute; opacity: 0.06; font-size: 18rem; bottom: -3rem; right: -3rem; line-height: 1; }
.login-brand-content { position: relative; z-index: 1; text-align: center; }
.login-brand h1 { color: white; font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.login-brand p { color: rgba(255,255,255,0.7); font-size: 1rem; margin-bottom: 2rem; }
.login-feature-list { list-style: none; text-align: left; }
.login-feature-list li { color: rgba(255,255,255,0.8); padding: 0.4rem 0; font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.login-feature-list .check { color: var(--secondary); }
.login-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--surface); }
.login-box { width: 100%; max-width: 420px; }
.login-box h2 { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 0.25rem; }
.login-box .subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 2rem; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; list-style: none; gap: 6px; flex-wrap: wrap; padding: 0; margin: 0; }
.page-item .page-link { 
    display: flex; align-items: center; justify-content: center;
    padding: 8px 14px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; 
    border: 1px solid var(--border); color: var(--text-secondary); 
    transition: var(--transition); text-decoration: none; background: var(--surface); 
    min-width: 40px;
}
.page-item.active .page-link { background: var(--primary); color: white !important; border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,91,112,0.3); }
.page-item.disabled .page-link { opacity: 0.5; cursor: not-allowed; background: var(--neutral); }
.page-link:hover { background: var(--primary); color: white !important; border-color: var(--primary); }

.brahm-pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.brahm-pagination a, .brahm-pagination span { padding: 6px 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 500; border: 1px solid var(--border); color: var(--text-secondary); transition: var(--transition); text-decoration: none; background: var(--surface); }
.brahm-pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); }
.brahm-pagination span.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Responsive ──────────────────────────────────────────────── */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 999; display: none; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,0.3); }
    .topbar { left: 0; }
    .main-content { margin-left: 0; }
    .hamburger-btn { display: flex; }
}

@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .login-brand { display: none; }
    .login-form-panel { padding: 1.5rem; }
    .scrumboard-column { flex: 0 0 230px; }
    .stat-value { font-size: 1.3rem; }
    .brahm-table { font-size: 0.8rem; }
    .brahm-table thead th, .brahm-table tbody td { padding: 0.6rem 0.75rem; }
    .topbar .page-title { font-size: 0.9rem; }
    .card-body { padding: 1rem; }
}

@media (max-width: 480px) {
    .topbar { padding: 0 1rem; }
    .filter-chips { gap: 0.35rem; }
    .filter-chip { font-size: 0.75rem; padding: 0.3rem 0.65rem; }
    .main-content { padding: 0.75rem; }
    .stat-card { padding: 1rem; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
}

/* ── Grid Utilities ──────────────────────────────────────────── */
.grid-2, .grid-3, .grid-4 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-primary   { color: var(--primary) !important; }
.text-secondary { color: var(--secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-danger    { color: var(--danger) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.bg-primary     { background: var(--primary) !important; }
.bg-secondary   { background: var(--secondary) !important; }
.bg-neutral     { background: var(--neutral) !important; }
.d-flex         { display: flex !important; }
.align-center   { align-items: center !important; }
.justify-between{ justify-content: space-between !important; }
.justify-end    { justify-content: flex-end !important; }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; } .mt-5 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.5rem; }
.me-1 { margin-right: 0.25rem; } .me-2 { margin-right: 0.5rem; } .ms-1 { margin-left: 0.25rem; } .ms-2 { margin-left: 0.5rem; } .ms-auto { margin-left: auto !important; }
.w-100 { width: 100% !important; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.fs-sm { font-size: 0.82rem; } .fs-xs { font-size: 0.75rem; }
.rounded { border-radius: var(--radius) !important; }
.text-center { text-align: center; } .text-right { text-align: right; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (min-width: 769px) and (max-width: 1024px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }

.grid-sidebar { display: grid; grid-template-columns: 300px 1fr; gap: 1.5rem; }
@media (max-width: 992px) { .grid-sidebar { grid-template-columns: 1fr; } }

.grid-sidebar-right { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; }
@media (max-width: 1100px) { 
    .grid-sidebar-right { display: flex; flex-direction: column-reverse; gap: 1rem; } 
}

.filter-container { 
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; 
    background: var(--surface); border: 1px solid var(--gray-200); 
    border-radius: 12px; padding: 0.85rem 1.2rem; 
}
@media (max-width: 576px) {
    .filter-container { flex-direction: column; align-items: stretch; }
    .filter-container > * { width: 100%; }
}

/* ── Dark mode overrides for inline styles ───────────────────── */
[data-theme="dark"] .topbar-right > div:last-child > div[style*="background:white"],
[data-theme="dark"] #userMenu {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}

/* ── Engine / Selection tint cards ──────────────────────────── */
/* Gemini green tints */
[data-theme="dark"] [style*="background:#f0fdf4"],
[data-theme="dark"] [style*="background: #f0fdf4"] {
    background: rgba(34,197,94,0.07) !important;
}
[data-theme="dark"] [style*="border:1.5px solid #bbf7d0"],
[data-theme="dark"] [style*="border: 1.5px solid #bbf7d0"],
[data-theme="dark"] [style*="border-top:3px solid #16a34a"],
[data-theme="dark"] [style*="border-top: 3px solid #16a34a"] {
    border-color: rgba(34,197,94,0.3) !important;
}

/* ChatGPT orange/yellow tints */
[data-theme="dark"] [style*="background:#fffbeb"],
[data-theme="dark"] [style*="background: #fffbeb"] {
    background: rgba(245,158,11,0.07) !important;
}
[data-theme="dark"] [style*="border:1.5px solid #fed7aa"],
[data-theme="dark"] [style*="border: 1.5px solid #fed7aa"] {
    border-color: rgba(245,158,11,0.3) !important;
}

/* Claude purple tints */
[data-theme="dark"] [style*="background:#faf5ff"],
[data-theme="dark"] [style*="background: #faf5ff"] {
    background: rgba(124,58,237,0.07) !important;
}
[data-theme="dark"] [style*="border:1.5px solid #ddd6fe"],
[data-theme="dark"] [style*="border: 1.5px solid #ddd6fe"] {
    border-color: rgba(124,58,237,0.3) !important;
}

/* Purple AI suggestion / template boxes */
[data-theme="dark"] [style*="background:#f5f3ff"],
[data-theme="dark"] [style*="background: #f5f3ff"] {
    background: rgba(124,58,237,0.08) !important;
}
[data-theme="dark"] [style*="border:1px solid #ddd6fe"],
[data-theme="dark"] [style*="border: 1px solid #ddd6fe"] {
    border-color: rgba(124,58,237,0.25) !important;
}

/* Light blue/indigo tints */
[data-theme="dark"] [style*="background:#e0e7ff"],
[data-theme="dark"] [style*="background: #e0e7ff"],
[data-theme="dark"] [style*="background:#fafbff"],
[data-theme="dark"] [style*="background: #fafbff"] {
    background: rgba(77,184,212,0.06) !important;
}
[data-theme="dark"] [style*="border:1.5px solid #e0e7ff"],
[data-theme="dark"] [style*="border: 1.5px solid #e0e7ff"] {
    border-color: rgba(77,184,212,0.2) !important;
}

/* Generic light grays */
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f8fafb"],
[data-theme="dark"] [style*="background: #f8fafb"] {
    background: var(--neutral) !important;
}
[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
[data-theme="dark"] [style*="border: 1px solid #e2e8f0"] {
    border-color: var(--border) !important;
}

/* ── Badge backgrounds (inline) ──────────────────────────────── */
[data-theme="dark"] [style*="background:#dcfce7"] {
    background: rgba(34,197,94,0.15) !important;
}
[data-theme="dark"] [style*="background:#fee2e2"] {
    background: rgba(239,68,68,0.15) !important;
}
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background:#fef9c3"] {
    background: rgba(245,158,11,0.15) !important;
}
[data-theme="dark"] [style*="background:#ede9fe"],
[data-theme="dark"] [style*="background:#ddd6fe"] {
    background: rgba(124,58,237,0.15) !important;
}
[data-theme="dark"] [style*="background:#dbeafe"],
[data-theme="dark"] [style*="background:#e0f2fe"],
[data-theme="dark"] [style*="background:#bfdbfe"] {
    background: rgba(59,130,246,0.15) !important;
}
[data-theme="dark"] [style*="background:#f1f5f9"] {
    background: rgba(100,116,139,0.15) !important;
}

/* ── Inline text colors ──────────────────────────────────────── */
[data-theme="dark"] [style*="color:#16a34a"],
[data-theme="dark"] [style*="color: #16a34a"],
[data-theme="dark"] [style*="color:#15803d"],
[data-theme="dark"] [style*="color: #15803d"],
[data-theme="dark"] [style*="color:#166534"],
[data-theme="dark"] [style*="color: #166534"] {
    color: #4ade80 !important;
}
[data-theme="dark"] [style*="color:#d97706"],
[data-theme="dark"] [style*="color: #d97706"],
[data-theme="dark"] [style*="color:#92400e"],
[data-theme="dark"] [style*="color: #92400e"] {
    color: #fbbf24 !important;
}
[data-theme="dark"] [style*="color:#7c3aed"],
[data-theme="dark"] [style*="color: #7c3aed"],
[data-theme="dark"] [style*="color:#4f46e5"],
[data-theme="dark"] [style*="color: #4f46e5"] {
    color: #a78bfa !important;
}
[data-theme="dark"] [style*="color:#dc2626"],
[data-theme="dark"] [style*="color: #dc2626"] {
    color: #f87171 !important;
}
[data-theme="dark"] [style*="color:#1d4ed8"],
[data-theme="dark"] [style*="color: #1d4ed8"],
[data-theme="dark"] [style*="color:#0284c7"],
[data-theme="dark"] [style*="color: #0284c7"],
[data-theme="dark"] [style*="color:#3b82f6"],
[data-theme="dark"] [style*="color: #3b82f6"] {
    color: #60a5fa !important;
}
[data-theme="dark"] [style*="color:#005B70"],
[data-theme="dark"] [style*="color: #005B70"] {
    color: #4db8d4 !important;
}

/* ── Engine selection CSS classes (JS-toggled) ───────────────── */
.engine-selected {
    transition: all 0.2s;
}
.engine-sel-gemini  { border-color: #16a34a !important; background: #f0fdf4 !important; }
.engine-sel-chatgpt { border-color: #d97706 !important; background: #fffbeb !important; }
.engine-sel-claude  { border-color: #7c3aed !important; background: #faf5ff !important; }
[data-theme="dark"] .engine-sel-gemini  { border-color: rgba(34,197,94,0.5) !important;  background: rgba(34,197,94,0.08) !important; }
[data-theme="dark"] .engine-sel-chatgpt { border-color: rgba(245,158,11,0.5) !important; background: rgba(245,158,11,0.08) !important; }
[data-theme="dark"] .engine-sel-claude  { border-color: rgba(124,58,237,0.5) !important; background: rgba(124,58,237,0.08) !important; }

.engine-sel-gemini  .sel-badge { background: rgba(22,163,74,0.15);  color: #16a34a; }
.engine-sel-chatgpt .sel-badge { background: rgba(217,119,6,0.15);  color: #d97706; }
.engine-sel-claude  .sel-badge { background: rgba(124,58,237,0.15); color: #7c3aed; }
[data-theme="dark"] .engine-sel-gemini  .sel-badge { color: #4ade80; background: rgba(34,197,94,0.15); }
[data-theme="dark"] .engine-sel-chatgpt .sel-badge { color: #fbbf24; background: rgba(245,158,11,0.15); }
[data-theme="dark"] .engine-sel-claude  .sel-badge { color: #a78bfa; background: rgba(124,58,237,0.15); }

/* ── Engine key sections ─────────────────────────────────────── */
.engine-box { border-radius:10px; padding:1rem; }
.engine-box-gemini  { border:1.5px solid #bbf7d0; background:#f0fdf4; }
.engine-box-chatgpt { border:1.5px solid #fed7aa; background:#fffbeb; }
.engine-box-claude  { border:1.5px solid #ddd6fe; background:#faf5ff; }
[data-theme="dark"] .engine-box-gemini  { border-color:rgba(34,197,94,0.25);  background:rgba(34,197,94,0.06); }
[data-theme="dark"] .engine-box-chatgpt { border-color:rgba(245,158,11,0.25); background:rgba(245,158,11,0.06); }
[data-theme="dark"] .engine-box-claude  { border-color:rgba(124,58,237,0.25); background:rgba(124,58,237,0.06); }

/* ── Inline white backgrounds ────────────────────────────────── */
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"] {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
}

/* ── Notifications & Topbar Buttons ─────────────────────────── */
.notif-wrapper { position: relative; }
.topbar-btn { background: none; border: none; font-size: 1.15rem; color: var(--text-secondary); cursor: pointer; padding: 0.6rem; position: relative; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.topbar-btn:hover { color: var(--primary); }
.notif-badge { position: absolute; top: 4px; right: 4px; background: #ef4444; color: #fff; font-size: 0.62rem; font-weight: 700; padding: 1px 4px; border-radius: 50%; min-width: 16px; text-align: center; border: 2px solid var(--surface); }
.notif-dropdown { position: absolute; top: 45px; right: 0; width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 1001; display: none; overflow: hidden; }
.notif-header { padding: 0.85rem 1.15rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 0.9rem; background: var(--gray-50); }
.notif-body { max-height: 350px; overflow-y: auto; }
.notif-item { padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); transition: 0.2s; cursor: pointer; text-align: left; }
.notif-item:hover { background: var(--gray-50); }
.notif-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 3px; color: var(--text-primary); }
.notif-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; }
.notif-empty { padding: 2.5rem; text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.notif-footer { padding: 0.75rem; text-align: center; background: var(--gray-50); border-top: 1px solid var(--border); }
.notif-footer a { font-size: 0.8rem; color: var(--primary); font-weight: 600; text-decoration: none; }
[data-theme="dark"] .notif-item:hover, [data-theme="dark"] .notif-header, [data-theme="dark"] .notif-footer { background: rgba(255,255,255,0.03); }
