/* ── RESET & VARIABLES ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1a1a;
  --paper: #f5f0e8;
  --cream: #ede8dc;
  --rule: #c8bfaa;
  --accent: #8b1a1a;
  --accent2: #c0392b;
  --muted: #6b6355;
  --success: #2d6a4f;
  --warn: #b5651d;
  --surface: #ffffff;
  --mono: 'Courier New', monospace;
  --serif: Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}

/* ── MASTHEAD ───────────────────────────────────────────────────── */
.masthead {
  background: var(--ink);
  color: var(--paper);
  padding: 24px 40px;
  border-bottom: 4px solid var(--accent);
  display: flex;
  align-items: baseline;
  gap: 20px;
}
.masthead h1 {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--paper);
}
.masthead .sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--rule);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-left: 1px solid #555;
  padding-left: 20px;
}

/* ── LAYOUT ─────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ── UPLOAD ─────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--rule);
  border-radius: 4px;
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(139, 26, 26, 0.04);
}
.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  display: block;
}
.upload-zone h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin-bottom: 6px;
}
.upload-zone p {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: var(--mono);
}

.file-pill {
  background: var(--ink);
  color: var(--paper);
  padding: 11px 16px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.file-pill .name { flex: 1; }
.file-pill .size { color: var(--rule); }
.file-pill button {
  background: none;
  border: none;
  color: var(--rule);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 2px;
  transition: color 0.15s;
}
.file-pill button:hover { color: var(--accent2); }

/* ── SETTINGS ───────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.field select,
.field input[type=number] {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
  min-width: 150px;
}
.field input[type=number] { min-width: 80px; }

/* ── PROCESS BUTTON ─────────────────────────────────────────────── */
.process-btn {
  background: var(--accent);
  color: var(--paper);
  border: none;
  padding: 13px 24px;
  font-family: var(--serif);
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 2px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s;
}
.process-btn:hover:not(:disabled) { background: var(--accent2); }
.process-btn:disabled { background: var(--rule); cursor: not-allowed; }

/* ── PROGRESS ───────────────────────────────────────────────────── */
.progress-box {
  background: var(--cream);
  border-radius: 2px;
  padding: 14px 16px;
}
.prog-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.78rem;
  margin-bottom: 8px;
  font-weight: 600;
}
.track {
  height: 5px;
  background: var(--rule);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 10px;
}
.fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.35s;
}
.logbox {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.7;
}
.logbox .ok  { color: var(--success); }
.logbox .warn { color: var(--warn); }
.logbox .err  { color: var(--accent); }

/* ── ERROR ──────────────────────────────────────────────────────── */
.err-bar {
  background: #fdf0f0;
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 11px 16px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 16px;
}

/* ── RESULTS ────────────────────────────────────────────────────── */
.res-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
  flex-wrap: wrap;
  gap: 12px;
}
.res-header h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
}
.res-header .count {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.export-row { display: flex; gap: 8px; }
.btn-export {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}
.btn-export:hover { background: var(--accent); }
.btn-export.csv { background: var(--success); }
.btn-export.csv:hover { background: #1b4332; }

/* ── TABLE ──────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th {
  padding: 10px 12px;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
td {
  padding: 13px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--cream);
}
tr:hover td { background: var(--cream); }

.td-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  width: 95px;
}
.td-type { width: 115px; }
.td-bates {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  width: 105px;
}
.td-prov { font-weight: 600; width: 150px; }

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-weight: 600;
}
.type-office    { background: #e8f0fe; color: #1a56db; }
.type-imaging   { background: #fef3c7; color: #92400e; }
.type-lab       { background: #d1fae5; color: #065f46; }
.type-procedure { background: #ede9fe; color: #5b21b6; }
.type-hospital  { background: #fee2e2; color: #991b1b; }
.type-telehealth{ background: #e0f2fe; color: #075985; }
.type-referral  { background: #fce7f3; color: #9d174d; }
.type-other     { background: #f3f4f6; color: #374151; }

.soap-line { line-height: 1.55; margin-bottom: 3px; }
.soap-line strong {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  margin-right: 4px;
}

/* ── MISC ───────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 50px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  border: 1px dashed var(--rule);
  border-radius: 2px;
}
.spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  text-align: center;
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 20px;
}
