:root {
    --bg: #eef7ff;
    --panel: #ffffff;
    --panel-soft: #f7fbff;
    --primary: #39a3ff;
    --primary-dark: #1464c3;
    --primary-deep: #0d4e98;
    --primary-soft: #d8ecff;
    --text: #183b5b;
    --muted: #6b84a0;
    --border: #d5e6f7;
    --success: #1ea971;
    --warning: #f1a208;
    --danger: #e2574c;
    --shadow: 0 20px 45px rgba(20, 100, 195, 0.08);
    --shadow-soft: 0 12px 28px rgba(20, 100, 195, 0.06);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, #f7fbff 0%, #eef7ff 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

canvas {
    max-width: 100%;
}

.app-shell {
    display: grid;
    grid-template-columns: 310px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #1f7ed7 0%, #0e5eb8 100%);
    color: #fff;
    padding: 26px 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    min-height: 170px;
    padding: 26px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.brand-logo {
    width: min(100%, 240px);
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.nav-menu {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.nav-menu a {
    padding: 15px 18px;
    border-radius: 18px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: #fff;
    color: var(--primary-dark);
    transform: translateX(2px);
}

.sidebar-footer {
    display: grid;
    gap: 14px;
}

.user-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-card span {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.92rem;
}

.content {
    padding: 28px;
}

.topbar {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(239, 247, 255, 0.96) 100%);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 24px 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.topbar h1,
.panel-header h2 {
    margin: 0 0 6px;
}

.topbar h1 {
    font-size: 1.7rem;
    font-weight: 800;
}

.topbar p,
.panel-header span,
.footer p {
    margin: 0;
    color: var(--muted);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 22px;
}

.panel.soft-panel {
    background: linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.cards-grid.compact-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-cards .stat-card {
    min-height: 148px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f3f9ff 100%);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.95rem;
}

.stat-card strong {
    font-size: 2.1rem;
    color: var(--primary-dark);
    line-height: 1;
}

.stat-card small {
    color: var(--muted);
    font-size: 0.84rem;
}

.stat-card.highlight {
    background: linear-gradient(180deg, #eaf5ff 0%, #d8ecff 100%);
}

.stat-card.success-card strong {
    color: var(--success);
}

.stat-card.warning-card strong {
    color: #b56d00;
}

.stat-card.danger-card strong {
    color: var(--danger);
}

.filters-grid,
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}

.filters-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.form-grid.single {
    grid-template-columns: 1fr;
}

.form-grid .full-width,
.filters-grid .full-width {
    grid-column: 1 / -1;
}

label {
    display: inline-block;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 8px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: #f9fcff;
    color: var(--text);
    border-radius: 16px;
    padding: 14px 16px;
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(43, 143, 232, 0.12);
}

textarea {
    resize: vertical;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    padding: 0;
}

.checkbox-row label {
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: var(--primary-dark);
    border: 1px solid var(--border);
}

.btn-danger {
    background: #fff3f2;
    color: var(--danger);
    border: 1px solid #ffd4d0;
}

.btn-sm {
    padding: 9px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.filter-actions,
.form-actions,
.actions-cell {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.table-wrap {
    overflow: auto;
    border: 1px solid #e6eef7;
    border-radius: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
    background: #fff;
}

thead th {
    background: #e6f2ff;
    color: var(--primary-dark);
    font-size: 0.92rem;
    text-align: left;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px;
    border-bottom: 1px solid #e8f0f7;
    vertical-align: top;
}

tbody tr:hover {
    background: #f8fbff;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge.success {
    background: #e8fbf3;
    color: var(--success);
}

.badge.warning {
    background: #fff5e3;
    color: #b56d00;
}

.badge.danger {
    background: #fff0ef;
    color: var(--danger);
}

.alert {
    padding: 14px 18px;
    border-radius: 18px;
    margin-bottom: 18px;
    font-weight: 700;
    border: 1px solid transparent;
}

.alert-success {
    background: #e9fbf1;
    color: var(--success);
    border-color: #c7f1db;
}

.alert-danger {
    background: #fff1ef;
    color: var(--danger);
    border-color: #ffd9d4;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.chart-panel {
    overflow: hidden;
}

.chart-panel.wide {
    grid-column: 1 / -1;
}

.chart-box {
    position: relative;
    width: 100%;
    height: 320px;
}

.chart-box.chart-box-lg {
    height: 380px;
}

.chart-box canvas {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.page-grid {
    display: grid;
    gap: 18px;
}

.page-grid.form-main-layout,
.page-grid.two-cols,
.page-grid.two-cols-fixed {
    grid-template-columns: 1fr;
}

.footer {
    margin-top: 8px;
    padding-bottom: 10px;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #dceeff 0%, #f8fbff 55%, #dceeff 100%);
}

.login-card {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 30px;
    padding: 34px;
}

.login-logo-wrap {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.login-logo {
    width: min(100%, 280px);
    display: block;
    margin: 0 auto;
}

.login-tip {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #eef7ff;
    color: var(--primary-dark);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 26, 49, 0.52);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1200;
}

.modal-overlay.is-open {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 470px;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 28px 70px rgba(10, 43, 84, 0.22);
    border: 1px solid #d8e8f7;
    padding: 26px;
}

.modal-card h3 {
    margin: 0 0 10px;
    font-size: 1.25rem;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

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

@media (max-width: 1280px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .content {
        padding: 18px;
    }

    .filters-grid,
    .filters-grid.compact,
    .form-grid,
    .cards-grid,
    .cards-grid.compact-cards,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 760px;
    }
}

.panel-header-with-actions {
    align-items: flex-start;
}

.badge-neutral {
    background: #eef7ff;
    color: var(--primary-dark);
}

.compact-cards-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.import-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: end;
}

.import-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.import-help {
    background: #eef7ff;
    border: 1px dashed #bfdcf9;
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--primary-dark);
    line-height: 1.6;
}

.xlsx-preview {
    border: 1px solid #d9e8f8;
    border-radius: 20px;
    background: #fff;
    padding: 18px;
}

.xlsx-preview.is-empty {
    background: #f8fbff;
}

.preview-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.preview-pill {
    min-width: 140px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #eef7ff 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.preview-pill strong {
    display: block;
    font-size: 1.4rem;
    color: var(--primary-dark);
}

.preview-pill span {
    color: var(--muted);
    font-size: 0.86rem;
}

.preview-table {
    min-width: 780px;
}

.preview-note,
.table-subtext {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.records-table {
    min-width: 1260px;
}

.records-table td {
    vertical-align: top;
}

@media (max-width: 1024px) {
    .import-grid,
    .compact-cards-4 {
        grid-template-columns: 1fr;
    }
}
