/* ================================================================
   Third Echelon Tech  —  Design System v3
   Top-nav layout · Lucide icons · Full dark-mode
   ================================================================ */

/* ────────────────────────────────────────────────────────────────
   1. CSS Variables
   ──────────────────────────────────────────────────────────────── */
:root {
    /* Accent */
    --accent:         #2563eb;
    --accent-dark:    #1d4ed8;
    --accent-light:   rgba(37,99,235,0.10);
    --accent-ring:    rgba(37,99,235,0.25);

    /* Status */
    --success:        #16a34a;
    --danger:         #dc2626;
    --warning:        #d97706;
    --info:           #0891b2;

    /* Page & surface */
    --bg:             #f6f8fb;
    --surface:        #ffffff;
    --surface-2:      #f9fafb;

    /* Topnav */
    --nav-bg:         #ffffff;
    --nav-h:          56px;
    --nav-border:     #e5e7eb;

    /* Text */
    --t1:             #111827;
    --t2:             #6b7280;
    --t3:             #9ca3af;

    /* Border */
    --border:         #e5e7eb;
    --border-2:       #d1d5db;

    /* Radius */
    --r:              8px;
    --r-sm:           6px;
    --r-lg:           12px;
    --r-xl:           16px;

    /* Font */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Shadows */
    --sh-xs: 0 1px 2px rgba(0,0,0,0.06);
    --sh-sm: 0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --sh:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
    --sh-lg: 0 12px 36px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);
    --sh-xl: 0 24px 60px rgba(0,0,0,0.12), 0 8px 20px rgba(0,0,0,0.06);

    /* Dropdown shadow */
    --sh-drop: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}

html.dark {
    --accent:         #3b82f6;
    --accent-dark:    #2563eb;
    --accent-light:   rgba(59,130,246,0.12);
    --accent-ring:    rgba(59,130,246,0.30);

    --success:        #22c55e;
    --danger:         #f87171;
    --warning:        #fbbf24;
    --info:           #22d3ee;

    --bg:             #111111;
    --surface:        #242424;
    --surface-2:      #2e2e2e;

    --nav-bg:         #0a0a0a;
    --nav-border:     #2e2e2e;

    --t1:             #f1f5f9;
    --t2:             #94a3b8;
    --t3:             #525252;

    --border:         #2e2e2e;
    --border-2:       #383838;

    --sh-xs: 0 1px 2px rgba(0,0,0,0.4);
    --sh-sm: 0 1px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
    --sh:    0 4px 16px rgba(0,0,0,0.5), 0 1px 4px rgba(0,0,0,0.3);
    --sh-lg: 0 12px 36px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
    --sh-xl: 0 24px 60px rgba(0,0,0,0.7), 0 8px 20px rgba(0,0,0,0.5);

    --sh-drop: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
}

/* ────────────────────────────────────────────────────────────────
   2. Reset & Base
   ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--t1);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); }

/* ────────────────────────────────────────────────────────────────
   3. Lucide icon defaults
   ──────────────────────────────────────────────────────────────── */
svg[data-lucide] {
    width:  16px;
    height: 16px;
    stroke-width: 1.8;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────────
   4. Impersonation banner
   ──────────────────────────────────────────────────────────────── */
.impersonation-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: #7c3aed;
    color: #fff;
    text-align: center;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
}
.impersonation-bar a { color: #ddd6fe; text-decoration: underline; }

/* ────────────────────────────────────────────────────────────────
   5. Top Navigation
   ──────────────────────────────────────────────────────────────── */
.topnav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: var(--sh-xs);
    height: var(--nav-h);
}

.topnav-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    gap: 4px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Brand */
.topnav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    margin-right: 12px;
    flex-shrink: 0;
}

.brand-gem {
    color: var(--accent);
    font-size: 20px;
    line-height: 1;
}

.brand-text {
    font-size: 15px;
    font-weight: 800;
    color: var(--t1);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

/* ── Nav links row ── */
.tnav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

/* Base link style */
.tnav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--t2);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}

.tnav-link:hover,
.tnav-drop-btn:hover { background: var(--surface-2); color: var(--t1); text-decoration: none; }

.tnav-link.active,
.tnav-drop.active > .tnav-drop-btn {
    background: var(--accent-light);
    color: var(--accent);
}

html.dark .tnav-link:hover,
html.dark .tnav-drop-btn:hover { background: rgba(255,255,255,0.06); color: var(--t1); }

html.dark .tnav-link.active,
html.dark .tnav-drop.active > .tnav-drop-btn { background: var(--accent-light); }

.tnav-icon {
    width: 15px;
    height: 15px;
    opacity: 0.75;
}

.tnav-chevron {
    width: 13px;
    height: 13px;
    opacity: 0.5;
    transition: transform 0.2s;
}

.tnav-drop.open .tnav-chevron { transform: rotate(180deg); }

/* ── Dropdown wrapper ── */
.tnav-drop {
    position: relative;
}

/* ── Dropdown menu ── */
.tnav-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.tnav-drop.open .tnav-menu {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.tnav-menu--right { left: auto; right: 0; }

.tnav-menu-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-drop);
    padding: 6px;
    min-width: 210px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* ── Dropdown item ── */
.tnav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--t2);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
}

.tnav-item svg[data-lucide] {
    width: 15px;
    height: 15px;
    color: var(--t3);
    flex-shrink: 0;
}

