/* Redakt — workspace styles.
   Restrained on purpose: this sits next to case files and payroll, so it should
   read like a professional tool, not a consumer app. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #16181d;
  --ink-2: #5a6270;
  --ink-3: #8b93a1;
  --line: #dfe3e9;
  --accent: #1b4dd6;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  /* Separate from --danger: the destructive button needs a fill that keeps
     white text legible, which is not the same colour that reads well as text. */
  --danger-fill: #b3261e;
  --danger-fill-ink: #ffffff;
  --ok: #12704a;
  --ok-bg: #e7f4ee;
  --warn: #8a5a00;
  /* Redaction bars sit on a rendered PDF page, which is white in both themes,
     so this stays near-black and is deliberately not themed. */
  --mark: #16181d;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.06), 0 8px 24px rgba(16, 20, 28, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272f;
    --ink: #eceef2;
    --ink-2: #a8b0bd;
    --ink-3: #7b8494;
    --line: #30353f;
    --accent: #6f95ff;
    --accent-ink: #10131a;
    --danger: #f2857c;
    --danger-fill: #c0392f;
    --danger-fill-ink: #ffffff;
    --ok: #6cd6a4;
    --ok-bg: #16302a;
    --warn: #e3b464;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ── Top bar ─────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 9px; }
/* The logo is a miniature of the icon: a light page with one bar removed from
   it. Its colours are fixed rather than themed, so the bar keeps its contrast
   against the page in both light and dark chrome. */
