:root {
  --blue: #0578FF;
  --blue-dark: #0060D6;
  --ink: #1F2328;
  --ink-2: #4B5260;
  --muted: #6B7280;
  --line: #E3E6EA;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --fix: #B3261E;   --fix-bg: #FDECEA;
  --check: #8A5300; --check-bg: #FFF4E0;
  --note: #3C4043;  --note-bg: #F1F3F4;
  --ok: #1E6B34;    --ok-bg: #E6F4EA;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 12px; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
body.no-scroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--fix); }
.copy-buffer { position: fixed; top: 0; left: -9999px; opacity: 0; }

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

/* ---------- buttons, pills ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 9px; border: 1px solid #D3D8DE; background: #fff;
  font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: #F2F4F7; }
.btn:focus-visible, .chip:focus-visible, .date-pill:focus-visible, .thumb:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(5, 120, 255, .35); outline-offset: 1px;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn-quiet:hover { background: #EAEDF1; }
.btn-small { min-height: 34px; padding: 5px 11px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn.flashed { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.btn-linklike { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: underline; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
  line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.pill.fix, .badge.fix { color: var(--fix); background: var(--fix-bg); }
.pill.check, .badge.check { color: var(--check); background: var(--check-bg); }
.pill.note, .badge.note { color: var(--note); background: var(--note-bg); }
.pill.ok, .badge.ok { color: var(--ok); background: var(--ok-bg); }
.pill-lg { font-size: 13.5px; padding: 3px 12px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 26px 26px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}
.brand { color: var(--blue); font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14.5px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.login-card input {
  width: 100%; height: 46px; padding: 0 12px; border: 1px solid #C9CFD6; border-radius: 10px; font-size: 16px; background: #fff;
}
.login-card input[aria-invalid="true"] { border-color: var(--fix); }
.login-error { color: var(--fix); background: var(--fix-bg); border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 14px; }
.login-card .btn { margin-top: 16px; min-height: 46px; font-size: 16px; }

/* ---------- header ---------- */
.top { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 0 12px; margin-bottom: 14px; }
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.top .brand { font-size: 22px; }
.sub { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 6px; }

