:root {
    --bg: #f4f7fb;
    --ink: #0f1d2a;
    --muted: #5b6b7b;
    --brand: #0b6e99;
    --brand-strong: #0a5373;
    --surface: #ffffff;
    --line: #d8e0e8;
    --success: #1f8b4c;
    --danger: #c62839;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, #d9f2ff 0%, rgba(217, 242, 255, 0) 40%),
        radial-gradient(circle at 90% 100%, #ffe8d1 0%, rgba(255, 232, 209, 0) 50%),
        var(--bg);
}

.bg-shape {
    position: fixed;
    z-index: -1;
    border-radius: 999px;
    filter: blur(60px);
    opacity: 0.35;
}

.bg-shape-a {
    width: 220px;
    height: 220px;
    background: #8bd3f7;
    top: -40px;
    left: -50px;
}

.bg-shape-b {
    width: 280px;
    height: 280px;
    background: #ffc17c;
    right: -70px;
    bottom: -80px;
}

.topbar {
    background: rgba(10, 27, 39, 0.9);
    backdrop-filter: blur(6px);
    color: #fff;
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.welcome {
    font-size: 14px;
    color: #d3e6f2;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert-error {
    background: #ffe8eb;
    border: 1px solid #ffc6ce;
    color: #8e1624;
}

.alert-success {
    background: #e4f9ec;
    border: 1px solid #bceecf;
    color: #106f38;
}

.auth-card,
.panel-shell .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 24px rgba(10, 26, 39, 0.07);
}

.auth-card {
    width: min(480px, 100%);
    margin: 36px auto 0;
}

h1, h2, h3 {
    margin-top: 0;
    line-height: 1.2;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 18px;
    margin-bottom: 12px;
    margin-top: 26px;
}

.muted {
    color: var(--muted);
    margin-top: -6px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.tab-btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 12px;
    text-decoration: none;
    border: 1px solid var(--line);
    color: var(--ink);
    background: #fff;
    font-weight: 600;
}

.tab-btn.is-active {
    color: #fff;
    background: linear-gradient(120deg, var(--brand), var(--brand-strong));
    border-color: transparent;
}

.tab-pane {
    display: none;
}

.tab-pane.is-active {
    display: block;
}

.obsidian-placeholder {
    margin-top: 18px;
    border-radius: 14px;
    background: linear-gradient(120deg, #eff8ff, #fff7ef);
    border: 1px solid #d8e6f2;
    padding: 16px;
}

.obsidian-placeholder ul {
    margin: 12px 0 0 18px;
    padding: 0;
}

.form-grid {
    display: grid;
    gap: 10px;
}

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

label {
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

input:focus {
    outline: 2px solid #8cd5ff;
    border-color: #8cd5ff;
}

.checkbox-wrap {
    display: flex;
    align-items: end;
    padding-bottom: 8px;
}

.form-actions {
    display: flex;
    align-items: end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(120deg, var(--brand), var(--brand-strong));
}

.btn-ghost {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.hint-box {
    margin-top: 14px;
    border-radius: 10px;
    border: 1px dashed #b8c8d8;
    background: #f8fbff;
    padding: 10px 12px;
    font-size: 14px;
    color: #2c3d4d;
}

.subtabs {
    display: flex;
    gap: 8px;
    margin: 16px 0 14px;
    flex-wrap: wrap;
}

.calc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
    gap: 16px;
}

.calc-main,
.calc-side {
    min-width: 0;
}

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

.calc-section {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fbfdff;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.section-head h3 {
    margin: 0;
}

.mini-note {
    color: var(--muted);
    font-size: 13px;
}

.quick-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-soft {
    background: #edf6fc;
    color: #1a4d69;
    border: 1px solid #c8deed;
    font-weight: 600;
}

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

.metric-card {
    border: 1px solid #e3ebf2;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

.full-card {
    grid-column: 1 / -1;
}

.metric-card label {
    display: block;
    margin-bottom: 7px;
}

.metric-inputs {
    display: grid;
    grid-template-columns: 1fr 96px;
    gap: 10px;
    align-items: center;
}

.metric-range {
    width: 100%;
}

.metric-number {
    text-align: center;
    font-weight: 700;
}

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

.action-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.subtab-btn {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink);
    background: #fff;
    font-weight: 600;
}

.subtab-btn.is-active {
    color: #fff;
    background: linear-gradient(120deg, #1c8fbe, #0a5373);
    border-color: transparent;
}

.full-col {
    grid-column: 1 / -1;
}

.custom-total {
    color: #3e5266;
    font-size: 14px;
}

.custom-total strong {
    font-size: 16px;
}

.score-card {
    margin-top: 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 16px;
}

.guide-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(175deg, #f8fbff, #fffdf8);
}

.guide-card h3 {
    margin: 0 0 8px;
}

.guide-card details {
    border: 1px solid #dbe7f2;
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
    margin-top: 10px;
}

.guide-card summary {
    cursor: pointer;
    font-weight: 700;
}

.guide-card p {
    margin: 8px 0 0;
    font-size: 14px;
}

.score-value {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    margin-top: 6px;
    font-weight: 700;
}

.score-note {
    margin-bottom: 0;
    color: #30485b;
}

.status-green {
    border-color: #b6e7ca;
    background: #e8f9ef;
}

.status-yellow {
    border-color: #ffe4a6;
    background: #fff7e4;
}

.status-orange {
    border-color: #ffd2a6;
    background: #fff0e4;
}

.status-red {
    border-color: #ffc6ce;
    background: #ffe8eb;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    font-size: 14px;
    vertical-align: top;
}

.inline-form {
    display: flex;
    gap: 6px;
    min-width: 280px;
}

.inline-form input {
    min-width: 90px;
}

.owner-note {
    font-size: 13px;
    color: #5b6b7b;
}

.resumen-module {
    margin-top: 16px;
    display: grid;
    gap: 16px;
}

.resumen-title-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    width: fit-content;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #bddbe8;
    background: #eef9ff;
    color: #17425a;
    font-size: 13px;
    font-weight: 700;
}

.resumen-ui {
    --r-bg: #f6fbff;
    --r-ink: #102533;
    --r-muted: #5a7081;
    --r-line: #c9dcea;
    --r-primary: #0f8f8d;
    --r-primary-strong: #0a6d83;
    --r-accent: #ec7a3f;
    --r-soft: #eaf7ff;
    --r-pos: #117a52;
    --r-neg: #a33341;
    --r-shadow: 0 16px 30px rgba(9, 39, 57, 0.10);
    color: var(--r-ink);
    font-family: "Space Grotesk", "Manrope", sans-serif;
}

.resumen-intro {
    border: 1px solid var(--r-line);
    border-radius: 18px;
    background:
        radial-gradient(circle at 10% 10%, rgba(15, 143, 141, 0.22), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(236, 122, 63, 0.18), transparent 35%),
        linear-gradient(130deg, rgba(15, 143, 141, 0.09), rgba(10, 109, 131, 0.06)),
        #fff;
    padding: 18px;
    box-shadow: var(--r-shadow);
}

.resumen-ui .btn {
    border-radius: 12px;
    font-weight: 800;
}

.resumen-ui .btn-primary {
    background: linear-gradient(125deg, var(--r-primary), var(--r-primary-strong));
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.resumen-ui .btn-ghost {
    border-color: var(--r-line);
    color: #17374a;
    background: #fff;
}

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

.resumen-box {
    border: 1px solid var(--r-line);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, var(--r-bg));
    padding: 16px;
    box-shadow: var(--r-shadow);
}

.resumen-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    letter-spacing: 0.01em;
}

.no-top {
    margin-top: 0;
}

.tiny {
    font-size: 13px;
    color: var(--r-muted);
}

.money-positive {
    color: var(--r-pos);
    font-weight: 700;
}

.money-negative {
    color: var(--r-neg);
    font-weight: 700;
}

.btn-mini {
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.1;
}

.btn-danger {
    border-color: #f8c3b9;
    color: #8a2f2f;
    background: #fff2ee;
}

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

.person-card {
    display: grid;
    gap: 6px;
    text-decoration: none;
    color: var(--r-ink);
    border: 1px solid #d2e3ef;
    background:
        radial-gradient(circle at 90% 15%, rgba(15, 143, 141, 0.09), transparent 45%),
        #fff;
    border-radius: 16px;
    padding: 14px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.person-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 26px rgba(10, 50, 76, 0.14);
    border-color: #a5cfe5;
}

.person-name {
    font-size: 17px;
    font-weight: 800;
}

.person-meta {
    font-size: 13px;
    color: var(--r-muted);
}

.person-tag {
    display: inline-flex;
    width: fit-content;
    padding: 2px 9px;
    border-radius: 999px;
    background: #edf6ff;
    border: 1px solid #c7ddef;
    color: #32566f;
    font-size: 12px;
    font-weight: 700;
}

.person-balance {
    font-size: 15px;
    font-weight: 700;
}

.resumen-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.resumen-detail-card {
    border: 1px solid #bfd9e8;
    border-radius: 18px;
    background:
        radial-gradient(circle at 14% 15%, rgba(15, 143, 141, 0.20), transparent 38%),
        linear-gradient(125deg, rgba(15, 143, 141, 0.10), rgba(236, 122, 63, 0.08)),
        #fff;
    padding: 14px;
    box-shadow: var(--r-shadow);
}

.resumen-table {
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
}

.resumen-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--r-soft);
    color: #17374a;
    font-weight: 800;
    border-bottom: 1px solid #c9deeb;
}

.resumen-table th,
.resumen-table td {
    border-bottom: 1px solid #d9e7f1;
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 13px;
    line-height: 1.25;
}

.resumen-table tbody tr:nth-child(odd) {
    background: #fcfeff;
}

.resumen-table tbody tr:nth-child(even) {
    background: #f8fcff;
}

.resumen-table tbody tr:hover {
    background: #edf7ff;
}

.resumen-table tbody tr.is-resumen-row {
    background: linear-gradient(90deg, rgba(236, 122, 63, 0.14), rgba(15, 143, 141, 0.10));
}

.resumen-table tbody tr.is-resumen-row:hover {
    background: linear-gradient(90deg, rgba(236, 122, 63, 0.18), rgba(15, 143, 141, 0.12));
}

.resumen-cut-info {
    margin-top: 4px;
    display: grid;
    gap: 2px;
    font-size: 11px;
    font-weight: 600;
    color: #3d5264;
}

.resumen-filter-bar {
    margin-bottom: 8px;
    align-items: end;
    grid-template-columns: minmax(0, 190px) minmax(0, 190px) minmax(0, 1fr) auto;
}

.resumen-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.resumen-section-head h3 {
    margin: 0;
}

.resumen-filter-bar .action-bar {
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.resumen-filter-bar .btn-mini {
    min-height: 34px;
}

.import-inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.import-inline-form input[type="file"] {
    max-width: 170px;
    font-size: 12px;
    border: 1px solid #c9dce8;
    border-radius: 10px;
    padding: 5px 8px;
    background: #fff;
}

.date-proxy-wrap {
    position: relative;
}

.date-proxy-display {
    width: 100%;
    border: 1px solid #c9dce8;
    border-radius: 12px;
    padding: 11px 42px 11px 12px;
    background: #fff;
    color: #17374a;
    font: inherit;
}

.date-proxy-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px;
}

.date-proxy-native {
    position: absolute;
    right: 10px;
    top: 50%;
    width: 26px;
    height: 26px;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
}

.date-proxy-wrap:focus-within .date-proxy-display {
    outline: 2px solid rgba(15, 143, 141, 0.28);
    border-color: #63b7c8;
}

.resumen-type-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.type-switch-btn {
    border: 1px solid #c5d9e7;
    border-radius: 11px;
    background: #fff;
    color: #23445a;
    font: inherit;
    font-weight: 700;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 150ms ease;
}

.type-switch-btn:hover {
    border-color: #86bed7;
    background: #f1faff;
}

.type-switch-btn.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(125deg, var(--r-primary), var(--r-primary-strong));
    box-shadow: 0 8px 18px rgba(10, 93, 119, 0.24);
}

