/* ============================================================================
   KIC Ingest Review — Midnight Library theme
   Matches system.keyideacapital.com exactly: dark navy canvas, gold accent,
   Georgia headings, Helvetica Neue body.
   ============================================================================ */

:root {
  --bg:           #0a1628;
  --surface:      #0f1f3d;
  --surface-2:    #162440;
  --border:       rgba(201,168,76,0.18);
  --border-hover: rgba(201,168,76,0.35);
  --accent:       #c9a84c;
  --accent-dim:   rgba(201,168,76,0.12);
  --accent-glow:  rgba(201,168,76,0.08);
  --text:         #f0ead6;
  --text-soft:    rgba(240,234,214,0.72);
  --text-muted:   rgba(240,234,214,0.42);
  --danger:       #c0392b;
  --danger-dim:   rgba(192,57,43,0.18);
  --success:      #27ae60;

  --tier-high-bg:  rgba(39,174,96,0.14);
  --tier-high-ink: #4cd07d;
  --tier-med-bg:   rgba(201,168,76,0.14);
  --tier-med-ink:  #c9a84c;
  --tier-low-bg:   rgba(192,57,43,0.14);
  --tier-low-ink:  #e05c4f;

  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow:    0 4px 20px rgba(0,0,0,0.45);
  --easing:    cubic-bezier(0.2,0,0,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ── */
.ingest-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ── */
.ingest-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 150ms;
}
.back-link:hover { color: var(--accent); }

.ingest-topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.ingest-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: normal;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.ingest-stats { display: flex; gap: 6px; }

.stat-chip {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-feature-settings: "tnum";
  letter-spacing: 0.02em;
}

.ingest-topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

#search {
  width: 280px;
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms var(--easing);
}
#search::placeholder { color: var(--text-muted); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── 3-col layout ── */
.ingest-main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 420px;
  min-height: 0;
}

@media (max-width: 1280px) { .ingest-main { grid-template-columns: 200px 1fr 380px; } }
@media (max-width: 980px)  { .ingest-main { grid-template-columns: 1fr; }
  .ingest-filters, .ingest-detail { display: none; } }

/* ── LEFT: filters ── */
.ingest-filters {
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.filter-group { margin-bottom: 18px; }

.filter-group-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
}

.seg {
  flex: 1;
  padding: 5px 6px;
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 120ms var(--easing), color 120ms var(--easing);
  font-family: inherit;
}
.seg:not(:last-child) { border-right: 1px solid var(--border); }
.seg.active { background: var(--accent-dim); color: var(--accent); }
.seg:hover:not(.active) { background: var(--accent-glow); color: var(--text); }

#filter-flag, #filter-source {
  width: 100%;
  padding: 6px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
#filter-flag option { background: var(--surface); }
#filter-source::placeholder { color: var(--text-muted); }
#filter-flag:focus, #filter-source:focus { border-color: var(--accent); }

.conf-range { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.conf-range input { flex: 1; accent-color: var(--accent); }
.conf-num { font-size: 11px; color: var(--text-soft); font-feature-settings: "tnum"; width: 34px; }

/* ── Buttons ── */
button { font-family: inherit; cursor: pointer; }

.btn-primary, .btn-secondary, .btn-danger, .btn-link {
  padding: 7px 13px;
  border-radius: var(--radius-md);
  font-size: 12px;
  border: 1px solid transparent;
  transition: background 120ms var(--easing), border-color 120ms var(--easing), opacity 120ms;
}

.btn-primary {
  background: var(--accent);
  color: #0a1628;
  border-color: var(--accent);
  font-weight: 600;
  width: 100%;
  margin-top: 7px;
}
.btn-primary:hover { background: #d4b45e; border-color: #d4b45e; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-danger {
  background: var(--danger-dim);
  color: #e05c4f;
  border-color: rgba(192,57,43,0.30);
}
.btn-danger:hover { background: rgba(192,57,43,0.25); }

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 5px 0;
  width: 100%;
  text-align: center;
}
.btn-link:hover { text-decoration: underline; }

/* ── MIDDLE: list ── */
.ingest-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.bulk-all {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.bulk-actions { display: flex; gap: 7px; }
.bulk-actions .btn-primary { margin-top: 0; width: auto; }

.list-items {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.list-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid rgba(201,168,76,0.07);
  cursor: pointer;
  transition: background 100ms var(--easing);
  background: transparent;
  align-items: start;
}
.list-item:hover { background: var(--accent-glow); }
.list-item.selected {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}

.list-item-body { min-width: 0; }

.list-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  color: var(--text);
}

