:root {
    --bg: #f5f1ea;
    --bg-deep: #ece4d7;
    --surface: rgba(255, 251, 245, 0.82);
    --surface-strong: #fffaf4;
    --surface-muted: rgba(92, 82, 67, 0.06);
    --ink: #191713;
    --muted: #696153;
    --line: rgba(41, 34, 25, 0.1);
    --accent: #1f6f5c;
    --accent-soft: rgba(31, 111, 92, 0.12);
    --danger: #b4573f;
    --danger-soft: rgba(180, 87, 63, 0.14);
    --shadow-soft: 0 22px 60px rgba(45, 37, 27, 0.11);
    --shadow-strong: 0 18px 40px rgba(27, 22, 15, 0.12);
    --radius-xl: 34px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --font-display: "Iowan Old Style", "Palatino Linotype", serif;
    --font-body: "Inter", "SF Pro Text", "Helvetica Neue", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    background: linear-gradient(180deg, #faf6f0 0%, #efe6da 100%);
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.92), transparent 28%),
        radial-gradient(circle at bottom left, rgba(220, 232, 225, 0.55), transparent 26%),
        linear-gradient(180deg, #faf6f0 0%, #efe6da 100%);
    min-height: 100vh;
}

img {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

textarea {
    resize: vertical;
}

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 22px 18px 120px;
}

.screen {
    display: grid;
    gap: 18px;
}

.capture-screen {
    gap: 20px;
}

.capture-topbar,
.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.capture-topbar h1,
.screen-header h1,
.result-sheet h2,
.empty-state h2,
.detail-panel h2,
.auth-card h1,
.capture-panel h2,
.capture-preview-meta h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 8vw, 4.3rem);
    line-height: 0.94;
    letter-spacing: -0.045em;
}

.capture-topbar h1 {
    max-width: 11ch;
}

.eyebrow,
.hero-kicker,
.detail-label,
.screen-meta,
.helper-copy,
.auth-hint,
.receipt-card__date,
.note-module__toggle {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.lede {
    margin: 12px 0 0;
    max-width: 32rem;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
}

.capture-workspace,
.result-sheet,
.auth-card,
.filter-bar,
.empty-state,
.detail-panel,
.detail-image-frame,
.receipt-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(14px);
}

.capture-workspace {
    overflow: hidden;
    display: grid;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08)),
        var(--surface);
}

.capture-visual {
    position: relative;
    min-height: 360px;
    padding: 24px;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.88), transparent 30%),
        linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(248, 241, 232, 0.72)),
        linear-gradient(135deg, #ede1cf, #dfeee7);
}

.capture-visual__idle,
.capture-visual__preview {
    display: grid;
    gap: 18px;
    height: 100%;
}

.capture-visual__copy {
    max-width: 22rem;
    align-self: end;
    display: grid;
    gap: 8px;
}

.receipt-preview-art {
    position: relative;
    min-height: 260px;
    margin-top: 8px;
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.82)),
        repeating-linear-gradient(180deg, transparent, transparent 18px, rgba(31, 111, 92, 0.07) 18px, rgba(31, 111, 92, 0.07) 20px);
    box-shadow: 0 20px 38px rgba(33, 28, 22, 0.14);
    transform: rotate(-7deg);
}

.receipt-preview-art::before,
.receipt-preview-art::after {
    content: "";
    position: absolute;
    left: 22px;
    right: 22px;
    height: 10px;
    border-radius: 999px;
    background: rgba(25, 23, 19, 0.08);
}

.receipt-preview-art::before {
    top: 28px;
}

.receipt-preview-art::after {
    top: 56px;
    width: 52%;
}

.capture-preview-frame {
    display: grid;
    place-items: center;
    min-height: 300px;
    padding: 14px;
    border-radius: 28px;
    background: rgba(255, 250, 244, 0.6);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.capture-preview-meta {
    display: grid;
    gap: 8px;
    align-self: end;
}

.preview-sheet__image,
.detail-image-frame img {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 22px;
    background: #f2eadf;
}

.capture-panel,
.result-sheet,
.auth-card,
.empty-state,
.detail-panel,
.filter-bar {
    padding: 22px;
}

.capture-panel,
.capture-panel__intro,
.capture-actions,
.capture-review,
.result-sheet,
.auth-card,
.empty-state,
.detail-panel {
    display: grid;
    gap: 14px;
}

.capture-panel {
    position: relative;
}

.button-row {
    display: grid;
    gap: 10px;
}

.button,
.bottom-nav__button,
.note-module__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    border: 0;
    border-radius: 999px;
    padding: 0 20px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 180ms ease, opacity 180ms ease, background 180ms ease, border-color 180ms ease;
}

.button:hover,
.bottom-nav__button:hover,
.button:focus-visible,
.bottom-nav__button:focus-visible,
.note-module__toggle:focus-visible,
.note-module__toggle:hover {
    transform: translateY(-1px);
}

