/* =====================================================
   Woreda System — Dark Console Theme
   Palette:  bg #0a0f1a | panel #111a29 | panel-alt #0d1522
             border #1e293b | accent #2dd9b8 | accent-dim rgba(45,217,184,.14)
             text #e6ebf1 | muted #7d8ba3 | danger #f87171 | warning #eab308
   Type:     display = Space Grotesk | body = system sans | data/labels = JetBrains Mono
===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #0a0f1a;
    --panel: #111a29;
    --panel-alt: #0d1522;
    --border: #1e293b;
    --accent: #2dd9b8;
    --accent-dim: rgba(45, 217, 184, 0.14);
    --accent-dark: #12b89a;
    --text: #e6ebf1;
    --muted: #7d8ba3;
    --danger: #f87171;
    --danger-dim: rgba(248, 113, 113, 0.14);
    --warning: #eab308;
    --warning-dim: rgba(234, 179, 8, 0.14);
}

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

body {
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, .brand, .stat-value {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
}

.eyebrow, .label-mono, .stat-box .label, .badge, table th,
.section-tabs a, .topbar nav a, .sidebar a {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---- App shell: topbar + sidebar + main ---- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    background: var(--panel-alt);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar .brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    padding: 2px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; }
.brand-text .brand { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: .01em; }
.brand-text .tagline {
    font-size: 10.5px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; margin-top: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-chip .user-icon {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent-dim); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.role-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
    background: var(--panel); border: 1px solid var(--border); color: var(--muted);
    padding: 3px 9px; border-radius: 20px;
}

.section-pill {
    display: flex; align-items: center; gap: 6px;
    background: var(--accent-dim); border: 1px solid var(--accent);
    color: var(--accent); font-size: 12px; font-weight: 600;
    padding: 6px 14px; border-radius: 20px;
    font-family: 'JetBrains Mono', monospace;
}
.section-pill.none { border-color: var(--border); color: var(--muted); background: transparent; }

.signout-btn {
    display: flex; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--border); color: var(--text);
    padding: 7px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.signout-btn:hover { border-color: var(--danger); color: var(--danger); text-decoration: none; }

/* ---- Body: sidebar + content ---- */
.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: 230px; flex-shrink: 0;
    background: var(--panel-alt);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
}
.sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    color: var(--muted); font-size: 12.5px; letter-spacing: .02em;
    margin-bottom: 4px;
}
.sidebar a svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; }
.sidebar a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sidebar a.active {
    background: var(--accent-dim); color: var(--accent); font-weight: 600;
}

.container { flex: 1; max-width: 1180px; margin: 0 auto; padding: 26px 28px; width: 100%; }

/* ---- Cards ---- */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 22px;
}
.card h2, .card h3 { margin-bottom: 14px; color: var(--text); font-weight: 600; }

/* ---- Stat / ledger cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 18px 20px;
    display: flex; flex-direction: column; gap: 10px;
}
.stat-box .stat-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-icon {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--accent-dim); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.stat-box .label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.stat-box .value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-box .sublabel { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-box.alert-box { border-left-color: var(--danger); }
.stat-box.alert-box .value { color: var(--danger); }
.stat-box.alert-box .stat-icon { background: var(--danger-dim); color: var(--danger); }
.stat-box.accent-blue .value { color: var(--accent); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th, table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table th {
    color: var(--muted); font-weight: 500; font-size: 11px;
    text-transform: uppercase; letter-spacing: .08em;
}
table tr:hover td { background: var(--panel-alt); }

/* ---- Badges ---- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.badge.green { background: rgba(45, 217, 184, .14); color: var(--accent); }
.badge.red { background: var(--danger-dim); color: var(--danger); }
.badge.gray { background: var(--panel-alt); color: var(--muted); border: 1px solid var(--border); }
.badge.orange { background: var(--warning-dim); color: var(--warning); }

/* ---- Progress bars ---- */
.progress-bar { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 20px; height: 8px; width: 100%; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 20px; }
.progress-bar-fill.low { background: var(--danger); }
.progress-bar-fill.mid { background: var(--warning); }

/* ---- Buttons ---- */
.btn {
    display: inline-block; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--accent);
    background: var(--accent); color: #06231c; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.btn-danger:hover { background: var(--danger-dim); }
.btn.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn.btn-secondary:hover { background: var(--panel-alt); }
.btn.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---- Forms ---- */
form.stacked label {
    display: block; margin-bottom: 6px; font-weight: 600; font-size: 12.5px;
    color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
form.stacked input[type=text],
form.stacked input[type=password],
form.stacked input[type=number],
form.stacked input[type=file],
form.stacked select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 16px; font-size: 14px; background: var(--panel-alt); color: var(--text);
}
form.stacked input:focus, form.stacked select:focus {
    outline: none; border-color: var(--accent);
}

/* ---- Login screens (no sidebar) ---- */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at top, #101a2b 0%, var(--bg) 60%);
}
.login-box {
    background: var(--panel); border: 1px solid var(--border);
    padding: 36px 34px; border-radius: 14px; width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; color: var(--text); }
.login-box p.subtitle { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.login-logo {
    width: 68px; height: 68px; margin: 0 auto 16px; display: block;
    border-radius: 14px; background: #fff; padding: 5px; border: 1px solid var(--border);
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 11px; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.alert.error { background: var(--danger-dim); color: var(--danger); border-color: rgba(248,113,113,.35); }
.alert.success { background: var(--accent-dim); color: var(--accent); border-color: rgba(45,217,184,.35); }
.alert.info { background: rgba(125,139,163,.12); color: var(--muted); border-color: var(--border); }

/* ---- Section tabs (year switcher) ---- */
.section-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.section-tabs a {
    padding: 7px 16px; border-radius: 20px; background: var(--panel);
    border: 1px solid var(--border); color: var(--muted); font-size: 11.5px;
}
.section-tabs a.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.text-muted { color: var(--muted); font-size: 12.5px; }

/* ---- Mobile menu toggle button (hidden on desktop) ---- */
.menu-toggle {
    display: none;
    background: var(--panel); border: 1px solid var(--border); color: var(--text);
    width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.menu-toggle svg { width: 18px; height: 18px; stroke: currentColor; }

.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
    .menu-toggle { display: flex; }

    .topbar { padding: 10px 14px; }
    .brand-text .tagline { display: none; }
    .user-chip .role-pill { display: none; }
    .topbar-right { gap: 8px; }
    .section-pill { font-size: 10.5px; padding: 5px 10px; }
    .signout-btn span.signout-label { display: none; }

    .app-body { position: relative; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 240px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s ease;
        overflow-y: auto;
        padding-top: 70px;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        display: none;
        position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90;
    }
    .sidebar-backdrop.open { display: block; }

    .container { padding: 16px 14px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-box { padding: 14px 14px; }
    .stat-box .value { font-size: 21px; }

    /* Let wide tables scroll horizontally instead of squeezing/wrapping badly */
    table { display: block; overflow-x: auto; white-space: nowrap; }
    table thead, table tbody, table tr { display: table; width: 100%; table-layout: auto; }

    .login-wrapper { padding: 16px; }
    .login-box { padding: 28px 22px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .flex-between { align-items: stretch; }
    .btn { width: 100%; text-align: center; }
    .btn.btn-sm { width: auto; }
}