.hint { flex-basis: 100%; color: var(--muted); font-size: 12.5px; margin-top: -4px; }
.strip {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--line); font-size: 12.5px;
}
.strip-title { font-weight: 700; color: var(--ink-2); margin-right: 2px; padding-top: 3px; }
.req-list { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; margin: 0; padding: 0; flex: 1 1 260px; min-width: 0; }
.req {
  display: flex; flex-direction: column; gap: 1px; max-width: 100%; padding: 3px 10px; border-radius: 10px;
  background: var(--note-bg); color: var(--note);
}
.req-line { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.req .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.req-label { font-weight: 600; overflow-wrap: anywhere; }
.req-status { font-weight: 600; flex: none; }
.req-time { opacity: .8; flex: none; }
.req-msg { opacity: .9; white-space: normal; overflow-wrap: anywhere; padding-left: 13px; }
.strip-more { font-size: 12.5px; padding-top: 3px; }
.req-queued { background: #EAF2FF; color: #0A4FB0; }
.req-running { background: var(--check-bg); color: var(--check); }
.req-running .dot { animation: pulse 1.2s ease-in-out infinite; }
.req-done { background: var(--ok-bg); color: var(--ok); }
.req-failed { background: var(--fix-bg); color: var(--fix); }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- dates, summary, filters ---------- */
.dates { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 6px; scrollbar-width: thin; }
.date-pill {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid #D3D8DE; background: #fff; cursor: pointer; font-weight: 600; font-size: 14px;
}
.date-pill.on { border-color: var(--blue); background: #EAF2FF; color: #0A4FB0; box-shadow: inset 0 0 0 1px var(--blue); }
.dates-key { color: var(--muted); font-size: 12px; margin: -2px 0 10px; }
.dates-key .n { min-width: 0; padding: 0 6px; }
.notice { margin-top: 8px; padding: 7px 10px; border-radius: 8px; background: #EAF2FF; color: #0A4FB0; font-size: 14px; }
.date-counts { display: inline-flex; align-items: center; gap: 3px; }
.n { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11.5px; line-height: 1; font-weight: 700; }
.n.fix { background: var(--fix-bg); color: var(--fix); }
.n.check { background: var(--check-bg); color: var(--check); }
.n.ok { background: var(--ok-bg); color: var(--ok); }

.summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.summary-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.summary h2 { font-size: 18px; }
.summary .link { font-weight: 600; font-size: 14px; text-decoration: none; }
.summary .link:hover { text-decoration: underline; }
.summary-meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.tally { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tally-item { padding: 4px 10px; border-radius: 8px; font-size: 14px; }
.tally-item b { font-size: 15px; }
.tally-item.fix { background: var(--fix-bg); color: var(--fix); }
.tally-item.check { background: var(--check-bg); color: var(--check); }
.tally-item.ok { background: var(--ok-bg); color: var(--ok); }
.summary-text { margin-top: 10px; color: var(--ink-2); font-size: 14.5px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid #D3D8DE; background: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}
.chip-n { font-size: 12px; color: var(--muted); font-weight: 700; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on .chip-n { color: rgba(255, 255, 255, .75); }
.chip-fix.on { background: var(--fix); border-color: var(--fix); }
.chip-check.on { background: var(--check); border-color: var(--check); }
.chip-clean.on { background: var(--ok); border-color: var(--ok); }
.filter-inputs { display: flex; gap: 8px; flex: 1 1 320px; justify-content: flex-end; }
.filter-inputs select, .filter-inputs input {
  height: 36px; border: 1px solid #D3D8DE; border-radius: 9px; background: #fff; padding: 0 10px; font-size: 14px; min-width: 0;
}
.filter-inputs select { flex: 0 1 150px; }
.filter-inputs input { flex: 1 1 200px; max-width: 280px; }

/* ---------- unit cards ---------- */
.unit {
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 6px; margin-bottom: 12px; transition: box-shadow .3s;
}
.unit.v-fix { border-left-color: var(--fix); }
.unit.v-check { border-left-color: #E3A33B; }
.unit.v-ok { border-left-color: #4CAF6A; }
.unit.target, .clean-row.target { box-shadow: 0 0 0 3px rgba(5, 120, 255, .35); }
.unit-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.unit-title h2 { font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.unit-meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.unit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.action-msg { font-size: 13.5px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; }
.action-msg.st-queued { background: #EAF2FF; color: #0A4FB0; }
.action-msg.st-running { background: var(--check-bg); color: var(--check); }
.action-msg.st-done { background: var(--ok-bg); color: var(--ok); }
.action-msg.st-failed { background: var(--fix-bg); color: var(--fix); }

.file { border-top: 1px solid var(--line); margin-top: 12px; padding: 12px 0 8px; }
.file-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 2; background: var(--card); padding: 6px 0 4px; margin-top: -6px;
}
.file-title { min-width: 0; }
.file-unit { display: block; font-size: 12px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.file-name { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.no-issues { color: var(--ok); font-size: 14px; margin-top: 6px; }

.recheck { margin-top: 10px; background: #EEF5FF; border: 1px solid #CFE2FF; border-radius: 10px; padding: 9px 12px; font-size: 14px; color: #17406F; }
.recheck-head b { color: #0A4FB0; }
.resolved { margin: 6px 0 0; padding: 0; list-style: none; }
.resolved li { position: relative; padding-left: 22px; margin-top: 3px; }
.resolved li::before {
  content: ""; position: absolute; left: 4px; top: .38em; width: 10px; height: 5px;
  border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg);
}
.resolved-title { margin-top: 6px; font-weight: 700; color: var(--ok); font-size: 13px; }
.recheck-none { margin-top: 4px; color: var(--ink-2); }

.issues { list-style: none; margin: 10px 0 0; padding: 0; }
.issue {
  display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--line);
}
.issue:first-child { border-top: 0; padding-top: 4px; }
.issue-tag { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.tc { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.issue-body { min-width: 0; }
.onscreen { margin-bottom: 5px; }
.q-mark { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.onscreen q {
  display: inline-block; quotes: "\201C" "\201D"; background: #F4F5F7; border-left: 3px solid #C9CFD6;
  padding: 3px 9px; border-radius: 0 6px 6px 0; font-weight: 600; overflow-wrap: anywhere;
}
.what { color: var(--ink); overflow-wrap: anywhere; }
.issue-fix { margin-top: 5px; overflow-wrap: anywhere; color: var(--ink-2); }
.fix-label {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: #0A4FB0; background: #EAF2FF; border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px;
}
.thumb {
  justify-self: start; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #111; cursor: zoom-in;
  overflow: hidden; line-height: 0; max-width: 100%;
}
.thumb img { display: block; max-width: 100%; max-height: 200px; width: auto; height: auto; }

/* ---------- clean list ---------- */
.clean { margin: 18px 0 8px; }
.clean-title { font-size: 16px; color: var(--ok); margin-bottom: 8px; }
.clean-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.clean-row { padding: 12px 16px; border-top: 1px solid var(--line); }
.clean-row:first-child { border-top: 0; }
.clean-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clean-files { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere; }
.clean-row .unit-actions { margin-top: 8px; }

.empty { background: var(--card); border: 1px dashed #C9CFD6; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-2); }

.foot { color: var(--muted); font-size: 13px; padding-top: 10px; padding-bottom: 36px; }
.foot p { margin-top: 8px; }
.foot .pill { margin: 0 4px 0 6px; }
.foot .pill:first-child { margin-left: 0; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: #0B0D11; display: flex; align-items: center; justify-content: center;
  padding: 56px 12px 16px;
}
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 6px; background: #000; }
.lightbox figcaption { color: #E8EAED; font-size: 14px; text-align: center; max-width: 720px; }
.lb-close {
  position: absolute; top: 12px; right: 12px; min-height: 38px; padding: 6px 14px; border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; cursor: pointer;
}

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  .wrap { padding: 0 22px; }
  .top { padding: 18px 0 14px; margin-bottom: 18px; }
  .top .brand { font-size: 24px; }
  .unit { padding: 18px 22px 8px; }
  .unit-actions { margin-top: 12px; }
  .issue { grid-template-columns: 112px minmax(0, 1fr) auto; gap: 14px; align-items: start; }
  .issue-tag { flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 1px; }
  .thumb { justify-self: end; }
  .thumb img { max-width: 220px; max-height: 150px; }
  .clean-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; }
  .clean-row .unit-actions { margin: 0; justify-content: flex-end; }
  .clean-row .action-msg { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .top-actions { width: 100%; }
  .top-actions #recheckSheet { flex: 1; }
  .filter-inputs { flex-basis: 100%; }
  .filter-inputs select { flex: 0 1 42%; }
  .filter-inputs input { max-width: none; }
  .unit-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .thumb img { max-height: 180px; }
}

@media print {
  .top-actions, .unit-actions, .filters, .strip, .dates { display: none !important; }
  body { background: #fff; }
}
