:root {
  --bg:         #efefef;
  --surface:    #ffffff;
  --surface2:   #f7f7f7;
  --border:     #d4d4d4;
  --border2:    #e8e8e8;
  --text:       #1a1a1a;
  --muted:      #717171;
  --accent:     #c0152a;
  --accent-h:   #9b0e21;
  --accent-bg:  rgba(192,21,42,.07);
  --green:      #1e6b2e;
  --green-bg:   rgba(30,107,46,.07);
  --radius:     6px;
  --shadow:     0 1px 3px rgba(0,0,0,.10);
}

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

body {
  font-family: system-ui,-apple-system,sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  position: sticky; top:0; z-index:100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
}
.logo span { color: var(--text); font-weight:400 }
#settings-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  transition: border-color .15s, color .15s;
}
#settings-btn:hover { border-color: var(--text); color: var(--text) }

/* ── Steps ── */
#steps {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 38px;
  font-size: 12px;
  color: var(--muted);
}
#steps.hidden { display: none }
.step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.step.active { color: var(--accent); border-bottom-color: var(--accent); font-weight:600 }
.step.done   { color: var(--text) }
.step-arrow  { color: var(--border); margin: 0 -4px }

/* ── Main layout ── */
#app {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

/* ── Screens ── */
.screen { display: none }
.screen.active { display: block }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card + .card { margin-top: 16px }

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}
.card-title small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

/* ── Upload zone ── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface2);
}
#drop-zone:hover, #drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}
#drop-zone .dz-icon { font-size: 32px; margin-bottom: 12px; opacity:.5 }
#drop-zone .dz-label { font-weight: 600; margin-bottom: 6px }
#drop-zone .dz-hint  { color: var(--muted); font-size: 12px }
#drop-zone .dz-formats { font-size: 11px; color: var(--muted); margin-top: 10px }
#file-input { display:none }

.landing-intro {
  text-align: center;
  margin: 40px 0 24px;
}
.landing-intro h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}
.landing-tagline {
  font-size: 14px;
  color: var(--muted);
}
.landing-disclaimer {
  max-width: 620px;
  margin: 20px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Info box (per-screen instructions) ── */
.help-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.help-box .help-icon { flex: 0 0 auto; font-size: 14px }

/* ── Profile match banner ── */
.profile-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Inline tooltip dot ── */
.info-dot {
  display: inline-block;
  width: 14px; height: 14px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  cursor: help;
  margin-left: 4px;
}
.info-dot:hover { color: var(--text); border-color: var(--text) }

/* ── File info bar ── */
.file-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
}
.file-bar .file-icon { font-size: 18px; opacity:.7 }
.file-bar .file-name { font-weight: 600; flex:1 }
.file-bar .file-meta { color: var(--muted); font-size: 12px }
.file-bar .file-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--border);
  color: var(--muted);
}

/* ── Batch wizard file sections ── */
.batch-file-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.batch-file-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.batch-file-note {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}
.batch-auto {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--border);
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: auto;
}
.batch-warn {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  margin-left: auto;
}
.batch-file-error .batch-file-hdr,
.batch-file-skip  .batch-file-hdr { opacity: .6 }
.batch-cols { margin: 0 }
.batch-cols td, .batch-cols th { padding: 6px 10px }

/* Column mode toggle group (batch wizard) */
.col-mode-grp {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.col-mode-opt {
  padding: 3px 9px;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  color: var(--muted);
  transition: background .1s, color .1s;
}
.col-mode-opt:last-child { border-right: none }
.col-mode-opt.active.mode-skip   { background: var(--border2); color: var(--text) }
.col-mode-opt.active.mode-key    { background: #fef9c3; color: #854d0e }
.col-mode-opt.active.mode-redact { background: var(--accent-bg); color: var(--accent); font-weight:600 }

/* ── Form elements ── */
.field { margin-bottom: 16px }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type=text], input[type=password], select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus, select:focus {
  border-color: var(--text);
}

/* radio group */
.radio-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.radio-group label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.radio-group input[type=radio] { accent-color: var(--accent) }

/* hints list */
.hints-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.hint-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
}
.hint-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.hint-add {
  display: flex;
  gap: 6px;
}
.hint-add input { flex: 1 }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h) }
.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--border2) }
.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  font-weight: 400;
}
.btn-ghost:hover:not(:disabled) { color: var(--text) }
.btn-full { width: 100%; justify-content: center }
.btn-sm   { padding: 4px 10px; font-size: 12px; font-weight: 500 }

/* ── Spinner ── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.scanning .spinner { display: block }
.scanning .btn-label { display: none }

@keyframes spin { to { transform: rotate(360deg) } }

.scan-progress {
  text-align: center;
  padding: 32px 0;
  color: var(--muted);
}
.scan-progress .spin-lg {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 14px;
}

/* ── Span table ── */
.span-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}
.span-stats strong { color: var(--text); font-size: 15px }

.span-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

table.spans {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.spans th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}
table.spans td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
}
table.spans tr.rejected td { opacity: .45 }
table.spans tr:hover td { background: var(--surface2) }

