:root {
    --bg: #06101d;
    --panel: #0e2034;
    --line: rgba(255,255,255,.11);
    --text: #eef7ff;
    --muted: #91a8c0;
    --accent: #5ad8ff;
    --green: #72f4a5;
    --red: #ff8fa3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, #123958, transparent 35%),
        linear-gradient(145deg, #040a12, #071523 55%, #06101d);
}

.hidden { display: none !important; }

.center {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(19,42,67,.94), rgba(8,23,39,.94));
    box-shadow: 0 30px 90px rgba(0,0,0,.4);
}

.login-card {
    width: min(430px, 100%);
    padding: 32px;
}

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

.app {
    max-width: 1150px;
    margin: auto;
    padding: 28px 16px 70px;
}

header,
.title-row,
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

header {
    margin-bottom: 20px;
}

header h1 {
    margin: 5px 0 0;
    font-size: clamp(2rem, 6vw, 3.5rem);
}

.eyebrow {
    color: var(--accent);
    letter-spacing: .15em;
    font-size: .72rem;
    font-weight: 800;
}

.grid {
    display: grid;
    grid-template-columns: 1.4fr .7fr;
    gap: 18px;
}

.overview,
.archive,
.editor {
    padding: 22px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 25px;
}

.stats div {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: rgba(255,255,255,.04);
}

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

.stats strong {
    font-size: 1.3rem;
}

.editor { margin-top: 18px; }

.row {
    display: grid;
    grid-template-columns: 1fr 170px 45px;
    gap: 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.row:first-of-type {
    grid-template-columns: 1fr 170px;
}

input {
    width: 100%;
    padding: 13px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #071421;
}

.amount { text-align: right; }

button {
    padding: 13px 16px;
    border: 0;
    border-radius: 13px;
    font-weight: 800;
    cursor: pointer;
    color: #031018;
    background: linear-gradient(135deg, #67ddff, #72f4a5);
}

.secondary {
    color: var(--text);
    border: 1px solid var(--line);
    background: rgba(255,255,255,.07);
}

.remove {
    color: var(--red);
    background: rgba(255,143,163,.1);
}

.save {
    width: 100%;
    margin-top: 20px;
}

.archive-item {
    padding: 12px;
    margin-top: 9px;
    border: 1px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
    background: rgba(255,255,255,.04);
}

.archive-item small {
    display: block;
    color: var(--muted);
}

.error { color: var(--red); margin-top: 10px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 25px;
    opacity: 0;
    padding: 12px 17px;
    color: #031018;
    font-weight: 800;
    border-radius: 999px;
    background: #eef7ff;
    transform: translate(-50%, 20px);
    transition: .25s;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

dialog {
    border: 0;
    background: transparent;
}

dialog::backdrop {
    background: rgba(0,0,0,.65);
}

.dialog {
    width: min(420px, 90vw);
    padding: 25px;
    color: var(--text);
    border-radius: 20px;
    background: var(--panel);
}

@media (max-width: 800px) {
    .grid,
    .stats {
        grid-template-columns: 1fr;
    }

    header {
        align-items: flex-start;
    }

    .row {
        grid-template-columns: 1fr 110px 40px;
    }

    .row:first-of-type {
        grid-template-columns: 1fr 110px;
    }
}


.expense-row {
    grid-template-columns: 145px 1fr 150px 45px;
}

.item-date {
    min-width: 0;
}

.bottom-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.calculate-button {
    color: #031018;
    background: linear-gradient(135deg, #ffd76a, #ffad66);
}

.save {
    width: 100%;
    margin-top: 0;
}

.save:disabled {
    cursor: not-allowed;
    opacity: 0.38;
    filter: grayscale(0.7);
}

.calculation-result {
    margin-top: 20px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.calculation-result.pending {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

.calculation-result.calculated {
    display: grid;
    gap: 9px;
    background: rgba(114, 244, 165, 0.08);
    border-color: rgba(114, 244, 165, 0.25);
}

.calculation-result.calculated div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.calculation-result.calculated span {
    color: var(--muted);
}

.calculation-total {
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.calculation-total strong {
    color: var(--green);
    font-size: 1.2rem;
}

.error-result {
    color: var(--red);
    background: rgba(255, 143, 163, 0.08);
    border-color: rgba(255, 143, 163, 0.25);
}

@media (max-width: 800px) {
    .expense-row {
        grid-template-columns: 1fr 1fr;
    }

    .expense-row .name {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .expense-row .item-date {
        grid-column: 1;
        grid-row: 2;
    }

    .expense-row .amount {
        grid-column: 2;
        grid-row: 2;
    }

    .expense-row .remove {
        grid-column: 1 / -1;
        grid-row: 3;
        width: 100%;
    }

    .bottom-actions {
        grid-template-columns: 1fr;
    }
}
