:root {
    --bg: #f5f7fb;
    --bg-accent: #e9eef5;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: #ffffff;
    --line: rgba(15, 23, 42, 0.10);
    --line-soft: rgba(15, 23, 42, 0.06);
    --ink: #111827;
    --muted: #6b7280;
    --accent: #274c77;
    --accent-strong: #17324d;
    --accent-soft: rgba(39, 76, 119, 0.10);
    --teal: #0f766e;
    --green: #15803d;
    --red: #b91c1c;
    --amber: #b7791f;
    --radius: 24px;
    --radius-sm: 16px;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.04);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 23, 42, 0.03) 0%, rgba(15, 23, 42, 0) 30%),
        linear-gradient(180deg, #fbfcfe 0%, var(--bg) 52%, var(--bg-accent) 100%);
}

.shell {
    width: min(1400px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 46px;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: "DM Sans", "Plus Jakarta Sans", sans-serif;
    letter-spacing: -0.04em;
}

h1 {
    font-size: clamp(2.2rem, 4vw, 3.2rem);
    line-height: 0.95;
    font-weight: 700;
}

h2 {
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    line-height: 1.02;
    font-weight: 700;
}

h3 {
    font-size: 1.05rem;
    line-height: 1.1;
    font-weight: 700;
}

.hero-copy,
.muted {
    color: var(--muted);
}

.panel,
.metric,
.projection-card {
    background: var(--panel);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
    margin-bottom: 20px;
}

.section-tag {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.7rem;
    color: var(--accent-strong);
    font-weight: 800;
}

.topbar,
.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.topbar {
    margin-bottom: 20px;
}

.topbar-actions,
.form-actions,
.inline-form,
.auth-form,
.catalog-row,
.user-editor-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.panel-heading {
    margin-bottom: 18px;
    align-items: end;
}

.user-pill {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(183, 121, 31, 0.10);
    color: var(--accent-strong);
    border: 1px solid rgba(39, 76, 119, 0.10);
    font-weight: 700;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.metric {
    padding: 20px;
    position: relative;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric strong {
    font-size: 1.7rem;
    font-weight: 700;
}

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

.field-wide {
    grid-column: span 2;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
button,
a.button-secondary {
    font: inherit;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: rgba(17, 24, 39, 0.18);
    box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.06);
}

button,
.button-secondary {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:hover,
.button-secondary:hover {
    transform: translateY(-1px);
}

button {
    background: linear-gradient(135deg, #17324d 0%, #274c77 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(39, 76, 119, 0.18);
}

.button-secondary {
    background: rgba(39, 76, 119, 0.08);
    color: var(--accent);
    border: 1px solid rgba(39, 76, 119, 0.12);
    box-shadow: var(--shadow-soft);
}

.button-small {
    display: inline-block;
    padding: 9px 14px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.button-danger {
    background: rgba(185, 28, 28, 0.08);
    color: var(--red);
}

.panel-anchor {
    scroll-margin-top: 18px;
}

.table-wrap,
.projection-matrix-wrap {
    overflow: auto;
    border: 1px solid rgba(39, 76, 119, 0.12);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.78);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
}

th {
    color: #4b5563;
    font-weight: 700;
    background: rgba(249, 250, 251, 0.92);
}

.projection-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(246, 248, 252, 0.96) 100%);
}

.projection-heading {
    margin-bottom: 20px;
}

.projection-filter-form {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

.projection-filter-form label {
    min-width: 220px;
}

.projection-matrix {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.94rem;
}

.projection-matrix th,
.projection-matrix td {
    min-width: 110px;
    padding: 9px 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    border-right: 1px solid rgba(15, 23, 42, 0.04);
    text-align: right;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.82);
}

.projection-matrix th:first-child,
.projection-matrix td:first-child {
    position: sticky;
    left: 0;
    min-width: 280px;
    text-align: left;
    background: #fcfdff;
    z-index: 1;
}

.projection-matrix thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 2;
    font-size: 0.84rem;
}

.projection-matrix thead th:first-child {
    z-index: 3;
}

.projection-level-type td {
    font-weight: 700;
    color: var(--accent-strong);
    background: rgba(39, 76, 119, 0.08);
}

.projection-level-responsible td {
    font-weight: 700;
    color: var(--ink);
    background: rgba(15, 118, 110, 0.06);
}

.projection-entity-row td:first-child {
    padding-left: 28px;
}

.projection-total-row td,
.receivables-total-row td {
    font-weight: 700;
    background: rgba(183, 121, 31, 0.10);
}

.amount-negative {
    color: var(--red);
}

.amount-positive {
    color: var(--green);
}

.amount-empty {
    color: transparent;
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(21, 128, 61, 0.08);
    border-color: rgba(21, 128, 61, 0.10);
    color: #116149;
}

.flash-error {
    background: rgba(185, 28, 28, 0.08);
    border-color: rgba(185, 28, 28, 0.10);
    color: #a12626;
}

.auth-panel {
    max-width: 560px;
    margin: 60px auto;
}

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

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

.inline-form-stretch input,
.catalog-row input {
    flex: 1 1 240px;
}

.stack-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.user-editor {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(39, 76, 119, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.74);
}

.category-warning {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(183, 121, 31, 0.18);
    background: rgba(183, 121, 31, 0.10);
    color: #8a6116;
}

.donut-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.donut-card {
    padding: 20px;
    border: 1px solid rgba(39, 76, 119, 0.12);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.90) 0%, rgba(250, 251, 253, 0.96) 100%);
    box-shadow: var(--shadow-soft);
}

.donut-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.donut-card-header h3 {
    margin: 0 0 6px;
}

.donut-card-header p,
.empty-copy,
.donut-legend-values span {
    margin: 0;
    color: var(--muted);
}

