/* =========================================================================
   AAG Delivery — Design System
   ========================================================================= */

:root {
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50:  #f8fafc;

    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    #06b6d4;

    --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.05);
    --shadow:    0 1px 3px 0 rgb(15 23 42 / 0.08), 0 1px 2px -1px rgb(15 23 42 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
    --shadow-lg: 0 10px 25px -5px rgb(15 23 42 / 0.10), 0 8px 10px -6px rgb(15 23 42 / 0.08);
    --shadow-xl: 0 20px 40px -12px rgb(79 70 229 / 0.25);

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-w: 260px;
    --navbar-h:  64px;

    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
    font-family: var(--font-sans);
    color: var(--ink-900);
    background: var(--ink-50);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    letter-spacing: -0.011em;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.02em; color: var(--ink-900); }
.text-muted { color: var(--ink-500) !important; }

a { color: var(--brand-600); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-700); }

code { background: var(--ink-100); color: var(--ink-900); padding: 2px 6px; border-radius: 6px; font-size: .85em; }

/* ===== Top navbar ===== */
.app-navbar {
    height: var(--navbar-h);
    background: #ffffff;
    border-bottom: 1px solid var(--ink-200);
    position: sticky;
    top: 0;
    z-index: 1030;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.app-navbar .brand {
    display: flex; align-items: center; gap: .65rem;
    font-weight: 800; letter-spacing: -0.025em; font-size: 1.1rem;
    color: var(--ink-900);
}
.app-navbar .brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--brand-grad);
    display: grid; place-items: center;
    color: white; font-size: 1.05rem;
    box-shadow: var(--shadow-md);
}
.app-navbar .user-chip {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .6rem .35rem .85rem;
    border-radius: 999px;
    background: var(--ink-100);
    font-size: .85rem; color: var(--ink-700);
}
.app-navbar .user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-grad); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: .8rem;
}
.app-navbar .btn-logout {
    border: 1px solid var(--ink-200); background: #fff; color: var(--ink-700);
    border-radius: 10px; padding: .4rem .75rem; font-weight: 500;
    transition: all .15s;
}
.app-navbar .btn-logout:hover { background: var(--ink-100); color: var(--ink-900); border-color: var(--ink-300); }

.navbar-toggle {
    background: transparent; border: 1px solid var(--ink-200);
    border-radius: 10px; padding: .4rem .55rem; color: var(--ink-700);
    display: none;
}
.navbar-toggle:hover { background: var(--ink-100); }

/* ===== Sidebar ===== */
.app-shell { display: flex; min-height: calc(100vh - var(--navbar-h)); }
.app-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: #ffffff; border-right: 1px solid var(--ink-200);
    padding: 1.25rem .75rem;
    overflow-y: auto;
}
.app-sidebar .nav-section {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
    font-weight: 700; color: var(--ink-400);
    padding: .25rem .9rem; margin-top: 1rem; margin-bottom: .25rem;
}
.app-sidebar .nav-section:first-child { margin-top: 0; }
.app-sidebar .nav-item { display: block; }
.app-sidebar .nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .9rem; margin: .15rem 0;
    color: var(--ink-700); border-radius: var(--radius-sm);
    font-weight: 500; font-size: .93rem;
    transition: all .15s;
}
.app-sidebar .nav-link i {
    font-size: 1.1rem; color: var(--ink-400);
    transition: color .15s;
    width: 20px; text-align: center;
}
.app-sidebar .nav-link:hover { background: var(--ink-100); color: var(--ink-900); }
.app-sidebar .nav-link:hover i { color: var(--brand-600); }
.app-sidebar .nav-link.active {
    background: var(--brand-grad); color: #fff;
    box-shadow: var(--shadow-md);
}
.app-sidebar .nav-link.active i { color: #fff; }

/* ===== Main content ===== */
.app-main {
    flex: 1; min-width: 0;
    padding: 1.75rem 2rem;
}
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.65rem; margin: 0; line-height: 1.2; }
.page-header .subtitle { color: var(--ink-500); font-size: .92rem; margin-top: .25rem; }

