:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1e1e1e;
    --border: #2a2a2a;
    --text: #e5e5e5;
    --text-dim: #888;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --radius: 8px;
    --font: system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    padding: 2rem 2rem 1rem;
    max-width: 1000px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.875rem;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

/* Upload */
.upload-section { margin: 1.5rem 0; }

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.dropzone-content svg {
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.dropzone-content p { margin-bottom: 0.25rem; }

.dropzone-content .link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.dropzone-content .hint {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.upload-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.upload-status.loading {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent);
}

.upload-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.upload-status.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--green);
}

/* Tabs */
.upload-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Progress bar */
.progress-bar {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    min-width: 3rem;
    text-align: right;
}

.hidden { display: none !important; }

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.result-section { margin: 2rem 0; }

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-header h2 { font-size: 1.2rem; }

.result-meta { display: flex; gap: 0.5rem; }

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .result-grid { grid-template-columns: 1fr; }
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.result-card h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.data-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
}

.data-label {
    color: var(--text-dim);
    white-space: nowrap;
}

.data-value {
    font-weight: 500;
    word-break: break-word;
}

.data-value.empty {
    color: var(--text-dim);
    font-style: italic;
    font-weight: 400;
}

/* Line items table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.8rem;
}

tbody td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }

/* Confidence */
.confidence-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
}

.confidence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.confidence-dot.high { background: var(--green); }
.confidence-dot.medium { background: var(--yellow); }
.confidence-dot.low { background: var(--red); }

.confidence-note {
    color: var(--text-dim);
    font-size: 0.8rem;
}

/* Actions */
.result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    transition: background 0.2s;
}

.btn:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--surface-2); }

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: transparent;
    border-color: var(--border);
    color: var(--red);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

/* History */
.history-section {
    margin-top: 3rem;
}

.history-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#historyTable { margin-bottom: 1rem; }

.empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 2rem 0;
    font-size: 0.9rem;
}