.donut-card-header strong {
    font-size: 1.15rem;
    color: var(--accent-strong);
    white-space: nowrap;
}

.donut-visual-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.donut-chart {
    position: relative;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-hole {
    position: absolute;
    inset: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px;
    text-align: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.donut-hole span {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
}

.donut-hole strong {
    font-size: 1.06rem;
}

.donut-legend {
    display: grid;
    gap: 10px;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

.donut-legend-label,
.donut-legend-values {
    display: flex;
    align-items: center;
    gap: 10px;
}

.donut-legend-values {
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    text-align: right;
}

.donut-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex-shrink: 0;
}

@media (max-width: 1180px) {
    .donut-grid,
    .triple-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .triple-panels {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .metrics,
    .movement-form,
    .user-editor {
        grid-template-columns: 1fr 1fr;
    }

    .dual-panels {
        grid-template-columns: 1fr;
    }

    .topbar,
    .panel-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .projection-filter-form label {
        min-width: 100%;
    }

    .projection-filter-form button,
    .topbar-actions .button-secondary,
    .topbar-actions .user-pill {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .table-wrap,
    .projection-matrix-wrap {
        margin-inline: -6px;
    }
}

@media (max-width: 700px) {
    .triple-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body {
        background: linear-gradient(180deg, #fcfdff 0%, #f1f5f9 100%);
    }

    .shell {
        width: min(100%, calc(100% - 16px));
        padding: 16px 0 28px;
    }

    .panel {
        padding: 16px;
        border-radius: 18px;
    }

    .section-tag {
        font-size: 0.68rem;
        letter-spacing: 0.14em;
    }

    .topbar {
        gap: 14px;
        margin-bottom: 16px;
    }

    .topbar-actions,
    .projection-filter-form,
    .inline-form {
        width: 100%;
    }

    .topbar-actions > *,
    .projection-filter-form > *,
    .inline-form > * {
        width: 100%;
    }

    .metrics,
    .movement-form,
    .user-editor {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .field-wide {
        grid-column: span 1;
    }

    .metric {
        padding: 16px;
    }

    .metric strong {
        font-size: 1.35rem;
    }

    input,
    select,
    button,
    .button-secondary {
        min-height: 46px;
    }

    .projection-matrix th,
    .projection-matrix td,
    th,
    td {
        padding: 10px;
        font-size: 0.92rem;
    }

    .projection-matrix th:first-child,
    .projection-matrix td:first-child {
        min-width: 180px;
    }

    table {
        min-width: 760px;
    }

    .button-small {
        width: 100%;
        text-align: center;
    }

    .donut-card {
        padding: 16px;
    }

    .donut-card-header {
        flex-direction: column;
    }

    .donut-chart {
        width: 180px;
        height: 180px;
    }

    .donut-hole {
        inset: 24px;
        padding: 14px;
    }

    .donut-legend-row {
        align-items: flex-start;
    }
}

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

.trend-card {
    padding: 18px;
    border: 1px solid rgba(39, 76, 119, 0.12);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(249, 251, 253, 0.98) 100%);
    box-shadow: var(--shadow-soft);
}

.trend-card-head {
    margin-bottom: 14px;
}

.trend-title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.trend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    margin-top: 6px;
    flex-shrink: 0;
}

.trend-chart {
    width: 100%;
    height: 64px;
    display: block;
    margin-bottom: 14px;
}

.trend-month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 10px;
}

.trend-month-cell {
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

.trend-month-cell span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.trend-month-cell strong {
    font-size: 0.92rem;
}

.trend-table-wrap {
    margin-top: 18px;
}

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

.movements-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.movements-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 20px;
}

.movements-main-card,
.movement-side-card,
.movement-stat-card,
.movement-summary-item {
    border: 1px solid rgba(39, 76, 119, 0.10);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow: var(--shadow-soft);
}

.movements-main-card,
.movement-side-card {
    padding: 20px;
}

.movement-side-stack,
.movement-note-list {
    display: grid;
    gap: 14px;
}

.compact-heading {
    margin-bottom: 16px;
}

.movement-helper {
    max-width: 320px;
    margin: 0;
}

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

.movement-import-form {
    align-items: stretch;
}

.movement-import-form input {
    flex: 1 1 auto;
}

.movement-note-list span {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(39, 76, 119, 0.06);
    color: var(--accent-strong);
    font-weight: 600;
}

.movement-stat-strip,
.movement-summary-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.movement-stat-card,
.movement-summary-item {
    padding: 16px 18px;
}

.movement-stat-card span,
.movement-summary-item span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.movement-stat-card strong,
.movement-summary-item strong {
    font-size: 1.2rem;
}

.movement-table-heading {
    margin-bottom: 16px;
}

.movement-filter-form {
    max-width: 100%;
}

.movement-search-field {
    flex: 1 1 280px;
}

.movement-table-wrap {
    margin-top: 18px;
}

@media (max-width: 1180px) {
    .movements-hero,
    .movements-layout,
    .movement-stat-strip,
    .movement-summary-bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .movements-hero,
    .movements-layout,
    .movement-stat-strip,
    .movement-summary-bar {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .movements-main-card,
    .movement-side-card,
    .movement-stat-card,
    .movement-summary-item {
        border-radius: 18px;
    }

    .movement-form-roomy,
    .movement-stat-strip,
    .movement-summary-bar {
        grid-template-columns: 1fr;
    }
}

.movement-edit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    margin-bottom: 18px;
    border-radius: 18px;
    background: rgba(39, 76, 119, 0.08);
    border: 1px solid rgba(39, 76, 119, 0.12);
}

.movement-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.movement-row-actions form {
    margin: 0;
}

@media (max-width: 640px) {
    .movement-edit-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .movement-row-actions {
        min-width: 170px;
    }
}
