/* ── New tokens ────────────────────────────────────────────────────────── */
:root {
    --green: #10b981;
    --green-hover: #059669;
    --green-dim: rgba(16, 185, 129, 0.1);
    --green-border: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;
}

/* ── Credits badge ─────────────────────────────────────────────────────── */
.credits-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    background: var(--green-dim);
    border: 1px solid var(--green-border);
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Extract page layout ───────────────────────────────────────────────── */
.extract-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.extract-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 768px) {
    .extract-columns {
        grid-template-columns: 1fr;
    }
}

.extract-section-title {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--subtle);
    margin-bottom: 1rem;
}

.extract-credit-note {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.6rem;
    text-align: center;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.extract-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    border: 1px dashed var(--border);
    border-radius: 12px;
    text-align: center;
    color: var(--muted);
}

.extract-empty svg {
    width: 40px;
    height: 40px;
    opacity: 0.4;
}

.extract-empty p {
    font-size: 0.875rem;
    color: var(--subtle);
}

/* ── Result schema card ────────────────────────────────────────────────── */
.result-schema {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ── Field rows ────────────────────────────────────────────────────────── */
.result-fields {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.result-field-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.result-field-row:last-child {
    border-bottom: none;
}

.result-field-row--total {
    background: rgba(16, 185, 129, 0.04);
}

.result-field-label {
    color: var(--subtle);
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.result-field-value {
    color: var(--text);
    text-align: right;
    word-break: break-word;
}

.result-total {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--green);
}

/* ── Confidence bar tweaks ─────────────────────────────────────────────── */
.conf-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--subtle);
    margin-bottom: 0.4rem;
}

/* ── Line items table ──────────────────────────────────────────────────── */
.result-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.result-items-table th {
    text-align: left;
    padding: 0.4rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--subtle);
    border-bottom: 1px solid var(--border);
}

.result-items-table td {
    padding: 0.45rem 0.6rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.result-items-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Actions row ───────────────────────────────────────────────────────── */
.result-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Pricing page ──────────────────────────────────────────────────────── */
.pricing-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.5rem 5rem;
}

.pricing-header {
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pricing-title {
    font-family: "DM Serif Display", serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.pricing-subtitle {
    font-size: 0.9rem;
    color: var(--subtle);
    text-align: center;
}

.pricing-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .pricing-cards {
        grid-template-columns: 1fr;
    }
}

.pricing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.15s ease;
}

.pricing-card:hover {
    border-color: var(--muted);
}

.pricing-card--featured {
    border-color: var(--green-border);
    box-shadow: 0 0 0 1px var(--green-border);
}

.pricing-plan-name {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--subtle);
}

.pricing-credits {
    font-size: 3rem;
    font-weight: 300;
    color: var(--text);
    line-height: 1;
}

.pricing-credits-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: -0.25rem;
}

.pricing-price {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.pricing-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    margin-bottom: 0.5rem;
}

.pricing-features li {
    font-size: 0.82rem;
    color: var(--subtle);
    padding-left: 1rem;
    position: relative;
}

.pricing-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--green);
    font-size: 0.75rem;
}

/* ── JSON result syntax coloring (monospace) ───────────────────────────── */
.result-text {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--subtle);
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    max-height: 240px;
    overflow-y: auto;
}

/* ── Loading spinner on submit button ──────────────────────────────────── */
.ocr-submit.loading {
    position: relative;
    pointer-events: none;
}

.ocr-submit.loading svg {
    display: none;
}

.ocr-submit.loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Toast notifications ──────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    max-width: 360px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.toast--success {
    background: #1a2e1f;
    border: 1px solid rgba(112,200,152,0.25);
    color: #70c898;
}

.toast--error {
    background: #2e1a1a;
    border: 1px solid rgba(220,80,80,0.25);
    color: #e06060;
}

.toast--warning {
    background: #2a2510;
    border: 1px solid rgba(220,180,60,0.25);
    color: #d4b240;
}

/* ── Full-screen scan overlay ─────────────────────── */
#scan-overlay,
#rerun-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 14, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#scan-overlay.scan-overlay--visible,
#rerun-overlay.scan-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

.scan-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.scan-receipt-wrap {
    position: relative;
    width: 72px;
    height: 90px;
    margin-bottom: 0.25rem;
}

.scan-doc-icon {
    width: 72px;
    height: 90px;
}

.scan-line {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
    border-radius: 2px;
    animation: scan-sweep 1.6s ease-in-out infinite;
}

@keyframes scan-sweep {
    0%   { top: 11px; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: 79px; opacity: 0; }
}

.scan-filename {
    font-size: 0.82rem;
    color: var(--muted);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scan-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}

.scan-dots {
    display: flex;
    gap: 6px;
}

.scan-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: dot-bounce 1.2s ease-in-out infinite;
}

.scan-dots span:nth-child(2) { animation-delay: 0.2s; }
.scan-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1;   }
}

.scan-credit-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
}

/* ── Custom modal ─────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 14, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    transform: translateY(8px);
    transition: transform 0.25s ease;
    text-align: center;
}

.modal-overlay--visible .modal-card {
    transform: translateY(0);
}

.modal-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(var(--accent-rgb, 130,110,255), 0.12);
    border: 1px solid rgba(var(--accent-rgb, 130,110,255), 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--accent);
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.modal-body {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-credit-cost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.modal-btn:hover { opacity: 0.8; }

.modal-btn--cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.modal-btn--confirm {
    background: var(--accent);
    color: #fff;
}
