:root {
    --ink: #17211b;
    --muted: #68736c;
    --line: #dfe5df;
    --paper: #ffffff;
    --canvas: #f4f6f2;
    --green: #1f6d4a;
    --green-dark: #155239;
    --mint: #ddf3e6;
    --amber: #a86708;
    --red: #a53838;
    --radius: 16px;
    --shadow: 0 12px 35px rgba(30, 51, 39, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% 0%, rgba(156, 210, 174, .22), transparent 30rem),
        var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.topbar {
    height: 72px;
    padding: 0 max(24px, calc((100vw - 1180px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .03em; }
.brand-mark {
    width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: 11px; color: white; background: var(--green); font-family: Georgia, serif; font-size: 22px;
}
.brand small { margin-left: 3px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.topbar-actions form { margin: 0; }
.user-name { color: var(--muted); font-size: 14px; }
.link-button { padding: 0; border: 0; background: none; color: var(--green); cursor: pointer; font-weight: 700; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 80px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 5vw, 48px); font-weight: 500; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 18px; }
.eyebrow { margin-bottom: 10px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.page-heading p { margin-bottom: 0; }

.button {
    min-height: 44px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 750; transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .7; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--green); box-shadow: 0 8px 18px rgba(31,109,74,.18); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: #b9d9c4; color: var(--green); background: #eff9f3; }
.button.secondary.copied { color: white; background: var(--green); }
.button.ghost { border-color: var(--line); background: white; }
.button.small { min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.button.wide { width: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { min-height: 150px; padding: 24px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.stat-card.accent { background: var(--mint); border-color: #cbe9d6; }
.stat-card.dark { color: white; background: var(--ink); border-color: var(--ink); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card.dark .stat-label, .stat-card.dark .stat-note { color: #aeb9b2; }
.stat-card strong { margin-top: auto; font-size: 31px; letter-spacing: -.035em; }
.stat-note { margin-top: 3px; color: var(--muted); font-size: 12px; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.panel-header { padding: 22px 24px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-header .muted { font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 20px; border-bottom: 1px solid #edf0ed; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #fafbf9; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 750; }
.align-right { text-align: right; }
.actions { display: flex; justify-content: flex-end; gap: 7px; }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; background: #f0f2f0; color: #5e6862; font-size: 12px; font-weight: 750; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-active { color: var(--amber); background: #fff5db; }
.status-paid { color: var(--green); background: var(--mint); }
.status-error { color: var(--red); background: #ffebeb; }
.error-detail { color: var(--red); font-size: 12px; border-bottom: 1px dotted; cursor: help; }

.empty-state { padding: 70px 24px; text-align: center; }
.empty-state h3 { margin: 12px 0 6px; }
.empty-state p { color: var(--muted); }
.empty-icon, .result-icon { width: 54px; height: 54px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--mint); font-size: 24px; }
.result-icon.success { color: white; background: var(--green); }

.narrow-shell { width: min(650px, 100%); margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 20px; color: var(--muted); font-size: 14px; font-weight: 650; }
.form-card, .login-card { padding: clamp(26px, 5vw, 44px); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.form-card h1, .login-card h1 { font-size: clamp(31px, 6vw, 42px); }
.form-stack { display: grid; gap: 20px; margin-top: 30px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 750; }
.field label span { margin-left: 3px; color: var(--red); }
.field input, .field select {
    width: 100%; height: 48px; padding: 0 14px; color: var(--ink); background: #fbfcfa;
    border: 1px solid #cfd7d0; border-radius: 10px; outline: none; transition: .15s;
}
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,109,74,.11); background: white; }
.field small { color: var(--muted); font-size: 12px; }
.field-error { color: var(--red); font-size: 12px; }
.global-error { padding: 12px 14px; border-radius: 9px; background: #ffeded; }
.secure-note { padding: 14px; display: flex; align-items: flex-start; gap: 11px; border-radius: 11px; background: #f0f7f2; color: #3f5949; }
.secure-note span { font-size: 22px; line-height: 1; }
.secure-note p { margin: 0; font-size: 12px; line-height: 1.55; }
.form-actions { padding-top: 5px; display: flex; justify-content: flex-end; gap: 10px; }

.login-wrap { min-height: calc(100vh - 200px); display: grid; place-items: center; }
.login-card { width: min(440px, 100%); }
.centered { text-align: center; }
.centered .result-icon { margin-bottom: 20px; }
.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 14px 16px; border: 1px solid #b9d9c4; border-radius: 10px; color: var(--green); background: #edf8f1; font-size: 14px; }
.message.error { border-color: #edbaba; color: var(--red); background: #fff0f0; }

@media (max-width: 760px) {
    .topbar { height: 64px; padding: 0 18px; }
    .brand small, .user-name { display: none; }
    .page-shell { width: min(100% - 28px, 650px); padding-top: 30px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading .button { width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 120px; }
    table, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }
    tr { padding: 16px; border-bottom: 1px solid var(--line); }
    tbody tr:last-child { border-bottom: 0; }
    td { padding: 7px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 0; white-space: normal; text-align: right; }
    td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
    .actions { justify-content: flex-end; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
}
