:root {
    color-scheme: light;
    --ink: #111827;
    --muted: #667085;
    --line: #e6e8ef;
    --paper: #ffffff;
    --mist: #f5f7fb;
    --teal: #0f766e;
    --rose: #be123c;
    --gold: #b7791f;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgb(20 184 166 / 0.16), transparent 28rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
    overflow: hidden;
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgb(20 184 166 / 0.28), transparent 24rem),
        linear-gradient(160deg, #08111f 0%, #111827 52%, #0f172a 100%);
    color: white;
}

.login-heading p {
    margin: 0;
    color: #5eead4;
    font-size: 0.82rem;
    font-weight: 950;
    letter-spacing: 0.26em;
    text-transform: uppercase;
}

.login-heading h1 {
    margin: 0.55rem 0 0;
    color: #ffffff;
    font-size: 2.15rem;
    font-weight: 950;
    line-height: 1;
    text-shadow: 0 12px 30px rgb(0 0 0 / 0.32);
}

.login-card {
    border: 1px solid rgb(255 255 255 / 0.12);
    border-radius: 0.95rem;
    background: rgb(255 255 255 / 0.08);
    padding: 1.1rem;
    box-shadow: 0 24px 60px rgb(0 0 0 / 0.28);
    backdrop-filter: blur(18px);
}

.login-card .label {
    color: rgb(226 232 240 / 0.78);
}

svg {
    width: 1.08rem;
    height: 1.08rem;
    stroke-width: 2.35;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid rgb(255 255 255 / 0.58);
    background: rgb(248 250 252 / 0.84);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.brand span {
    display: grid;
    width: 2.55rem;
    height: 2.55rem;
    place-items: center;
    border-radius: 0.7rem;
    background: #111827;
    color: white;
    font-size: 0.85rem;
    font-weight: 950;
    box-shadow: 0 14px 28px rgb(17 24 39 / 0.18);
}

.brand strong {
    font-size: 1.02rem;
    font-weight: 950;
    letter-spacing: -0.01em;
}

.year-switcher {
    position: relative;
}

.year-switcher summary {
    display: inline-flex;
    min-height: 2.25rem;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid rgb(15 118 110 / 0.16);
    border-radius: 999px;
    background: rgb(240 253 250 / 0.9);
    padding: 0 0.58rem 0 0.7rem;
    color: #115e59;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 950;
    list-style: none;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.92);
}

.year-switcher summary::-webkit-details-marker {
    display: none;
}

.year-switcher summary svg {
    width: 0.9rem;
    height: 0.9rem;
}

.year-menu {
    position: absolute;
    right: 0;
    top: 2.65rem;
    z-index: 50;
    width: min(16rem, calc(100vw - 2rem));
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: white;
    padding: 0.8rem;
    box-shadow: 0 22px 45px rgb(17 24 39 / 0.18);
}

.year-menu p {
    margin: 0 0 0.55rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.year-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.38rem;
    margin-bottom: 0.72rem;
}

.year-options a {
    display: flex;
    min-height: 2.35rem;
    align-items: center;
    justify-content: center;
    border: 1px solid #edf0f6;
    border-radius: 0.6rem;
    background: #f8fafc;
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 950;
    text-decoration: none;
}

.year-options a.is-current {
    border-color: rgb(15 118 110 / 0.26);
    background: #0f766e;
    color: white;
}

.year-menu form {
    display: grid;
    gap: 0.5rem;
    border-top: 1px solid var(--line);
    padding-top: 0.72rem;
}

.label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.input,
.file-input {
    width: 100%;
    min-height: 3.05rem;
    border: 1px solid #d7dbe5;
    border-radius: 0.65rem;
    background: white;
    padding: 0.78rem 0.85rem;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 720;
    outline: none;
}