.button[disabled],
.note-module__toggle[disabled] {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.button--primary {
    background: var(--ink);
    color: #fffdf8;
}

.button--secondary {
    background: var(--accent-soft);
    color: var(--accent);
}

.button--ghost {
    background: rgba(25, 23, 19, 0.06);
    color: var(--ink);
}

.button--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.button--block,
.button-row .button {
    width: 100%;
}

.button--xl {
    min-height: 72px;
    font-size: 1.08rem;
}

.status {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
}

.status--success {
    background: var(--accent-soft);
    color: var(--accent);
}

.status--error {
    background: var(--danger-soft);
    color: var(--danger);
}

.note-module {
    display: grid;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid rgba(41, 34, 25, 0.08);
}

.note-module__toggle {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0;
    background: transparent;
    color: var(--muted);
}

.note-module__fields {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.48);
    border: 1px solid rgba(41, 34, 25, 0.06);
}

.field {
    display: grid;
    gap: 8px;
}

.field input,
.field textarea,
.filter-bar select {
    width: 100%;
    border: 1px solid rgba(31, 31, 28, 0.1);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.78);
    padding: 14px 16px;
    color: var(--ink);
}

.filter-bar {
    display: grid;
    gap: 14px;
}

.result-sheet {
    overflow: hidden;
}

.result-sheet__icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-soft);
    position: relative;
}

.result-sheet__icon::before {
    content: "";
    position: absolute;
    inset: 20px 16px 18px 22px;
    border-right: 4px solid var(--accent);
    border-bottom: 4px solid var(--accent);
    transform: rotate(40deg);
}

.result-sheet.is-error .result-sheet__icon {
    background: var(--danger-soft);
}

.result-sheet.is-error .result-sheet__icon::before {
    inset: auto;
    width: 26px;
    height: 26px;
    border: 0;
    background:
        linear-gradient(var(--danger), var(--danger)) center/4px 26px no-repeat,
        linear-gradient(var(--danger), var(--danger)) center/26px 4px no-repeat;
    top: 19px;
    left: 19px;
    transform: rotate(45deg);
}

.receipt-list {
    display: grid;
    gap: 14px;
}

.receipt-card {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 14px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
}

.receipt-card img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 20px;
    background: #ddd3c4;
}

.receipt-card__note {
    margin: 6px 0 0;
    color: var(--ink);
    line-height: 1.45;
}

.detail-grid {
    display: grid;
    gap: 14px;
}

.detail-image-frame {
    padding: 12px;
}

.text-link {
    color: var(--accent);
    text-decoration: none;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(calc(100% - 24px), 700px);
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(255, 250, 243, 0.88);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(14px);
}

.bottom-nav__link,
.bottom-nav__button {
    min-height: 48px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    background: transparent;
}

.bottom-nav__link {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav__link.is-active {
    background: rgba(25, 23, 19, 0.07);
    color: var(--ink);
}

.bottom-nav__logout {
    margin: 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;
}

.capture-workspace[data-capture-state="idle"] .capture-visual__preview,
.capture-workspace[data-capture-state="idle"] .capture-review,
.capture-workspace[data-capture-state="idle"] .result-sheet {
    display: none;
}

.capture-workspace[data-capture-state="preview"] .capture-visual__idle,
.capture-workspace[data-capture-state="uploading"] .capture-visual__idle,
.capture-workspace[data-capture-state="success"] .capture-visual__idle,
.capture-workspace[data-capture-state="error"] .capture-visual__idle {
    display: none;
}

.capture-workspace[data-capture-state="uploading"] .capture-panel,
.capture-workspace[data-capture-state="success"] .capture-panel,
.capture-workspace[data-capture-state="error"] .capture-panel {
    align-content: start;
}

.capture-workspace[data-capture-state="uploading"] .capture-review,
.capture-workspace[data-capture-state="success"] .capture-review,
.capture-workspace[data-capture-state="error"] .capture-review {
    display: grid;
}

.capture-workspace[data-capture-state="success"] .capture-actions,
.capture-workspace[data-capture-state="success"] .capture-review,
.capture-workspace[data-capture-state="error"] .capture-actions {
    display: none;
}

.capture-workspace[data-capture-state="success"] .result-sheet,
.capture-workspace[data-capture-state="error"] .result-sheet {
    display: grid;
}

.capture-workspace[data-capture-state="error"] .capture-review {
    display: grid;
}

.capture-workspace[data-capture-state="error"] .result-sheet {
    margin-top: 8px;
}

@media (min-width: 700px) {
    .app-shell {
        padding-top: 32px;
    }

    .capture-workspace {
        grid-template-columns: 1.08fr 0.92fr;
        min-height: 720px;
    }

    .capture-visual {
        padding: 30px;
    }

    .capture-panel {
        padding: 30px;
        justify-content: center;
    }

    .detail-grid,
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}
