/* ==========================================================================
   DocHub — design tokens
   Colours come from a validated data-viz palette: the categorical slots are
   used in fixed order for tag identity, blue is the single sequential hue for
   magnitude bars, and the status four are reserved for state.
   ========================================================================== */

:root {
  color-scheme: light;

  /* surfaces & ink */
  --plane:            #f9f9f7;
  --surface:          #fcfcfb;
  --surface-2:        #f2f2ef;
  --ink:              #0b0b0b;
  --ink-2:            #52514e;
  --muted:            #898781;
  --grid:             #e1e0d9;
  --baseline:         #c3c2b7;
  --border:           rgba(11, 11, 11, .10);
  --border-strong:    rgba(11, 11, 11, .18);
  --shadow:           0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg:        0 8px 32px rgba(16, 24, 40, .14);

  /* categorical slots (fixed order — never cycled) */
  --series-1:         #2a78d6;   /* blue    */
  --series-2:         #eb6834;   /* orange  */
  --series-3:         #1baf7a;   /* aqua    */
  --series-4:         #eda100;   /* yellow  */
  --series-5:         #e87ba4;   /* magenta */

  /* sequential (magnitude) — blue ramp */
  --seq-100:          #cde2fb;
  --seq-250:          #86b6ef;
  --seq-450:          #2a78d6;
  --seq-550:          #1c5cab;

  /* status — reserved, never used as a series */
  --good:             #0ca30c;
  --warning:          #fab219;
  --serious:          #ec835a;
  --critical:         #d03b3b;
  --good-text:        #006300;

  --accent:           #2a78d6;
  --accent-hover:     #256abf;
  --accent-ink:       #ffffff;
  --accent-wash:      rgba(42, 120, 214, .10);

  --radius:           10px;
  --radius-sm:        7px;
  --radius-lg:        14px;
  --sidebar-w:        232px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:         #0d0d0d;
    --surface:       #1a1a19;
    --surface-2:     #232322;
    --ink:           #ffffff;
    --ink-2:         #c3c2b7;
    --muted:         #898781;
    --grid:          #2c2c2a;
    --baseline:      #383835;
    --border:        rgba(255, 255, 255, .10);
    --border-strong: rgba(255, 255, 255, .20);
    --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg:     0 8px 32px rgba(0, 0, 0, .55);

    --series-1:      #3987e5;
    --series-2:      #d95926;
    --series-3:      #199e70;
    --series-4:      #c98500;
    --series-5:      #d55181;

    --seq-100:       #184f95;
    --seq-250:       #1c5cab;
    --seq-450:       #3987e5;
    --seq-550:       #86b6ef;

    --good-text:     #0ca30c;

    --accent:        #3987e5;
    --accent-hover:  #5598e7;
    --accent-wash:   rgba(57, 135, 229, .16);
  }
}

/* The viewer's toggle must win in both directions. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:         #0d0d0d;
  --surface:       #1a1a19;
  --surface-2:     #232322;
  --ink:           #ffffff;
  --ink-2:         #c3c2b7;
  --muted:         #898781;
  --grid:          #2c2c2a;
  --baseline:      #383835;
  --border:        rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .20);
  --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg:     0 8px 32px rgba(0, 0, 0, .55);

  --series-1:      #3987e5;
  --series-2:      #d95926;
  --series-3:      #199e70;
  --series-4:      #c98500;
  --series-5:      #d55181;

  --seq-100:       #184f95;
  --seq-250:       #1c5cab;
  --seq-450:       #3987e5;
  --seq-550:       #86b6ef;

  --good-text:     #0ca30c;

  --accent:        #3987e5;
  --accent-hover:  #5598e7;
  --accent-wash:   rgba(57, 135, 229, .16);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }

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

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-wash); }

/* ==========================================================================
   Boot & login
   ========================================================================== */

.boot {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-mark {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--ink-2); font-size: 14px; margin-bottom: 24px; }

/* ==========================================================================
   Offline overlay — sits above everything, leaving the app intact beneath.
   ========================================================================== */

.offline-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--plane);
}

.offline-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.offline-mark {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--serious) 14%, transparent);
  color: var(--serious);
}

.offline-card h1 { font-size: 20px; margin-bottom: 8px; }
.offline-body { color: var(--ink-2); font-size: 14px; margin-bottom: 22px; }

.offline-status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.4em;
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px;
}

.brand { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; background: var(--accent); margin-right: 8px;
  vertical-align: 1px;
}

.sidebar-close { display: none; }

.nav { flex: 1; overflow-y: auto; padding: 0 12px; }

.nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 16px 8px 6px; font-weight: 600;
}

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav a svg { flex: 0 0 16px; opacity: .9; }
.nav .nav-count {
  margin-left: auto; font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.theme-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-icon {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.page-title { font-size: 17px; flex: 1; min-width: 0; }

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

.user-chip { display: flex; align-items: center; gap: 9px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13px; font-weight: 600; }
.user-meta small { font-size: 11.5px; color: var(--muted); }

.menu-btn { display: none; }

.view {
  flex: 1;
  padding: 24px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
.view:focus { outline: none; }

/* ==========================================================================
   Buttons, forms, chips
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  font: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); }

.btn-ghost { background: none; border-color: transparent; color: var(--ink-2); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink);
}

input[type=text], input[type=password], input[type=email], input[type=url],
input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit; font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 400; cursor: pointer;
}
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 200px; margin-bottom: 16px; }

.alert {
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex; gap: 9px; align-items: flex-start;
}
.alert-critical { border-left-color: var(--critical); }
.alert-good     { border-left-color: var(--good); }
.alert-warning  { border-left-color: var(--warning); }
.alert strong { font-weight: 600; }

/* Tag chips: the hue rides a dot, the label stays in ink — a light
   categorical hue is illegible as text on the surface. */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 100%;
}
.tag .swatch {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px;
  background: var(--muted);
}
.tag-branch  .swatch { background: var(--series-1); }
.tag-doctype .swatch { background: var(--series-2); }
.tag-entity  .swatch { background: var(--series-3); }
.tag-keyword .swatch { background: var(--series-4); }
.tag-manual  .swatch { background: var(--series-5); }
.tag-branch, .tag-doctype { font-weight: 600; color: var(--ink); }
.tag .tag-x {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 0 0 2px;
}
.tag .tag-x:hover { color: var(--critical); }

button.tag { cursor: pointer; font: inherit; font-size: 12px; }
button.tag:hover { border-color: var(--accent); color: var(--ink); }
button.tag.on { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border);
}
.pill-good     { color: var(--good-text); }
.pill-warn     { color: var(--warning); }
.pill-critical { color: var(--critical); }
.pill-muted    { color: var(--muted); }

/* ==========================================================================
   Cards, tables, layout
   ========================================================================== */

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

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head .lede { color: var(--ink-2); font-size: 14px; margin-top: 4px; max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .strong { font-weight: 600; color: var(--ink); }
table.data .dim { color: var(--muted); font-size: 13px; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty .empty-mark { font-size: 30px; margin-bottom: 10px; opacity: .5; }
.empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 5px; }
.empty p { font-size: 14px; max-width: 46ch; margin: 0 auto 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--grid) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ==========================================================================
   Stat tiles & charts
   ========================================================================== */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.stat .value {
  font-size: 27px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em;
}
.stat .note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.stat .note.attention { color: var(--serious); }

/* Horizontal magnitude bars: one measure, one hue, value at the tip. */
.bars { display: flex; flex-direction: column; gap: 12px; }

.bar-row { display: grid; grid-template-columns: minmax(84px, 26%) 1fr; gap: 12px; align-items: center; }
.bar-row .bar-label {
  font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-fill {
  height: 14px;
  background: var(--seq-450);
  border-radius: 0 4px 4px 0;   /* rounded data-end, square at the baseline */
  min-width: 2px;
  /* --pct is the value's share of the maximum. The 4.5rem reserve keeps the
     tip label inside the row even when a bar is at full length. */
  width: calc(var(--pct, 0) / 100 * (100% - 4.5rem));
  flex: 0 1 auto;
  transition: width .3s ease;
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
.bar-row:hover .bar-fill { background: var(--seq-550); }
.bar-value {
  font-size: 13px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bar-row.zero .bar-value { color: var(--muted); font-weight: 400; }

.chart-toggle {
  display: flex; gap: 2px; background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 2px;
}
.chart-toggle button {
  border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 5px; cursor: pointer;
}
.chart-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }

/* ==========================================================================
   Documents
   ========================================================================== */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; }
.filters .grow { flex: 1 1 240px; }
.filters select, .filters input { min-width: 130px; }

.search-box { position: relative; }
.search-box input { padding-left: 34px; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

.doc-list { display: flex; flex-direction: column; gap: 10px; }

.doc-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  color: inherit; text-decoration: none;
}
.doc-card:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }

.doc-top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.doc-icon {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent-wash); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.doc-head { flex: 1; min-width: 0; }
.doc-title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-sub {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.doc-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--baseline); }
.doc-summary {
  font-size: 13px; color: var(--ink-2); margin: 8px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden;
}

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 20px; font-size: 13px; color: var(--muted);
}

/* Document detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 16px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.pdf-frame {
  width: 100%; height: 640px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

dl.meta { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; color: var(--ink); word-break: break-word; }

.text-dump {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  max-height: 340px; overflow: auto;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px;
  color: var(--ink-2);
}

/* ==========================================================================
   Upload
   ========================================================================== */

.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.dropzone .dz-strong { font-weight: 600; display: block; margin-bottom: 3px; }
.dropzone .dz-hint { font-size: 12.5px; color: var(--muted); }

.filelist { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; }
.filelist li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; background: var(--surface-2);
  border-radius: var(--radius-sm); margin-top: 6px; font-size: 13px;
}
.filelist .size { margin-left: auto; color: var(--muted); font-size: 12px; }
.filelist .scan-flag {
  font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}

/* Shown when a chosen file has no text layer and will be OCR'd in the browser. */
.ocr-notice {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding: 10px 13px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--muted);
  text-align: left;
}
.ocr-notice .btn { margin-left: auto; flex-shrink: 0; }

.result-card {
  border: 1px solid var(--border); border-left: 3px solid var(--good);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 12px;
}
.result-card.bad { border-left-color: var(--critical); }
.result-card h4 { font-size: 14px; margin-bottom: 6px; }

/* ==========================================================================
   Toasts & modal
   ========================================================================== */

.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 11px 14px;
  font-size: 13.5px;
  display: flex; gap: 9px; align-items: flex-start;
  animation: toast-in .18s ease;
}
.toast.good     { border-left-color: var(--good); }
.toast.critical { border-left-color: var(--critical); }
.toast.warning  { border-left-color: var(--warning); }
.toast .toast-x {
  margin-left: auto; border: 0; background: none; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.modal-root {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(11, 11, 11, .45);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}

.modal {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  margin: auto;
}
.modal.wide { max-width: 680px; }
.modal h2 { font-size: 17px; margin-bottom: 4px; }
.modal .modal-sub { font-size: 13.5px; color: var(--ink-2); margin-bottom: 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}

.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: var(--mono); font-size: 12.5px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-close, .menu-btn { display: grid; }
  .view { padding: 18px 16px; }
  .topbar { padding: 10px 16px; }
  .user-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

@media print {
  .sidebar, .topbar, .toasts, .page-actions { display: none !important; }
  .view { max-width: none; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