.toggle-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
  color: var(--muted);
}
.toggle-btn.approved {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.pii-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pii-badge.type-person   { background:#f5f5f5; border-color:#bbb; color:#333 }
.pii-badge.type-email    { background:#fff3f3; border-color:#e8b0b0; color:#8b1010 }
.pii-badge.type-phone    { background:#f5f5f5; border-color:#bbb; color:#333 }
.pii-badge.type-address  { background:#f5f5f5; border-color:#bbb; color:#333 }
.pii-badge.type-date     { background:#f5f5f5; border-color:#bbb; color:#333 }
.pii-badge.type-account  { background:#fff3f3; border-color:#e8b0b0; color:#8b1010 }
.pii-badge.type-url      { background:#f5f5f5; border-color:#bbb; color:#333 }
.pii-badge.type-secret   { background:#2a0a0a; border-color:#5a1010; color:#ffaaaa }
.pii-badge.type-custom   { background:#f5f5f5; border-color:#bbb; color:#333 }

.conf-dots { letter-spacing: 1px; font-size: 11px }
.conf-hi { color: var(--accent) }
.conf-md { color: var(--muted) }
.conf-lo { color: var(--border) }

/* source badge */
.src-badge {
  font-size: 10px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 2px;
  padding: 1px 4px;
}

/* ── Text highlight preview ── */
.text-preview {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 20px;
}
.text-preview mark.pii-mark {
  background: var(--accent-bg);
  color: var(--accent);
  border-bottom: 1.5px solid var(--accent);
  border-radius: 2px;
  padding: 0 1px;
  cursor: pointer;
  transition: background .12s;
}
.text-preview mark.pii-mark:hover { background: rgba(192,21,42,.16) }
.text-preview mark.pii-mark.rejected {
  background: rgba(0,0,0,.04);
  color: var(--muted);
  border-bottom-color: var(--border);
  text-decoration: line-through;
}
.preview-toggle {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
}
.preview-toggle:hover { color: var(--text) }

/* ── Add missed PII ── */
.add-span-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border2);
  flex-wrap: wrap;
}
.add-span-row input { flex: 2; min-width: 140px }
.add-span-row select { flex: 1; min-width: 110px; width: auto }

/* ── Column table ── */
table.cols {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.cols th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}
table.cols td {
  padding: 8px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
}
table.cols tr.suggested td:first-child::after {
  content: ' ✦';
  color: var(--accent);
  font-size: 10px;
}
.col-samples {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
table.cols input[type=checkbox] { accent-color: var(--accent); width:15px; height:15px }
table.cols select { width: auto; padding: 4px 6px; font-size: 12px }
table.cols tr.row-disabled { opacity: .45 }

/* ── Redaction mode selector ── */
.mode-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border2);
}
.mode-section .field { margin-bottom: 0 }

/* ── Done screen ── */
.done-card {
  text-align: center;
  padding: 40px 28px;
}
.done-icon { font-size: 40px; margin-bottom: 16px }
.done-card h2 { font-size: 20px; margin-bottom: 6px }
.done-card p  { color: var(--muted); margin-bottom: 24px }
.done-card .done-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Settings modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 15px; font-weight: 600 }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--muted);
}
.modal-close:hover { color: var(--text) }

/* ── Error / notice ── */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.notice-error   { background: #fff3f3; border-color: #e8b0b0; color: #8b0000 }
.notice-info    { background: var(--surface2); border-color: var(--border); color: var(--muted) }
.notice-success { background: var(--green-bg); border-color: var(--green); color: var(--green) }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border2);
  margin: 20px 0;
}

/* ── Annotation canvas ── */
.ann-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ann-toolbar .spacer { flex: 1 }
.ann-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
#ann-stats {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  min-height: 20px;
}
.ann-wrap {
  position: relative;
  display: block;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #e8e8e8;
  margin-bottom: 12px;
}
#ann-img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
#ann-canvas {
  position: absolute;
  top: 0; left: 0;
  cursor: crosshair;
}
#ann-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232,232,232,.7);
}
#ann-loader .spin-lg {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.ann-kbd {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.ann-kbd kbd {
  font-family: inherit;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}

/* ── Helpers ── */
.mt8  { margin-top: 8px }
.mt16 { margin-top: 16px }
.flex-end { display:flex; justify-content:flex-end; gap:8px }
.text-muted { color: var(--muted) }
.hidden { display:none !important }

/* ── Profile rows ── */
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }

/* ── Type filter grid (scan screen) ── */
.type-filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.type-toggle {
  cursor: pointer;
  border: none;
  font: inherit;
  transition: opacity .15s, filter .15s;
}
.type-toggle.type-off {
  opacity: .3;
  filter: grayscale(1);
}

/* ── Category bar (review screen) ── */
.category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.cat-badge {
  cursor: pointer;
  border: none;
  font: inherit;
  padding: 3px 10px;
  border-radius: 12px;
  transition: opacity .15s;
}
.cat-badge.cat-off  { opacity: .4; filter: grayscale(1); }
.cat-badge.cat-mixed { outline: 2px dashed currentColor; outline-offset: -2px; }
.cat-badge:hover { opacity: .8; }

/* ── Batch screen ── */
.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.batch-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; }
.batch-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.batch-table tr:last-child td { border-bottom: none; }

.status-dot { font-size: 11px; margin-right: 4px; }
.status-dot.pending    { color: var(--muted); }
.status-dot.processing { color: var(--accent); animation: blink 1s infinite; }
.status-dot.done       { color: var(--green); }
.status-dot.skipped    { color: var(--muted); }
.status-dot.error      { color: var(--accent); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
