:root {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #6b7280;
    --line: #d1d5db;
    --header: #1f2937;
    --header-2: #111827;
    --green: #16a34a;
    --lightblue: #38bdf8;
    --yellow: #facc15;
    --red: #dc2626;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(17, 24, 39, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: #0f766e; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header);
    color: var(--white);
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.topbar a { color: var(--white); opacity: .92; font-weight: 600; margin-left: 18px; }
.topbar a:hover { opacity: 1; }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-title span { display: block; color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(135deg, #16a34a, #38bdf8);
    color: white; display: grid; place-items: center; font-weight: 800;
    letter-spacing: .5px;
}
.container { max-width: 1180px; margin: 0 auto; padding: 28px 18px 70px; }
.container-login { max-width: 480px; }
body.login-page {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(56,189,248,.35), transparent 30%),
                linear-gradient(135deg, #111827, #1f2937 55%, #0f172a);
}

.card {
    background: var(--panel);
    border: 1px solid rgba(209,213,219,.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.login-card {
    margin-top: 12vh;
    color: white;
    background: rgba(31,41,55,.72);
    border: 1px solid rgba(255,255,255,.18);
    backdrop-filter: blur(12px);
}
.login-card label { color: #f9fafb; }
.login-card input { background: rgba(255,255,255,.98); }
.login-card .muted { color: #d1d5db; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.stat-card { border-left: 8px solid var(--green); }
.stat-card.blue { border-color: var(--lightblue); }
.stat-card.yellow { border-color: var(--yellow); }
.stat-card.red { border-color: var(--red); }
.stat-value { font-size: 34px; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); margin-top: 6px; }

h1, h2, h3 { margin: 0 0 12px; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.strong { font-weight: 800; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-row { margin: 0 0 14px; }
label { display: block; font-weight: 700; margin-bottom: 6px; color: #374151; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: white;
}
input:focus, select:focus { outline: 3px solid rgba(56,189,248,.25); border-color: #38bdf8; }

.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    margin: 2px;
}
.btn-primary { background: #0f766e; color: white; }
.btn-secondary { background: #e5e7eb; color: #111827; }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: #f59e0b; color: #111827; }
.btn-small { padding: 7px 10px; border-radius: 10px; font-size: 13px; }

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin: 0 0 16px;
    border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #166534; border-color: #86efac; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.data-table th, .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}
.data-table th {
    text-align: left;
    background: #f9fafb;
    color: #374151;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.data-table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.compact-table th, .compact-table td { padding: 8px 10px; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-weight: 800;
    font-size: 12px;
    background: #e5e7eb;
    color: #111827;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.blue { background: #e0f2fe; color: #075985; }
.badge.yellow { background: #fef9c3; color: #854d0e; }
.badge.red { background: #fee2e2; color: #991b1b; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }
.report-heading { text-align: center; margin-bottom: 20px; }
.report-heading h1 { font-size: 28px; }
.group-title {
    margin: 26px 0 8px;
    padding: 10px 12px;
    background: #111827;
    color: white;
    border-radius: 12px;
    break-after: avoid;
}
.subgroup-title {
    margin: 16px 0 8px;
    padding: 8px 10px;
    background: #e5e7eb;
    color: #111827;
    border-radius: 10px;
    break-after: avoid;
}
.print-footer-fallback { display: none; }

@media (max-width: 760px) {
    .topbar { position: static; align-items: flex-start; flex-direction: column; padding: 14px; gap: 12px; }
    .topbar nav { display: flex; flex-wrap: wrap; gap: 10px; }
    .topbar a { margin-left: 0; }
    .data-table { display: block; overflow-x: auto; }
}

@media print {
    body { background: white; color: black; }
    .no-print, .topbar, .alert { display: none !important; }
    .container { max-width: none; padding: 0; }
    .card { box-shadow: none; border: 0; padding: 0; margin: 0 0 12px; }
    a { color: black; text-decoration: none; }
    .data-table th { background: #eeeeee !important; color: black; }
    .data-table th, .data-table td { font-size: 10.5px; padding: 5px 6px; }
    .group-title { background: #111 !important; color: white !important; padding: 6px 8px; margin: 12px 0 6px; }
    .subgroup-title { padding: 5px 8px; margin: 8px 0 4px; }
    .report-heading { margin-bottom: 10px; }
    .print-footer-fallback {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        font-size: 9px;
        color: #4b5563;
        text-align: center;
        border-top: 1px solid #d1d5db;
        padding-top: 3px;
        background: white;
    }
}
