/* =========================================================================
   CCF PUBLIC TRUST - DESIGN SYSTEM (MEDIUM BLUE EDITION)
   ========================================================================= */
:root {
    --ink-900: #1E56A0;
    --ink-800: #2A65B8;
    --ink-700: #3B75C9;
    --gold-600: #B07C25;
    --gold-500: #C7962F;
    --gold-200: #F0DDB1;
    --gold-100: #FBF3E1;
    --leaf-700: #2E4F38;
    --leaf-500: #3E6B4A;
    --leaf-100: #E7EFE6;
    --paper: #F3F1EA;
    --surface: #FFFFFF;
    --line: #DEDACB;
    --line-strong: #C7C2AD;
    --text: #1C2233;
    --text-muted: #5B5F6E;
    --text-on-ink: #F2F1EC;
    --danger: #A83A32;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Public Sans', 'Segoe UI', Tahoma, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
    --radius-sm: 4px;
    --radius-md: 8px;
    --shadow-card: 0 1px 3px rgba(18,32,61,0.08), 0 4px 12px rgba(18,32,61,0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
}

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--paper);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden !important;
}

h1, h2, h3, h4 { 
    font-family: var(--font-display); 
    color: var(--ink-900); 
    font-weight: 600; 
    word-break: break-word;
}
h1 { font-size: 1.3rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
h3 { font-size: 1rem; margin-bottom: 0.35rem; }
h4 { font-size: 0.9rem; margin-bottom: 0.25rem; color: var(--ink-800); }
a { color: inherit; }

/* =========================================================================
   UNIFIED HEADER NAVBAR (CONSISTENT ACROSS ALL PAGES & DASHBOARDS)
   ========================================================================= */
.navbar {
    background-color: var(--ink-900);
    color: var(--text-on-ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.75rem;
    position: sticky;
    top: 0;
    z-index: 10000;
    border-bottom: 1px solid var(--ink-700);
    min-height: 72px;
    width: 100%;
    max-width: 100vw;
}

.navbar .logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.navbar .logo a {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.15;
    text-decoration: none !important;
}

.navbar .logo .main-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-on-ink);
    display: block;
    white-space: nowrap;
}

.navbar .logo .sub-title {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--gold-500);
    margin-top: 2px;
    display: block;
    white-space: nowrap;
}

.navbar nav { 
    display: flex; 
    align-items: center; 
    justify-content: center;
    flex: 1;
}

.nav-links { 
    display: flex; 
    list-style: none; 
    gap: 1.25rem; 
    align-items: center; 
    justify-content: center;
    margin: 0 auto;
}

.nav-links a {
    color: var(--text-on-ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    position: relative;
    padding: 0.35rem 0.1rem;
    white-space: nowrap;
}

.nav-links a.active, .nav-links a:hover { color: var(--gold-200); }

.navbar-right-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-sm);
    color: var(--gold-500);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    line-height: 1;
}

.auth-section { display: flex; align-items: center; }

.mobile-profile-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-500) 0%, #9E6B1D 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    border: 2px solid var(--gold-200);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.btn-power-off {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    color: #fca5a5;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-power-off span { display: inline-block; }

.container { 
    flex: 1; 
    max-width: 1180px; 
    width: 100%; 
    margin: 1rem auto; 
    padding: 0 0.75rem; 
    box-sizing: border-box;
}

/* =========================================================================
   CARDS, FORMS & TABLES
   ========================================================================= */
.card {
    background: var(--surface);
    padding: 1rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.admin-grid { 
    display: flex;
    flex-direction: column;
    gap: 1rem; 
    width: 100%; 
    max-width: 100%;
}
@media(min-width: 992px) { 
    .admin-grid { display: grid; grid-template-columns: 1fr 1fr; } 
}

.dashboard-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    width: 100%;
    max-width: 100%;
}

.form-row-2 {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
}
@media(min-width: 768px) {
    .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; }
}

.form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

input, textarea, select {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.6rem 0.75rem;
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 16px !important;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box !important;
}

label { 
    display: block; 
    font-weight: 600; 
    margin-bottom: 0.2rem; 
    font-size: 0.72rem; 
    letter-spacing: 0.02em; 
    text-transform: uppercase; 
    color: var(--text-muted); 
    word-break: break-word;
}

.btn, button {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background-color: var(--ink-900);
    color: var(--text-on-ink);
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media(min-width: 576px) {
    .btn, button { width: auto; }
}

.btn-primary { background-color: var(--gold-500); color: var(--ink-900); }
.btn-signin {
    background-color: transparent;
    border: 1px solid var(--gold-500);
    color: var(--gold-200);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    width: auto !important;
}
.btn-del { background-color: transparent; color: var(--danger); border: 1px solid var(--danger); width: auto !important; }

/* TABLES */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    margin-top: 0.75rem;
    background: var(--surface);
    display: block;
    box-sizing: border-box;
}

.data-table { 
    width: 100%; 
    min-width: 380px;
    border-collapse: collapse; 
    font-size: 0.8rem; 
}
.data-table th, .data-table td { 
    padding: 0.55rem 0.5rem; 
    text-align: left; 
    border-bottom: 1px solid var(--line); 
    vertical-align: middle;
    word-break: break-word;
}
.data-table th {
    background-color: var(--ink-900);
    color: var(--text-on-ink);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
}
.data-table td { font-family: var(--font-mono); font-size: 0.75rem; }

.badge-counter {
    background-color: var(--leaf-100);
    color: var(--leaf-700);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 20px;
    white-space: nowrap;
    display: inline-block;
}

footer {
    background-color: var(--ink-900);
    color: #9AA1B5;
    text-align: center;
    padding: 1rem 0.75rem;
    margin-top: auto;
    font-size: 0.8rem;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* =========================================================================
   MOBILE MENU OVERLAY (< 868px)
   ========================================================================= */
@media (max-width: 868px) {
    .navbar {
        padding: 0.6rem 0.85rem;
        min-height: 60px;
    }
    
    .navbar .logo .main-title {
        font-size: 0.85rem;
    }
    
    .menu-toggle { 
        display: block !important; 
        cursor: pointer !important;
        z-index: 10005 !important;
    }
    
    .navbar nav {
        position: static !important;
        display: block !important;
        width: auto !important;
        height: auto !important;
    }
    
    .navbar .nav-links,
    .nav-links {
        display: none !important;
        position: fixed !important;
        top: 60px !important;
        left: 4% !important;
        width: 92% !important;
        max-width: 380px !important;
        flex-direction: column !important;
        gap: 0 !important;
        margin: 0 !important;
        background-color: var(--ink-900) !important;
        border-radius: var(--radius-md) !important;
        border: 2px solid var(--gold-500) !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 75px) !important;
        z-index: 99999 !important;
    }
    
    .navbar.mobile-open nav:not([style*="display: none"]) .nav-links,
    .navbar.mobile-open nav:not([style*="display:none"]) .nav-links,
    .navbar .nav-links.active,
    .nav-links.active { 
        display: flex !important; 
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    .nav-links li { width: 100% !important; }
    
    .nav-links a {
        display: block !important;
        width: 100% !important;
        padding: 0.8rem 1rem !important;
        border-bottom: 1px solid rgba(255,255,255,0.08) !important;
        color: var(--text-on-ink) !important;
        text-align: center !important;
        font-size: 0.88rem !important;
    }

    .container { 
        padding: 0 0.6rem; 
        margin: 0.75rem auto;
    }
}