:root {
    --ink: #102238;
    --ink-soft: #536274;
    --line: #e4eaf0;
    --paper: #ffffff;
    --canvas: #f5f7fa;
    --navy: #0d2138;
    --navy-2: #17344f;
    --accent: #2d6f73;
    --good: #257a55;
    --watch: #9c6d16;
    --critical: #a84444;
    --positive-bg: #edf7f1;
    --watch-bg: #fbf5e8;
    --critical-bg: #fbefef;
    --shadow: 0 14px 34px rgba(24, 43, 65, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--canvas);
}

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

button,
input,
select {
    font: inherit;
}

a {
    color: inherit;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: linear-gradient(180deg, var(--navy), #0a1a2b);
    color: #fff;
    padding: 26px 18px 20px;
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 26px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #fff;
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 850;
    letter-spacing: -0.04em;
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 15px;
    letter-spacing: 0.08em;
}

.brand div > span {
    font-size: 11px;
    letter-spacing: 0.22em;
    opacity: 0.68;
}

.side-nav {
    display: grid;
    gap: 6px;
}

.nav-item {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 11px;
    border-radius: 12px;
    padding: 11px 12px;
    color: rgba(255,255,255,0.76);
    font-size: 14px;
    font-weight: 650;
    transition: 0.18s ease;
}

.nav-item:hover,
.nav-item.active {
    color: #fff;
    background: rgba(255,255,255,0.10);
}

.nav-item.active {
    box-shadow: inset 3px 0 0 #7fc5c0;
}

.nav-icon {
    width: 22px;
    text-align: center;
    opacity: 0.9;
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 18px;
}

.client-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.client-mini strong,
.client-mini span {
    display: block;
}

.client-mini strong {
    font-size: 12px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-mini div > span {
    color: rgba(255,255,255,0.55);
    font-size: 10px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    font-weight: 800;
}

.logout-link {
    display: inline-flex;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 12px;
    padding: 6px 0;
}

.main-panel {
    margin-left: 250px;
    min-width: 0;
}

.topbar {
    height: 74px;
    padding: 0 30px;
    background: rgba(255,255,255,0.93);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 26px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.menu-toggle {
    display: none;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 24px;
    cursor: pointer;
}

.topbar-context,
.topbar-period {
    min-width: 0;
}

.topbar-context strong,
.topbar-period strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-context {
    max-width: 340px;
}

.topbar-period {
    margin-left: auto;
    max-width: 300px;
}

.eyebrow {
    display: block;
    font-size: 10px;
    color: #8090a2;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-weight: 800;
    margin-bottom: 2px;
}

.topbar-badge,
.period-chip,
.demo-chip {
    border: 1px solid var(--line);
    background: #f7fafc;
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 11px;
    font-weight: 800;
    color: #536274;
    white-space: nowrap;
}

.content {
    padding: 32px;
    max-width: 1540px;
    margin: 0 auto;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-heading h1 {
    font-size: clamp(27px, 3vw, 38px);
    margin: 2px 0 0;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

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

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

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

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

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

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 20px;
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-label {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
}

.metric-value {
    font-size: clamp(24px, 2.5vw, 32px);
    font-weight: 820;
    letter-spacing: -0.035em;
    margin-top: 10px;
}

.metric-note {
    margin-top: 7px;
    font-size: 11px;
    color: #8794a3;
}

.status-card {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.status-card strong {
    font-size: 13px;
}

.status-pill {
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.good {
    background: var(--positive-bg);
    color: var(--good);
}

.status-pill.watch {
    background: var(--watch-bg);
    color: var(--watch);
}

.status-pill.critical {
    background: var(--critical-bg);
    color: var(--critical);
}

.section {
    margin-top: 22px;
}

.section-card {
    padding: 22px;
}

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

.section-header h2,
.section-header h3 {
    margin: 0;
    letter-spacing: -0.02em;
}

.section-header h2 {
    font-size: 19px;
}

.section-header p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 12px;
}

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

.chart-box.compact {
    height: 270px;
}

.gps-chart {
    width: 100%;
    height: 100%;
    display: block;
}

.control,
.control-inline {
    display: grid;
    gap: 6px;
}

.control label,
.form-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--ink-soft);
}

select,
input[type="number"],
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d8e0e8;
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    padding: 9px 12px;
    outline: none;
}

select:focus,
input:focus {
    border-color: #6e9b9c;
    box-shadow: 0 0 0 3px rgba(45,111,115,0.10);
}

.control-inline {
    min-width: 220px;
}

.legend-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--ink-soft);
    font-size: 11px;
    margin-top: 12px;
}

.legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
    background: #244f6d;
}

.legend-dot.forecast {
    background: #bfcbd6;
}

