:root {
    --blue: #00539b;
    --blue-dark: #003e78;
    --blue-soft: #e8f2fb;
    --red: #ef233c;
    --yellow: #ffc928;
    --green: #16834a;
    --orange: #d97706;
    --ink: #16324f;
    --muted: #66788a;
    --line: #dce5ee;
    --surface: #ffffff;
    --background: #f4f7fb;
    --sidebar: 248px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: var(--blue-dark);
    color: #fff;
    box-shadow: 6px 0 22px rgba(0, 52, 103, .12);
}

.sidebar-brand {
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-right: 1px solid var(--line);
}

.sidebar-brand img { width: 94px; height: auto; }
.sidebar-brand strong { color: var(--blue-dark); display: block; font-size: 15px; }
.sidebar-brand span { color: var(--muted); display: block; font-size: 11px; margin-top: 2px; }

.nav-list { list-style: none; margin: 0; padding: 16px 10px; overflow-y: auto; }
.nav-label { padding: 12px 12px 6px; color: #9fc3e5; font-size: 10px; text-transform: uppercase; font-weight: 800; }
.nav-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    gap: 11px;
    margin: 2px 0;
    padding: 9px 12px;
    border-radius: 6px;
    color: #dcecff;
    font-weight: 650;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: #fff; color: var(--blue-dark); }
.nav-icon { width: 22px; text-align: center; font-size: 12px; font-weight: 900; }

.sidebar-user { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.13); }
.sidebar-user strong, .sidebar-user span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { color: #b9d5ed; font-size: 12px; margin: 2px 0 10px; }
.sidebar-user a { font-size: 12px; color: #fff; text-decoration: underline; }

.main-shell { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
}
.topbar-title h1 { margin: 0; font-size: 20px; color: var(--blue-dark); }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }

.content { padding: 24px 28px 40px; max-width: 1680px; margin: 0 auto; }
.brand-rule { height: 4px; display: grid; grid-template-columns: 2fr 1fr 1fr; margin: -24px -28px 24px; }
.brand-rule i:nth-child(1) { background: var(--blue); }
.brand-rule i:nth-child(2) { background: var(--yellow); }
.brand-rule i:nth-child(3) { background: var(--red); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 17px; min-width: 0; }
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; margin-top: 7px; font-size: 23px; color: var(--blue-dark); }
.stat-card small { display: block; margin-top: 7px; color: var(--muted); }
.stat-card.danger { border-top: 3px solid var(--red); }
.stat-card.warning { border-top: 3px solid var(--yellow); }
.stat-card.success { border-top: 3px solid var(--green); }
.stat-card.info { border-top: 3px solid var(--blue); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.panel-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 15px; color: var(--blue-dark); }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px; }
.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: 10px 12px; color: #506477; background: #f6f8fb; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.data-table tbody tr:hover { background: #f9fbfd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-main { display: block; color: var(--ink); font-weight: 700; }
.cell-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.amount { white-space: nowrap; font-weight: 800; color: var(--blue-dark); }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.success { color: #0b6a3a; background: #dcf6e8; }
.badge.danger { color: #aa1d2e; background: #ffe4e8; }
.badge.warning { color: #89530a; background: #fff1c2; }
.badge.info { color: #0b568e; background: #dceffc; }
.badge.neutral { color: #526273; background: #edf1f5; }

.button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 750;
    white-space: nowrap;
}
.button:hover { filter: brightness(.97); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { background: var(--blue); color: #fff; }
.button.danger { background: var(--red); color: #fff; }
.button.warning { background: var(--yellow); color: #473600; }
.button.success { background: var(--green); color: #fff; }
.button.outline { border-color: var(--line); color: var(--blue-dark); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button.full { width: 100%; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)) auto; gap: 10px; align-items: end; }
.field, label { display: block; color: #526477; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea, label input, label select, label textarea {
    width: 100%;
    min-height: 40px;
    margin-top: 5px;
    padding: 8px 10px;
    border: 1px solid #cfd9e3;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    outline: none;
}
textarea { resize: vertical; }
.field input:focus, .field select:focus, label input:focus, label select:focus, label textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,83,155,.1); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; min-height: 40px; }
.check input { width: 18px; min-height: 18px; margin: 0; }

.alert { padding: 11px 13px; border-radius: 6px; margin-bottom: 12px; font-weight: 650; }
.alert.success { color: #0d6238; background: #def5e8; border: 1px solid #b9e8cf; }
.alert.danger { color: #9c1c2d; background: #ffe8eb; border: 1px solid #ffc6ce; }
.alert.warning { color: #76500a; background: #fff4cf; border: 1px solid #ffe18a; }
.alert.info { color: #0b568e; background: #e1f1fc; border: 1px solid #bedff5; }

.empty-state { padding: 44px 18px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--blue-dark); display: block; margin-bottom: 5px; }
.pagination { display: flex; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.pagination .active { background: var(--blue); color: #fff; border-color: var(--blue); }

.quick-list { list-style: none; margin: 0; padding: 0; }
.quick-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf1f5; }
.quick-list li:last-child { border: 0; }
.quick-list strong { display: block; }
.quick-list span { color: var(--muted); font-size: 12px; }
.progress { height: 8px; background: #eaf0f6; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue); border-radius: inherit; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(4, 31, 57, .62); }
.modal-backdrop.open { display: flex; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 8px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-footer { border: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px; }
.modal-close { border: 0; background: transparent; font-size: 22px; cursor: pointer; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; color: #fff; background: var(--ink); border-radius: 7px; box-shadow: 0 10px 32px rgba(0,0,0,.18); }
.toast.success { background: var(--green); }
.toast.danger { background: var(--red); }

.auth-body { background: #edf4fa; }
.auth-shell, .install-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, 1fr) minmax(390px, 560px); }
.auth-brand { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: clamp(32px, 6vw, 90px); background: var(--blue-dark); color: #fff; border-bottom: 6px solid var(--yellow); }
.auth-brand img { width: 190px; background: #fff; padding: 12px; border-radius: 8px; }
.auth-brand p { margin: 28px 0 0; color: var(--yellow); font-weight: 900; text-transform: uppercase; }
.auth-brand h1 { margin: 8px 0; max-width: 610px; font-size: 38px; line-height: 1.1; }
.auth-brand span { max-width: 530px; color: #cce2f5; font-size: 16px; }
.auth-card { align-self: center; width: min(420px, calc(100% - 40px)); margin: 30px auto; padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 60px rgba(11, 62, 105, .12); }
.install-card { width: min(520px, calc(100% - 40px)); }
.auth-card h2 { margin: 0 0 4px; color: var(--blue-dark); }
.auth-card > p { margin: 0 0 22px; color: var(--muted); }
.auth-card form { display: grid; gap: 14px; }
.step-indicator { display: flex; gap: 10px; margin-bottom: 24px; }
.step-indicator span { flex: 1; padding: 8px; color: #7d8b99; border-bottom: 3px solid #dbe3eb; font-size: 11px; text-align: center; }
.step-indicator .active { color: var(--blue-dark); border-color: var(--blue); font-weight: 800; }

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-grid { grid-template-columns: 1fr; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-shell { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .topbar { height: 64px; padding: 0 16px; }
    .topbar-title p { display: none; }
    .content { padding: 18px 14px 32px; }
    .brand-rule { margin: -18px -14px 18px; }
    .auth-shell, .install-shell { grid-template-columns: 1fr; }
    .auth-brand { min-height: 260px; padding: 34px 24px; }
    .auth-brand img { width: 150px; }
    .auth-brand p { margin-top: 18px; }
    .auth-brand h1 { font-size: 28px; }
}

@media (max-width: 560px) {
    .stats-grid, .form-grid, .filters { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .panel-header { align-items: flex-start; flex-direction: column; }
    .topbar-actions .button:not(.menu-toggle) { display: none; }
    .auth-card { padding: 22px; }
    .button.mobile-full { width: 100%; }
}

