/* ==========================================================================
   bluCompliance v1.1 — Stylesheet
   Light mode default, Sora sans-serif font
   ========================================================================== */

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

:root {
    /* Brand colors */
    --brand-primary: #1e5fbf;       /* bluCompliance signature blue */
    --brand-primary-dark: #164a96;
    --brand-primary-light: #4a85d4;
    --brand-accent: #06b6d4;        /* cyan accent */
    --brand-secondary: #0f172a;     /* deep navy */

    /* Light mode palette (default) */
    --bg-app: #f5f7fb;
    --bg-surface: #ffffff;
    --bg-surface-alt: #fafbfd;
    --bg-elevated: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-sidebar-active: #eff4fb;

    --border-light: #e5e9f0;
    --border-medium: #d6dce6;
    --border-strong: #c3cad7;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Status colors */
    --status-success: #10b981;
    --status-success-bg: #d1fae5;
    --status-warning: #f59e0b;
    --status-warning-bg: #fef3c7;
    --status-danger: #ef4444;
    --status-danger-bg: #fee2e2;
    --status-info: #3b82f6;
    --status-info-bg: #dbeafe;
    --status-neutral: #64748b;
    --status-neutral-bg: #f1f5f9;

    /* Risk colors */
    --risk-critical: #dc2626;
    --risk-critical-bg: #fee2e2;
    --risk-high: #ea580c;
    --risk-high-bg: #ffedd5;
    --risk-medium: #f59e0b;
    --risk-medium-bg: #fef3c7;
    --risk-low: #10b981;
    --risk-low-bg: #d1fae5;
    --risk-info: #3b82f6;
    --risk-info-bg: #dbeafe;

    /* Sidebar */
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
    --shadow-md: 0 2px 8px rgba(15,23,42,.06);
    --shadow-lg: 0 8px 24px rgba(15,23,42,.08);
    --shadow-card: 0 1px 3px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.04);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Type */
    --font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark mode override */
[data-theme="dark"] {
    --bg-app: #0b1220;
    --bg-surface: #111827;
    --bg-surface-alt: #1f2937;
    --bg-elevated: #1f2937;
    --bg-hover: #1e293b;
    --bg-sidebar: #111827;
    --bg-sidebar-active: #1e293b;

    --border-light: #1f2937;
    --border-medium: #334155;
    --border-strong: #475569;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-dark); text-decoration: underline; }

/* ==========================================================================
   Layout
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-brand .logo-mark {
    width: 36px; height: 36px;
    flex-shrink: 0;
}
.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.02em;
}
.sidebar-brand .brand-name .blu { color: var(--brand-primary); }
.sidebar-brand .brand-tagline {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section-title {
    padding: .75rem 1.25rem .25rem;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem 1.25rem;
    color: var(--text-secondary);
    font-size: .88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s ease;
    text-decoration: none;
}
.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.sidebar-nav a.active {
    background: var(--bg-sidebar-active);
    color: var(--brand-primary);
    border-left-color: var(--brand-primary);
    font-weight: 600;
}
.sidebar-nav a svg, .sidebar-nav a .icon {
    width: 18px; height: 18px; flex-shrink: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.user-menu {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background .15s;
}
.user-menu:hover { background: var(--bg-hover); }
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: .85rem;
}
.user-info { line-height: 1.2; }
.user-info .user-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); }
.user-info .user-role { font-size: .72rem; color: var(--text-muted); }

/* Main */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}
.page-content {
    padding: 1.5rem;
    max-width: 100%;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-header .page-subtitle { color: var(--text-tertiary); font-size: .9rem; margin-top: .25rem; }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-body.no-padding { padding: 0; }
.card-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface-alt);
}

/* Stat card */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}
.stat-card .stat-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}
.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -.02em;
}
.stat-card .stat-meta {
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--text-tertiary);
}
.stat-card .stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    color: var(--brand-primary);
}
.stat-card.success .stat-icon { background: var(--status-success-bg); color: var(--status-success); }
.stat-card.warning .stat-icon { background: var(--status-warning-bg); color: var(--status-warning); }
.stat-card.danger .stat-icon { background: var(--status-danger-bg); color: var(--status-danger); }
.stat-card.info .stat-icon { background: var(--status-info-bg); color: var(--status-info); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    white-space: nowrap;
    background: none;
    color: inherit;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: .95rem; }

.btn-primary {
    background: var(--brand-primary);
    color: var(--text-inverse);
    border-color: var(--brand-primary);
}
.btn-primary:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); color: white; }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-medium);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-success { background: var(--status-success); color: white; border-color: var(--status-success); }
.btn-success:hover { filter: brightness(.93); color: white; }

.btn-danger { background: var(--status-danger); color: white; border-color: var(--status-danger); }
.btn-danger:hover { filter: brightness(.93); color: white; }

.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-icon { padding: .5rem; width: 34px; height: 34px; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: .35rem;
}
.form-label.required::after { content: ' *'; color: var(--status-danger); }