.tipo-help {
    margin: -4px 0 2px;
    display: none;
}

.is-quick-active {
    background: #dff1ff !important;
    border-color: #8fc1df !important;
    color: #123f5a !important;
}

@media print {
    .topbar,
    .tabs,
    .resumen-print .btn,
    .resumen-print .resumen-filter-bar,
    .resumen-print .resumen-modal,
    .resumen-print .action-bar,
    .resumen-print .resumen-title-chip {
        display: none !important;
    }

    .resumen-print .resumen-print-head {
        display: flex;
        gap: 14px;
        align-items: center;
        flex-wrap: wrap;
        margin: 2px 0 8px;
        font-size: 12px;
    }

    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .resumen-print .resumen-box,
    .resumen-print .resumen-detail-card {
        border: 1px solid #bbb;
        box-shadow: none;
        background: #fff !important;
        margin: 0;
        padding: 6px;
    }

    .resumen-print .resumen-table th,
    .resumen-print .resumen-table td {
        font-size: 11px;
        padding: 4px 5px;
        color: #000 !important;
    }

    .resumen-print h2 {
        margin: 0 0 6px !important;
        font-size: 24px;
    }

    .resumen-print h3 {
        margin: 0 0 4px !important;
        font-size: 14px;
    }
}

.resumen-modal {
    border: none;
    padding: 0;
    background: transparent;
    width: min(540px, calc(100% - 24px));
    max-width: 540px;
    overflow: visible;
}