.tnav-item:hover, .tnav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    text-decoration: none;
}

.tnav-item:hover svg[data-lucide],
.tnav-item.active svg[data-lucide] { color: var(--accent); }

.tnav-item--danger { color: var(--danger); }
.tnav-item--danger svg[data-lucide] { color: var(--danger); }
.tnav-item--danger:hover { background: rgba(220,38,38,0.08); color: var(--danger); }

.tnav-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Suspense badge in dropdown */
.tnav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.6;
}

/* User info block inside dropdown */
.tnav-user-info {
    padding: 8px 12px 10px;
}

.tnav-user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--t1);
}

.tnav-user-role {
    font-size: 12px;
    color: var(--t3);
    margin-top: 1px;
}

/* ── Right cluster ── */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Icon buttons (bell, dark toggle, search) */
.tnav-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--t2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
}

.tnav-icon-btn svg[data-lucide] { width: 17px; height: 17px; }

.tnav-icon-btn:hover,
.tnav-icon-btn.active {
    background: var(--surface-2);
    color: var(--t1);
    text-decoration: none;
}

html.dark .tnav-icon-btn:hover,
html.dark .tnav-icon-btn.active { background: rgba(255,255,255,0.07); }

/* Notification dot */
.tnav-notif-dot {
    position: absolute;
    top: 3px; right: 3px;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid var(--nav-bg);
    line-height: 1;
}

/* User avatar button */
.tnav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.15s, opacity 0.15s;
    flex-shrink: 0;
    margin-left: 2px;
}

.tnav-avatar:hover { opacity: 0.9; box-shadow: 0 0 0 3px var(--accent-ring); }

/* Search form */
.tnav-search {
    display: flex;
    align-items: center;
}

.tnav-search-input {
    width: 0;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 13px;
    background: var(--surface-2);
    color: var(--t1);
    outline: none;
    opacity: 0;
    transition: width 0.25s ease, padding 0.25s ease, opacity 0.2s ease, border-color 0.15s;
    pointer-events: none;
}

.tnav-search.expanded .tnav-search-input {
    width: 220px;
    padding: 0 12px;
    opacity: 1;
    border: 1px solid var(--border);
    pointer-events: auto;
    margin-left: 4px;
}

.tnav-search.expanded .tnav-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Hamburger (mobile only) */
.tnav-hamburger {
    display: none;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--t2);
    cursor: pointer;
    border-radius: var(--r-sm);
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}

.tnav-hamburger svg[data-lucide] { width: 20px; height: 20px; }
.tnav-hamburger:hover { background: var(--surface-2); color: var(--t1); }

/* ────────────────────────────────────────────────────────────────
   6. Page Body
   ──────────────────────────────────────────────────────────────── */
.page-body {
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px 28px 48px;
    min-height: calc(100vh - var(--nav-h));
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -0.2px;
}

.page-content { /* container for flash + content */ }

/* ────────────────────────────────────────────────────────────────
   7. Login Page
   ──────────────────────────────────────────────────────────────── */
body.login-page { background: var(--bg); margin: 0; min-height: 100vh; display: flex; }

.login-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.login-left {
    flex: 0 0 42%;
    max-width: 520px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 64px 56px;
    position: relative;
    overflow: hidden;
}

html.dark .login-left { background: #0a0a0a; }

.login-left::before {
    content: '';
    position: absolute;
    top: -80px; right: -80px;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,0.2) 0%, transparent 65%);
    pointer-events: none;
}

.login-left::after {
    content: '';
    position: absolute;
    bottom: -100px; left: -60px;
    width: 340px; height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,0.1) 0%, transparent 65%);
    pointer-events: none;
}

.login-brand { position: relative; z-index: 1; margin-bottom: 52px; }

.login-brand-icon {
    font-size: 36px;
    color: var(--accent);
    display: block;
    margin-bottom: 22px;
    line-height: 1;
}

.login-brand-name {
    font-size: 30px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.6px;
    line-height: 1.15;
    margin-bottom: 14px;
}

.login-brand-sub {
    font-size: 14.5px;
    color: rgba(255,255,255,0.42);
    line-height: 1.7;
    max-width: 320px;
}

.login-features {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.52);
    font-size: 13.5px;
}

.login-feature-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: rgba(37,99,235,0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    background: var(--bg);
    overflow-y: auto;
}

.login-form-wrap { width: 100%; max-width: 400px; }

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -0.4px;
    margin-bottom: 6px;
}

.login-sub { font-size: 14px; color: var(--t2); margin-bottom: 34px; }

.login-footer {
    text-align: center;
    font-size: 13px;
    color: var(--t2);
    margin-top: 18px;
}

.login-footer a { color: var(--accent); font-weight: 500; }

.login-copy {
    text-align: center;
    font-size: 11.5px;
    color: var(--t3);
    margin-top: 44px;
}

@media (max-width: 800px) {
    .login-layout { flex-direction: column; }
    .login-left { flex: none; max-width: 100%; padding: 40px 28px; min-height: auto; }
    .login-left::before, .login-left::after { display: none; }
    .login-brand { margin-bottom: 20px; }
    .login-features { display: none; }
    .login-right { padding: 40px 24px; }
}

/* ────────────────────────────────────────────────────────────────
   8. Legacy auth card (forgot / reset / register)
   ──────────────────────────────────────────────────────────────── */