.table-wrap {
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.data-table th {
    font-size: 10px;
    color: #7f8d9d;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #fafbfd;
}

.data-table td:last-child,
.data-table th:last-child {
    text-align: right;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tr.strong td {
    font-weight: 850;
    background: #f4f8fa;
}

.data-table tr.subtotal td {
    font-weight: 750;
}

.negative {
    color: var(--critical);
}

.positive {
    color: var(--good);
}

.select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.kpi-detail {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
}

.kpi-summary {
    padding: 22px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.kpi-big {
    font-size: 44px;
    font-weight: 850;
    letter-spacing: -0.05em;
    margin: 10px 0 4px;
}

.kpi-description {
    color: var(--ink-soft);
    font-size: 13px;
}

.threshold-box {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.threshold-box span {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8291a0;
    font-weight: 800;
}

.threshold-box strong {
    display: block;
    margin-top: 5px;
    font-size: 13px;
}

.cash-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.cash-row:last-child {
    border-bottom: 0;
}

.cash-row strong {
    font-size: 13px;
}

.cash-row span {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.cash-row.emphasis {
    margin: 4px -10px;
    padding: 14px 10px;
    border-radius: 10px;
    background: #f7fafc;
    border-bottom: 0;
}

.progress-card {
    padding: 18px;
}

.progress-card strong {
    display: block;
    margin-top: 7px;
    font-size: 22px;
}

.progress-track {
    height: 9px;
    background: #edf1f4;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 14px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1c4867, #2d6f73);
    border-radius: inherit;
}

.form-card {
    padding: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.form-grid.forecast {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.button {
    min-height: 44px;
    border: 0;
    border-radius: 11px;
    padding: 10px 15px;
    background: var(--navy);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    cursor: pointer;
}

.button.secondary {
    background: #eef3f5;
    color: var(--ink);
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.notice {
    border-left: 4px solid #2d6f73;
    background: #edf6f6;
    border-radius: 10px;
    padding: 12px 14px;
    color: #38575e;
    font-size: 12px;
}

.scenario-grid {
    display: grid;
    grid-template-columns: 1.15fr repeat(3, minmax(120px, 0.9fr));
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.scenario-cell {
    padding: 13px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
    font-size: 12px;
}

.scenario-cell:nth-child(4n) {
    border-right: 0;
}

.scenario-cell.header {
    background: #f7f9fb;
    font-weight: 850;
}

.scenario-cell.value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.scenario-grid > :nth-last-child(-n+4) {
    border-bottom: 0;
}

.forecast-list {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.forecast-row {
    display: grid;
    grid-template-columns: 1.2fr repeat(4, 1fr);
    gap: 8px;
    padding: 11px 12px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 11px;
}

.mobile-overlay {
    display: none;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(45,111,115,0.18), transparent 35%),
        linear-gradient(135deg, #081a2d, #102d48 55%, #12343d);
}

.login-shell {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    background: rgba(255,255,255,0.98);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.24);
}

.login-visual {
    padding: 48px;
    color: #fff;
    background:
        linear-gradient(160deg, rgba(10,28,48,0.95), rgba(28,83,90,0.95)),
        #0f273e;
    display: flex;
    flex-direction: column;
    min-height: 540px;
}

.login-visual .brand {
    padding-left: 0;
}

.login-visual h1 {
    margin: auto 0 12px;
    font-size: 44px;
    line-height: 0.98;
    letter-spacing: -0.05em;
}

.login-visual p {
    margin: 0;
    max-width: 420px;
    color: rgba(255,255,255,0.72);
}

.login-form-wrap {
    padding: 48px;
    align-self: center;
}

.login-form-wrap h2 {
    margin: 0 0 8px;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.login-form-wrap > p {
    color: var(--ink-soft);
    margin: 0 0 24px;
    font-size: 13px;
}

.login-form {
    display: grid;
    gap: 14px;
}

.error-box {
    background: var(--critical-bg);
    color: var(--critical);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 12px;
}

.login-foot {
    margin-top: 18px;
    font-size: 11px;
    color: #8a96a3;
}

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

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

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

@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-104%);
        transition: transform 0.22s ease;
        width: min(84vw, 290px);
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(5,16,27,0.45);
    }

    body.menu-open .mobile-overlay {
        display: block;
    }

    .main-panel {
        margin-left: 0;
    }

    .topbar {
        padding: 0 18px;
        gap: 14px;
    }

    .menu-toggle {
        display: block;
    }

    .topbar-period {
        display: none;
    }

    .content {
        padding: 24px 18px 34px;
    }

    .kpi-detail {
        grid-template-columns: 1fr;
    }

    .login-shell {
        grid-template-columns: 1fr;
        max-width: 520px;
    }

    .login-visual {
        min-height: auto;
        padding: 28px;
    }

    .login-visual h1,
    .login-visual p {
        display: none;
    }

    .login-form-wrap {
        padding: 30px;
    }
}

@media (max-width: 640px) {
    .page-heading {
        align-items: flex-start;
    }

    .period-chip {
        display: none;
    }

    .grid-kpi,
    .grid-status,
    .grid-2,
    .grid-3,
    .select-row,
    .form-grid,
    .form-grid.forecast {
        grid-template-columns: 1fr;
    }

    .topbar-badge {
        margin-left: auto;
    }

    .topbar-context {
        max-width: 175px;
    }

    .section-card,
    .form-card {
        padding: 17px;
    }

    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .control-inline {
        width: 100%;
        min-width: 0;
    }

    .chart-box {
        height: 300px;
    }

    .table-wrap {
        border: 0;
        overflow: visible;
        background: transparent;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 5px 12px;
        margin-bottom: 9px;
        box-shadow: 0 7px 18px rgba(24,43,65,0.04);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
        text-align: right;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        text-align: left;
        color: var(--ink-soft);
        font-size: 10px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .data-table tr.strong td,
    .data-table tr.subtotal td {
        background: transparent;
    }

    .scenario-grid {
        grid-template-columns: 1fr;
        border: 0;
        gap: 10px;
    }

    .scenario-cell {
        border: 1px solid var(--line);
        border-radius: 10px;
        text-align: left !important;
    }

    .scenario-cell.header:not(:first-child) {
        display: none;
    }

    .scenario-cell.row-label {
        font-weight: 850;
        background: #f5f8fa;
        margin-top: 7px;
    }

    .scenario-cell.value::before {
        content: attr(data-scenario) ": ";
        font-weight: 850;
        color: var(--ink-soft);
    }

    .forecast-row {
        grid-template-columns: 1fr 1fr;
    }

    .login-body {
        padding: 14px;
    }

    .login-form-wrap {
        padding: 24px;
    }
}