.resumen-modal-card {
    width: 100%;
    border-radius: 20px;
    border: 1px solid #b8d7e7;
    background:
        radial-gradient(circle at 90% 10%, rgba(236, 122, 63, 0.12), transparent 35%),
        linear-gradient(180deg, rgba(247, 253, 255, 0.96), #ffffff 62%);
    padding: 20px;
    box-shadow: 0 24px 48px rgba(7, 24, 36, 0.26);
    animation: resumen-pop 180ms ease-out;
}

.resumen-ui input[type="text"],
.resumen-ui input[type="number"],
.resumen-ui input[type="date"],
.resumen-ui select {
    border: 1px solid #c9dce8;
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
}

.resumen-ui input:focus,
.resumen-ui select:focus {
    outline: 2px solid rgba(15, 143, 141, 0.28);
    border-color: #63b7c8;
}

.resumen-modal::backdrop {
    background:
        radial-gradient(circle at 18% 20%, rgba(15, 143, 141, 0.25), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(236, 122, 63, 0.18), transparent 35%),
        rgba(6, 15, 22, 0.62);
}

@keyframes resumen-pop {
    from {
        transform: translateY(10px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@media (max-width: 860px) {
    .calc-layout {
        grid-template-columns: 1fr;
    }

    .custom-grid,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

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

    .form-actions,
    .checkbox-wrap {
        padding-bottom: 0;
    }

    .resumen-grid {
        grid-template-columns: 1fr;
    }

    .resumen-filter-bar {
        grid-template-columns: 1fr;
    }

    .resumen-section-head {
        flex-wrap: wrap;
    }

    .person-grid {
        grid-template-columns: 1fr;
    }

    .form-actions.full-col {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}

@media (max-width: 680px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .inline-form {
        flex-direction: column;
        min-width: 230px;
    }

    .auth-card,
    .panel-shell .card {
        padding: 16px;
        border-radius: 14px;
    }

    .metric-inputs {
        grid-template-columns: 1fr 82px;
    }

    .action-bar {
        flex-direction: column;
    }
}