.select-input {
    appearance: none;
    margin-top: 0.16rem;
    margin-bottom: 0.55rem;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2.35' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") calc(100% - 0.78rem) 50% / 1.05rem 1.05rem no-repeat,
        linear-gradient(90deg, transparent calc(100% - 2.85rem), rgb(17 24 39 / 0.05) calc(100% - 2.85rem)),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-color: #cfd6e4;
    padding-right: 2.6rem;
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / 0.9),
        0 10px 20px rgb(17 24 39 / 0.05);
}

.select-input:hover {
    border-color: #aeb8c8;
}

.input:focus,
.file-input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgb(15 118 110 / 0.14);
}

.select-input:focus {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2.35' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") calc(100% - 0.78rem) 50% / 1.05rem 1.05rem no-repeat,
        linear-gradient(90deg, transparent calc(100% - 2.85rem), rgb(15 118 110 / 0.08) calc(100% - 2.85rem)),
        linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
}

.btn-primary,
.btn-secondary,
.btn-compact,
.icon-btn,
.small-action,
.delete-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.8rem;
    border-radius: 0.65rem;
    border: 0;
    font-weight: 950;
    text-decoration: none;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, #0f766e, #134e4a);
    color: white;
    box-shadow: 0 14px 26px rgb(15 118 110 / 0.25);
}

.btn-secondary {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
}

.btn-compact,
.icon-btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    box-shadow: 0 10px 22px rgb(17 24 39 / 0.06);
}

.btn-compact {
    padding: 0 0.85rem;
    font-size: 0.86rem;
}

.icon-btn {
    width: 2.8rem;
}

.alert-error {
    margin-bottom: 1rem;
    border: 1px solid #fecdd3;
    border-radius: 0.7rem;
    background: #fff1f2;
    padding: 0.8rem 0.9rem;
    color: #9f1239;
    font-size: 0.9rem;
    font-weight: 800;
}

.hero-panel {
    min-height: 11rem;
    border-radius: 1rem;
    background:
        linear-gradient(135deg, rgb(17 24 39 / 0.96), rgb(19 78 74 / 0.94)),
        #111827;
    padding: 1.15rem;
    color: white;
    box-shadow: 0 22px 50px rgb(17 24 39 / 0.22);
}