.form-control, .form-select, textarea.form-control {
    display: block;
    width: 100%;
    padding: .55rem .75rem;
    font-family: inherit;
    font-size: .88rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(30,95,191,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-help { font-size: .76rem; color: var(--text-muted); margin-top: .3rem; }

.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.form-check input[type="checkbox"], .form-check input[type="radio"] {
    width: 16px; height: 16px;
    accent-color: var(--brand-primary);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.table th {
    background: var(--bg-surface-alt);
    padding: .7rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-primary);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--bg-hover); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions a { margin-left: .5rem; color: var(--text-tertiary); font-size: .85rem; }
.table .actions a:hover { color: var(--brand-primary); }

/* ==========================================================================
   Badges & Pills
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    text-transform: capitalize;
    white-space: nowrap;
}
.badge-success { background: var(--status-success-bg); color: var(--status-success); }
.badge-warning { background: var(--status-warning-bg); color: #b45309; }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-info { background: var(--status-info-bg); color: var(--status-info); }
.badge-neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }

.badge-critical { background: var(--risk-critical-bg); color: var(--risk-critical); }
.badge-high { background: var(--risk-high-bg); color: var(--risk-high); }
.badge-medium { background: var(--risk-medium-bg); color: #b45309; }
.badge-low { background: var(--risk-low-bg); color: var(--risk-low); }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: .88rem;
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}
.alert-success { background: var(--status-success-bg); border-color: var(--status-success); color: #065f46; }
.alert-warning { background: var(--status-warning-bg); border-color: var(--status-warning); color: #92400e; }
.alert-danger { background: var(--status-danger-bg); border-color: var(--status-danger); color: #991b1b; }
.alert-info { background: var(--status-info-bg); border-color: var(--status-info); color: #1e40af; }

/* ==========================================================================
   Login page
   ========================================================================== */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fb 0%, #e8eef9 100%);
    padding: 1rem;
}
.login-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border: 1px solid var(--border-light);
}
.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.login-brand .logo-mark {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    display: block;
}
.login-brand h1 {
    font-size: 1.6rem;
    margin-bottom: .25rem;
    letter-spacing: -.02em;
}
.login-brand h1 .blu { color: var(--brand-primary); }
.login-brand .tagline { color: var(--text-tertiary); font-size: .85rem; margin: 0; }

/* ==========================================================================
   Charts & Misc
   ========================================================================== */

.heatmap-grid {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    gap: 4px;
    margin-top: 1rem;
}
.heatmap-cell {
    padding: .9rem .5rem;
    text-align: center;
    border-radius: 4px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.heatmap-cell.label { background: transparent; font-weight: 500; color: var(--text-tertiary); font-size: .76rem; padding: .5rem; }
.heatmap-l1 { background: #d1fae5; }
.heatmap-l2 { background: #a7f3d0; }
.heatmap-l3 { background: #fde68a; }
.heatmap-l4 { background: #fdba74; }
.heatmap-l5 { background: #fca5a5; }

.progress-bar {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
    margin-top: .25rem;
}
.progress-bar .fill {
    height: 100%;
    background: var(--brand-primary);
    transition: width .4s ease;
}
.progress-bar.success .fill { background: var(--status-success); }
.progress-bar.warning .fill { background: var(--status-warning); }
.progress-bar.danger .fill { background: var(--status-danger); }

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-tertiary);
}
.empty-state svg { color: var(--text-muted); margin-bottom: 1rem; }
.empty-state h4 { color: var(--text-secondary); margin-bottom: .25rem; }
.empty-state p { font-size: .9rem; margin-bottom: 1rem; }

/* Filters */
.filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .75rem;
    align-items: end;
}

/* Tabs */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tabs a {
    padding: .65rem 1rem;
    color: var(--text-tertiary);
    font-size: .88rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    white-space: nowrap;
}
.tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs a.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* Two-column detail layout */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}
.detail-grid .meta-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--border-light); }
.detail-grid .meta-row:last-child { border-bottom: 0; }
.detail-grid .meta-row .meta-label { color: var(--text-tertiary); font-size: .8rem; font-weight: 500; }
.detail-grid .meta-row .meta-value { color: var(--text-primary); font-size: .85rem; font-weight: 500; text-align: right; }

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

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        transition: transform .25s;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex !important; }
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-medium);
    padding: .4rem;
    border-radius: var(--radius-md);
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    gap: .25rem;
    justify-content: flex-end;
    align-items: center;
    padding: 1rem;
}
.pagination a, .pagination span {
    padding: .35rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination .current { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }

/* Utilities */
.text-muted { color: var(--text-muted) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-success { color: var(--status-success) !important; }
.text-warning { color: var(--status-warning) !important; }
.text-danger { color: var(--status-danger) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-grow { flex-grow: 1; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.small { font-size: .8rem; }

/* Donut chart container */
.donut-chart-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}
.donut-center {
    position: absolute;
    text-align: center;
}
.donut-center .num { font-size: 2rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.donut-center .lbl { font-size: .75rem; color: var(--text-tertiary); }
