/* =============================================
   DPT Operations Dashboard — Design System
   Premium Enterprise Edition
   ============================================= */

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

/* ---------- CSS Variables ---------- */
:root {
    /* Colours — Premium Light */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f7f8fa;
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-hover: rgba(16, 185, 129, 0.05);

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    --border-color: rgba(0, 0, 0, 0.06);
    --border-focus: rgba(16, 185, 129, 0.5);

    /* Accent — Teal/Emerald for DPT (finance theme) */
    --accent-primary: #059669;
    --accent-primary-glow: rgba(5, 150, 105, 0.12);
    --accent-secondary: #0d9488;
    --accent-light: #10b981;

    /* Health colours */
    --health-green: #059669;
    --health-green-bg: rgba(5, 150, 105, 0.07);
    --health-green-border: rgba(5, 150, 105, 0.2);
    --health-amber: #d97706;
    --health-amber-bg: rgba(217, 119, 6, 0.07);
    --health-amber-border: rgba(217, 119, 6, 0.2);
    --health-red: #dc2626;
    --health-red-bg: rgba(220, 38, 38, 0.06);
    --health-red-border: rgba(220, 38, 38, 0.2);

    /* Tier colours */
    --tier-platinum: #6366f1;
    --tier-gold: #eab308;
    --tier-silver: #94a3b8;
    --tier-bronze: #d97706;

    /* Sidebar — Deep teal gradient */
    --sidebar-width: 256px;
    --sidebar-bg: #064e3b;
    --sidebar-text: #a7f3d0;
    --sidebar-text-muted: rgba(167, 243, 208, 0.5);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(16, 185, 129, 0.25);

    /* Spacing */
    --header-height: 60px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 4px 20px var(--accent-primary-glow);

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 350ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(195deg, #064e3b 0%, #065f46 50%, #064e3b 100%);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base);
    border-right: none;
}

.sidebar-brand {
    padding: 22px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #10b981, #14b8a6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: 14px;
    color: #d1fae5;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: 10px;
    color: var(--sidebar-text-muted);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* ---------- Sidebar Nav ---------- */
.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 26px;
}

.nav-section-title {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--sidebar-text-muted);
    padding: 0 14px;
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13px;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #d1fae5;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: #10b981;
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
}

.nav-item:hover .nav-icon { opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-badge {
    margin-left: auto;
    background: rgba(239, 68, 68, 0.8);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    text-decoration: none;
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #14b8a6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: white;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #d1fae5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--sidebar-text-muted); text-transform: capitalize; }

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-refresh:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* ---------- Page Content ---------- */
.page-content {
    padding: 16px 20px;
}

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

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    display: block;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.health-green::before { background: var(--health-green); }
.kpi-card.health-amber::before { background: var(--health-amber); }
.kpi-card.health-red::before { background: var(--health-red); }

.kpi-card.health-green { border-color: var(--health-green-border); background: linear-gradient(145deg, #ffffff, #f0fdf4); }
.kpi-card.health-amber { border-color: var(--health-amber-border); background: linear-gradient(145deg, #ffffff, #fefce8); }
.kpi-card.health-red { border-color: var(--health-red-border); background: linear-gradient(145deg, #ffffff, #fef2f2); }

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

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-card.health-green .kpi-icon { background: var(--health-green-bg); color: var(--health-green); }
.kpi-card.health-amber .kpi-icon { background: var(--health-amber-bg); color: var(--health-amber); }
.kpi-card.health-red .kpi-icon { background: var(--health-red-bg); color: var(--health-red); }

.kpi-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 3px;
    letter-spacing: -1px;
}

.kpi-card.health-green .kpi-value { color: var(--health-green); }
.kpi-card.health-amber .kpi-value { color: var(--health-amber); }
.kpi-card.health-red .kpi-value { color: var(--health-red); }

.kpi-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

/* ---------- Cards / Panels ---------- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

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

.card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.1px;
}

.card-body { padding: 12px 14px; }
.card-body.no-padding { padding: 0; }

/* ---------- Data Tables ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: 7px 12px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.data-table thead th:hover { color: var(--text-primary); }
.data-table thead th.sorted { color: var(--accent-primary); }

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.data-table tbody tr:nth-child(even) { background: var(--bg-tertiary); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody td {
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Row colouring */
.data-table tbody tr.row-red { background: var(--health-red-bg) !important; }
.data-table tbody tr.row-red:hover { background: rgba(239, 68, 68, 0.12) !important; }
.data-table tbody tr.row-amber { background: var(--health-amber-bg) !important; }
.data-table tbody tr.row-amber:hover { background: rgba(245, 158, 11, 0.12) !important; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green { background: var(--health-green-bg); color: var(--health-green); border: 1px solid var(--health-green-border); }
.badge-amber { background: var(--health-amber-bg); color: var(--health-amber); border: 1px solid var(--health-amber-border); }
.badge-red { background: var(--health-red-bg); color: var(--health-red); border: 1px solid var(--health-red-border); }
.badge-blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-gray { background: rgba(100, 116, 139, 0.1); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-teal { background: rgba(20, 184, 166, 0.1); color: #14b8a6; border: 1px solid rgba(20, 184, 166, 0.3); }

/* Tier badges */
.badge-platinum { background: rgba(99, 102, 241, 0.12); color: #6366f1; border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-gold { background: rgba(234, 179, 8, 0.12); color: #ca8a04; border: 1px solid rgba(234, 179, 8, 0.3); }
.badge-silver { background: rgba(148, 163, 184, 0.12); color: #64748b; border: 1px solid rgba(148, 163, 184, 0.3); }
.badge-bronze { background: rgba(217, 119, 6, 0.12); color: #d97706; border: 1px solid rgba(217, 119, 6, 0.3); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 2px 8px var(--accent-primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--health-red);
    border: 1px solid var(--health-red-border);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 12px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-input::placeholder { color: var(--text-muted); }

/* ---------- Filters Bar ---------- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}

.filter-group label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.filter-group select,
.filter-group input {
    padding: 7px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ---------- Charts ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.chart-container {
    position: relative;
    height: 280px;
    padding: 8px;
}

/* ---------- Stats Row ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.stat-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 8px;
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination a:hover { background: var(--bg-hover); color: var(--text-primary); }

.pagination .active {
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
}

/* ---------- Grid Layouts ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #064e3b 0%, #065f46 40%, #047857 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
    top: -200px;
    right: -150px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand .brand-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #059669, #0d9488);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: white;
    margin: 0 auto 14px;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.login-brand h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.login-brand p {
    font-size: 13px;
    color: var(--text-muted);
}

.login-card .form-group { margin-bottom: 18px; }

.login-card .btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    justify-content: center;
    margin-top: 4px;
}

/* ---------- Flash Messages ---------- */
.flash {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash-success { background: var(--health-green-bg); color: var(--health-green); border: 1px solid var(--health-green-border); }
.flash-error { background: var(--health-red-bg); color: var(--health-red); border: 1px solid var(--health-red-border); }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ---------- Error Page ---------- */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.error-content { text-align: center; }
.error-content h1 { font-size: 72px; font-weight: 800; color: var(--text-muted); margin: 16px 0 8px; }
.error-content p { color: var(--text-secondary); margin-bottom: 24px; }

/* ---------- Settings Sections ---------- */
.settings-section { margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .top-bar { padding: 0 16px; }
    .filters-bar { flex-direction: column; }
}