/* ===== Cards ===== */
.card {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}
.card-body { padding: 1.25rem 1.4rem; }

/* ===== Stat cards ===== */
.stat-card {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    background: #fff;
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.15rem; color: #fff;
    flex-shrink: 0;
}
.stat-card .stat-label {
    font-size: .72rem; color: var(--ink-500);
    text-transform: uppercase; font-weight: 700; letter-spacing: .08em;
    margin-bottom: .3rem;
}
.stat-card .stat-value {
    font-size: 1.65rem; font-weight: 800; color: var(--ink-900);
    line-height: 1.1; letter-spacing: -0.025em;
}
.stat-card .stat-sub { font-size: .78rem; color: var(--ink-500); margin-top: .3rem; }

.stat-card.has-accent::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: var(--brand-grad);
}

/* Accent variants */
.bg-soft-primary { background: var(--brand-50); color: var(--brand-600); }
.bg-soft-success { background: #d1fae5; color: #047857; }
.bg-soft-warning { background: #fef3c7; color: #b45309; }
.bg-soft-danger  { background: #fee2e2; color: #b91c1c; }
.bg-soft-info    { background: #cffafe; color: #0e7490; }
.bg-soft-violet  { background: #ede9fe; color: #6d28d9; }

.bg-grad-primary { background: var(--brand-grad); color: #fff; }
.bg-grad-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.bg-grad-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.bg-grad-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.bg-grad-info    { background: linear-gradient(135deg, #06b6d4, #0891b2); color: #fff; }
.bg-grad-violet  { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; }

/* ===== Tables ===== */
.table-responsive { border-radius: var(--radius); overflow: auto; -webkit-overflow-scrolling: touch; }
.table {
    --bs-table-bg: transparent;
    color: var(--ink-900); margin: 0;
}
.table thead th {
    border-bottom: 1px solid var(--ink-200) !important;
    background: var(--ink-50);
    color: var(--ink-500); text-transform: uppercase;
    font-size: .72rem; letter-spacing: .08em; font-weight: 700;
    padding: .65rem .85rem;
    white-space: nowrap;
}
.table tbody td { padding: .7rem .85rem; border-top: 1px solid var(--ink-100); font-size: .9rem; }
.table tbody tr:hover { background: var(--ink-50); }
.table-sm thead th { padding: .55rem .7rem; }
.table-sm tbody td { padding: .55rem .7rem; font-size: .87rem; }

/* Sticky head */
.table-sticky thead th { position: sticky; top: 0; z-index: 2; }

/* ===== Buttons ===== */
.btn {
    font-weight: 500; border-radius: 10px; padding: .5rem 1rem;
    transition: all .15s; box-shadow: none;
}
.btn-sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: .7rem 1.25rem; font-size: 1rem; border-radius: 12px; }

.btn-primary {
    background: var(--brand-grad); border: none; color: #fff;
    box-shadow: 0 2px 4px -1px rgb(79 70 229 / 0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 15px -4px rgb(79 70 229 / 0.5); background: var(--brand-grad); }
.btn-primary:focus { box-shadow: 0 0 0 4px rgb(79 70 229 / 0.2); }

.btn-outline-primary { border: 1px solid var(--ink-200); color: var(--ink-700); background: #fff; }
.btn-outline-primary:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }

.btn-outline-secondary { border: 1px solid var(--ink-200); color: var(--ink-700); background: #fff; }
.btn-outline-secondary:hover { background: var(--ink-100); color: var(--ink-900); }

.btn-outline-warning { border: 1px solid #fde68a; color: #b45309; background: #fffbeb; }
.btn-outline-warning:hover { background: #fef3c7; color: #92400e; }

/* ===== Forms ===== */
.form-control, .form-select {
    border: 1px solid var(--ink-200); border-radius: 10px;
    padding: .55rem .85rem; font-size: .92rem;
    background: #fff; color: var(--ink-900);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgb(99 102 241 / 0.15);
}
.form-control-sm, .form-select-sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
.form-label { font-weight: 600; color: var(--ink-700); font-size: .87rem; margin-bottom: .35rem; }

/* ===== Badges ===== */
.badge {
    font-weight: 600; padding: .3rem .55rem; border-radius: 6px;
    font-size: .72rem; letter-spacing: .02em;
}
.badge.bg-success { background: var(--success) !important; }
.badge.bg-warning { background: var(--warning) !important; color: #fff; }
.badge.bg-danger  { background: var(--danger) !important; }
.badge.bg-info    { background: var(--info) !important; }
.badge.bg-secondary { background: var(--ink-100) !important; color: var(--ink-700); }

/* ===== Alerts ===== */
.alert {
    border: 1px solid transparent; border-radius: var(--radius);
    padding: .85rem 1rem; font-size: .92rem;
}
.alert-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.alert-info    { background: #cffafe; border-color: #67e8f9; color: #155e75; }

/* ===== Login screen ===== */
.auth-shell {
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #db2777 100%);
    display: grid; place-items: center;
    padding: 1.5rem; position: relative; overflow: hidden;
}
.auth-shell::before, .auth-shell::after {
    content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .4;
}
.auth-shell::before { width: 480px; height: 480px; background: #fbbf24; top: -200px; left: -150px; }
.auth-shell::after  { width: 520px; height: 520px; background: #06b6d4; bottom: -240px; right: -180px; }

.auth-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: rgb(255 255 255 / 0.95); backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: 0 30px 60px -12px rgb(0 0 0 / 0.4);
    padding: 2.5rem;
}
.auth-card .auth-brand {
    display: flex; align-items: center; justify-content: center; gap: .7rem;
    margin-bottom: .75rem;
}
.auth-card .auth-brand .brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--brand-grad); color: #fff;
    display: grid; place-items: center; font-size: 1.2rem;
    box-shadow: 0 10px 25px -8px rgb(79 70 229 / 0.5);
}
.auth-card .auth-title {
    font-size: 1.5rem; font-weight: 800; letter-spacing: -0.025em;
}
.auth-card .auth-subtitle {
    text-align: center; color: var(--ink-500);
    font-size: .92rem; margin-bottom: 1.75rem;
}
.auth-card .btn-primary { width: 100%; padding: .75rem; font-size: 1rem; }

/* ===== Modals ===== */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--ink-200); padding: 1rem 1.25rem; }
.modal-body   { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--ink-200); padding: 1rem 1.25rem; }

/* ===== Utility ===== */
.text-success-strong { color: var(--success); font-weight: 700; }
.text-danger-strong  { color: var(--danger); font-weight: 700; }

/* ===== Mobile ===== */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed; top: var(--navbar-h); left: 0; bottom: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar.open { transform: translateX(0); }
    .navbar-toggle { display: inline-flex; align-items: center; }
    .app-main { padding: 1.25rem 1rem; }
    .sidebar-overlay {
        position: fixed; top: var(--navbar-h); left: 0; right: 0; bottom: 0;
        background: rgb(15 23 42 / 0.4); backdrop-filter: blur(2px);
        z-index: 1035;
        opacity: 0; pointer-events: none;
        transition: opacity .2s;
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
}

@media (max-width: 575.98px) {
    :root { --navbar-h: 56px; }
    .app-navbar { padding: 0 .85rem; }
    .app-navbar .brand { font-size: 1rem; }
    .app-navbar .brand-mark { width: 32px; height: 32px; }
    .app-navbar .user-chip .full-name { display: none; }
    .app-navbar .user-chip { padding: .25rem .25rem; gap: 0; }
    .app-main { padding: 1rem .75rem; }
    .page-header h1 { font-size: 1.3rem; }
    .stat-card { padding: .9rem 1rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .auth-card { padding: 1.75rem 1.5rem; }
}

/* Hide scrollbar on sidebar (nice-to-have) */
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }

/* Chart canvas spacing */
canvas { display: block !important; }

/* =========================================================================
   Rich dashboard components
   ========================================================================= */

/* ===== Hero banner ===== */
.hero-banner {
    position: relative;
    border-radius: var(--radius-xl);
    padding: 1.75rem 2rem;
    background: var(--brand-grad);
    color: #fff;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}
.hero-banner::before {
    content: ""; position: absolute; right: -80px; top: -80px;
    width: 280px; height: 280px; border-radius: 50%;
    background: rgb(255 255 255 / 0.1);
}
.hero-banner::after {
    content: ""; position: absolute; right: 80px; bottom: -100px;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgb(255 255 255 / 0.08);
}
.hero-banner > * { position: relative; z-index: 1; }
.hero-banner .hero-eyebrow { opacity: .85; font-size: .85rem; font-weight: 500; }
.hero-banner h1 { color: #fff; font-size: 2rem; margin: .25rem 0 .35rem; }
.hero-banner .hero-meta { opacity: .9; font-size: .95rem; }
.hero-avatar {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgb(255 255 255 / 0.25);
    backdrop-filter: blur(10px);
    display: grid; place-items: center;
    font-size: 1.5rem; font-weight: 800; color: #fff;
    border: 2px solid rgb(255 255 255 / 0.4);
}
.hero-status {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgb(255 255 255 / 0.18); color: #fff;
    padding: .3rem .65rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; backdrop-filter: blur(8px);
}

/* ===== Big metric pill (delta vs benchmark) ===== */
.metric-pill {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .15rem .5rem; border-radius: 6px;
    font-size: .72rem; font-weight: 600;
}
.metric-pill.up   { background: #d1fae5; color: #047857; }
.metric-pill.down { background: #fee2e2; color: #b91c1c; }
.metric-pill.flat { background: var(--ink-100); color: var(--ink-500); }

/* ===== Calendar heatmap (GitHub-style) ===== */
.heatmap {
    display: grid;
    grid-template-columns: 38px repeat(7, 1fr);
    gap: 6px;
    align-items: center;
}
.heatmap-head, .heatmap-row-label {
    font-size: .68rem; color: var(--ink-400); font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
}
.heatmap-head { text-align: center; padding-bottom: .25rem; }
.heatmap-row-label { text-align: right; padding-right: .5rem; }
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: var(--ink-100);
    position: relative;
    cursor: default;
    transition: transform .15s ease, box-shadow .15s ease;
    display: grid; place-items: center;
}
.heatmap-cell:not(.empty):hover {
    transform: scale(1.15); z-index: 5;
    box-shadow: var(--shadow-md);
}
.heatmap-cell.empty { background: transparent; }
.heatmap-cell .day-num {
    font-size: .7rem; font-weight: 600; color: var(--ink-400);
    pointer-events: none;
}
.heatmap-cell.level-1 { background: #c7f0d8; }
.heatmap-cell.level-2 { background: #86efac; }
.heatmap-cell.level-2 .day-num { color: #065f46; }
.heatmap-cell.level-3 { background: #34d399; }
.heatmap-cell.level-3 .day-num { color: #fff; }
.heatmap-cell.level-4 { background: #059669; }
.heatmap-cell.level-4 .day-num { color: #fff; }
.heatmap-cell.off { background: #fde68a; }
.heatmap-cell.off .day-num { color: #92400e; }
.heatmap-legend {
    display: flex; align-items: center; gap: .35rem;
    font-size: .72rem; color: var(--ink-500);
}
.heatmap-legend .sq {
    width: 14px; height: 14px; border-radius: 3px; display: inline-block;
}

/* ===== Driver activity card (grid view of daily.php) ===== */
.driver-card {
    border: 1px solid var(--ink-200);
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s, box-shadow .15s, border-color .15s;
    position: relative;
}
.driver-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-200);
}
.driver-card .dc-head {
    display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem;
}
.driver-card .dc-avatar {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--brand-grad); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.driver-card .dc-name { font-weight: 600; font-size: .92rem; color: var(--ink-900); }
.driver-card .dc-sub  { font-size: .76rem; color: var(--ink-500); }
.driver-card .dc-big {
    font-size: 1.55rem; font-weight: 800; line-height: 1; letter-spacing: -0.025em;
    color: var(--ink-900); margin-bottom: .15rem;
}
.driver-card .dc-big-label {
    font-size: .68rem; color: var(--ink-500); text-transform: uppercase;
    letter-spacing: .08em; font-weight: 700;
}
.driver-card .dc-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
    margin-top: .85rem; padding-top: .75rem;
    border-top: 1px solid var(--ink-100);
}
.driver-card .dc-stat { text-align: center; }
.driver-card .dc-stat-value { font-weight: 700; font-size: .9rem; color: var(--ink-900); }
.driver-card .dc-stat-label { font-size: .65rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .06em; }
.driver-card .dc-flag {
    position: absolute; top: 10px; right: 10px;
    font-size: .65rem; padding: .2rem .45rem;
    border-radius: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}

/* ===== Date stepper ===== */
.date-stepper {
    display: inline-flex; align-items: center;
    background: #fff; border: 1px solid var(--ink-200);
    border-radius: 10px; overflow: hidden;
}
.date-stepper .step-btn {
    background: #fff; border: none; padding: .45rem .7rem;
    color: var(--ink-700);
    transition: background .15s;
}
.date-stepper .step-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.date-stepper input[type="date"] {
    border: none; padding: .45rem .65rem; font-weight: 500;
    color: var(--ink-900); background: #fff;
}
.date-stepper input[type="date"]:focus { outline: none; }

/* ===== Score ring ===== */
.score-ring-wrap {
    position: relative; width: 160px; height: 160px;
    margin: 0 auto;
}
.score-ring-value {
    position: absolute; inset: 0; display: grid; place-items: center;
    pointer-events: none;
}
.score-ring-value .big { font-size: 2.25rem; font-weight: 800; line-height: 1; color: var(--ink-900); letter-spacing: -0.03em; }
.score-ring-value .lbl { font-size: .68rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-top: .15rem; }

/* ===== View toggle ===== */
.view-toggle {
    display: inline-flex; background: var(--ink-100); border-radius: 10px; padding: 3px;
}
.view-toggle .vt-btn {
    border: none; background: transparent; padding: .35rem .85rem;
    font-size: .82rem; font-weight: 600; color: var(--ink-500);
    border-radius: 8px; transition: all .15s;
}
.view-toggle .vt-btn.active { background: #fff; color: var(--ink-900); box-shadow: var(--shadow-sm); }

/* ===== Insight tile (best day / worst day callouts) ===== */
.insight-tile {
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    border: 1px solid var(--ink-200);
    background: #fff;
    position: relative;
}
.insight-tile .it-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center; color: #fff;
    margin-bottom: .65rem;
}
.insight-tile .it-label {
    font-size: .68rem; color: var(--ink-500); text-transform: uppercase;
    letter-spacing: .08em; font-weight: 700;
}
.insight-tile .it-value { font-size: 1.15rem; font-weight: 700; color: var(--ink-900); }
.insight-tile .it-sub { font-size: .8rem; color: var(--ink-500); }

/* ===== Performance tier dot ===== */
.tier-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
    margin-right: .35rem;
}
.tier-dot.tier-top { background: #10b981; box-shadow: 0 0 0 3px #10b98133; }
.tier-dot.tier-mid { background: #f59e0b; box-shadow: 0 0 0 3px #f59e0b33; }
.tier-dot.tier-low { background: #ef4444; box-shadow: 0 0 0 3px #ef444433; }

/* ===== Sparkline mini-chart ===== */
.sparkline { width: 100%; height: 38px; }

@media (max-width: 575.98px) {
    .hero-banner { padding: 1.25rem 1.3rem; }
    .hero-banner h1 { font-size: 1.5rem; }
    .heatmap { grid-template-columns: 30px repeat(7, 1fr); gap: 4px; }
    .heatmap-cell .day-num { font-size: .58rem; }
}

/* =========================================================================
   Target / progress components
   ========================================================================= */

.target-bar {
    height: 14px; border-radius: 99px;
    background: var(--ink-100);
    overflow: hidden; position: relative;
}
.target-bar .fill {
    position: relative; height: 100%; border-radius: 99px;
    transition: width 1s cubic-bezier(.22,.61,.36,1);
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: .5rem; color: #fff;
    font-size: .65rem; font-weight: 700; letter-spacing: .04em;
    min-width: 0;
}
.target-bar .fill::after {
    content: ""; position: absolute; inset: 0; border-radius: 99px;
    background: linear-gradient(90deg, rgb(255 255 255 / 0) 0%, rgb(255 255 255 / 0.25) 50%, rgb(255 255 255 / 0) 100%);
    animation: shine 2.5s infinite;
}
@keyframes shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.target-bar .fill.ahead    { background: linear-gradient(90deg, #10b981, #059669); }
.target-bar .fill.on_track { background: linear-gradient(90deg, #6366f1, #4f46e5); }
.target-bar .fill.behind   { background: linear-gradient(90deg, #f59e0b, #d97706); }
.target-bar .fill.critical { background: linear-gradient(90deg, #ef4444, #dc2626); }
.target-bar .fill.no_data  { background: linear-gradient(90deg, #cbd5e1, #94a3b8); }

.target-row {
    display: grid;
    grid-template-columns: 110px 1fr 110px;
    align-items: center;
    gap: .85rem;
    padding: .65rem 0;
}
.target-row .t-label { font-weight: 600; color: var(--ink-700); font-size: .92rem; }
.target-row .t-value { text-align: right; font-weight: 700; color: var(--ink-900); font-size: .95rem; }
.target-row .t-value .target-num { color: var(--ink-500); font-weight: 500; font-size: .8rem; }

.status-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .65rem; border-radius: 999px;
    font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.status-chip.ahead    { background: #d1fae5; color: #047857; }
.status-chip.on_track { background: var(--brand-50); color: var(--brand-700); }
.status-chip.behind   { background: #fef3c7; color: #b45309; }
.status-chip.critical { background: #fee2e2; color: #b91c1c; }
.status-chip.no_data  { background: var(--ink-100); color: var(--ink-500); }

/* ===== Target modal ===== */
.target-modal .modal-content {
    border-radius: var(--radius-xl);
    overflow: hidden; border: none;
    box-shadow: 0 30px 60px -12px rgb(15 23 42 / 0.35);
}
.target-modal .modal-header {
    background: var(--brand-grad); color: #fff;
    border-bottom: none; padding: 1.5rem 1.75rem;
}
.target-modal .modal-header h5 { color: #fff; font-size: 1.25rem; margin: 0; }
.target-modal .modal-header .eyebrow {
    font-size: .78rem; font-weight: 600; opacity: .85;
    text-transform: uppercase; letter-spacing: .08em;
}
.target-modal .modal-header .btn-close { filter: brightness(0) invert(1); }
.target-modal .modal-body { padding: 1.5rem 1.75rem; }
.target-modal .modal-footer { border-top: 1px solid var(--ink-200); padding: 1rem 1.75rem; }

.target-banner {
    background: var(--brand-grad);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1rem;
    text-align: center;
}
.target-banner .big {
    font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
}
.target-banner .sub { font-size: .9rem; opacity: .9; margin-top: .25rem; }

.bucket-tile {
    border-radius: var(--radius);
    padding: .85rem 1rem;
    background: #fff; border: 1px solid var(--ink-200);
    text-align: center;
}
.bucket-tile .bt-count { font-size: 1.85rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.bucket-tile .bt-label { font-size: .72rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-top: .35rem; }
.bucket-tile.ahead    .bt-count { color: #10b981; }
.bucket-tile.on_track .bt-count { color: #4f46e5; }
.bucket-tile.behind   .bt-count { color: #f59e0b; }
.bucket-tile.critical .bt-count { color: #ef4444; }
.bucket-tile.no_data  .bt-count { color: #94a3b8; }

@media (max-width: 575.98px) {
    .target-row { grid-template-columns: 84px 1fr 90px; gap: .5rem; }
    .target-banner .big { font-size: 2rem; }
}

/* =========================================================================
   Salary tier components
   ========================================================================= */

.tier-badge {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .35rem .85rem; border-radius: 999px;
    font-weight: 700; font-size: .85rem;
    color: #fff; letter-spacing: .02em;
    white-space: nowrap;
}
.tier-badge.tier-A { background: linear-gradient(135deg, #10b981, #059669); }
.tier-badge.tier-B { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.tier-badge.tier-C { background: linear-gradient(135deg, #f59e0b, #d97706); }
.tier-badge.tier-D { background: linear-gradient(135deg, #ef4444, #dc2626); }

.salary-banner {
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #4f46e5 100%);
    color: #fff;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.salary-banner::before {
    content: ""; position: absolute; right: -60px; top: -60px;
    width: 220px; height: 220px; border-radius: 50%;
    background: rgb(255 255 255 / 0.06);
}
.salary-banner > * { position: relative; z-index: 1; }
.salary-banner .sb-label {
    font-size: .75rem; text-transform: uppercase;
    letter-spacing: .08em; opacity: .85; font-weight: 600;
}
.salary-banner .sb-amount {
    font-size: 2.75rem; font-weight: 800; line-height: 1;
    letter-spacing: -0.03em; margin: .3rem 0;
}
.salary-banner .sb-currency {
    font-size: 1.2rem; opacity: .8; font-weight: 600; margin-right: .25rem;
}
.salary-banner .sb-formula {
    font-size: .82rem; opacity: .9; margin-top: .35rem;
    font-family: 'Inter', sans-serif;
}
.salary-banner .sb-next {
    margin-top: 1rem; padding: .65rem .9rem;
    background: rgb(255 255 255 / 0.1);
    border-radius: 10px; backdrop-filter: blur(8px);
    display: flex; align-items: center; gap: .6rem;
    font-size: .88rem;
}

/* ===== Salary tier bar with markers ===== */
.tier-bar-wrap {
    padding: 1.25rem 0 1.85rem;
    position: relative;
}
.tier-bar {
    height: 22px;
    background: var(--ink-100);
    border-radius: 999px;
    position: relative;
    overflow: visible;
}
.tier-bar .tb-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 20%, #6366f1 55%, #10b981 95%);
    transition: width 1.1s cubic-bezier(.22,.61,.36,1);
    position: relative;
    z-index: 1;
}
.tier-bar .tb-marker {
    position: absolute;
    top: -6px; bottom: -6px;
    width: 3px;
    background: #fff;
    border-radius: 1.5px;
    box-shadow: 0 0 0 1.5px rgb(15 23 42 / 0.15);
    z-index: 3;
}
.tier-bar .tb-marker .tb-flag {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink-900);
    color: #fff;
    padding: .15rem .5rem;
    border-radius: 6px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}
.tier-bar .tb-marker .tb-flag::after {
    content: ""; position: absolute; bottom: -4px; left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--ink-900);
}
.tier-bar .tb-marker .tb-count {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: .7rem;
    font-weight: 700;
    color: var(--ink-500);
}
.tier-bar .tb-current {
    position: absolute;
    top: -10px; bottom: -10px;
    width: 4px;
    background: var(--ink-900);
    border-radius: 2px;
    z-index: 4;
    box-shadow: 0 0 0 3px rgb(255 255 255 / 0.8);
}

/* ===== Tier comparison table ===== */
.tier-list { display: grid; gap: .5rem; }
.tier-list .tl-row {
    display: grid; grid-template-columns: auto 1fr auto;
    gap: .75rem; align-items: center;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ink-200);
    background: #fff;
    font-size: .9rem;
}
.tier-list .tl-row.active {
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--brand-500);
    background: var(--brand-50);
}
.tier-list .tl-rule { color: var(--ink-700); }
.tier-list .tl-pay  { font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }

@media (max-width: 575.98px) {
    .salary-banner { padding: 1.25rem 1.3rem; }
    .salary-banner .sb-amount { font-size: 2rem; }
    .tier-bar .tb-flag { font-size: .58rem; padding: .1rem .35rem; }
    .tier-list .tl-row { grid-template-columns: auto 1fr; }
    .tier-list .tl-row .tl-pay { grid-column: 1 / -1; text-align: right; }
}