.auth-page {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    border: 1px solid var(--border);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 { font-size: 22px; font-weight: 700; color: var(--t1); margin-top: 10px; }
.auth-header p { color: var(--t2); font-size: 13.5px; margin-top: 4px; }
.brand-icon.large { font-size: 30px; color: var(--accent); display: block; }
.auth-footer-link { text-align: center; margin-top: 18px; font-size: 13px; color: var(--t2); }

/* ────────────────────────────────────────────────────────────────
   9. Forms
   ──────────────────────────────────────────────────────────────── */
.auth-form, .app-form { display: flex; flex-direction: column; gap: 16px; }

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

.form-group label, .form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--t2);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-control {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--t1);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-control--sm { padding: 5px 10px; font-size: 13px; }

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-fieldset legend {
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.form-inline-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

.required { color: var(--danger); }

.form-card {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
    padding: 28px;
    max-width: 760px;
}

/* ────────────────────────────────────────────────────────────────
   10. Buttons
   ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.12s, box-shadow 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg[data-lucide] { width: 15px; height: 15px; }
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 2px 8px var(--accent-ring);
}

.btn-secondary {
    background: var(--surface);
    color: var(--t2);
    border-color: var(--border-2);
}
.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--t1);
    border-color: var(--t3);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    filter: brightness(0.88);
    box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}

.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ────────────────────────────────────────────────────────────────
   11. Alerts
   ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 11px 15px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert-danger {
    background: rgba(220,38,38,0.07);
    color: var(--danger);
    border-color: rgba(220,38,38,0.2);
}

.alert-success {
    background: rgba(22,163,74,0.07);
    color: var(--success);
    border-color: rgba(22,163,74,0.2);
}

/* ────────────────────────────────────────────────────────────────
   12. KPI Cards
   ──────────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 20px 22px;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    transition: box-shadow 0.15s, transform 0.15s;
}

.kpi-card:hover { box-shadow: var(--sh); transform: translateY(-1px); }

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.kpi-value { font-size: 28px; font-weight: 700; color: var(--t1); line-height: 1.1; }
.kpi-sub   { font-size: 11.5px; color: var(--t3); margin-top: 4px; }

.kpi-card--green  { border-left-color: var(--success); }
.kpi-card--yellow { border-left-color: var(--warning); }
.kpi-card--accent { border-left-color: var(--accent); }
.kpi-card--danger { border-left-color: var(--danger); }
.kpi-card--red {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
    border-left-color: #f87171;
}
.kpi-card--red .kpi-label { color: rgba(255,255,255,0.65); }
.kpi-card--red .kpi-value { color: #fff; }

/* ────────────────────────────────────────────────────────────────
   13. Data Table
   ──────────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
}

.data-table th, .data-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.data-table th {
    background: #0f172a;
    color: rgba(255,255,255,0.88);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

html.dark .data-table th { background: #1e1e1e; }

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ────────────────────────────────────────────────────────────────
   14. Badges
   ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-active    { background: rgba(22,163,74,0.12);   color: #15803d; }
.badge-renewal   { background: rgba(217,119,6,0.12);   color: #b45309; }
.badge-cancelled { background: rgba(220,38,38,0.12);   color: #b91c1c; }
.badge-expired   { background: rgba(100,116,139,0.12); color: #64748b; }
.badge-overdue   { background: rgba(220,38,38,0.85);   color: #fff; }
.badge-warning   { background: rgba(217,119,6,0.12);   color: #b45309; }
.badge-success   { background: rgba(22,163,74,0.12);   color: #15803d; }

html.dark .badge-active    { background: rgba(22,163,74,0.18);   color: #86efac; }
html.dark .badge-renewal   { background: rgba(217,119,6,0.18);   color: #fcd34d; }
html.dark .badge-cancelled { background: rgba(220,38,38,0.18);   color: #fca5a5; }
html.dark .badge-expired   { background: rgba(100,116,139,0.18); color: #94a3b8; }
html.dark .badge-warning   { background: rgba(217,119,6,0.18);   color: #fcd34d; }
html.dark .badge-success   { background: rgba(22,163,74,0.18);   color: #86efac; }

/* Invoice status */
.invoice-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.invoice-status--draft   { background: rgba(100,116,139,0.12); color: #475569; }
.invoice-status--sent    { background: rgba(8,145,178,0.12);   color: #0e7490; }
.invoice-status--paid    { background: rgba(22,163,74,0.12);   color: #15803d; }
.invoice-status--overdue { background: rgba(220,38,38,0.12);   color: #b91c1c; }
.invoice-status--void    { background: rgba(100,116,139,0.10); color: #64748b; }

html.dark .invoice-status--draft   { background: rgba(100,116,139,0.18); color: #94a3b8; }
html.dark .invoice-status--sent    { background: rgba(8,145,178,0.18);   color: #67e8f9; }
html.dark .invoice-status--paid    { background: rgba(22,163,74,0.18);   color: #86efac; }
html.dark .invoice-status--overdue { background: rgba(220,38,38,0.18);   color: #fca5a5; }
html.dark .invoice-status--void    { background: rgba(100,116,139,0.15); color: #64748b; }

/* ────────────────────────────────────────────────────────────────
   15. Section Header
   ──────────────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 { font-size: 17px; font-weight: 600; color: var(--t1); }

/* ────────────────────────────────────────────────────────────────
   16. Cards
   ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
}

.profile-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 18px;
    margin-bottom: 18px;
    align-items: start;
}

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

.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}

.profile-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-list {
    display: grid;
    grid-template-columns: 90px 1fr;
    padding: 12px 16px;
}

.detail-list dt {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-list dd {
    font-size: 13.5px;
    color: var(--t1);
    padding: 8px 0 8px 12px;
    border-bottom: 1px solid var(--border);
    margin: 0;
}

.detail-list dt:last-of-type,
.detail-list dd:last-of-type { border-bottom: none; }

/* ────────────────────────────────────────────────────────────────
   17. Notes
   ──────────────────────────────────────────────────────────────── */
.notes-card { margin-bottom: 18px; }

.notes-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.notes-form textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 13.5px;
    background: var(--surface);
    color: var(--t1);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.notes-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.notes-list { display: flex; flex-direction: column; }

.note-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }

.note-meta { font-size: 12px; color: var(--t3); margin-bottom: 5px; }
.note-meta strong { color: var(--t2); }

.note-body { font-size: 13.5px; color: var(--t1); line-height: 1.6; margin-bottom: 8px; }

.note-delete { opacity: 0.5; transition: opacity 0.15s; }
.note-delete:hover { opacity: 1; }

/* ────────────────────────────────────────────────────────────────
   18. Report cards
   ──────────────────────────────────────────────────────────────── */
.report-cards { display: flex; flex-direction: column; gap: 8px; }

.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 15px 18px;
    text-decoration: none;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
    color: var(--t1);
}

.report-card:hover {
    box-shadow: var(--sh);
    border-color: var(--accent);
    transform: translateX(2px);
    text-decoration: none;
}

.report-card__icon { font-size: 20px; color: var(--accent); flex-shrink: 0; width: 36px; text-align: center; }
.report-card__body { flex: 1; }
.report-card__title { font-size: 14px; font-weight: 600; color: var(--t1); }
.report-card__desc { font-size: 13px; color: var(--t3); margin-top: 2px; }

.report-toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.report-header { margin-bottom: 20px; }
.report-agency { font-size: 20px; font-weight: 700; color: var(--t1); }
.report-title { font-size: 13px; color: var(--t3); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.report-date { font-size: 12px; color: var(--t3); margin-top: 4px; }

.report-summary {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--sh-sm);
}

.report-stat { flex: 1; padding: 14px 18px; border-right: 1px solid var(--border); text-align: center; }
.report-stat:last-child { border-right: none; }
.report-stat__label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--t3); margin-bottom: 5px; }
.report-stat__value { display: block; font-size: 22px; font-weight: 700; color: var(--t1); }

.report-total-row td { background: var(--surface-2); border-top: 2px solid var(--border); }

/* ────────────────────────────────────────────────────────────────
   19. Pagination
   ──────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 18px; flex-wrap: wrap; }

.pagination a, .pagination .active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--t2);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.pagination a:hover { background: var(--surface-2); color: var(--t1); text-decoration: none; }

.pagination a.active, .pagination .active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination-ellipsis { color: var(--t3); padding: 0 4px; font-size: 13px; }

/* ────────────────────────────────────────────────────────────────
   20. Filter tabs & pills
   ──────────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 2px solid var(--border); }

.filter-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--t3);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.12s, border-color 0.12s;
}

.filter-tab:hover { color: var(--t1); text-decoration: none; }
.filter-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.filter-pill {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--t2);
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.filter-pill:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

.filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ────────────────────────────────────────────────────────────────
   21. Count badge
   ──────────────────────────────────────────────────────────────── */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
}

/* ────────────────────────────────────────────────────────────────
   22. Table utilities
   ──────────────────────────────────────────────────────────────── */
.table-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.table-actions form { margin: 0; }

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border-2);
    border-radius: var(--r);
    padding: 48px;
    text-align: center;
    color: var(--t3);
    font-size: 14px;
}

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

.row-overdue   { background: rgba(220,38,38,0.05) !important; }
.row-due-today { background: rgba(217,119,6,0.05) !important; }
html.dark .row-overdue   { background: rgba(220,38,38,0.08) !important; }
html.dark .row-due-today { background: rgba(217,119,6,0.08) !important; }

.task-desc { font-size: 12px; color: var(--t3); margin-top: 3px; }

/* ────────────────────────────────────────────────────────────────
   23. Document vault
   ──────────────────────────────────────────────────────────────── */
.vault-grid { display: flex; flex-direction: column; gap: 8px; }

.vault-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    transition: box-shadow 0.15s;
}

.vault-card:hover { box-shadow: var(--sh); }

.vault-card__icon {
    background: #0f172a;
    color: rgba(255,255,255,0.9);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: var(--r-sm);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vault-card__body { flex: 1; min-width: 0; }
.vault-card__name { font-size: 13.5px; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vault-card__meta { font-size: 12px; color: var(--t3); margin-top: 2px; }
.vault-card__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────────
   24. Pipeline / Kanban
   ──────────────────────────────────────────────────────────────── */
.pipeline-summary { display: flex; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--sh-sm); overflow: hidden; }
.pipeline-stat { flex: 1; padding: 14px 18px; text-align: center; border-right: 1px solid var(--border); }
.pipeline-stat:last-child { border-right: none; }
.pipeline-stat__label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--t3); margin-bottom: 5px; }
.pipeline-stat__value { display: block; font-size: 24px; font-weight: 700; color: var(--t1); }

.pipeline-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 960px) { .pipeline-board { grid-template-columns: 1fr; } }

.pipeline-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }

