:root {
    --bg: #f6efe5;
    --panel: #fffaf4;
    --panel-strong: #ffffff;
    --text: #2d241d;
    --muted: #6f6258;
    --line: #dccfbe;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --danger-bg: #fde8e8;
    --danger-text: #9b1c1c;
    --shadow: 0 18px 60px rgba(45, 36, 29, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 30%),
        linear-gradient(135deg, #f8f2ea 0%, #efe3d4 100%);
}

.auth-page,
.dashboard-page {
    display: grid;
    place-items: center;
    padding: 32px;
}

.auth-card,
.shell {
    width: min(100%, 980px);
}

.auth-card {
    max-width: 480px;
    background: var(--panel-strong);
    border: 1px solid rgba(220, 207, 190, 0.9);
    border-radius: 24px;
    padding: 36px;
    box-shadow: var(--shadow);
}

.shell {
    display: grid;
    gap: 24px;
}

.shell-header,
.grid {
    display: grid;
    gap: 16px;
}

.grid-wide {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    align-items: start;
}

.shell-header {
    grid-template-columns: 1fr auto;
    align-items: start;
}

.grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.panel {
    background: rgba(255, 250, 244, 0.94);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.eyebrow {
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--brand-strong);
    margin-bottom: 10px;
}

h1,
h2,
p,
ul {
    margin-top: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    margin-bottom: 12px;
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 12px;
}

.lead,
li,
p {
    color: var(--muted);
    line-height: 1.6;
}

.session-meta {
    margin-bottom: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-form {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

label {
    font-weight: 700;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    background: #fffdf9;
}

input:focus {
    outline: 2px solid rgba(15, 118, 110, 0.25);
    border-color: var(--brand);
}

button,
.logout-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 0;
    padding: 14px 20px;
    font: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

button:hover,
.logout-link:hover {
    background: var(--brand-strong);
}

.logout-link {
    color: #fff;
    background: #3d342d;
}

.alert {
    border: 1px solid #f5c2c7;
    background: var(--danger-bg);
    color: var(--danger-text);
    border-radius: 14px;
    padding: 12px 14px;
}

.alert-success {
    border-color: #b7ebc6;
    background: #ebfff1;
    color: #17643a;
}

code {
    font-family: "Courier New", monospace;
}

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

.payments-groups {
    display: grid;
    gap: 20px;
}

.payments-group h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand-strong);
}

.payments-list {
    display: grid;
    gap: 12px;
}

.payment-item {
    width: 100%;
    text-align: left;
    background: #fffdf9;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px 18px;
    display: grid;
    gap: 6px;
}

.payment-item:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
}

.payment-main {
    display: grid;
    gap: 6px;
}

.payment-title {
    font-weight: 700;
}

.payment-meta {
    color: var(--muted);
}

.delete-form {
    margin-top: -4px;
}

.delete-button {
    width: 100%;
    cursor: pointer;
    background: #8b2c2c;
    color: #fff;
    font-weight: 700;
}

.delete-button:hover {
    background: #6f1f1f;
}

.archive-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 12px;
}

.archive-heading {
    min-width: 0;
}

.archive-toolbar h2 {
    margin-bottom: 0;
    flex: 0 0 auto;
}

.archive-search {
    display: grid;
    gap: 10px;
    justify-items: end;
    width: 470px;
    max-width: 100%;
    flex: 0 0 470px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 249, 0.82);
}

.archive-search-inline {
    width: min(100%, 1000px);
    max-width: 100%;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.archive-search-fields {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.search-reset {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #3d342d;
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
}

.search-reset:hover {
    background: #2e2722;
}

.search-strip {
    display: flex;
    justify-content: flex-end;
    margin-top: -8px;
    margin-bottom: 4px;
}

.archive-search-row {
    width: 100%;
}

.archive-search-row-top {
    display: grid;
    grid-template-columns: 190px 48px;
    justify-content: end;
    gap: 10px;
    align-items: center;
}

.archive-search-row-text {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 10px;
    align-items: center;
}

.archive-search input {
    text-align: left;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
}

.archive-search input[type="date"] {
    width: 190px;
    min-width: 190px;
    max-width: 190px;
}

.search-button {
    width: 48px !important;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
    padding: 0 !important;
    flex: 0 0 48px;
    justify-self: end;
    align-self: center;
    display: inline-flex;
    background: #3d342d;
    color: #fff;
    font-weight: 700;
    border-radius: 12px;
}

.search-button:hover {
    background: #2e2722;
}

.archive-tree {
    display: grid;
    gap: 18px;
}

.tree-year,
.tree-month {
    border: 0;
    background: transparent;
}

.tree-year > summary,
.tree-month > summary {
    cursor: pointer;
    list-style: none;
    padding: 6px 0;
    font-weight: 700;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-year > summary::-webkit-details-marker,
.tree-month > summary::-webkit-details-marker {
    display: none;
}

.tree-year > summary::before,
.tree-month > summary::before {
    content: "▸";
    display: inline-block;
    width: 14px;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.tree-year[open] > summary::before,
.tree-month[open] > summary::before {
    transform: rotate(90deg);
}

.tree-year > summary::after,
.tree-month > summary::after {
    content: "📁";
    font-size: 0.95rem;
}

.tree-label {
    color: var(--text);
}

.tree-months {
    margin-left: 26px;
    padding: 4px 0 0 10px;
    display: grid;
    gap: 12px;
    border-left: 1px solid var(--line);
}

.simple-list {
    margin-left: 26px;
    padding: 8px 0 8px 10px;
    border-left: 1px dashed var(--line);
    background: #fffdf9;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.simple-table th,
.simple-table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
}

.simple-table thead th {
    font-weight: 700;
    color: var(--text);
    background: rgba(220, 207, 190, 0.18);
}

.simple-table tbody td {
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.simple-table th:nth-child(1),
.simple-table td:nth-child(1) {
    width: 160px;
}

.simple-table th:nth-child(4),
.simple-table td:nth-child(4) {
    width: 150px;
}

.link-button {
    cursor: pointer;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--brand-strong);
    text-decoration: underline;
    font: inherit;
    font-weight: 700;
}

.search-hit {
    background: #fff35a;
    color: #241a00;
    padding: 0 2px;
    border-radius: 3px;
}

.modal-open {
    overflow: hidden;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 18, 16, 0.6);
}

.modal-card {
    position: relative;
    width: min(1000px, calc(100vw - 32px));
    height: min(85vh, 900px);
    margin: 40px auto;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    display: grid;
    grid-template-rows: auto 1fr;
}

.modal-header {
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--line);
}

.modal-header p {
    margin-bottom: 0;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
    padding: 0;
    background: #3d342d;
}

#modal-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #f4f4f4;
}

@media (max-width: 720px) {
    .auth-page,
    .dashboard-page {
        padding: 20px;
    }

    .auth-card,
    .panel {
        padding: 22px;
    }

    .shell-header {
        grid-template-columns: 1fr;
    }

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

    .archive-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .search-strip {
        justify-content: stretch;
        margin-top: 0;
    }

    .archive-search {
        width: 100%;
        flex: none;
        justify-items: stretch;
    }

    .archive-search-inline {
        display: grid;
        gap: 10px;
        grid-template-columns: 1fr;
    }

    .archive-search-fields {
        display: grid;
        gap: 10px;
    }

    .archive-search-row-top,
    .archive-search-row-text {
        grid-template-columns: 1fr;
    }

    .archive-search input {
        text-align: left;
    }

    .archive-search input[type="date"] {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .modal-card {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        margin: 8px auto;
        border-radius: 18px;
    }

    .simple-list {
        overflow-x: auto;
    }
}