.list-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 10px;
  color: var(--text-muted);
}

.list-item-conf {
  font-weight: 600;
  font-feature-settings: "tnum";
  color: var(--text-soft);
}

/* ── Pills ── */
.tier-pill, .kind-pill, .flag-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 3px;
  margin-right: 3px;
  vertical-align: middle;
}

.tier-pill.high   { background: var(--tier-high-bg); color: var(--tier-high-ink); }
.tier-pill.medium { background: var(--tier-med-bg);  color: var(--tier-med-ink); }
.tier-pill.low    { background: var(--tier-low-bg);  color: var(--tier-low-ink); }

.kind-pill { background: rgba(240,234,214,0.08); color: var(--text-soft); }
.flag-pill { background: var(--danger-dim); color: #e05c4f; }

.list-footer {
  padding: 10px 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── RIGHT: detail ── */
.ingest-detail {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 22px 20px;
}

.detail-empty {
  text-align: center;
  padding-top: 100px;
  color: var(--text-muted);
}
.detail-empty .muted { font-size: 11px; margin-top: 8px; color: var(--text-muted); }

.detail-header { margin-bottom: 20px; }

.detail-header h2 {
  margin: 10px 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: normal;
  color: var(--text);
  letter-spacing: 0.01em;
}

.detail-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-feature-settings: "tnum";
}

#detail-form {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.field { display: flex; flex-direction: column; gap: 3px; }

.field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.field-input, .field-textarea {
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms var(--easing);
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-muted); }
.field-input:focus, .field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-textarea { min-height: 56px; resize: vertical; }

.field.edited .field-input,
.field.edited .field-textarea {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.detail-provenance {
  margin-bottom: 20px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.detail-provenance h3 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.detail-provenance pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SF Mono", "Menlo", "Courier New", monospace;
  font-size: 10px;
  color: var(--text-soft);
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(to top, var(--surface) 70%, transparent);
}

.detail-actions .btn-primary,
.detail-actions .btn-secondary,
.detail-actions .btn-danger {
  margin-top: 0;
  width: 100%;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  box-shadow: var(--shadow);
  transition: opacity 200ms var(--easing), transform 200ms var(--easing);
  pointer-events: none;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(39,174,96,0.4); color: #4cd07d; }
.toast.error   { border-color: rgba(192,57,43,0.4); color: #e05c4f; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.35); }

/* ── Tab bar ── */
.ingest-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.ingest-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
  margin-bottom: -1px;
}
.ingest-tab:hover { color: var(--text); }
.ingest-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Upload panel ── */
.upload-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 24px;
  gap: 24px;
}
.upload-zone {
  width: 100%;
  max-width: 560px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms, background 200ms;
}
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-icon {
  font-size: 36px;
  margin-bottom: 12px;
  color: var(--accent);
}
.upload-heading {
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 6px;
}
.upload-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.upload-browse-btn {
  display: inline-block;
  padding: 8px 20px;
  cursor: pointer;
}
.upload-status-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 13px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 0;
}
.upload-status-msg { margin: 0; }
.upload-batches {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-batch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.upload-batch-label {
  font-size: 11px;
  min-width: 120px;
  color: var(--text-muted);
  white-space: nowrap;
}
.upload-batch-row.active .upload-batch-label { color: var(--accent); font-weight: 600; }
.upload-batch-row.done   .upload-batch-label { color: var(--text-soft); }
.upload-progress-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--border);
  border-radius: 3px;
  width: 0%;
  transition: width 0.25s ease;
}
.upload-batch-row.active .upload-progress-bar { background: var(--accent); }
.upload-batch-row.done   .upload-progress-bar { background: rgba(201,168,76,0.45); transition: none; }
.upload-progress-pct {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
  color: var(--text-muted);
}
.upload-batch-row.active .upload-progress-pct { color: var(--accent); }
.upload-batch-row.done   .upload-progress-pct { color: var(--text-soft); }
.upload-time-est {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 16px;
}
.upload-report-area {
  width: 100%;
  max-width: 560px;
  text-align: center;
}
.upload-report-title {
  font-family: Georgia, serif;
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 20px;
  font-weight: normal;
}
.upload-report-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.report-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  text-align: center;
}
.report-tile-num {
  font-family: Georgia, serif;
  font-size: 28px;
  color: var(--accent);
  display: block;
}
.report-tile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-top: 4px;
}
