:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --line: #dbe4ef;
    --text: #172033;
    --muted: #667085;
    --primary: #4BB8FA;
    --primary-dark: #209ee9;
    --blue: #2563eb;
    --amber: #b45309;
    --green: #15803d;
    --danger: #b91c1c;
    --shadow: 0 12px 30px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.dark-mode {
    --bg: #0b1220;
    --panel: #121c2f;
    --line: #25344d;
    --text: #e6edf7;
    --muted: #9fb0c8;
    --shadow: 0 16px 34px rgba(0, 0, 0, .22);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef7f5 0%, #f4f7fb 45%, #fff8ed 100%);
}
.auth-box {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .08);
}
.auth-brand {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin-bottom: 24px;
    text-align: center;
}
.auth-brand img {
    width: 54px;
    height: 54px;
    object-fit: contain;
}
.auth-brand strong {
    font-size: 18px;
    letter-spacing: 0;
}
.auth-brand span {
    color: var(--muted);
    font-size: 14px;
}
.auth-actions {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 14px;
}
.auth-actions a,
.auth-back {
    color: #0969a8;
    font-size: 14px;
    font-weight: 700;
}
.auth-back {
    display: inline-flex;
    margin-top: 16px;
}
.auth-note {
    background: #eaf6ff;
    border: 1px solid #c7e9ff;
    border-radius: 8px;
    color: #0969a8;
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 14px;
    padding: 10px 12px;
}
.captcha-box {
    min-height: 46px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 8px;
    margin-bottom: 8px;
    user-select: none;
    background:
        repeating-linear-gradient(18deg, rgba(75, 184, 250, .35) 0 1px, transparent 1px 11px),
        repeating-linear-gradient(-24deg, rgba(15, 23, 42, .14) 0 1px, transparent 1px 16px),
        linear-gradient(135deg, #fff8dd, #dff3ff);
    text-decoration-line: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: rgba(9, 105, 168, .45);
}
.auth-year-select {
    background-color: #eef6fd;
    border-color: transparent;
    min-height: 46px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand small { color: #94a3b8; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 8px;
    display: grid; place-items: center; color: #fff; background: var(--primary);
}
.brand-logo {
    object-fit: contain;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 280px;
    flex: 0 0 280px;
    background: #0f172a;
    color: #e5edf7;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
body.dark-mode .sidebar {
    background: #070d1a;
    border-right: 1px solid #1e2a40;
}
.sidebar .brand { padding: 8px 10px 14px; }
.sidebar-user {
    display: flex;
    align-items: center;
    margin: 0 4px 22px;
    padding: 11px 12px;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(75, 184, 250, .13), rgba(255, 255, 255, .05));
}
.sidebar-user-meta {
    min-width: 0;
    display: grid;
    gap: 5px;
}
.sidebar-user-meta strong {
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-user-meta span {
    width: fit-content;
    max-width: 100%;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    padding: 5px 8px;
    text-transform: capitalize;
}
body.dark-mode .sidebar-user {
    background: linear-gradient(135deg, rgba(75, 184, 250, .16), rgba(18, 28, 47, .62));
    border-color: #263854;
}
.nav-label { color: #94a3b8; font-size: 12px; text-transform: uppercase; margin: 18px 10px 8px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border-radius: 8px;
    color: #cbd5e1; margin: 2px 0;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 13px;
}
.nav-sub .nav-link {
    text-transform: capitalize;
    font-weight: 500;
    font-size: 14px;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.09); color: #fff; }
.nav-sub { margin-left: 14px; border-left: 1px solid rgba(255,255,255,.12); padding-left: 8px; }
.nav-dropdown summary { list-style: none; cursor: pointer; justify-content: space-between; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-caret { margin-left: auto; transition: transform .18s ease; }
.nav-dropdown[open] .nav-caret { transform: rotate(90deg); }
.year-pills a {
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 6px;
    text-align: center;
}
.active-year-badge {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 8px;
    background: #eaf6ff;
    color: #0969a8;
    font-weight: 800;
    white-space: nowrap;
}
.year-pills a.active {
    background: var(--primary);
    color: #fff;
}
.main { flex: 1; min-width: 0; }
.topbar {
    min-height: 68px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}
body.dark-mode .topbar {
    background: rgba(18, 28, 47, .88);
}
.mobile-toggle { display: none; }
.content { padding: 24px; max-width: 1440px; margin: 0 auto; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-title { margin: 0 0 6px; font-size: 26px; line-height: 1.2; }
.page-subtitle { color: var(--muted); margin: 0; }
.year-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}
.year-filter label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.year-filter .select { min-width: 110px; }
.year-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.year-pills a {
    background: #eaf6ff;
    color: #0969a8;
    min-width: 62px;
}

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.card {
    position: relative;
    overflow: hidden;
    min-height: 158px;
}
.card::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 24px;
    width: 58px;
    height: 58px;
    border-radius: 8px;
    opacity: .16;
    background: currentColor;
    transform: rotate(8deg);
}
.metric-heading { margin: 0 0 16px; position: relative; z-index: 1; }
.metric-label { color: var(--text); font-size: 14px; font-weight: 800; margin: 0 0 3px; }
.metric-title { color: var(--text); font-size: 14px; font-weight: 400; margin: 0; }
.metric-value { font-size: 36px; font-weight: 700; margin: 0; position: relative; z-index: 1; }
.metric-meta { margin: 8px 0 0; color: var(--muted); font-size: 13px; position: relative; z-index: 1; }
.tone-primary { border-top: 4px solid #38bdf8; color: #0ea5e9; }
.tone-success { border-top: 4px solid #22c55e; color: #16a34a; }
.tone-info { border-top: 4px solid #6366f1; color: #4f46e5; }
.tone-warning { border-top: 4px solid #f59e0b; color: #d97706; }
.tone-danger { border-top: 4px solid #ef4444; color: #dc2626; }
body.dark-mode .card::after { opacity: .22; }

.btn {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    background: #e2e8f0;
    color: #0f172a;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: #eef2f7; }
body.dark-mode .btn-light { background: #1d2a40; color: #e6edf7; }
.btn-sm { padding: 7px 10px; min-height: 34px; font-size: 13px; }
.theme-toggle {
    margin-left: auto;
}
.theme-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0f172a;
    box-shadow: inset -5px -4px 0 #eef2f7;
}
body.dark-mode .theme-icon {
    background: #facc15;
    box-shadow: 0 0 0 3px rgba(250, 204, 21, .16);
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { color: #344054; font-size: 14px; font-weight: 600; }
body.dark-mode .field label { color: #dbeafe; }
.input, .select, .textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}
body.dark-mode .input,
body.dark-mode .select,
body.dark-mode .textarea,
body.dark-mode .table-wrap {
    background: #0d1628;
    color: var(--text);
    border-color: #33445f;
}
body.dark-mode .input::file-selector-button {
    border: 0;
    border-radius: 6px;
    background: #dbeafe;
    color: #0f172a;
    font-weight: 700;
    margin-right: 10px;
    padding: 7px 10px;
}
.textarea { min-height: 82px; resize: vertical; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #172033; font-size: 13px; font-weight: 700; }
body.dark-mode th { background: #18243a; color: var(--text); }
.dashboard-table th { font-weight: 800; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-wait { background: #fef3c7; color: #92400e; }
.badge-role { background: #e0f2fe; color: #075985; text-transform: capitalize; }
.badge-progress { background: #dff3ff; color: #0969a8; }
body.dark-mode .badge-wait { background: #4a3411; color: #fcd384; }
body.dark-mode .badge-ok { background: #123d28; color: #9be6b4; }
body.dark-mode .badge-progress { background: #12334a; color: #9bd7f7; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    background: currentColor;
    flex: 0 0 16px;
}
.icon-upload {
    clip-path: polygon(46% 12%, 54% 12%, 54% 58%, 69% 58%, 50% 78%, 31% 58%, 46% 58%, 46% 12%, 12% 80%, 12% 90%, 88% 90%, 88% 80%);
}
.icon-save {
    clip-path: polygon(12% 10%, 72% 10%, 88% 26%, 88% 90%, 12% 90%, 12% 10%, 24% 18%, 24% 42%, 68% 42%, 68% 18%, 24% 18%, 24% 82%, 76% 82%, 76% 58%, 24% 58%, 24% 82%);
}

.element-block { margin-bottom: 18px; }
.element-title { font-size: 18px; margin: 0 0 10px; }
body.dark-mode .element-title { color: #f8fbff; }
.monitoring-panel { margin-bottom: 18px; }
.requirement {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 14px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    margin-bottom: 10px;
}
.doc-title { margin: 0 0 8px; font-weight: 700; line-height: 1.4; }
.doc-meta { color: var(--muted); font-size: 13px; margin: 0; }
body.dark-mode .requirement {
    background: #111b2e;
    border-color: #31415c;
    box-shadow: 0 12px 26px rgba(0, 0, 0, .18);
}
body.dark-mode .doc-title {
    color: #f4f8ff;
}
body.dark-mode .doc-meta {
    color: #adc0dc;
}
.dashboard-info-card {
    margin-top: 18px;
}
.dashboard-info {
    border-left: 4px solid var(--primary);
    background: #eaf6ff;
    color: #075985;
    border-radius: 8px;
    padding: 12px 14px;
}
.dashboard-info p {
    margin: 4px 0 0;
    color: #0969a8;
    line-height: 1.5;
}
body.dark-mode .dashboard-info {
    background: #10263d;
    color: #bae6fd;
}
body.dark-mode .dashboard-info p {
    color: #9bd7f7;
}
.settings-section {
    margin-bottom: 16px;
}
.settings-table table {
    min-width: 620px;
}
.year-input {
    max-width: 160px;
}
.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 600;
}
.switch-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

@media (max-width: 1080px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .requirement { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar {
        display: none;
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        width: min(86vw, 310px);
    }
    .sidebar.open { display: block; }
    .mobile-toggle { display: inline-flex; }
    .topbar { padding: 12px 14px; }
    .content { padding: 16px; }
    .page-head { display: grid; }
    .year-filter { align-items: stretch; justify-content: space-between; }
    .year-pills { width: 100%; }
    .cards, .form-grid { grid-template-columns: 1fr; }
    .card, .panel { padding: 15px; }
    .metric-value { font-size: 30px; }
}