.hero-panel p,
.screen-head p {
    margin: 0 0 0.25rem;
    color: rgb(255 255 255 / 0.72);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hero-panel h1 {
    margin: 0.55rem 0 1.1rem;
    font-size: clamp(2rem, 12vw, 3.8rem);
    line-height: 0.94;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.pill-success,
.pill-warning {
    display: inline-flex;
    min-height: 2rem;
    align-items: center;
    border-radius: 999px;
    padding: 0 0.75rem;
    font-size: 0.76rem;
    font-weight: 950;
}

.pill-success {
    background: rgb(20 184 166 / 0.18);
    color: #99f6e4;
}

.pill-warning {
    background: rgb(251 191 36 / 0.2);
    color: #fde68a;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.stat-card,
.surface,
.row-card {
    border: 1px solid rgb(255 255 255 / 0.72);
    border-radius: 0.9rem;
    background: rgb(255 255 255 / 0.9);
    box-shadow: 0 16px 34px rgb(17 24 39 / 0.08);
}

.stat-card {
    min-height: 8rem;
    padding: 0.95rem;
}

.stat-card i,
.stat-card svg {
    color: var(--teal);
}

.stat-card.expense i,
.stat-card.expense svg {
    color: var(--rose);
}

.stat-card span {
    display: block;
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 0.32rem;
    font-size: clamp(1.15rem, 6vw, 1.7rem);
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.surface {
    padding: 1rem;
}

.section-title,
.screen-head,
.row-main,
.row-actions,
.action-pair {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.screen-head {
    margin-bottom: 1rem;
}

.screen-head p {
    color: var(--muted);
}

.screen-head h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 950;
    letter-spacing: -0.02em;
}

.section-title {
    margin-bottom: 0.85rem;
}

.section-title h2 {
    margin: 0;
    font-size: 1.03rem;
    font-weight: 950;
}

.section-title span {
    min-width: 2rem;
    border-radius: 999px;
    background: #eef2f7;
    padding: 0.18rem 0.58rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 950;
}

.chart-list {
    display: grid;
    gap: 0.9rem;
}

.chart-row-button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 0.72rem;
    background: transparent;
    padding: 0.35rem;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.chart-row-button:active {
    background: #f1f5f9;
}

.note-panel {
    background:
        linear-gradient(180deg, rgb(255 255 255 / 0.95), rgb(248 250 252 / 0.9)),
        white;
}

.note-form {
    display: grid;
    gap: 0.72rem;
}

.note-form textarea {
    width: 100%;
    min-height: 7rem;
    resize: vertical;
    border: 1px solid #d6dce8;
    border-radius: 0.72rem;
    background:
        linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    padding: 0.85rem;
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 650;
    line-height: 1.45;
    outline: none;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.9);
}

.note-form textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgb(15 118 110 / 0.12);
}

.chart-row strong,
.chart-row span {
    font-size: 0.88rem;
}

.chart-row strong {
    overflow-wrap: anywhere;
}

.chart-row span {
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 900;
}

.bar {
    height: 0.55rem;
    margin-top: 0.45rem;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f7;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f766e, #f59e0b);
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
}

.modal-shell[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgb(15 23 42 / 0.58);
    backdrop-filter: blur(10px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 27rem);
    max-height: min(78vh, 42rem);
    overflow: auto;
    border: 1px solid rgb(255 255 255 / 0.72);
    border-radius: 1rem;
    background: rgb(255 255 255 / 0.98);
    padding: 1rem;
    box-shadow: 0 26px 70px rgb(15 23 42 / 0.28);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.modal-head p {
    margin: 0 0 0.24rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-head h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 950;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.modal-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.9rem;
    border-radius: 0.75rem;
    background: #f8fafc;
    padding: 0.75rem;
}

.modal-total span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-total strong {
    color: var(--rose);
    font-weight: 950;
}

.modal-list {
    display: grid;
    gap: 0.42rem;
    margin-top: 0.8rem;
}

.modal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    border-bottom: 1px solid #eef2f7;
    padding: 0.62rem 0.1rem;
}

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

.modal-row span {
    min-width: 0;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 850;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.modal-row strong {
    flex: 0 0 auto;
    color: var(--rose);
    font-size: 0.9rem;
    font-weight: 950;
    text-align: right;
}

.row-card {
    padding: 0.72rem;
}

.expense-groups {
    display: grid;
    gap: 0.95rem;
}

.expense-group {
    display: grid;
    gap: 0.5rem;
}

.expense-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    position: sticky;
    top: 4.5rem;
    z-index: 10;
    border: 1px solid rgb(17 24 39 / 0.08);
    border-radius: 0.75rem;
    background: rgb(248 250 252 / 0.92);
    padding: 0.62rem 0.72rem;
    box-shadow: 0 12px 24px rgb(17 24 39 / 0.08);
    backdrop-filter: blur(14px);
    cursor: pointer;
    list-style: none;
}

.expense-group-head::-webkit-details-marker {
    display: none;
}

.expense-group-head h2 {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 950;
    line-height: 1.1;
}

.expense-group-head p {
    margin: 0.18rem 0 0;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.expense-group-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
}

.expense-group-meta strong {
    color: var(--rose);
    font-size: 0.92rem;
    font-weight: 950;
    text-align: right;
}

.expense-group-meta svg {
    width: 0.95rem;
    height: 0.95rem;
    color: var(--muted);
    transition: transform 160ms ease;
}

.expense-group[open] .expense-group-meta svg {
    transform: rotate(180deg);
}

.expense-group > .space-y-2 {
    padding-top: 0.52rem;
}

.row-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.row-card h3 {
    margin: 0.12rem 0 0;
    font-size: 0.92rem;
    font-weight: 950;
    line-height: 1.22;
    overflow-wrap: anywhere;
}

.amount {
    flex: 0 0 auto;
    max-width: 42%;
    text-align: right;
    font-size: 0.9rem;
    line-height: 1.16;
    overflow-wrap: anywhere;
}

.row-actions {
    margin-top: 0.58rem;
    justify-content: flex-end;
}

.row-actions.has-document {
    justify-content: space-between;
}

.action-pair {
    justify-content: flex-end;
    gap: 0.38rem;
    flex: 0 0 auto;
}

.small-action,
.delete-action,
.muted-chip {
    min-height: 2rem;
    padding: 0 0.58rem;
    font-size: 0.7rem;
}

.small-action {
    border: 1px solid #ccfbf1;
    background: #f0fdfa;
    color: #115e59;
}

.delete-action {
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #be123c;
}

.muted-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 0.65rem;
    background: #f1f5f9;
    color: var(--muted);
    font-weight: 900;
}

.edit-form {
    border-top: 1px solid var(--line);
    padding-top: 0.78rem;
}

.edit-form label,
.premium-form label {
    display: block;
}

.empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 0.9rem;
    background: rgb(255 255 255 / 0.7);
    padding: 1.35rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    border-radius: 0.75rem;
    background: #eef2f7;
    padding: 0.35rem;
}

