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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
    display: flex;
    min-height: 100vh;
}

a { color: #1e3a5f; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: 230px;
    min-height: 100vh;
    background: #1e3a5f;
    color: #c8d8e8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    line-height: 1.3;
}

.sidebar-logo small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #8aaac8;
    margin-top: 4px;
}

.sidebar nav { flex: 1; padding: 12px 0; }

.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: #c8d8e8;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.sidebar nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: #4da3e8;
}

.sidebar nav .nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6a8caa;
    padding: 14px 20px 4px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: #8aaac8;
}

.sidebar-footer strong { color: #c8d8e8; display: block; margin-bottom: 4px; }

.sidebar-footer a {
    color: #8aaac8;
    font-size: 12px;
}

.sidebar-footer a:hover { color: #fff; }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #dde3ea;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1e3a5f;
}

.topbar .user-info {
    font-size: 13px;
    color: #666;
}

.topbar .role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
}

.role-badge.admin    { background: #fce4b3; color: #7a4f00; }
.role-badge.supervisor { background: #d4e8f8; color: #1e3a5f; }
.role-badge.user     { background: #e8f5e9; color: #2e7d32; }
.role-badge.council  { background: #ede7f6; color: #4527a0; }
.role-badge.auditor  { background: #fce4ec; color: #880e4f; }

.auditor-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: #fce4ec;
    color: #880e4f;
    margin-left: 6px;
    border: 1px solid #f48fb1;
}

.content { padding: 28px; flex: 1; }

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flashes { margin-bottom: 20px; }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13.5px;
    border-left: 4px solid;
}

.flash.success { background: #e8f5e9; color: #2e7d32; border-color: #4caf50; }
.flash.error   { background: #fdecea; color: #c62828; border-color: #f44336; }
.flash.info    { background: #e3f2fd; color: #1565c0; border-color: #2196f3; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: #1e3a5f;
}

.card-body { padding: 20px; }

/* ── Balance cards grid ───────────────────────────────────────────────────── */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.balance-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 18px 20px;
    border-top: 4px solid #1e3a5f;
}

.balance-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1e3a5f;
    margin-bottom: 12px;
}

.balance-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 13px;
}

.balance-stat:last-child { border-bottom: none; }
.balance-stat .label { color: #666; }
.balance-stat .value { font-weight: 600; }
.balance-stat.available .value { color: #2e7d32; font-size: 15px; }
.balance-stat.pending .value { color: #e65100; }
.balance-stat.approved-up .value { color: #1565c0; }

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    background: #f7f8fa;
    color: #1e3a5f;
    font-weight: 600;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #dde3ea;
    white-space: nowrap;
}

tbody tr { border-bottom: 1px solid #eee; }
tbody tr:hover { background: #fafbfc; }
tbody td { padding: 10px 12px; vertical-align: middle; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-pending   { background: #fff3e0; color: #e65100; }
.badge-approved  { background: #e3f2fd; color: #1565c0; }
.badge-denied    { background: #fdecea; color: #c62828; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-active     { background: #e8f5e9; color: #2e7d32; }
.badge-inactive   { background: #f5f5f5; color: #757575; }
.badge-cancelled  { background: #f3e5f5; color: #6a1b9a; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, box-shadow 0.15s;
    text-align: center;
    white-space: nowrap;
}

.btn:hover { opacity: 0.88; text-decoration: none; }

.btn-primary { background: #1e3a5f; color: #fff; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-danger  { background: #c62828; color: #fff; }
.btn-warning { background: #f57c00; color: #fff; }
.btn-light   { background: #f0f2f5; color: #333; border: 1px solid #dde3ea; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #444; }

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cdd5df;
    border-radius: 5px;
    font-size: 13.5px;
    color: #333;
    background: #fff;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: #4da3e8;
    box-shadow: 0 0 0 3px rgba(77,163,232,0.15);
}

select.form-control { cursor: pointer; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

.form-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 15px; font-weight: 600; color: #1e3a5f; }
.modal-close { cursor: pointer; font-size: 20px; color: #999; border: none; background: none; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #eee; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e3a5f;
}

.login-box {
    background: #fff;
    border-radius: 10px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-org {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 4px;
}

/* ── Hub page ─────────────────────────────────────────────────────────────── */
.hub-wrap {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    width: 100%;
    max-width: 680px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.hub-header { margin-bottom: 28px; }

.hub-org {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 4px;
}

.hub-header h1 {
    font-size: 24px;
    color: #1e3a5f;
    font-weight: 700;
    margin-bottom: 4px;
}

.hub-header p { color: #666; font-size: 13px; }

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    border-radius: 10px;
    border: 2px solid #dde3ea;
    background: #f7f8fa;
    color: #1e3a5f;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.module-card:hover {
    border-color: #1e3a5f;
    background: #fff;
    box-shadow: 0 4px 16px rgba(30,58,95,0.12);
    text-decoration: none;
}

.module-card-admin { border-color: #fce4b3; background: #fffbf2; }
.module-card-admin:hover { border-color: #e6a817; background: #fff; }

.module-icon { font-size: 32px; margin-bottom: 10px; }
.module-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.module-desc { font-size: 12px; color: #666; }

.hub-footer {
    font-size: 12px;
    color: #888;
    border-top: 1px solid #eee;
    padding-top: 16px;
}

.hub-footer a { color: #1e3a5f; }
.hub-footer strong { color: #333; }

.login-box h1 {
    font-size: 20px;
    color: #1e3a5f;
    margin-bottom: 6px;
    font-weight: 700;
}

.login-box p { color: #666; font-size: 13px; margin-bottom: 24px; }
.login-box .btn { width: 100%; padding: 10px; font-size: 14px; margin-top: 8px; }

/* ── Misc helpers ─────────────────────────────────────────────────────────── */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: #888; font-size: 12px; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.empty-state .icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── Expandable user row ──────────────────────────────────────────────────── */
.expand-row { background: #f7f8fa !important; }
.expand-row td { padding: 16px 20px; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.sub-card { background: #fff; border: 1px solid #dde3ea; border-radius: 6px; padding: 12px 14px; }
.sub-card h4 { font-size: 12px; font-weight: 700; color: #1e3a5f; margin-bottom: 10px; text-transform: uppercase; }

/* ── Team calendar ────────────────────────────────────────────────────────── */
.cal-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.cal-table thead th {
    text-align: center;
    padding: 10px 4px;
    font-size: 12px;
    font-weight: 700;
    color: #1e3a5f;
    background: #f7f8fa;
    border-bottom: 2px solid #dde3ea;
}

.cal-cell {
    vertical-align: top;
    padding: 6px 5px;
    border: 1px solid #eee;
    height: 100px;
    width: 14.28%;
}

.cal-cell.cal-empty { background: #fafafa; }
.cal-cell.cal-today { background: #f0f6ff; }

.cal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-align: right;
    padding-right: 2px;
}

.cal-today-num {
    background: #1e3a5f;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    float: right;
    font-size: 11px;
}

.cal-event {
    border-radius: 3px;
    padding: 2px 5px;
    margin-bottom: 2px;
    font-size: 11px;
    line-height: 1.3;
    cursor: default;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cal-event-name { font-weight: 600; margin-right: 3px; }
.cal-event-type { opacity: 0.8; }

.cal-pending   { background: #fff3e0; color: #bf6000; border-left: 3px solid #e65100; }
.cal-approved  { background: #e3f2fd; color: #1565c0; border-left: 3px solid #1976d2; }
.cal-completed { background: #e8f5e9; color: #2e7d32; border-left: 3px solid #388e3c; }

.cal-legend {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* ── Audit log ────────────────────────────────────────────────────────────── */
.audit-action { font-weight: 600; color: #1e3a5f; }
.audit-details { font-family: monospace; font-size: 11px; color: #555; max-width: 340px; word-break: break-all; }
