:root {
    --bg: #f6f7f4;
    --surface: #ffffff;
    --text: #17211b;
    --muted: #66736b;
    --line: #dde4de;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --accent: #b42318;
    --paid: #2563eb;
    --shadow: 0 12px 32px rgba(23, 33, 27, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px max(16px, calc((100vw - 1180px) / 2));
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    flex-shrink: 0;
    color: var(--text);
    font-weight: 800;
}

.nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.nav a {
    min-width: max-content;
    padding: 8px 10px;
    color: var(--muted);
    border-radius: 8px;
}

.nav a.active,
.nav a:hover {
    color: var(--primary);
    background: #e5f4f1;
}

.container {
    width: min(1180px, calc(100vw - 32px));
    margin: 24px auto 56px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 18px;
    padding: 24px;
    color: #fff;
    background: linear-gradient(135deg, #0f766e 0%, #2f6f48 100%);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 8px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 56px);
    line-height: 1.05;
    letter-spacing: 0;
}

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

.stats div {
    padding: 14px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
}

.stats span {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
}

.stats strong {
    display: block;
    font-size: 19px;
    overflow-wrap: anywhere;
}

.panel,
.auth-panel {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel,
.narrow {
    width: min(480px, 100%);
    margin: 56px auto;
}

h1,
h2 {
    margin: 0 0 16px;
    line-height: 1.2;
    letter-spacing: 0;
}

h2 {
    font-size: 20px;
}

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

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-title h1,
.section-title h2 {
    margin: 0;
}

label {
    display: grid;
    gap: 7px;
    color: #334139;
    font-size: 14px;
    font-weight: 650;
}

input,
select,
button,
.button {
    min-height: 42px;
    padding: 9px 11px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cdd8d1;
    border-radius: 8px;
    font: inherit;
}

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

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 750;
}

.primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.primary:hover {
    background: var(--primary-dark);
}

.ghost {
    color: var(--primary);
    background: #eef7f5;
    border-color: #cbe4df;
}

.form-grid,
.entry-grid,
.filters,
.export-box {
    display: grid;
    gap: 14px;
}

.entry-grid {
    grid-template-columns: 160px 1fr 180px 220px 150px;
    align-items: end;
}

.entry-grid .wide {
    grid-column: span 4;
}

.filters {
    grid-template-columns: repeat(5, minmax(130px, 1fr)) auto auto;
    align-items: end;
    margin-bottom: 16px;
}

.export-box {
    grid-template-columns: minmax(180px, 280px) auto 1fr;
    align-items: end;
    margin-bottom: 16px;
    padding: 12px;
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.flash {
    margin-bottom: 14px;
    padding: 12px 14px;
    color: #0b513f;
    background: #e9f8f3;
    border: 1px solid #bde7d9;
    border-radius: 8px;
}

.flash.danger {
    color: #8a1f17;
    background: #fff0ee;
    border-color: #f1c0ba;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    color: #4b5a51;
    background: #f1f5f2;
    font-size: 13px;
}

.money {
    font-weight: 800;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    min-width: 60px;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge.unpaid {
    color: #8a1f17;
    background: #fff0ee;
}

.badge.paid {
    color: #1d4ed8;
    background: #eaf1ff;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.actions form {
    display: inline;
}

.actions button {
    min-height: 32px;
    padding: 4px 8px;
    color: var(--primary);
    background: transparent;
    border: 0;
}

.actions .danger-link {
    color: var(--accent);
}

.empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 920px) {
    .hero,
    .entry-grid,
    .filters,
    .export-box {
        grid-template-columns: 1fr;
    }

    .entry-grid .wide {
        grid-column: auto;
    }
}

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

    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 12px;
    }

    .hero,
    .panel,
    .auth-panel {
        padding: 16px;
    }

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

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }
}
