/* Care OCR console */

:root {
  --bg: #0f1420;
  --bg-elev: #161d2c;
  --bg-elev-2: #1d2638;
  --border: #273246;
  --text: #e6ebf5;
  --text-muted: #8a97b1;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, 0.15);
  --ok: #3ccf91;
  --warn: #f5b84c;
  --err: #ff6b6b;
  --info: #7aa7ff;
  --neutral: #6b7690;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2740 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain { color: inherit; }

h1 { font-size: 26px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 12px; }
h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }
.empty { color: var(--text-muted); text-align: center; padding: 28px 0; margin: 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 32, 0.8); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--text); font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }
.brand-sub { color: var(--text-muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.topbar-nav a { color: var(--text-muted); margin-left: 18px; font-weight: 500; }
.topbar-nav a.active { color: var(--text); }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 60px; }
.breadcrumb { margin-bottom: 14px; font-size: 14px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; border: 1px solid; font-size: 14px; }
.flash-notice { background: rgba(60, 207, 145, 0.12); border-color: rgba(60, 207, 145, 0.4); color: #bff3dc; }
.flash-alert { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.4); color: #ffd1d1; }

/* Hero + upload */
.hero { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.hero p { margin: 0; max-width: 620px; }
.hero-compact { margin-bottom: 18px; }
.actions { display: flex; gap: 10px; align-items: center; }

.upload-form { flex-shrink: 0; }
.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  padding: 18px 28px; border: 1.5px dashed rgba(91, 157, 255, 0.55); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); font-weight: 500; transition: background .15s, border-color .15s;
}
.upload-drop:hover { background: rgba(91, 157, 255, 0.25); border-color: var(--accent); }
.upload-drop input { display: none; }
.upload-icon { font-size: 22px; color: var(--accent); line-height: 1; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat-value { display: block; font-size: 22px; font-weight: 600; font-family: var(--mono); }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat-done .stat-value { color: var(--ok); }
.stat-failed .stat-value { color: var(--err); }
.stat-extracting .stat-value, .stat-searching .stat-value, .stat-syncing .stat-value { color: var(--info); }

/* Cards & tables */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.data-card dl { margin: 0; }
.data-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px; }
.data-row:first-child { border-top: 0; }
.data-row dt { color: var(--text-muted); }
.data-row dd { margin: 0; word-break: break-word; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg-elev-2); }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table tbody tr:last-child td { border-bottom: 0; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap; }
.badge-pending, .badge-skipped { background: rgba(107, 118, 144, 0.18); color: #b7c0d4; border-color: rgba(107, 118, 144, 0.4); }
.badge-extracting, .badge-searching, .badge-syncing, .badge-running { background: rgba(122, 167, 255, 0.16); color: #c7d8ff; border-color: rgba(122, 167, 255, 0.45); }
.badge-done, .badge-success { background: rgba(60, 207, 145, 0.16); color: #a9efd0; border-color: rgba(60, 207, 145, 0.45); }
.badge-failed, .badge-error { background: rgba(255, 107, 107, 0.16); color: #ffc2c2; border-color: rgba(255, 107, 107, 0.45); }
.badge-warning { background: rgba(245, 184, 76, 0.16); color: #ffe1a6; border-color: rgba(245, 184, 76, 0.45); }
.badge-outcome-created { background: rgba(60, 207, 145, 0.16); color: #a9efd0; border-color: rgba(60, 207, 145, 0.45); }
.badge-outcome-updated { background: rgba(91, 157, 255, 0.16); color: #c7d8ff; border-color: rgba(91, 157, 255, 0.45); }
.badge-outcome-ambiguous { background: rgba(245, 184, 76, 0.16); color: #ffe1a6; border-color: rgba(245, 184, 76, 0.45); }
.badge-outcome-extracted_only { background: rgba(107, 118, 144, 0.18); color: #b7c0d4; border-color: rgba(107, 118, 144, 0.4); }

.badge-extracting, .badge-searching, .badge-syncing, .badge-running, .pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* Step dots (index) */
.steps-strip { display: inline-flex; gap: 5px; }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--neutral); display: inline-block; }
.step-dot.status-success { background: var(--ok); }
.step-dot.status-warning { background: var(--warn); }
.step-dot.status-error { background: var(--err); }
.step-dot.status-running { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.step-dot.status-skipped { background: transparent; border: 1.5px solid var(--neutral); }

/* Timeline (show) */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; border-left: 2px solid var(--border); }
.timeline-item { position: relative; padding: 0 0 18px 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -8px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--neutral); border: 2px solid var(--bg-elev); }
.timeline-item.status-success .timeline-dot { background: var(--ok); }
.timeline-item.status-warning .timeline-dot { background: var(--warn); }
.timeline-item.status-error .timeline-dot { background: var(--err); }
.timeline-item.status-running .timeline-dot { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.timeline-item.status-skipped .timeline-dot { background: var(--bg-elev); border-color: var(--neutral); }
.timeline-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline-message { margin: 4px 0 0; color: var(--text); }
.timeline-item.status-error .timeline-message { color: #ffc2c2; }

.payloads { margin-top: 8px; }
.payloads summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.payload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.payload-grid pre { margin: 0; background: #0b1019; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font: 12.5px/1.45 var(--mono); overflow: auto; max-height: 360px; color: #cfd8ea; }

.error-box { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(255, 107, 107, 0.12); border: 1px solid rgba(255, 107, 107, 0.4); color: #ffd1d1; font-family: var(--mono); font-size: 13px; }

/* Buttons */
.btn { display: inline-block; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent); color: #0b1019; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3, .payload-grid { grid-template-columns: 1fr; }
  .page { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
}

/* Costs tab */
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.table .num { text-align: right; }
.table-compact td, .table-compact th { padding: 6px 10px; }
.chart { margin: 0; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { stroke: var(--text-muted); stroke-width: 1; }
.chart-tick { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.chart-bar { fill: var(--accent); }
.chart-hit { fill: transparent; }
.chart-bar-group:hover .chart-hit { fill: rgba(91, 157, 255, 0.08); }
.chart-bar-group:hover .chart-bar { fill: #8ebbff; }

/* Filters */
.filters { margin-bottom: 14px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.filter-grow { flex: 1 1 260px; }
.filter > span { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.filter input, .filter select {
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font: inherit; font-size: 14px; min-height: 36px; color-scheme: dark;
}
.filter input:focus, .filter select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-actions { flex-direction: row; gap: 8px; min-width: 0; }
.filter-actions .btn { min-height: 36px; padding: 0 14px; }

/* Stat tiles as filters */
a.stat { color: inherit; display: block; transition: border-color .15s, background .15s; }
a.stat:hover { text-decoration: none; border-color: var(--text-muted); }
a.stat.stat-active { border-color: var(--accent); background: var(--accent-soft); }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pagination-pages { display: flex; gap: 4px; }
.pagination-count { margin: 12px 0 0; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 8px; border: 1px solid var(--border); color: var(--text); font-family: var(--mono); font-size: 13px;
}
a.page-link:hover { border-color: var(--text-muted); text-decoration: none; }
.page-link.current { background: var(--accent); border-color: var(--accent); color: #0b1019; font-weight: 600; }
.page-link.disabled, .page-link.gap { color: var(--text-muted); border-color: transparent; }

/* Authentication */
.auth { display: flex; justify-content: center; padding: 48px 0; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 28px 22px; }
.auth-title { font-size: 22px; margin-bottom: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-form .filter input { width: 100%; }
.auth-links { margin: 16px 0 0; text-align: center; font-size: 14px; }
.btn-block { width: 100%; text-align: center; min-height: 40px; }
.btn-small { padding: 5px 10px; font-size: 13px; min-height: 0; }
.topbar-nav { display: flex; align-items: center; gap: 18px; }
.topbar-nav a { margin-left: 0; }
.topbar-user { color: var(--text-muted); font-size: 13px; font-family: var(--mono); }
.inline-form { display: inline; }

/* Dashboard */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.segmented a { padding: 6px 14px; color: var(--text-muted); font-size: 13px; font-weight: 500; border-right: 1px solid var(--border); }
.segmented a:last-child { border-right: 0; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.active { background: var(--accent-soft); color: var(--text); }

.kpis { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-hero { grid-column: span 2; }
.kpi-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.kpi-value { font-size: 28px; font-weight: 600; font-family: var(--mono); line-height: 1.1; }
.kpi-hero .kpi-value { font-size: 40px; color: var(--ok); }
.kpi-warn { color: var(--warn); }
.kpi-sub { color: var(--text-muted); font-size: 12.5px; }
.kpi-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--bg-elev-2); margin-top: 8px; gap: 2px; }
.kpi-bar-seg { display: block; height: 100%; }

.seg-created { fill: var(--ok); background: var(--ok); }
.seg-updated { fill: var(--accent); background: var(--accent); }
.seg-ambiguous { fill: var(--warn); background: var(--warn); }
.seg-failed { fill: var(--err); background: var(--err); }
.seg-extracted_only { fill: var(--neutral); background: var(--neutral); }

.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-bottom: 18px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--text-muted); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.meters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.meter { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; font-size: 14px; }
.meter-track { display: block; height: 8px; border-radius: 999px; background: var(--bg-elev-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.meter-fill.meter-mid { background: var(--warn); }
.meter-fill.meter-low { background: var(--err); }
.meter-value { text-align: right; font-size: 13px; }
h2.mt { margin-top: 22px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
