/* Provax Invoice Agent - Professional UI */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --primary-bg: #eff6ff;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 14px;
}

/* Layout */
.container { max-width: 1440px; margin: 0 auto; padding: 0 1.5rem; }

/* Header */
.header {
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    padding: 0;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header .container {
    display: flex;
    align-items: center;
    height: 56px;
}
.header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header h1::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(5,150,105,0.6);
}
.header nav {
    margin-left: auto;
    display: flex;
    gap: 0;
}
.header nav a {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0 1rem;
    height: 56px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.header nav a:hover {
    color: white;
    background: rgba(255,255,255,0.05);
    border-bottom-color: var(--primary-light);
}

/* Page title */
h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}
h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}
h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    cursor: default;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
    line-height: 1;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}
th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 56px;
}
tbody tr {
    transition: background 0.1s;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-green { background: var(--success-light); color: #065f46; }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-red { background: var(--danger-light); color: #991b1b; }
.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Confidence bar */
.confidence-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    overflow: hidden;
    min-width: 60px;
}
.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.conf-high { background: var(--success); }
.conf-medium { background: var(--warning); }
.conf-low { background: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; box-shadow: var(--shadow); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; box-shadow: var(--shadow); }
.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    box-shadow: var(--shadow-sm);
}
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* Review layout */
.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: calc(100vh - 220px);
}
.pdf-viewer {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--gray-100);
    box-shadow: var(--shadow);
}
.pdf-viewer iframe, .pdf-viewer embed {
    width: 100%;
    height: 100%;
    border: none;
}
.review-form {
    overflow-y: auto;
    padding-right: 0.5rem;
}
.review-form::-webkit-scrollbar { width: 6px; }
.review-form::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* Form fields */
.field-group {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.field-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    min-width: 130px;
    text-align: right;
    font-weight: 500;
}
.field-value {
    flex: 1;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    transition: all 0.15s;
    color: var(--gray-900);
}
.field-value:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
select.field-value {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}
.field-confidence {
    width: 40px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}
.upload-area:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.25rem;
}
.tab {
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab:hover { color: var(--gray-700); background: var(--gray-50); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Alert cards */
.alert {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-warning { background: var(--warning-light); border-left: 4px solid var(--warning); }
.alert-danger { background: var(--danger-light); border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-light); border-left: 4px solid var(--success); }
.alert-info { background: var(--primary-bg); border-left: 4px solid var(--primary-light); }

/* Code */
code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    background: var(--gray-100);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--gray-700);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-400);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 1024px) {
    .review-grid { grid-template-columns: 1fr; height: auto; }
    .pdf-viewer { height: 50vh; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}
@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    .header nav { gap: 0; }
    .header nav a { padding: 0 0.5rem; font-size: 0.75rem; }
    .field-group { flex-direction: column; align-items: stretch; }
    .field-label { text-align: left; min-width: auto; }
}
