/* -------------------------------------------------------
   Receipt Intelligence Platform — app.css
   Theme: Refined monochrome with amber accent
   Fonts: Syne (display) + DM Sans (body)
------------------------------------------------------- */

/* -------------------------------------------------------
   Custom Properties
------------------------------------------------------- */
:root {
    --ink:         #0d0d0f;
    --ink-muted:   #6b6b78;
    --ink-faint:   #a8a8b3;
    --surface:     #ffffff;
    --surface-2:   #f5f5f7;
    --surface-3:   #ebebef;
    --border:      #e2e2e8;
    --border-dark: #c8c8d2;
    --amber:       #e8a020;
    --amber-light: #fdf3e0;
    --amber-dark:  #b87a10;
    --green:       #1a9e6e;
    --green-light: #e6f7f1;
    --red:         #d63f3f;
    --red-light:   #fdeaea;
    --radius-sm:   6px;
    --radius:      12px;
    --radius-lg:   20px;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:      0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
    --shadow-lg:   0 16px 48px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.06);
    --transition:  0.18s cubic-bezier(.4,0,.2,1);
    --max-width:   1160px;
    --font-display:'Syne', sans-serif;
    --font-body:   'DM Sans', sans-serif;
}

/* -------------------------------------------------------
   Reset
------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.65;
    color: var(--ink);
    background: var(--surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a   { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* -------------------------------------------------------
   Layout
------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: 24px;
}

.main-content { flex: 1; }

/* -------------------------------------------------------
   Header
------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ink);
}

.logo-mark {
    width: 28px;
    height: 28px;
    background: var(--ink);
    border-radius: 7px;
    position: relative;
    flex-shrink: 0;
}

.logo-mark::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--amber);
    border-radius: 3px;
}

.logo strong { color: var(--amber); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    color: var(--ink);
    transition: background var(--transition), color var(--transition);
}

.nav-link:hover { background: var(--surface-2); }
.nav-link--muted { color: var(--ink-muted); }

.token-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--amber);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    margin-right: 4px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    padding: 4px;
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
    display: block;
    transition: transform var(--transition);
}

.mobile-nav {
    display: none;
    flex-direction: column;
    padding: 16px 24px 24px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
}

.mobile-nav a {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-weight: 500;
    color: var(--ink);
    transition: background var(--transition);
}

.mobile-nav a:hover { background: var(--surface-2); }
.mobile-nav.is-open { display: flex; }

/* -------------------------------------------------------
   Footer
------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-brand { font-size: .85rem; color: var(--ink-muted); }

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    font-size: .85rem;
    color: var(--ink-muted);
    transition: color var(--transition);
}

.footer-links a:hover { color: var(--ink); }

/* -------------------------------------------------------
   Buttons
------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .95rem;
    font-weight: 500;
    line-height: 1;
    border: 1.5px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn--primary {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.btn--primary:hover { background: #1e1e28; }

.btn--amber {
    background: var(--amber);
    color: #fff;
    border-color: var(--amber);
}

.btn--amber:hover {
    background: var(--amber-dark);
    border-color: var(--amber-dark);
}

.btn--outline {
    background: transparent;
    color: var(--ink);
    border-color: var(--border-dark);
}

.btn--outline:hover {
    border-color: var(--ink);
    background: var(--surface-2);
}

.btn--ghost {
    background: transparent;
    color: var(--ink-muted);
    border-color: transparent;
}

.btn--ghost:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn--sm  { padding: 7px 16px; font-size: .85rem; }
.btn--lg  { padding: 14px 32px; font-size: 1.05rem; }
.btn--full { width: 100%; }

/* -------------------------------------------------------
   Forms
------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--ink-muted);
    letter-spacing: .01em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(13,13,15,.08);
}

.form-control::placeholder { color: var(--ink-faint); }

.form-error {
    font-size: .82rem;
    color: var(--red);
    margin-top: 2px;
}

/* -------------------------------------------------------
   Cards
------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.card--raised { box-shadow: var(--shadow); }

/* -------------------------------------------------------
   Alerts
------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert--error   { background: var(--red-light); color: var(--red); border-color: #f5c6c6; }
.alert--success { background: var(--green-light); color: var(--green); border-color: #b3e8d4; }
.alert--info    { background: var(--amber-light); color: #7a5500; border-color: #f5dfa0; }

/* -------------------------------------------------------
   Upload zone
------------------------------------------------------- */
.upload-zone {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 56px 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--surface-2);
    position: relative;
}

