:root {
    --primary: #002852;
    --primary-dark: #00163b;
    --primary-light: #2a4b6e;
    --accent: #ffcb2b;
    --accent-light: #ffda5c;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1a2332;
    --text-muted: #5a6b7e;
    --border: #d0d9e3;
    --success: #2d8a4e;
    --warning: #c77d0a;
    --danger: #b83232;
    --info: #2b6cb0;
    --nav-bg: #002852;
    --nav-text: #ffffff;
    --hero-gradient: linear-gradient(135deg, #002852 0%, #2a4b6e 50%, #00163b 100%);
    --card-shadow: 0 2px 8px rgba(0,40,82,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ===== NAV ===== */
.topnav {
    background: var(--nav-bg);
    height: 62px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--nav-text);
    flex-shrink: 0;
    margin-right: 1rem;
}

.topnav-brand img { height: 42px; width: auto; }
.topnav-brand .brand-text { font-size: 1rem; font-weight: 800; letter-spacing: 0.3px; }

/* Desktop menu items */
.topnav-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    /* overflow-x would clip dropdown panels */
}

/* Dropdown trigger */
.nav-item {
    position: relative;
}

.nav-item > a, .topnav-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.4rem 0.7rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav-item > a:hover, .topnav-link:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-item > a.active, .topnav-link.active {
    background: rgba(255,255,255,0.15);
    color: var(--accent);
}
.topnav-link.active[style*="accent"] {
    filter: brightness(0.9);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* CVAS Portal button — dimmed when on other pages, bright when active */
.topnav-link.portal-btn {
    background: #e6b522;
    color: #002852;
    border-radius: 6px;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    transition: background 0.15s, filter 0.15s;
}
.topnav-link.portal-btn:hover {
    background: #ffcb2b;
    filter: brightness(1.05);
}
.topnav-link.portal-btn.active {
    background: #ffda5c;
    color: #001d3d;
    box-shadow: 0 0 8px rgba(255,203,43,0.5), inset 0 1px 2px rgba(0,0,0,0.15);
}

.nav-item > a .fa-chevron-down { font-size: 0.55rem; opacity: 0.6; margin-left: 1px; }

/* Dropdown panel — JS-driven only, no :hover */
.dropdown-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--primary-dark);
    border-radius: 0 0 8px 8px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 0.35rem 0;
    z-index: 10001;
}

.nav-item.open .dropdown-panel {
    display: block;
}

.dropdown-panel a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.dropdown-panel a:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent);
    color: #fff;
}

.dropdown-panel a.active {
    background: rgba(255,203,43,0.15);
    border-left-color: var(--accent);
    color: var(--accent);
}

.dropdown-panel a i { width: 18px; text-align: center; font-size: 0.85rem; }
.dropdown-section-title {
    display: block;
    padding: 0.35rem 0.85rem 0.15rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent);
    border-top: 1px solid rgba(255,255,255,0.12);
    margin-top: 0.15rem;
}
.dropdown-panel a + .dropdown-section-title { border-top: 1px solid rgba(255,255,255,0.15); margin-top: 0.25rem; padding-top: 0.4rem; }

/* Right section */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: 10002;
}

.topnav-right .topnav-link {
    font-size: 0.86rem;
    opacity: 0.75;
}
.topnav-right .topnav-link:hover { opacity: 1; }

/* ADMIN dropdown in right nav */
.topnav-right .nav-item.open .dropdown-panel {
    display: block;
}

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--nav-text);
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    margin-left: 0.5rem;
}

/* ===== MOBILE DRAWER ===== */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.25s;
}
.drawer-overlay.active { display: block; opacity: 1; }

.drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background: var(--primary-dark);
    z-index: 10003;
    overflow-y: auto;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}
