/* schimba — flat, calm, high-contrast UI. Tokens first; components use only tokens. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #526077;
  --border: #dde3ec;
  --border-strong: #b8c2d1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8f0fe;
  --accent-text: #1d4ed8;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --ok-text: #14532d;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --warn-text: #78350f;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --danger-text: #7f1d1d;
  --old-bg: #fde2e2;
  --old-text: #9f1239;
  --new-bg: #d7f5e0;
  --new-text: #14532d;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.05);
  --shadow-lg: 0 10px 30px rgb(15 23 42 / 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --actionbar-h: 76px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #121a2b;
    --surface-2: #162036;
    --surface-3: #1c2740;
    --text: #e6ebf3;
    --text-2: #c3cddc;
    --muted: #97a4b8;
    --border: #26324a;
    --border-strong: #3a4966;
    --accent: #2563eb;
    --accent-hover: #3b73f0;
    --accent-soft: #1a2a4d;
    --accent-text: #93b8ff;
    --ok: #4ade80;
    --ok-soft: #10301f;
    --ok-text: #a7f3c1;
    --warn: #fbbf24;
    --warn-soft: #33260b;
    --warn-text: #fde5a0;
    --danger: #f87171;
    --danger-soft: #3a1618;
    --danger-text: #fecaca;
    --old-bg: #4a1d24;
    --old-text: #fecdd3;
    --new-bg: #123a24;
    --new-text: #bbf7d0;
    --focus: #7aa7ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.has-actionbar { padding-bottom: calc(var(--actionbar-h) + 16px); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.9rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 0.05em 0.35em; border-radius: 4px; }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1:focus, h1:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tabular { font-variant-numeric: tabular-nums; }
.sprite { display: none; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* ── Top bar ─────────────────────────────── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--on-accent); flex: none; }
.brand-mark .icon { width: 24px; height: 24px; stroke-width: 2.4; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Stepper ─────────────────────────────── */
.stepper { margin-top: 20px; }
.stepper ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; counter-reset: s; }
.step {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 14px; min-height: 60px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.step:hover:not(:disabled) { border-color: var(--border-strong); }
.step:disabled { cursor: not-allowed; opacity: 0.6; }
.step-num { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-weight: 700; flex: none; }
.step-num .icon { display: none; width: 18px; height: 18px; stroke-width: 3; }
.step-text { display: flex; flex-direction: column; min-width: 0; }
.step-title { font-weight: 650; color: var(--text); }
.step-sub { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step[aria-current="step"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.step[aria-current="step"] .step-num { background: var(--accent); color: var(--on-accent); }
.step.is-done .step-num { background: var(--ok); color: #fff; }
.step.is-done .step-num span { display: none; }
.step.is-done .step-num .icon { display: block; }

/* ── Panels ──────────────────────────────── */
main { padding-top: 20px; padding-bottom: 40px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); animation: panel-in 220ms var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel > h1 + .lead { margin-top: 6px; }
.lead { color: var(--text-2); max-width: 68ch; }
.hint { font-size: 0.9rem; color: var(--muted); }
.section-title { margin: 28px 0 12px; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; white-space: nowrap; line-height: 1.2;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 80ms var(--ease);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-link { background: none; border: 0; padding: 0 4px; min-height: 32px; color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-danger { background: #b91c1c; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 1.05rem; }
.btn-xl { min-height: 60px; padding: 0 28px; font-size: 1.15rem; width: 100%; }
.btn-icon { min-width: 44px; padding: 0 10px; }
.btn.is-busy { position: relative; pointer-events: none; }
.btn.is-busy > .icon { visibility: hidden; }
.btn.is-busy::before { content: ""; position: absolute; left: 16px; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
.btn-xl.is-busy::before { left: 28px; }

.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; vertical-align: -3px; }
.spinner-lg { width: 44px; height: 44px; border-width: 4px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--surface-2);
  color: var(--text); font-weight: 550;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip .icon { color: var(--accent-text); width: 1.1em; height: 1.1em; }

/* ── Drop zone ───────────────────────────── */
.dropzone {
  margin-top: 20px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 36px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.is-over, body.is-dragging .dropzone { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.dz-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.dz-icon .icon { width: 32px; height: 32px; }
.dz-title { font-size: 1.2rem; font-weight: 650; }
.dz-or { color: var(--muted); font-size: 0.9rem; }
.dz-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dz-hint { margin-top: 6px; color: var(--muted); font-size: 0.9rem; }

/* ── Progress ────────────────────────────── */
.upload-progress { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.progress-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.progress { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.progress > span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: inherit; transition: width 200ms var(--ease); }
.progress.is-indeterminate > span { width: 35% !important; animation: indeterminate 1.2s var(--ease) infinite; }
@keyframes indeterminate { from { left: -35%; } to { left: 100%; } }
.progress-lg { height: 14px; }
.progress-sub { margin-top: 6px; font-size: 0.9rem; color: var(--muted); }

/* ── File list ───────────────────────────── */
.files-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-top: 28px; }
.files-summary { color: var(--muted); flex: 1 1 auto; }
.file-list, .result-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.file {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 4px 14px;
  padding: 12px 12px 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.file-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.file-icon.k-docx, .file-icon.k-doc { background: #e3ecfd; color: #1e4fb8; }
.file-icon.k-pdf { background: #fde6e6; color: #b42323; }
.file-icon.k-zip { background: #f1e8fd; color: #6b35b8; }
@media (prefers-color-scheme: dark) {
  .file-icon.k-docx, .file-icon.k-doc { background: #1a2a4d; color: #9dbbff; }
  .file-icon.k-pdf { background: #3a1a1c; color: #ffb4b4; }
  .file-icon.k-zip { background: #2b1d45; color: #d2b8ff; }
}
.file-main { min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { font-size: 0.87rem; color: var(--muted); overflow-wrap: anywhere; }
.file-msg { grid-column: 2 / -1; font-size: 0.9rem; color: var(--text-2); display: flex; gap: 6px; align-items: flex-start; }
.file-msg .icon { margin-top: 2px; }
.file-bar { grid-column: 2 / -1; height: 6px; margin-top: 2px; }
.file.is-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.file.is-unsupported { background: var(--surface-2); }
.file.is-partial { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 650; white-space: nowrap; border: 1px solid transparent;
}
.badge .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.badge-ok { background: var(--ok-soft); color: var(--ok-text); }
.badge-warn { background: var(--warn-soft); color: var(--warn-text); }
.badge-error { background: var(--danger-soft); color: var(--danger-text); }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-info { background: var(--accent-soft); color: var(--accent-text); }

/* ── Rules ───────────────────────────────── */
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
.examples-label { color: var(--muted); font-size: 0.9rem; margin-right: 4px; }
.no-files-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); }
.no-files-note > .icon { color: var(--accent-text); }
.no-files-note > span { flex: 1 1 260px; }

.rule-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; }
.rule { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 14px 16px 12px; transition: border-color 150ms var(--ease); }
.rule:focus-within { border-color: var(--border-strong); }
.rule.is-error { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.rule-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rule-num { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; background: var(--rc-bg, var(--surface-3)); color: var(--rc-fg, var(--text-2)); }
.rule-tools { margin-left: auto; display: flex; gap: 2px; }
.rule-tools .btn { min-height: 40px; padding: 0 10px; font-weight: 550; font-size: 0.9rem; }
.rule-tools .btn.has-changes::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.seg { display: inline-flex; margin: 0; padding: 3px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); gap: 2px; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 7px; font-weight: 600; font-size: 0.93rem; color: var(--text-2); transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg label:hover input:not(:checked) + span { background: var(--surface-3); }

.rule-fields { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.9rem; color: var(--text-2); }
.input, .field input, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: 1.05rem;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.field input:hover, textarea:hover { border-color: var(--muted); }
.field input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.rule-arrow { display: grid; place-items: center; height: 48px; color: var(--muted); }
.rule-arrow .icon { width: 22px; height: 22px; }

.rule-status { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 0.93rem; min-height: 1.5em; }
.rule-status.is-stale { opacity: 0.6; }
.st-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-2); }
.st-line .icon { width: 1.1em; height: 1.1em; }
.st-count.ok { color: var(--ok-text); font-weight: 600; }
.st-count.ok .icon { color: var(--ok); }
.st-count.zero { color: var(--warn-text); font-weight: 600; }
.st-count.zero .icon { color: var(--warn); }
.st-error { color: var(--danger-text); font-weight: 600; background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; }
.st-warn { color: var(--warn-text); background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; }
.st-muted { color: var(--muted); }
.st-label strong { color: var(--text); }
.ex-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ex { font-family: var(--mono); font-size: 0.84rem; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }

.rule-options { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 4px; }
.rule-options-title { font-weight: 650; font-size: 0.9rem; margin-bottom: 2px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.check small { color: var(--muted); font-size: 0.87rem; }
.check-text { display: flex; flex-direction: column; }

.rule-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bulk { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.bulk-label { display: block; font-weight: 650; margin-bottom: 8px; }
.bulk textarea { font-family: var(--mono); font-size: 0.98rem; resize: vertical; min-height: 140px; line-height: 1.5; }
.bulk .hint { margin-top: 6px; }
.bulk-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.field-error { margin-top: 8px; color: var(--danger-text); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: 0.93rem; }
.other-dates-hint { margin-top: 18px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* rule colours (number badges + filter chips) */
[data-rc="0"] { --rc-bg: #dbe7fe; --rc-fg: #1e40af; }
[data-rc="1"] { --rc-bg: #f3e1fb; --rc-fg: #7e22ce; }
[data-rc="2"] { --rc-bg: #d9f3ef; --rc-fg: #0f766e; }
[data-rc="3"] { --rc-bg: #fde9d7; --rc-fg: #b45309; }
[data-rc="4"] { --rc-bg: #fbe0ea; --rc-fg: #be185d; }
[data-rc="5"] { --rc-bg: #e4e8ee; --rc-fg: #334155; }
@media (prefers-color-scheme: dark) {
  [data-rc="0"] { --rc-bg: #1c2d57; --rc-fg: #a9c3ff; }
  [data-rc="1"] { --rc-bg: #34204a; --rc-fg: #e1b8ff; }
  [data-rc="2"] { --rc-bg: #113734; --rc-fg: #8ee6d8; }
  [data-rc="3"] { --rc-bg: #3a2812; --rc-fg: #fcc98d; }
  [data-rc="4"] { --rc-bg: #3d1a2a; --rc-fg: #f9a8c9; }
  [data-rc="5"] { --rc-bg: #273246; --rc-fg: #cbd5e1; }
}

/* ── Preview ─────────────────────────────── */
.preview-summary { margin-top: 18px; font-size: 1.1rem; font-weight: 600; }
.preview-summary .muted { color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.notice { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); }
.notice > .icon { margin-top: 2px; }
.notice-body { flex: 1; min-width: 0; }
.notice-body ul { margin: 6px 0 0; padding-left: 18px; }
.notice-body li { overflow-wrap: anywhere; }
.notice-warn { background: var(--warn-soft); color: var(--warn-text); }
.notice-error { background: var(--danger-soft); color: var(--danger-text); }
.notice-info { background: var(--accent-soft); color: var(--text); }
.notice .btn { margin-top: 8px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.toolbar-right { margin-left: auto; display: flex; gap: 4px; }
.filter { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 0.9rem; font-weight: 550; color: var(--text-2); max-width: 100%; }
.filter-chip .fc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.filter-chip .rule-num { min-width: 22px; height: 22px; font-size: 0.8rem; border-radius: 6px; }
.filter-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.filter-chip .tabular { color: var(--muted); }

.preview-files { display: grid; gap: 10px; margin-top: 14px; }
.fgroup { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.fgroup-head { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 12px; background: var(--surface-2); }
.fgroup-head input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex: none; margin: 12px; }
.fgroup-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 6px; text-align: left; background: none; border: 0; border-radius: 6px; }
.fgroup-toggle .chev { transition: transform 150ms var(--ease); color: var(--muted); }
.fgroup-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.fgroup-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.fgroup-folder { color: var(--muted); font-weight: 400; font-size: 0.87rem; display: block; }
.fgroup-toggle .badge { margin-left: auto; }
.occ-list { list-style: none; margin: 0; padding: 0; }
.occ { border-top: 1px solid var(--border); }
.occ > label { display: grid; grid-template-columns: auto auto 1fr; gap: 4px 12px; align-items: start; padding: 10px 14px 10px 20px; cursor: pointer; }
.occ > label:hover { background: var(--surface-2); }
.occ input { width: 20px; height: 20px; accent-color: var(--accent); margin: 2px 0 0; cursor: pointer; }
.occ-tags { display: flex; gap: 6px; align-items: center; }
.occ-tags .rule-num { min-width: 22px; height: 22px; font-size: 0.78rem; border-radius: 6px; }
.occ-loc { font-size: 0.8rem; color: var(--muted); white-space: nowrap; padding-top: 2px; }
.occ-ctx { line-height: 1.7; overflow-wrap: anywhere; color: var(--text-2); }
.occ-ctx del { background: var(--old-bg); color: var(--old-text); text-decoration: line-through; text-decoration-thickness: 2px; padding: 1px 4px; border-radius: 4px; }
.occ-ctx ins { background: var(--new-bg); color: var(--new-text); text-decoration: none; font-weight: 650; padding: 1px 4px; border-radius: 4px; }
.occ-ctx .to { color: var(--muted); margin: 0 3px; }
.occ.is-off .occ-ctx { opacity: 0.55; }
.occ.is-off .occ-ctx ins { background: transparent; text-decoration: line-through; font-weight: 400; color: var(--muted); }
.occ.is-off .occ-ctx del { background: transparent; color: var(--text-2); text-decoration: none; }
.occ.is-locked > label { cursor: not-allowed; background: var(--surface-2); }
.occ.is-locked .occ-ctx { opacity: 0.7; }
.occ.is-locked .occ-ctx del, .occ.is-locked .occ-ctx ins { background: var(--surface-3); color: var(--text-2); }
.occ-reason { grid-column: 3; font-size: 0.87rem; color: var(--warn-text); display: flex; gap: 6px; align-items: center; }
.occ-more { padding: 10px 20px; font-size: 0.9rem; color: var(--muted); border-top: 1px solid var(--border); }

.other-dates { margin-top: 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.other-dates summary { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; font-weight: 650; cursor: pointer; list-style: none; }
.other-dates summary::-webkit-details-marker { display: none; }
.other-dates summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 150ms var(--ease); }
.other-dates[open] summary::after { transform: rotate(-135deg); }
.other-dates > .hint { padding: 0 16px; }
.other-list { list-style: none; margin: 10px 0 0; padding: 0 8px 8px; display: grid; gap: 2px; }
.other-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 8px; border-top: 1px solid var(--border); }
.other-main { flex: 1 1 240px; min-width: 0; }
.other-label { font-weight: 650; }
.other-samples { font-size: 0.87rem; color: var(--muted); overflow-wrap: anywhere; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); display: grid; justify-items: center; gap: 10px; }
.empty .icon { width: 40px; height: 40px; color: var(--muted); }
.empty-title { font-weight: 650; font-size: 1.1rem; color: var(--text); }
.skeleton { display: grid; gap: 10px; margin-top: 18px; }
.skeleton span { display: block; height: 56px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Action bar ──────────────────────────── */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(15 23 42 / 0.06); padding-bottom: env(safe-area-inset-bottom); }
.actionbar-inner { display: flex; align-items: center; gap: 12px; min-height: var(--actionbar-h); padding-top: 10px; padding-bottom: 10px; }
.actionbar-info { flex: 1; min-width: 0; color: var(--text-2); font-size: 0.93rem; text-align: right; }
.actionbar-info strong { color: var(--text); }
#nav-next { min-width: 220px; }
#nav-next.is-apply { background: var(--ok); }
#nav-next.is-apply:hover:not(:disabled) { background: #166534; }
@media (prefers-color-scheme: dark) { #nav-next.is-apply { background: #15803d; } }

/* ── Apply + results ─────────────────────── */
.apply-box { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 28px 8px; }
.apply-box .progress { width: min(520px, 100%); }
.done-hero { display: flex; gap: 16px; align-items: center; }
.done-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); flex: none; }
.done-icon .icon { width: 30px; height: 30px; stroke-width: 3; }
.done-hero.is-warn .done-icon { background: var(--warn-soft); color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 22px; }
.stat { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.stat-value { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; display: flex; align-items: center; gap: 6px; }
.stat-value .icon { color: var(--ok); }
.stat.is-warn .stat-value .icon { color: var(--warn); }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.action-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); display: grid; gap: 8px; align-content: start; }
.result { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.result-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.result-notes { grid-column: 2 / -1; font-size: 0.88rem; color: var(--warn-text); margin: 0; padding-left: 18px; }
.result.is-unchanged { background: var(--surface-2); }
.done-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.done-footer .btn-danger-ghost { margin-left: auto; }

/* ── Toasts ──────────────────────────────── */
.toasts { position: fixed; z-index: 90; right: 16px; bottom: calc(var(--actionbar-h) + 16px); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #0f172a; color: #f1f5f9; box-shadow: var(--shadow-lg); animation: toast-in 200ms var(--ease); font-size: 0.95rem; }
@media (prefers-color-scheme: dark) { .toast { background: #e6ebf3; color: #0f172a; } }
.toast .icon { margin-top: 1px; }
.toast.t-ok .icon { color: #4ade80; }
.toast.t-error .icon { color: #f87171; }
@media (prefers-color-scheme: dark) { .toast.t-ok .icon { color: #15803d; } .toast.t-error .icon { color: #b91c1c; } }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 0 4px; min-height: 28px; }
.toast-close { background: none; border: 0; color: inherit; opacity: 0.7; padding: 0; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; }
.toast-close:hover { opacity: 1; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 150ms, transform 150ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Dialogs ─────────────────────────────── */
.dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgb(15 23 42 / 0.55); }
.dialog form { padding: 24px; display: grid; gap: 12px; }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dialog-help { width: min(640px, calc(100vw - 32px)); }
.help-steps, .help-tips { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: var(--text-2); }
.dialog h3 { margin-top: 6px; }

.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 760px) {
  .wrap { padding: 0 12px; }
  .panel { padding: 20px 16px; border-radius: 10px; }
  .stepper { margin-top: 12px; }
  .step { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px; min-height: 64px; text-align: center; }
  .step-sub { display: none; }
  .step-title { font-size: 0.85rem; line-height: 1.2; }
  .step-num { width: 28px; height: 28px; }
  .brand-text span { display: none; }
  #help-open span { display: none; }
  #help-open { min-width: 44px; padding: 0 10px; }
  .rule-fields { grid-template-columns: 1fr; gap: 6px; }
  .rule-arrow { height: 20px; transform: rotate(90deg); justify-self: start; margin-left: 10px; }
  .rule-tools .btn span { display: none; }
  .rule-tools .btn { min-width: 44px; }
  .actions-grid { grid-template-columns: 1fr; }
  .file { grid-template-columns: auto 1fr auto; }
  .file .badge { grid-column: 2; grid-row: 2; justify-self: start; }
  .file .btn-remove { grid-column: 3; grid-row: 1; }
  .result { grid-template-columns: auto 1fr; }
  .result-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .result-actions .btn { flex: 1 1 auto; }
  .result-notes { grid-column: 1 / -1; }
  .occ > label { grid-template-columns: auto 1fr; padding-left: 12px; }
  .occ-tags { grid-column: 2; }
  .occ-ctx, .occ-reason { grid-column: 2; }
  .toolbar-right { margin-left: 0; }
  .actionbar-info { display: none; }
  #nav-next { min-width: 0; flex: 1; }
  .actionbar-inner { gap: 8px; }
  .done-footer .btn { flex: 1 1 100%; }
  .done-footer .btn-danger-ghost { margin-left: 0; }
  .done-hero { align-items: flex-start; }
  .toasts { right: 12px; left: 12px; width: auto; }
}
@media (max-width: 400px) {
  #nav-back span { display: none; }
  #nav-back { min-width: 44px; padding: 0 12px; }
  .btn-lg { padding: 0 16px; font-size: 1rem; }
  .seg label span { padding: 0 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .spinner, .btn.is-busy::before { animation: spin 1.4s linear infinite !important; }
}

/* ── Refinements ─────────────────────────── */
.rule-head { flex-wrap: nowrap; }
.rule-tools { margin: 6px 0 0 -10px; display: flex; flex-wrap: wrap; gap: 2px; }
.rule-tools .btn { min-height: 40px; padding: 0 10px; font-weight: 550; font-size: 0.9rem; color: var(--muted); }
.rule-tools .btn:hover:not(:disabled) { color: var(--text); }
.rule-tools .btn[aria-expanded="true"] { color: var(--accent-text); background: var(--accent-soft); }
.rule-tools .btn-ghost-danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.other-dates-hint { flex-wrap: nowrap; align-items: flex-start; }
.other-dates-hint > .icon { margin-top: 3px; color: var(--accent-text); }
.other-dates-hint .btn-link { min-height: 0; padding: 0; }
.st-line .btn-link { min-height: 0; padding: 0 2px; }

.dropzone.is-compact { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 16px 20px; gap: 12px 16px; }
.dropzone.is-compact .dz-icon { width: 44px; height: 44px; margin: 0; }
.dropzone.is-compact .dz-icon .icon { width: 22px; height: 22px; }
.dropzone.is-compact .dz-title { font-size: 1.02rem; }
.dropzone.is-compact .dz-or, .dropzone.is-compact .dz-hint { display: none; }
.dropzone.is-compact .btn { min-height: 40px; }
.file-more { display: flex; justify-content: center; padding-top: 4px; }

.result-details { margin-top: 24px; border: 1px solid var(--border); border-radius: var(--radius); }
.result-details > summary { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px; cursor: pointer; list-style: none; }
.result-details > summary::-webkit-details-marker { display: none; }
.result-details > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 150ms var(--ease); flex: none; }
.result-details[open] > summary::after { transform: rotate(-135deg); }
.rd-text { display: flex; flex-direction: column; }
.rd-title { font-weight: 650; font-size: 1.1rem; }
.result-details .result-list { margin: 0; padding: 0 12px 12px; }
.fgroup-name, .file-name { overflow-wrap: break-word; word-break: normal; }

@media (max-width: 760px) {
  .rule-tools .btn span { display: inline; }
  .rule-tools .btn { min-width: 0; }
  .fgroup-toggle { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; }
  .fgroup-toggle .badge { grid-column: 2; justify-self: start; margin-left: 0; }
  .fgroup-name { overflow-wrap: anywhere; }
  .dropzone.is-compact { flex-direction: column; }
}

.occ > label { grid-template-columns: auto 7.5rem 1fr; }
.occ-tags { flex-wrap: wrap; align-items: flex-start; }
.occ-loc { white-space: normal; line-height: 1.3; padding-top: 3px; }
.done-footer .btn-danger-ghost { margin-left: 0; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px dashed color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone .hint { flex: 1 1 280px; }
.step.is-done .step-num { color: var(--surface); }
@media (max-width: 760px) {
  .occ > label { grid-template-columns: auto 1fr; }
  .occ-tags { flex-wrap: nowrap; }
  .danger-zone .btn { width: 100%; }
}

/* ── Review fixes ────────────────────────── */
/* Icon + text stay on one row; long messages wrap inside the text span, not under the icon. */
.st-line { flex-wrap: nowrap; align-items: flex-start; }
.st-line > .icon { margin-top: 0.2em; }
.st-text { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.st-count .st-text, .st-muted .st-text, .st-label .st-text { flex: 0 1 auto; }
.field input[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.actionbar-info .info-error { color: var(--danger-text); font-weight: 650; display: inline-flex; align-items: center; gap: 6px; }
.notice-title { font-size: 1rem; font-weight: 700; margin: 0 0 4px; }
.notice-title:focus { outline: none; }
.notice-body p { margin: 0; }
.preview-summary.is-zero { display: grid; gap: 8px; justify-items: start; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.preview-summary .zero-title { display: inline-flex; align-items: center; gap: 8px; }
.preview-summary .zero-title .icon { color: var(--warn); }
.step-sub, .brand-text span { max-width: 100%; }
