:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

h1 { margin: 0 0 12px; font-size: 1.5rem; }

.container { max-width: 900px; margin: 32px auto; padding: 0 16px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .04);
}

.card.narrow { max-width: 420px; margin: 64px auto; }
@media (max-width: 460px) { .card.narrow { margin: 32px 16px; } }

.card.pending { text-align: center; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.row h1 { margin: 0; }

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

form label { display: block; margin-bottom: 14px; font-size: .9rem; font-weight: 500; }

input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}
input:focus { outline: 2px solid var(--primary); border-color: transparent; }

button {
    width: 100%;
    padding: 11px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #fff; color: var(--red); border: 1px solid var(--red); }
button.secondary:hover { background: var(--red-bg); }

.actions { margin-top: 24px; max-width: 260px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: .9rem; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.success { background: var(--green-bg); color: var(--green); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: var(--amber-bg); color: var(--amber); }
.card.pending .badge { margin-bottom: 16px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 1.8s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
    70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.account-id code {
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 1rem;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-wrap: anywhere;
}
.stat .muted { font-size: .8rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--bg); }

/* ---- Letters, preferences, admin settings ---- */
h2 { margin: 0 0 12px; font-size: 1.15rem; }
.container .card + .card { margin-top: 20px; }
.container > .alert { margin-bottom: 16px; }

.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar .brand { color: var(--text); font-weight: 700; }
.btn-small { padding: 6px 14px; border-radius: 8px; background: var(--primary); color: #fff !important; font-weight: 600; font-size: .9rem; }
.btn-small:hover { background: var(--primary-dark); text-decoration: none; }

.stat .big { font-size: 2rem; line-height: 1.1; }

.letter-action { position: relative; margin-top: 20px; max-width: 280px; }
button:disabled { background: #c7c9d1; cursor: not-allowed; }
.dropdown {
    margin-top: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
    overflow: hidden;
}
.dropdown-title { margin: 0; padding: 10px 14px; font-size: .8rem; font-weight: 600; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.dropdown a { display: block; padding: 11px 14px; color: var(--text); }
.dropdown a:hover { background: var(--bg); text-decoration: none; }
.dropdown-empty { margin: 0; padding: 11px 14px; }

.narrow-form { max-width: 560px; }
textarea, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.list { list-style: none; margin: 0 0 18px; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li form { margin-left: auto; }
.link-danger { width: auto; padding: 4px 8px; background: none; color: var(--red); font-weight: 500; }
.link-danger:hover { background: var(--red-bg); }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form input, .inline-form select { flex: 1 1 200px; width: auto; margin: 0; }
.inline-form button { width: auto; padding: 10px 18px; }

.letters-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.letters-form label { flex: 1 1 160px; margin: 0; }
.letters-form button { width: auto; padding: 10px 18px; }

.preview label { display: block; margin-bottom: 14px; font-size: .9rem; font-weight: 500; }
.preview input:disabled, .preview textarea:disabled { background: var(--bg); }

.submission { padding: 14px 0; border-bottom: 1px solid var(--border); }
.submission .row { margin-bottom: 8px; }
.submission dl { margin: 0; display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; font-size: .92rem; }
.submission dt { color: var(--muted); }
.submission dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Public refund landing page ---- */
.landing-page {
    --landing-peach: #ef8d6f;
    --landing-peach-dark: #bd5f46;
    --landing-blush: #fff1eb;
    --landing-ink: #352a27;
    --landing-muted: #796b66;
    min-height: 100vh;
    background: #fffdfb;
    color: var(--landing-ink);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}
.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 28px;
}
.landing-brand { color: var(--landing-ink); font-size: 1.15rem; font-weight: 800; }
.landing-brand span { color: var(--landing-peach-dark); margin-left: 5px; }
.landing-page a { text-decoration: none; }
.landing-page a:hover { text-decoration: none; }
.landing-header nav { display: flex; align-items: center; gap: 24px; }
.landing-nav-link { color: var(--landing-ink); font-weight: 600; }
.landing-nav-cta { padding: 10px 18px; border-radius: 6px; background: var(--landing-ink); color: #fff; font-weight: 600; }
.landing-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 60px;
    max-width: 1120px;
    min-height: 440px;
    margin: 24px auto 0;
    padding: 64px 70px;
    background: linear-gradient(115deg, #fff1eb 0%, #fff8f4 60%, #fffdfb 100%);
    border-radius: 8px;
}
.landing-copy { max-width: 590px; }
.landing-kicker { margin: 0 0 16px; color: var(--landing-peach-dark); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.landing-hero h1 { margin: 0; font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.08; letter-spacing: 0; }
.landing-intro { max-width: 480px; margin: 20px 0 0; color: var(--landing-muted); font-size: 1.05rem; }
.landing-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 28px; }
.landing-button { display: inline-flex; align-items: center; gap: 18px; padding: 14px 20px; border-radius: 6px; background: var(--landing-peach-dark); color: #fff; font-weight: 700; }
.landing-button:hover { background: #a84e38; }
.landing-button span { font-size: 1.2rem; }
.landing-secondary { color: var(--landing-ink); font-weight: 600; }
.landing-note { display: flex; gap: 16px; width: min(290px, 100%); padding: 22px; background: #fff; border: 1px solid #f2dfd6; border-radius: 8px; box-shadow: 0 14px 38px rgba(104, 58, 41, .08); }
.landing-note-icon { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--landing-blush); color: var(--landing-peach-dark); font-weight: 800; }
.landing-note strong { display: block; margin: 2px 0 6px; }
.landing-note p { margin: 0; color: var(--landing-muted); font-size: .9rem; }
.landing-steps { display: grid; grid-template-columns: .8fr 1.2fr; gap: 80px; max-width: 980px; margin: 0 auto; padding: 64px 28px 50px; }
.landing-section-heading h2 { margin: 0; font-size: 1.75rem; }
.landing-steps ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 0; padding: 0; list-style: none; }
.landing-steps li { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 2px solid #f0c3b2; }
.landing-steps li > span { color: var(--landing-peach-dark); font-size: .78rem; font-weight: 800; }
.landing-steps h3 { margin: 0 0 7px; font-size: 1rem; }
.landing-steps li p { margin: 0; color: var(--landing-muted); font-size: .88rem; }
.landing-footer { max-width: 1120px; margin: 0 auto; padding: 18px 28px 28px; border-top: 1px solid #f2e8e3; color: var(--landing-muted); font-size: .85rem; }
@media (max-width: 760px) {
    .landing-header { padding: 18px 20px; }
    .landing-hero { align-items: flex-start; flex-direction: column; gap: 30px; min-height: 0; margin: 12px 14px 0; padding: 42px 26px; }
    .landing-hero h1 { font-size: 2.65rem; }
    .landing-steps { grid-template-columns: 1fr; gap: 28px; padding: 48px 26px; }
}
@media (max-width: 520px) {
    .landing-header nav { gap: 14px; }
    .landing-nav-cta { padding: 9px 12px; }
    .landing-steps ol { grid-template-columns: 1fr; gap: 18px; }
    .landing-actions { align-items: flex-start; flex-direction: column; gap: 16px; }
}

/* ---- Submission statuses ---- */
.status-pending { background: var(--amber-bg); color: var(--amber); }
.status-processing { background: #dbeafe; color: #1d4ed8; }
.status-in_review { background: #ede9fe; color: #6d28d9; }
.status-approved { background: var(--green-bg); color: var(--green); }
.status-completed { background: #ccfbf1; color: #0f766e; }
.status-rejected { background: var(--red-bg); color: var(--red); }
.status-form { margin-top: 12px; max-width: 360px; }
.push-right { margin-left: auto; }
.list li:last-child { border-bottom: 0; }
.link-danger.armed, button.secondary.armed { background: var(--red); color: #fff; }
