:root {
    --wilcote-blue: #0a66c2;
    --wilcote-blue-dark: #084d94;
    --wilcote-blue-light: #e8f1fb;
    --surface: #ffffff;
    --surface-muted: #f4f7fb;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --radius: 0.75rem;
    --radius-lg: 1rem;
}

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

body {
    background: var(--surface-muted);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────── */
.portal-navbar {
    background: linear-gradient(135deg, var(--wilcote-blue) 0%, var(--wilcote-blue-dark) 100%);
    box-shadow: var(--shadow-md);
    padding: 0.65rem 0;
}

.portal-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-navbar .navbar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.portal-navbar .nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem !important;
    border-radius: 0.5rem;
    transition: background 0.15s, color 0.15s;
    margin: 0 0.1rem;
}

.portal-navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.portal-navbar .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.portal-navbar .dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    margin-top: 0.5rem;
}

.portal-navbar .dropdown-item {
    border-radius: 0.4rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
}

.portal-navbar .dropdown-item:hover,
.portal-navbar .dropdown-item.active {
    background: var(--wilcote-blue-light);
    color: var(--wilcote-blue);
}

.portal-navbar .badge {
    font-weight: 600;
    font-size: 0.7rem;
}

/* ── Main content ───────────────────────────────────────── */
.portal-main {
    padding: 2rem 0 3rem;
}

/* ── Page headers ───────────────────────────────────────── */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1,
.page-title {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-header-row h1 {
    margin-bottom: 0;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    transition: box-shadow 0.2s;
}

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

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

.card-body {
    padding: 1.25rem;
}

/* ── Stat cards (dashboard) ─────────────────────────────── */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none !important;
    display: block;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .card-body {
    padding: 1.35rem 1.5rem;
    position: relative;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
    margin-bottom: 0.35rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 0;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.2;
}

.stat-card-primary { background: linear-gradient(135deg, #0a66c2, #1a7fd4); color: #fff; }
.stat-card-success { background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.stat-card-warning { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; }
.stat-card-info    { background: linear-gradient(135deg, #0284c7, #38bdf8); color: #fff; }
.stat-card-secondary { background: linear-gradient(135deg, #475569, #64748b); color: #fff; }
.stat-card-danger  { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* ── Tables ─────────────────────────────────────────────── */
.table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.table thead th {
    background: var(--surface-muted);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table thead th a {
    color: var(--text-muted);
    text-decoration: none;
}

.table thead th a:hover {
    color: var(--wilcote-blue);
}

.table tbody td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
    border-color: var(--border);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(244, 247, 251, 0.6);
}

.table tbody tr:hover > * {
    background-color: var(--wilcote-blue-light) !important;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--wilcote-blue);
    border-color: var(--wilcote-blue);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--wilcote-blue-dark);
    border-color: var(--wilcote-blue-dark);
    box-shadow: 0 2px 8px rgba(10, 102, 194, 0.35);
}

.btn-outline-primary {
    color: var(--wilcote-blue);
    border-color: var(--wilcote-blue);
}

.btn-outline-primary:hover {
    background: var(--wilcote-blue);
    border-color: var(--wilcote-blue);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.35em 0.65em;
    border-radius: 0.35rem;
    letter-spacing: 0.02em;
}

/* ── Forms & filters ────────────────────────────────────── */
.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--wilcote-blue);
    box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.15);
}

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.filter-bar .form-label {
    margin-bottom: 0.25rem;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
}

.alert-secondary {
    background: var(--surface-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
    margin-bottom: 0;
    gap: 0.2rem;
}

.pagination .page-link {
    border-radius: 0.35rem;
    border-color: var(--border);
    color: var(--text);
    font-size: 0.8rem;
    padding: 0.3rem 0.55rem;
    line-height: 1.2;
    min-width: 2rem;
    text-align: center;
}

.pagination .page-item.active .page-link {
    background: var(--wilcote-blue);
    border-color: var(--wilcote-blue);
}

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    background: var(--surface-muted);
}

.portal-pagination {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.25rem;
}

/* ── Empty states ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
    display: block;
}

/* ── Login page ─────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a66c2 0%, #084d94 50%, #1e3a5f 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.login-card-header {
    background: linear-gradient(135deg, var(--wilcote-blue), var(--wilcote-blue-dark));
    color: #fff;
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.login-card-header .login-logo {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.login-card-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.login-card-body {
    padding: 2rem;
}

.login-card .form-control {
    padding: 0.65rem 1rem;
}

.login-card .btn-primary {
    padding: 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
}

/* ── Select2 overrides ──────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border) !important;
    border-radius: 0.5rem !important;
    min-height: 38px;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--wilcote-blue) !important;
    box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.15) !important;
}

/* ── Responsive tweaks ──────────────────────────────────── */
@media (max-width: 768px) {
    .portal-main {
        padding: 1.25rem 0 2rem;
    }

    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-card .stat-value {
        font-size: 1.6rem;
    }
}