.upload-zone:hover,
.upload-zone.is-dragover {
    border-color: var(--amber);
    background: var(--amber-light);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: var(--surface-3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--ink-muted);
}

.upload-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}

.upload-subtitle {
    font-size: .875rem;
    color: var(--ink-muted);
}

.upload-file-info {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 20px;
    text-align: left;
}

.upload-file-info.is-visible { display: flex; }

.upload-file-name {
    font-size: .9rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-size {
    font-size: .8rem;
    color: var(--ink-muted);
    flex-shrink: 0;
}

/* -------------------------------------------------------
   Progress / Loader
------------------------------------------------------- */
.progress-bar {
    height: 3px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    background: var(--amber);
    border-radius: 999px;
    width: 0;
    transition: width .3s ease;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state {
    display: none;
    align-items: center;
    gap: 10px;
    font-size: .9rem;
    color: var(--ink-muted);
    padding: 12px 0;
}

.loading-state.is-visible { display: flex; }

/* -------------------------------------------------------
   Result table
------------------------------------------------------- */
.result-card { animation: fadeUp .3s ease; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table tr { border-bottom: 1px solid var(--border); }
.result-table tr:last-child { border-bottom: none; }

.result-table td {
    padding: 12px 0;
    font-size: .925rem;
    vertical-align: top;
}

.result-table td:first-child {
    width: 40%;
    color: var(--ink-muted);
    font-weight: 500;
    padding-right: 16px;
}

.result-table td:last-child { font-weight: 400; }

.result-amount {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

/* -------------------------------------------------------
   Pricing cards
------------------------------------------------------- */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.pricing-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.pricing-card:hover {
    border-color: var(--border-dark);
    box-shadow: var(--shadow);
}

.pricing-card.is-selected {
    border-color: var(--amber);
    background: var(--amber-light);
}

.pricing-card__badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--amber);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.pricing-card__amount {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.pricing-card__tokens {
    font-size: .85rem;
    color: var(--ink-muted);
}

/* -------------------------------------------------------
   Dashboard
------------------------------------------------------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-card__label {
    font-size: .82rem;
    color: var(--ink-muted);
    margin-top: 4px;
}

.receipts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.receipts-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-muted);
    border-bottom: 2px solid var(--border);
}

.receipts-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.receipts-table tr:hover td { background: var(--surface-2); }
.receipts-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.badge--done    { background: var(--green-light); color: var(--green); }
.badge--pending { background: var(--amber-light); color: #7a5500; }
.badge--failed  { background: var(--red-light); color: var(--red); }

/* -------------------------------------------------------
   Section headings
------------------------------------------------------- */
.section-label {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 8px;
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -.02em;
    color: var(--ink);
}

h2 {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.015em;
}

h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
}

/* -------------------------------------------------------
   Page sections
------------------------------------------------------- */
.section { padding-block: 72px; }
.section--sm { padding-block: 48px; }

/* -------------------------------------------------------
   Hero
------------------------------------------------------- */
.hero {
    padding-block: 88px 72px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -80px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(232,160,32,.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-label { margin-bottom: 20px; }
.hero-title { margin-bottom: 20px; }

.hero-title em {
    font-style: normal;
    color: var(--amber);
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--ink-muted);
    max-width: 520px;
    line-height: 1.7;
    margin-bottom: 36px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.hero-trust {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .83rem;
    color: var(--ink-muted);
    margin-top: 20px;
}

.hero-trust-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

/* -------------------------------------------------------
   Features grid
------------------------------------------------------- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.feature-card {
    padding: 28px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-dark);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: var(--surface-2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.feature-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--ink);
}

.feature-title { font-weight: 600; margin-bottom: 6px; }
.feature-desc  { font-size: .88rem; color: var(--ink-muted); line-height: 1.6; }

/* -------------------------------------------------------
   Auth pages
------------------------------------------------------- */
.auth-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-heading {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.auth-subheading {
    font-size: .92rem;
    color: var(--ink-muted);
    margin-bottom: 28px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-footer {
    text-align: center;
    font-size: .88rem;
    color: var(--ink-muted);
    margin-top: 20px;
}

.auth-footer a {
    color: var(--ink);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* -------------------------------------------------------
   Utilities
------------------------------------------------------- */
.text-center { text-align: center; }
.text-muted  { color: var(--ink-muted); }
.text-small  { font-size: .875rem; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-48 { margin-top: 48px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }

/* -------------------------------------------------------
   Queue list (multi-file upload)
------------------------------------------------------- */
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
}

.queue-item {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 110px 44px;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    transition: background var(--transition);
}

.queue-item:last-child {
    border-bottom: none;
}

.queue-item:nth-child(even) {
    background: #f7f7f9;
}

.queue-item:hover {
    background: #f1f1f4;
}

.queue-item--done { background: #eef8f3; }
.queue-item--failed,
.queue-item--token_limit { background: #fdf1f1; }
.queue-item--processing { background: #fff8eb; }
.queue-item--duplicate { background: #f3f3f5; }

.qi-icon {
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qi-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.qi-dot--idle   { background: #cbd5e1; }
.qi-dot--ok     { background: #2563eb; }
.qi-dot--cached { background: #7c3aed; }
.qi-dot--done   { background: #16a34a; }
.qi-dot--fail   { background: #dc2626; }

.qi-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--amber);
    border-radius: 50%;
    display: inline-block;
    animation: spin .6s linear infinite;
}

.qi-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qi-name {
    font-weight: 600;
    color: var(--ink);
    font-size: .95rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qi-meta {
    font-size: .8rem;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.qi-error {
    margin-top: 3px;
    font-size: .78rem;
    color: var(--red);
    line-height: 1.35;
}

.qi-pages {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ececf1;
    font-size: 11px;
    font-weight: 700;
    color: #4b5563;
}

.qi-status {
    font-size: .8rem;
    font-weight: 700;
    color: var(--ink-muted);
    text-align: left;
    white-space: nowrap;
}

.qi-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #8b8b97;
    font-size: 20px;
    line-height: 1;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.qi-remove:hover {
    background: #ececf1;
    color: var(--red);
}

/* Results table extra column */
.results-table .td-amount {
    font-weight: 600;
    white-space: nowrap;
}

.results-table .td-desc {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Alert link */
.alert-link {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    color: inherit;
}

/* -------------------------------------------------------
   Responsive
------------------------------------------------------- */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-toggle { display: flex; }

    .hero { padding-block: 56px 48px; }

    .pricing-grid { grid-template-columns: 1fr 1fr; }

    .receipts-table th:nth-child(n+4),
    .receipts-table td:nth-child(n+4) { display: none; }
}

@media (max-width: 640px) {
    .queue-item {
        grid-template-columns: 24px minmax(0, 1fr) 34px;
        gap: 10px;
    }

    .qi-status {
        grid-column: 2 / 3;
        margin-top: 4px;
    }

    .qi-remove {
        grid-column: 3 / 4;
        grid-row: 1 / 3;
    }
}

@media (max-width: 480px) {
    .pricing-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .btn--lg { width: 100%; }
}