.brand-mark {
  width: 18px; height: 22px;
  background: #f7f8fa;
  border: 1.5px solid #16181d;
  border-radius: 2px;
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; top: 8px; height: 5px;
  background: #16181d;
}
@media (prefers-color-scheme: dark) {
  .brand-mark { border-color: #8b93a1; }
}
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.tagline { margin: 0; color: var(--ink-2); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.offline-badge {
  font-size: 12px;
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  padding: 3px 9px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ── Buttons & inputs ────────────────────────────────────────────── */
.btn {
  font: inherit;
  padding: 7px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn-danger {
  background: var(--danger-fill);
  border-color: var(--danger-fill);
  color: var(--danger-fill-ink);
  font-weight: 600;
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); background: var(--danger-fill); }
.btn-ghost { background: transparent; }
.btn-tiny { padding: 4px 9px; font-size: 13px; }
.btn-block { width: 100%; }
.link {
  background: none; border: none; padding: 0;
  font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline;
}
.input {
  font: inherit;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.input:focus-visible, .btn:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Views ───────────────────────────────────────────────────────── */
.view { flex: 1; min-height: 0; }
.view[hidden] { display: none; }

.view-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 28px; overflow: auto;
}
.dropzone {
  width: min(560px, 100%);
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 44px 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--surface-2); }
.dropzone h1 { font-size: 20px; margin-bottom: 4px; }
.dropzone p { margin: 4px 0; color: var(--ink-2); }
.dropzone-note { font-size: 13px; color: var(--ink-3); margin-top: 14px !important; }
.dropzone-icon { width: 56px; height: 56px; margin-bottom: 12px; }
.dropzone-icon .s-page { fill: none; stroke: var(--ink-3); stroke-width: 2; }
.dropzone-icon .s-line { fill: var(--ink-3); opacity: 0.55; }
.dropzone-icon .s-bar { fill: var(--mark); }

.explainer {
  width: min(560px, 100%);
  color: var(--ink-2);
  font-size: 13.5px;
}
.explainer h2 { font-size: 14px; color: var(--ink); margin-bottom: 6px; }
.explainer p { margin: 0 0 8px; }

/* ── Editor layout ───────────────────────────────────────────────── */
.view-editor { display: grid; grid-template-columns: 168px 1fr 320px; }

.thumbs {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.thumbs-head {
  padding: 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px;
}
.doc-name {
  font-size: 12px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.thumb-list { list-style: none; margin: 0; padding: 10px; overflow-y: auto; flex: 1; }
.thumb {
  width: 100%; padding: 0; margin-bottom: 10px; cursor: pointer;
  background: var(--surface-2); border: 2px solid transparent; border-radius: 4px;
  display: block; position: relative; line-height: 0;
}
.thumb canvas { width: 100%; height: auto; border-radius: 2px; display: block; }
.thumb.is-current { border-color: var(--accent); }
.thumb-num {
  position: absolute; bottom: 3px; right: 4px;
  font-size: 10px; line-height: 1.4; padding: 0 4px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
}
.thumb-count {
  position: absolute; top: 3px; left: 4px;
  font-size: 10px; line-height: 1.5; padding: 0 5px; border-radius: 100px;
  background: var(--danger); color: #fff; font-weight: 600;
}

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex: none;
}
.stage-bar-sep { width: 1px; height: 18px; background: var(--line); }
.stage-bar-spacer { flex: 1; }
.page-label { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 84px; text-align: center; }
.hint { font-size: 12.5px; color: var(--ink-3); }

.stage-scroll { flex: 1; overflow: auto; padding: 20px; display: flex; justify-content: center; }
.page-wrap {
  position: relative; align-self: flex-start;
  box-shadow: var(--shadow); background: #fff; line-height: 0;
}
.page-canvas { display: block; }
.overlay { position: absolute; inset: 0; cursor: crosshair; }

.mark {
  position: absolute;
  background: var(--mark);
  outline: 1px solid rgba(255, 255, 255, 0.45);
}
.mark[data-source="manual"] { background: #16181d; }
.mark-del {
  position: absolute; top: -9px; right: -9px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid #fff; background: var(--danger); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
  display: none;
}
.mark:hover .mark-del { display: block; }
.drawing {
  position: absolute;
  background: rgba(22, 24, 29, 0.55);
  border: 1px solid #fff;
  pointer-events: none;
}

/* ── Right panel ─────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.panel-block { padding: 14px; border-bottom: 1px solid var(--line); }
.panel-block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); margin-bottom: 6px; }
.panel-note { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-3); }
.panel-status { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.row { display: flex; gap: 6px; }
.row .input { flex: 1; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.check small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.findings { margin-top: 10px; }
.finding-group {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px;
}
.finding-group:first-child { border-top: none; }
.finding-label { flex: 1; }
.finding-count {
  font-variant-numeric: tabular-nums; color: var(--ink-2);
  background: var(--surface-2); border-radius: 100px; padding: 1px 8px; font-size: 12px;
}
.findings-actions { margin-top: 10px; display: grid; gap: 6px; }
.findings-empty { font-size: 13px; color: var(--ink-2); margin: 0; }
.upsell {
  margin: 8px 0 0; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 12.5px; color: var(--ink-2);
}

.panel-foot { padding: 14px; margin-top: auto; }
.mark-summary { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }

/* ── Overlays ────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(12, 14, 18, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.scrim[hidden] { display: none; }
.card {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
}
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card-progress { width: min(400px, 100%); }
.muted { color: var(--ink-2); margin: 0 0 14px; font-size: 13.5px; }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.card-actions .btn-ghost:first-child { margin-right: auto; }

.bar { height: 6px; background: var(--surface-2); border-radius: 100px; overflow: hidden; margin: 14px 0 8px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.checks { list-style: none; margin: 0; padding: 0; }
.check-item {
  display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px;
}
.check-item:first-child { border-top: none; }
.check-icon { flex: none; font-weight: 700; width: 16px; }
.check-item.ok .check-icon { color: var(--ok); }
.check-item.fail .check-icon { color: var(--danger); }
.check-detail { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }

.stats {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-3);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
.verdict-ok { color: var(--ok); }
.verdict-fail { color: var(--danger); }
.error { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.licence-state { font-size: 13.5px; margin: 0 0 14px; }