.segmented button {
    min-height: 2.6rem;
    border: 0;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--muted);
    font-weight: 950;
}

.segmented button.is-active {
    background: white;
    color: var(--ink);
    box-shadow: 0 8px 18px rgb(17 24 39 / 0.08);
}

.add-surface {
    position: relative;
    overflow: hidden;
    border-color: rgb(255 255 255 / 0.92);
    background:
        linear-gradient(180deg, rgb(255 255 255 / 0.96), rgb(248 250 252 / 0.92)),
        white;
    box-shadow:
        0 22px 50px rgb(17 24 39 / 0.12),
        inset 0 1px 0 rgb(255 255 255 / 0.9);
}

.add-surface::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 0.28rem;
    background: linear-gradient(90deg, #0f766e, #f59e0b, #be123c);
}

.premium-form {
    border: 1px solid #edf0f6;
    border-radius: 0.85rem;
    background: rgb(255 255 255 / 0.82);
    padding: 0.82rem;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.9);
}

.premium-form .label {
    color: #475467;
}

.premium-form .input,
.premium-form .file-input {
    border-color: #d6dce8;
    background-color: #fbfcff;
}

.upload-zone {
    display: block;
}

.file-input {
    min-height: 4.4rem;
    border-style: dashed;
    border-width: 1.5px;
    border-color: #a7f3d0;
    background:
        linear-gradient(180deg, rgb(240 253 250 / 0.9), rgb(255 255 255 / 0.96));
    color: #115e59;
    cursor: pointer;
}

.file-input::file-selector-button {
    min-height: 2.25rem;
    margin-right: 0.7rem;
    border: 0;
    border-radius: 0.55rem;
    background: #0f766e;
    padding: 0 0.78rem;
    color: white;
    font-weight: 950;
    box-shadow: 0 10px 20px rgb(15 118 110 / 0.22);
}

.upload-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    margin-top: 0.42rem;
    color: #667085;
    font-size: 0.76rem;
    font-weight: 850;
}

.bottom-tabs {
    position: fixed;
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.25rem;
    max-width: 27rem;
    margin: 0 auto;
    border: 1px solid rgb(17 24 39 / 0.12);
    border-radius: 0.9rem;
    background: rgb(17 24 39 / 0.94);
    padding: 0.35rem;
    box-shadow: 0 22px 45px rgb(17 24 39 / 0.28);
    backdrop-filter: blur(16px);
}

.bottom-tabs a {
    display: flex;
    min-height: 3rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    border-radius: 0.65rem;
    color: rgb(255 255 255 / 0.72);
    font-size: 0.68rem;
    font-weight: 950;
    text-decoration: none;
}

.bottom-tabs a.is-active {
    background: white;
    color: var(--ink);
}

.bottom-tabs svg {
    width: 1rem;
    height: 1rem;
}