.pipeline-col__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #0f172a;
    color: rgba(255,255,255,0.9);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

html.dark .pipeline-col__header { background: #1e1e1e; }

.pipeline-col__header .count-badge { background: rgba(255,255,255,0.15); color: #fff; }
.pipeline-empty { padding: 20px; text-align: center; color: var(--t3); font-size: 13px; }
.pipeline-card { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 14px; transition: box-shadow 0.15s; }
.pipeline-card:last-child { border-bottom: none; }
.pipeline-card:hover { box-shadow: var(--sh-sm); }
.pipeline-card__name { font-size: 13.5px; font-weight: 600; color: var(--t1); margin-bottom: 5px; }
.pipeline-card__meta { font-size: 12px; color: var(--t3); display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.pipeline-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ────────────────────────────────────────────────────────────────
   25. Inline select & misc
   ──────────────────────────────────────────────────────────────── */
.inline-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 12px;
    background: var(--surface);
    color: var(--t1);
    cursor: pointer;
    outline: none;
}

.retention-bar { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; width: 100%; }
.retention-bar__fill { background: var(--success); height: 100%; border-radius: 4px; transition: width 0.3s ease; }

.portal-link-input {
    padding: 7px 11px;
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-family: var(--font);
    width: 320px;
    background: var(--accent-light);
    color: var(--t1);
    cursor: pointer;
}

.token-code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: var(--accent-light);
    border: 1px solid rgba(37,99,235,0.3);
    border-radius: 4px;
    padding: 6px 10px;
    word-break: break-all;
    flex: 1;
    color: var(--accent);
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 16px;
    border-radius: var(--r);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.8;
}

html.dark .code-block { background: #0a0a0a; }

.token-reveal { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.portal-link-box { display: flex; align-items: center; }
.form-inline-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

.text-muted { color: var(--t3) !important; font-size: 13px; }

/* ────────────────────────────────────────────────────────────────
   26. Activity feed & notifications
   ──────────────────────────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; }

.activity-entry { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.activity-entry:last-child { border-bottom: none; }

.log-action { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.log-action--create { background: rgba(22,163,74,0.12); color: #15803d; }
.log-action--update { background: rgba(8,145,178,0.12); color: #0e7490; }
.log-action--delete { background: rgba(220,38,38,0.12); color: #b91c1c; }
html.dark .log-action--create { background: rgba(22,163,74,0.18); color: #86efac; }
html.dark .log-action--update { background: rgba(8,145,178,0.18); color: #67e8f9; }
html.dark .log-action--delete { background: rgba(220,38,38,0.18); color: #fca5a5; }

.activity-description { font-size: 13.5px; color: var(--t1); font-weight: 500; }
.activity-meta { font-size: 12px; color: var(--t3); margin-top: 2px; }

.notif-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.notif-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.notif-item:last-child { border-bottom: none; }
.notif-item--unread { background: rgba(37,99,235,0.04); }
html.dark .notif-item--unread { background: rgba(59,130,246,0.08); }

.notif-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; margin-top: 2px; }
.notif-icon--expiry  { background: rgba(217,119,6,0.12); color: #b45309; }
.notif-icon--overdue { background: rgba(220,38,38,0.12); color: #b91c1c; }
.notif-icon--task    { background: rgba(8,145,178,0.12); color: #0e7490; }
.notif-icon--claim   { background: rgba(220,38,38,0.12); color: #b91c1c; }
.notif-icon--info    { background: rgba(22,163,74,0.12); color: #15803d; }
html.dark .notif-icon--expiry  { background: rgba(217,119,6,0.18);  color: #fcd34d; }
html.dark .notif-icon--overdue { background: rgba(220,38,38,0.18);  color: #fca5a5; }
html.dark .notif-icon--task    { background: rgba(8,145,178,0.18);  color: #67e8f9; }
html.dark .notif-icon--claim   { background: rgba(220,38,38,0.18);  color: #fca5a5; }
html.dark .notif-icon--info    { background: rgba(22,163,74,0.18);  color: #86efac; }

.notif-message { font-size: 13.5px; color: var(--t1); font-weight: 500; }
.notif-time { font-size: 12px; color: var(--t3); margin-top: 3px; }

/* ────────────────────────────────────────────────────────────────
   27. Calendar
   ──────────────────────────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-month-title { font-size: 17px; font-weight: 600; color: var(--t1); }
.cal-grid-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day-header { padding: 8px 0; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--t3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 78px; padding: 6px 7px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-decoration: none; display: block; color: var(--t1); transition: background 0.1s; }
.cal-cell:hover { background: var(--accent-light); text-decoration: none; }
.cal-cell--empty { background: var(--surface-2); pointer-events: none; }
.cal-cell--today .cal-day-num { background: var(--accent); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-cell--selected { background: var(--accent-light); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day-num { font-size: 13px; font-weight: 600; display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-dot--scheduled { background: var(--accent); }
.cal-dot--completed { background: var(--success); }
.cal-dot--cancelled { background: var(--t3); }
.cal-dot--no_show   { background: var(--danger); }
.cal-dot-more { font-size: 10px; color: var(--t3); line-height: 8px; }

.cal-day-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.cal-day-panel__header { padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.cal-day-panel__empty { padding: 18px 14px; color: var(--t3); text-align: center; }
.cal-day-panel__list { display: flex; flex-direction: column; }
.cal-appt-item { padding: 11px 14px; border-bottom: 1px solid var(--border); border-left: 3px solid var(--border); }
.cal-appt-item:last-child { border-bottom: none; }
.cal-appt-item--scheduled { border-left-color: var(--accent); }
.cal-appt-item--completed { border-left-color: var(--success); }
.cal-appt-item--cancelled { border-left-color: var(--t3); }
.cal-appt-item--no_show   { border-left-color: var(--danger); }
.cal-appt-time  { font-size: 12px; color: var(--t3); font-weight: 500; }
.cal-appt-title { font-size: 14px; font-weight: 600; margin: 2px 0; color: var(--t1); }
.cal-appt-meta  { font-size: 12px; color: var(--t3); }

/* ────────────────────────────────────────────────────────────────
   28. Appointment pills
   ──────────────────────────────────────────────────────────────── */
.appt-pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.appt-pill--scheduled { background: rgba(8,145,178,0.12); color: #0e7490; }
.appt-pill--completed { background: rgba(22,163,74,0.12); color: #15803d; }
.appt-pill--cancelled { background: rgba(100,116,139,0.12); color: #64748b; }
.appt-pill--no_show   { background: rgba(220,38,38,0.12); color: #b91c1c; }
html.dark .appt-pill--scheduled { background: rgba(8,145,178,0.18);   color: #67e8f9; }
html.dark .appt-pill--completed { background: rgba(22,163,74,0.18);   color: #86efac; }
html.dark .appt-pill--cancelled { background: rgba(100,116,139,0.18); color: #94a3b8; }
html.dark .appt-pill--no_show   { background: rgba(220,38,38,0.18);   color: #fca5a5; }

.appt-status { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.appt-status--active     { background: rgba(22,163,74,0.12);  color: #15803d; }
.appt-status--pending    { background: rgba(217,119,6,0.12);  color: #b45309; }
.appt-status--terminated { background: rgba(220,38,38,0.12);  color: #b91c1c; }
html.dark .appt-status--active     { background: rgba(22,163,74,0.18);  color: #86efac; }
html.dark .appt-status--pending    { background: rgba(217,119,6,0.18);  color: #fcd34d; }
html.dark .appt-status--terminated { background: rgba(220,38,38,0.18);  color: #fca5a5; }

/* ────────────────────────────────────────────────────────────────
   29. Settings tabs
   ──────────────────────────────────────────────────────────────── */
.settings-tabs { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 2px solid var(--border); }
.settings-tab { padding: 8px 20px; font-size: 13.5px; font-weight: 500; color: var(--t3); text-decoration: none; border-radius: var(--r-sm) var(--r-sm) 0 0; border: 1px solid transparent; border-bottom: none; margin-bottom: -2px; transition: color 0.12s; }
.settings-tab:hover { color: var(--t1); text-decoration: none; }
.settings-tab.active { color: var(--t1); background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface); font-weight: 600; }

/* ────────────────────────────────────────────────────────────────
   30. Carrier / AM badges
   ──────────────────────────────────────────────────────────────── */
.carrier-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .carrier-detail-grid { grid-template-columns: 1fr; } }

.am-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.am-badge--excellent { background: rgba(22,163,74,0.12); color: #15803d; }
.am-badge--good      { background: rgba(8,145,178,0.12); color: #0e7490; }
.am-badge--fair      { background: rgba(217,119,6,0.12); color: #b45309; }
html.dark .am-badge--excellent { background: rgba(22,163,74,0.18); color: #86efac; }
html.dark .am-badge--good      { background: rgba(8,145,178,0.18); color: #67e8f9; }
html.dark .am-badge--fair      { background: rgba(217,119,6,0.18); color: #fcd34d; }

.row-inactive td { opacity: 0.45; }
.contact-add-form { padding-top: 4px; }

/* ────────────────────────────────────────────────────────────────
   31. Search results
   ──────────────────────────────────────────────────────────────── */
.search-page-form { margin-bottom: 22px; }
.search-page-bar { display: flex; gap: 8px; max-width: 600px; }
.search-page-input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 15px; font-family: var(--font); background: var(--surface); color: var(--t1); outline: none; transition: border-color 0.15s; }
.search-page-input:focus { border-color: var(--accent); }
.search-meta { font-size: 13px; color: var(--t3); margin-bottom: 18px; }
.search-group { margin-bottom: 22px; }
.search-group-header { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--t3); padding: 0 0 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.search-group-count { background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 600; }
.search-results-list { display: flex; flex-direction: column; }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; text-decoration: none; color: inherit; border-radius: var(--r-sm); transition: background 0.1s; }
.search-result-item:hover { background: var(--accent-light); text-decoration: none; }
.search-result-icon { font-size: 17px; width: 26px; text-align: center; flex-shrink: 0; color: var(--t3); }
.search-result-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.search-result-title { font-size: 14px; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 12px; color: var(--t3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 12px; color: var(--t3); white-space: nowrap; flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────────
   32. Endorsements
   ──────────────────────────────────────────────────────────────── */
.endorsement-timeline { padding: 0; }
.endorsement-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.endorsement-item:last-child { border-bottom: none; }
.endorsement-date { font-size: 11px; font-weight: 700; color: var(--t1); white-space: nowrap; min-width: 70px; padding-top: 2px; }
.endorsement-body { flex: 1; }
.endorsement-type { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--t3); margin-bottom: 2px; }
.endorsement-desc { font-size: 13px; color: var(--t1); line-height: 1.4; }
.endorsement-premium { font-size: 12px; font-weight: 600; margin-top: 3px; color: var(--t1); }
.endorsement-meta { font-size: 11px; color: var(--t3); margin-top: 4px; }

/* ────────────────────────────────────────────────────────────────
   33. Invoice detail
   ──────────────────────────────────────────────────────────────── */
.invoice-summary-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 760px) { .invoice-summary-grid { grid-template-columns: 1fr; } }

.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th { width: 38%; text-align: left; padding: 7px 10px; color: var(--t3); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
.detail-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--t1); }

/* ────────────────────────────────────────────────────────────────
   34. Policy comparison
   ──────────────────────────────────────────────────────────────── */
.cmp-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 8px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
.cmp-table thead th { background: #0f172a; color: rgba(255,255,255,0.9); padding: 11px 14px; text-align: left; font-size: 12px; font-weight: 600; border: none; vertical-align: top; }
html.dark .cmp-table thead th { background: #1e1e1e; }
.cmp-table thead th.cmp-col-best { background: #14532d; }
.cmp-label-col { width: 160px; min-width: 140px; }
.cmp-pol-col { min-width: 200px; }
.cmp-pol-header { display: flex; flex-direction: column; gap: 4px; }
.cmp-pol-number { font-size: 14px; font-weight: 700; color: #fff; }
.cmp-pol-client { font-size: 11px; color: rgba(255,255,255,0.55); font-weight: 400; }
.cmp-best-badge { font-size: 10px !important; padding: 2px 6px !important; margin-bottom: 2px; width: fit-content; }
.cmp-table tbody tr:nth-child(even) { background: var(--surface-2); }
.cmp-table tbody tr:hover { background: rgba(37,99,235,0.04); }
.cmp-row-diff { background: rgba(217,119,6,0.05) !important; }
.cmp-label { padding: 9px 14px; font-weight: 500; color: var(--t2); font-size: 12px; border-right: 1px solid var(--border); white-space: nowrap; }
.cmp-diff-indicator { color: var(--warning); font-size: 8px; margin-left: 4px; vertical-align: middle; }
.cmp-cell { padding: 9px 14px; border-right: 1px solid var(--border); vertical-align: middle; color: var(--t1); }
.cmp-cell:last-child { border-right: none; }
.cmp-cell-highlighted { background: rgba(217,119,6,0.06); }
.cmp-cell-best { background: rgba(22,163,74,0.07) !important; }
.cmp-best-icon { color: var(--success); font-size: 12px; margin-left: 4px; }
.cmp-endorsement-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cmp-diff-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: rgba(217,119,6,0.5); margin-right: 4px; vertical-align: middle; }
.cmp-best-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: rgba(22,163,74,0.5); margin-right: 4px; vertical-align: middle; }

/* ────────────────────────────────────────────────────────────────
   35. Compliance
   ──────────────────────────────────────────────────────────────── */
.compliance-section { margin-bottom: 22px; }
.compliance-section-title { font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: var(--r-sm) var(--r-sm) 0 0; border-left: 3px solid transparent; }
.compliance-section-title--high   { background: rgba(220,38,38,0.08);  border-left-color: var(--danger);  color: #b91c1c; }
.compliance-section-title--medium { background: rgba(217,119,6,0.08);  border-left-color: var(--warning); color: #92400e; }
.compliance-section-title--low    { background: rgba(37,99,235,0.07);  border-left-color: var(--accent);  color: var(--accent); }
html.dark .compliance-section-title--high   { color: #fca5a5; }
html.dark .compliance-section-title--medium { color: #fcd34d; }
.compliance-desc { font-size: 12px; color: var(--t3); margin: 5px 0 7px; }

/* ────────────────────────────────────────────────────────────────
   36. Renewal Workflow / Kanban
   ──────────────────────────────────────────────────────────────── */
.rw-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
@media (max-width: 1200px) { .rw-board { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .rw-board { grid-template-columns: 1fr 1fr; } }
.rw-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); min-height: 120px; overflow: hidden; }
.rw-col-header { padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--t2); text-transform: uppercase; letter-spacing: 0.4px; }
.rw-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; margin: 8px; box-shadow: var(--sh-xs); transition: box-shadow 0.15s; }
.rw-card:hover { box-shadow: var(--sh-sm); }
.rw-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.rw-card-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* ────────────────────────────────────────────────────────────────
   37. Analytics
   ──────────────────────────────────────────────────────────────── */
.analytics-kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 1200px) { .analytics-kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .analytics-kpi-row { grid-template-columns: repeat(2, 1fr); } }

.analytics-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .analytics-grid-2 { grid-template-columns: 1fr; } }

.analytics-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .analytics-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  { .analytics-grid-3 { grid-template-columns: 1fr; } }

.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--sh-sm); }
.chart-title { font-size: 12px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--t3); font-size: 13px; text-align: center; padding: 28px 0; }

.analytics-period-bar { display: flex; gap: 8px; margin-bottom: 22px; align-items: center; flex-wrap: wrap; }
.analytics-period-bar .filter-tab { padding: 6px 16px; font-size: 13px; }

/* ────────────────────────────────────────────────────────────────
   38. Mobile responsive nav
   ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .tnav-hamburger { display: inline-flex; }

    .tnav {
        display: none;
        position: fixed;
        top: var(--nav-h);
        left: 0; right: 0;
        background: var(--nav-bg);
        border-bottom: 1px solid var(--nav-border);
        flex-direction: column;
        padding: 8px 12px 16px;
        gap: 2px;
        z-index: 999;
        box-shadow: var(--sh-lg);
        max-height: calc(100vh - var(--nav-h));
        overflow-y: auto;
    }

    .tnav.open { display: flex; }

    .tnav-drop { width: 100%; }

    .tnav-menu {
        position: static;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        display: none;
        padding-left: 12px;
    }

    .tnav-drop.open .tnav-menu { display: block; }

    .tnav-menu-inner {
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 0;
    }

    .tnav-link, .tnav-drop-btn { width: 100%; justify-content: flex-start; }
}

/* ────────────────────────────────────────────────────────────────
   39. Print
   ──────────────────────────────────────────────────────────────── */
@media print {
    .topnav, .quick-actions, .report-toolbar, .no-print { display: none !important; }
    .page-body { padding: 0; }
    body { font-size: 12px; color: #000; background: #fff; }
    .data-table { box-shadow: none; border: 1px solid #ccc; }
    .data-table th { background: #0f172a !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-summary { box-shadow: none; border: 1px solid #ccc; }
    .badge { border: 1px solid #ccc; }
    a { text-decoration: none; color: inherit; }
    .filter-tabs, .table-actions, .analytics-period-bar { display: none !important; }
    .analytics-grid-2, .analytics-grid-3 { grid-template-columns: 1fr 1fr; }
    .chart-card { break-inside: avoid; }
    html.dark body, html.dark * { background: #fff !important; color: #000 !important; border-color: #ccc !important; }
}

/* ────────────────────────────────────────────────────────────────
   40. Dashboard Charts & Enhanced Layout
   ──────────────────────────────────────────────────────────────── */
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.dash-grid-wide { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.dash-grid-wide-rev { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 24px; }

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--sh-sm);
}
.chart-card__title {
    font-size: 11px;
    font-weight: 700;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 4px;
}
.chart-card__subtitle {
    font-size: 12px;
    color: var(--t3);
    margin-bottom: 16px;
}
.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { padding: 32px; text-align: center; color: var(--t3); font-size: 13px; }

.stat-compare {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}
.stat-compare__val { font-size: 28px; font-weight: 700; color: var(--t1); line-height: 1; }
.stat-compare__tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
}
.stat-compare__tag--up   { background: rgba(34,197,94,.15); color: var(--success); }
.stat-compare__tag--down { background: rgba(239,68,68,.15);  color: var(--danger); }
.stat-compare__tag--flat { background: rgba(100,116,139,.15); color: var(--t2); }
.stat-compare__prev { font-size: 11px; color: var(--t3); }

.ar-aging-bar { display: flex; gap: 0; border-radius: 6px; overflow: hidden; height: 10px; margin: 12px 0 8px; }
.ar-aging-bar__seg { height: 100%; transition: width .4s ease; }
.ar-aging-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.ar-aging-legend__item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--t2); }
.ar-aging-legend__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.expiry-list { list-style: none; }
.expiry-list__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.expiry-list__item:last-child { border-bottom: none; }
.expiry-list__dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--warning);
}
.expiry-list__dot--urgent { background: var(--danger); }
.expiry-list__policy { font-size: 13px; font-weight: 600; color: var(--t1); }
.expiry-list__client { font-size: 11px; color: var(--t3); margin-top: 1px; }
.expiry-list__days  { margin-left: auto; font-size: 11px; font-weight: 700; white-space: nowrap; }
.expiry-list__days--urgent { color: var(--danger); }
.expiry-list__days--warn   { color: var(--warning); }

.kpi-mini { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.kpi-mini:last-child { border-bottom: none; padding-bottom: 0; }
.kpi-mini__icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-mini__icon svg { width: 18px; height: 18px; }
.kpi-mini__label { font-size: 11px; color: var(--t3); line-height: 1; margin-bottom: 3px; }
.kpi-mini__val   { font-size: 17px; font-weight: 700; color: var(--t1); line-height: 1; }

.producer-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; border-bottom: 1px solid var(--border);
}
.producer-row:last-child { border-bottom: none; }
.producer-row__avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-light); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.producer-row__name { font-size: 13px; font-weight: 500; color: var(--t1); }
.producer-row__bar-wrap { flex: 1; background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.producer-row__bar { height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s ease; }
.producer-row__val { font-size: 11px; color: var(--t2); white-space: nowrap; min-width: 50px; text-align: right; }

.dash-quick-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin-bottom: 24px;
}
.dash-quick-actions a { white-space: nowrap; }

@media (max-width: 1024px) {
    .dash-grid-3 { grid-template-columns: 1fr 1fr; }
    .dash-grid-wide, .dash-grid-wide-rev { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .dash-grid-3, .dash-grid-2, .dash-grid-wide, .dash-grid-wide-rev { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────────
   41. Site Footer
   ──────────────────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 14px 28px;
    margin-top: auto;
}
.site-footer__inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--t3);
}
.site-footer__brand {
    font-weight: 600;
    color: var(--t2);
    display: flex;
    align-items: center;
    gap: 5px;
}
.site-footer__divider { opacity: .4; }
.site-footer__powered strong { color: var(--accent); font-weight: 600; }
