/* Kosh ERP -- application shell.
   Built mobile-first: the same markup is the phone app (installed as a PWA) and the
   desktop app, so the sidebar collapses to a drawer rather than there being two layouts
   to keep in step. */

:root {
    --kosh-accent: #1d4ed8;
    --kosh-ink: #0f172a;
    --kosh-muted: #64748b;
    --kosh-line: #e2e8f0;
    --kosh-bg: #f6f7f9;
    --kosh-surface: #ffffff;
    --kosh-sidebar-bg: #0f172a;
    --kosh-sidebar-ink: #cbd5e1;
    --kosh-sidebar-width: 250px;
    --kosh-topbar-height: 56px;
    --kosh-radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Devanagari", sans-serif;
    background: var(--kosh-bg);
    color: var(--kosh-ink);
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

/* ---------- Shell ---------- */

.kosh-shell { display: flex; min-height: 100vh; }

.kosh-sidebar {
    width: var(--kosh-sidebar-width);
    flex: 0 0 var(--kosh-sidebar-width);
    background: var(--kosh-sidebar-bg);
    color: var(--kosh-sidebar-ink);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform .2s ease;
}

.kosh-main {
    flex: 1 1 auto;
    margin-left: var(--kosh-sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Brand ---------- */

.kosh-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.kosh-brand-mark {
    flex: 0 0 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--kosh-accent);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .04em;
    display: grid;
    place-items: center;
}

.kosh-brand-text { display: flex; flex-direction: column; min-width: 0; }
.kosh-brand-text strong {
    color: #fff;
    font-size: 14px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kosh-brand-text small { color: #94a3b8; font-size: 11px; }

/* ---------- Navigation ---------- */

.kosh-nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 0 16px; }

.kosh-nav-group {
    padding: 14px 16px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #64748b;
}

.kosh-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--kosh-sidebar-ink);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.kosh-nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }

.kosh-nav-link.active {
    background: rgba(255, 255, 255, .08);
    border-left-color: var(--kosh-accent);
    color: #fff;
    font-weight: 600;
}

.kosh-nav-link .ico { width: 20px; text-align: center; font-size: 15px; }

.kosh-sidebar-foot {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.kosh-user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kosh-user-role { color: #94a3b8; font-size: 11px; margin-bottom: 8px; }

/* ---------- Top bar ---------- */

.kosh-topbar {
    height: var(--kosh-topbar-height);
    background: var(--kosh-surface);
    border-bottom: 1px solid var(--kosh-line);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.kosh-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--kosh-ink);
}

.kosh-org-switch { max-width: 260px; flex: 1 1 auto; margin: 0; }
.kosh-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.kosh-fy {
    font-size: 12px;
    font-weight: 600;
    color: var(--kosh-muted);
    background: var(--kosh-bg);
    border: 1px solid var(--kosh-line);
    border-radius: 999px;
    padding: 4px 10px;
    white-space: nowrap;
}

.kosh-content { padding: 20px; flex: 1 1 auto; }

/* ---------- Signed-out pages ---------- */

.kosh-plain {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(29, 78, 216, .14), transparent 70%),
        var(--kosh-bg);
}

.kosh-auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--kosh-surface);
    border: 1px solid var(--kosh-line);
    border-radius: 14px;
    padding: 28px 26px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .07);
}

/* ---------- Reusable pieces ---------- */

.kosh-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.kosh-page-head h1 { font-size: 21px; font-weight: 700; margin: 0 0 2px; }
.kosh-page-head p { margin: 0; color: var(--kosh-muted); font-size: 13.5px; }

.kosh-card {
    background: var(--kosh-surface);
    border: 1px solid var(--kosh-line);
    border-radius: var(--kosh-radius);
    padding: 18px;
    margin-bottom: 18px;
}

.kosh-card-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--kosh-muted);
    margin-bottom: 12px;
}

/* Stat tiles on the dashboard */
.kosh-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kosh-stat {
    background: var(--kosh-surface);
    border: 1px solid var(--kosh-line);
    border-radius: var(--kosh-radius);
    padding: 15px 16px;
}

.kosh-stat-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--kosh-muted);
    margin-bottom: 6px;
}

.kosh-stat-value { font-size: 24px; font-weight: 700; line-height: 1.15; }
.kosh-stat-note { font-size: 12px; color: var(--kosh-muted); margin-top: 4px; }
.kosh-stat.accent { border-left: 3px solid var(--kosh-accent); }
.kosh-stat.warn .kosh-stat-value { color: #b45309; }
.kosh-stat.bad .kosh-stat-value { color: #b91c1c; }
.kosh-stat.good .kosh-stat-value { color: #15803d; }

/* Tables scroll inside their own box so the page never scrolls sideways on a phone */
.kosh-table-wrap { overflow-x: auto; }
.kosh-table-wrap table { margin-bottom: 0; }

table.kosh-table { width: 100%; font-size: 14px; border-collapse: collapse; }
table.kosh-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--kosh-muted);
    border-bottom: 1px solid var(--kosh-line);
    padding: 9px 10px;
    white-space: nowrap;
}
table.kosh-table td {
    padding: 10px;
    border-bottom: 1px solid var(--kosh-line);
    vertical-align: middle;
}
table.kosh-table tbody tr:hover { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.kosh-empty { text-align: center; padding: 40px 20px; color: var(--kosh-muted); }
.kosh-empty-mark { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.badge-status { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-issued { background: #dbeafe; color: #1e40af; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }

.btn-accent { background: var(--kosh-accent); border-color: var(--kosh-accent); color: #fff; }
.btn-accent:hover { filter: brightness(.93); color: #fff; }

.form-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-hint { font-size: 12px; color: var(--kosh-muted); margin-top: 3px; }

.kosh-scrim { display: none; }

/* ---------- Phone ---------- */

@media (max-width: 900px) {
    .kosh-sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .kosh-shell.nav-open .kosh-sidebar { transform: translateX(0); }
    .kosh-main { margin-left: 0; }
    .kosh-menu-btn { display: block; }
    .kosh-content { padding: 14px; }

    .kosh-shell.nav-open .kosh-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1035;
    }

    /* Touch targets big enough to hit while standing in a field, on a phone,
       one-handed -- which is exactly how the NGO data will be entered. */
    .kosh-nav-link { padding: 12px 16px; }
    .btn { min-height: 42px; }
    .form-control, .form-select { min-height: 42px; font-size: 16px; } /* 16px stops iOS zooming on focus */
}

/* ---------- Print: invoices and receipts ---------- */

@media print {
    .kosh-sidebar, .kosh-topbar, .kosh-scrim, .no-print { display: none !important; }
    .kosh-main { margin-left: 0; }
    .kosh-content { padding: 0; }
    body { background: #fff; font-size: 12px; }
    .kosh-card { border: none; padding: 0; }
}