.drawer.open { right: 0; }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.drawer-header img { height: 38px; }
.drawer-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.drawer-close:hover { color: #fff; }

.drawer-section {
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.drawer-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    user-select: none;
}

.drawer-section-header .fa-chevron-down {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.drawer-section.collapsed .drawer-section-header .fa-chevron-down {
    transform: rotate(-90deg);
}

.drawer-section.collapsed .drawer-links {
    display: none;
}

.drawer-links a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem 0.55rem 1.25rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s;
}

.drawer-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.drawer-links a.active { color: var(--accent); background: rgba(255,203,43,0.1); }
.drawer-links a i { width: 18px; text-align: center; font-size: 0.85rem; }

.drawer-footer {
    margin-top: auto;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.drawer-footer a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.82rem;
}
.drawer-footer a:hover { color: rgba(255,255,255,0.9); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .topnav-menu { display: none; }
    .topnav-right .topnav-link:not(.topnav-logout):not(.admin-trigger) { display: none; }
    .topnav-right .nav-item { display: none; }
    .hamburger { display: block; }
}

@media (min-width: 1025px) {
    .drawer-overlay, .drawer { display: none !important; }
}

/* ===== GENERAL STYLES (below nav) ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Hero */
.hero {
    background: var(--hero-gradient);
    color: white;
    padding: 2rem 2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.hero h2 { font-size: 1.8rem; margin-bottom: 0.25rem; }
.hero p { opacity: 0.9; font-size: 1.05rem; }
.hero .subtitle { font-size: 0.95rem; opacity: 0.75; margin-top: 0.25rem; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    border-left: 4px solid #ffcb2b;
}

.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Cards */
.form-container {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 800px;
}
.card {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--primary-dark); }
.card-body { padding: 1.25rem; }

/* Tables */
.table-responsive { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

table th {
    background: #002852;
    color: #ffcb2b;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
table tr:hover { background: rgba(255,203,43,0.06); }

/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.3px; }
.badge-donated { background: #e6f9ee; color: #1a7a3a; }
.badge-rented { background: #e8f0fe; color: #1a5fa0; }
.badge-purchased { background: #fef3e6; color: #a0600a; }
.badge-pending { background: #fff5d6; color: #8a6d00; }
.badge-confirmed { background: #e6f9ee; color: #1a7a3a; }
.badge-delivered { background: #e0f2e9; color: #0d6b3a; }
.badge-returned { background: #e8ecf0; color: #5a6b7e; }
.badge-cancelled { background: #fde8e8; color: #b83232; }
.badge-unpaid { background: #fde8e8; color: #b83232; }
.badge-partial { background: #fef3e6; color: #a0600a; }
.badge-paid { background: #e6f9ee; color: #1a7a3a; }
.badge-cash { background: #e8f0fe; color: #1a5fa0; }
.badge-trade { background: #f3e8fe; color: #6b21a8; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem; border-radius: 8px; font-size: 0.88rem;
    font-weight: 600; text-decoration: none; border: none; cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: #ffcb2b; color: #002852; }
.btn-primary:hover { background: #ffda5c; color: #002852; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #992626; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-group.full-width { grid-column: 1 / -1; }

label { font-size: 0.85rem; font-weight: 600; color: var(--text); }

input, select, textarea {
    padding: 0.55rem 0.75rem; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; font-family: inherit;
    background: var(--surface); color: var(--text); transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none; border-color: #ffcb2b;
    box-shadow: 0 0 0 3px rgba(255,203,43,0.2);
}

textarea { min-height: 80px; resize: vertical; }

/* Filters */
.filters {
    display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center;
    margin-bottom: 1.25rem; padding: 1rem; background: var(--surface);
    border-radius: 10px; box-shadow: var(--card-shadow);
}
.filters select, .filters input { min-width: 150px; }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

.detail-section {
    background: var(--surface); border-radius: 10px;
    box-shadow: var(--card-shadow); padding: 1.25rem;
}

.detail-section h3 {
    font-size: 1rem; font-weight: 700; color: var(--primary-dark);
    margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border);
}

.detail-row { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.detail-value { font-weight: 500; text-align: right; }

/* Flash messages */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; font-weight: 500; }
.flash-success { background: #e6f9ee; color: #1a7a3a; border: 1px solid #b8e6cc; }
.flash-info { background: #e8f0fe; color: #1a5fa0; border: 1px solid #b8d0f0; }
.flash-error { background: #fde8e8; color: #b83232; border: 1px solid #f0b8b8; }

/* Actions row */
.actions { display: flex; gap: 0.5rem; align-items: center; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text); }

/* Value highlight */
.value-cash { color: var(--success); font-weight: 700; }
.value-trade { color: #6b21a8; font-weight: 700; }

/* Mobile responsive */
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .topnav { padding: 0 0.75rem; }
    .hero { padding: 1.25rem; }
    .hero h2 { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .filters { flex-direction: column; }
    .filters select, .filters input { min-width: 0; width: 100%; }
    .filters form { flex-direction: column; width: 100%; }
    table th, table td { padding: 0.5rem 0.5rem; font-size: 0.82rem; }
    .actions { flex-wrap: wrap; }
    .container { padding: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .hero h2 { font-size: 1.2rem; }
    .topnav-brand .brand-text { display: none; }
}

/* Pagination */
.pagination { gap: 3px; flex-wrap: wrap; list-style: none !important; padding-left: 0 !important; margin: 0; }
.pagination .page-item { list-style: none !important; display: inline-block; }
.pagination .page-item .page-link {
    border: 1px solid #dee2e6;
    border-radius: 6px !important;
    color: #495057;
    font-size: 0.82rem;
    font-weight: 500;
    min-width: 34px;
    padding: 5px 10px;
    text-align: center;
    transition: all 0.15s ease;
    margin: 0 1px;
}
.pagination .page-item .page-link:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #212529;
}
.pagination .page-item.active .page-link {
    background: #002852;
    border-color: #002852;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,40,82,0.25);
}
.pagination .page-item.disabled .page-link {
    color: #adb5bd;
    background: transparent;
    border-color: #dee2e6;
}
.pagination .page-item:not(.active):not(.disabled) .page-link {
    background: #fff;
}
.pagination-info {
    font-size: 0.78rem;
    color: #868e96;
    text-align: center;
    margin-top: 6px;
}
