:root {
  --paper: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #1B2333;
  --muted: #5B6578;
  --faint: #8A93A5;
  --line: #DDE1E8;
  --line-strong: #C5CBD6;
  --accent: #23305E;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6E9F4;
  --high: #B42318;
  --high-bg: #FCE8E6;
  --medium: #A64B06;
  --medium-bg: #FDF0DD;
  --low: #475467;
  --low-bg: #ECEEF2;
  --ok: #24704F;
  --ok-bg: #E3F2EA;
  --shadow: 0 1px 2px rgba(27, 35, 51, .06), 0 8px 24px rgba(27, 35, 51, .08);
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11151D;
    --surface: #181E29;
    --surface-2: #1D2431;
    --ink: #E7EAF0;
    --muted: #A0A9BA;
    --faint: #7A8396;
    --line: #2A3242;
    --line-strong: #3A4457;
    --accent: #9FB1F0;
    --accent-ink: #11151D;
    --accent-soft: #252F4A;
    --high: #FF8A7A;
    --high-bg: #3A1F1E;
    --medium: #F2B266;
    --medium-bg: #3A2C18;
    --low: #B5BDCB;
    --low-bg: #262D3A;
    --ok: #74D1A4;
    --ok-bg: #18342A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell::before { content: ""; position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--surface);
  border-right: 1px solid var(--line); z-index: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 22px 14px; background: var(--surface); z-index: 1;
}
.wordmark { display: flex; align-items: center; gap: 10px; padding: 0 10px; text-decoration: none; color: var(--ink);
  font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.wordmark svg { width: 26px; height: 26px; }
.wordmark svg circle { fill: var(--accent); }
.wordmark svg .ring { fill: none; stroke: var(--surface); stroke-width: 3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count { min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--high); color: #fff; font-size: 12px;
  font-weight: 700; text-align: center; line-height: 20px; }
@media (prefers-color-scheme: dark) { .nav-count { color: #11151D; } }

.view { padding: 32px 40px 64px; max-width: 1240px; width: 100%; outline: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell::before { display: none; }
  .sidebar { position: sticky; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 5; min-width: 0; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; min-width: 0; order: 3; scrollbar-width: none; }
  .nav a { white-space: nowrap; }
  .job-dock { order: 2; margin-left: auto; }
  .view { padding: 20px 16px 48px; }
}

/* ---------- job dock (always visible: scans never block navigation) ---------- */
.job-dock { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.job-card { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); text-decoration: none; color: var(--ink); font-size: 13px; }
.job-card strong { display: block; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-card span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-card .bar { margin-top: 8px; }
.job-card.queued { opacity: .75; }
@media (max-width: 860px) { .job-card { padding: 4px 10px; max-width: 220px; } .job-card span { display: none; } .job-card .bar { margin-top: 4px; } }

.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; transition: width .4s ease; }
.bar.indeterminate > i { width: 35%; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; letter-spacing: -.015em; margin: 0; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--high); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 0; height: auto; color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--faint); font-size: 12.5px; }
input[type=text], input[type=search], input[type=number], input[type=date], select, textarea {
  height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; width: 100%; }
input[type=search] { min-width: 280px; }
@media (max-width: 600px) { input[type=search] { min-width: 0; width: 100%; } }
.check { display: flex; gap: 8px; align-items: flex-start; }
.toolbar .check { align-items: center; margin: 0 4px; }
[hidden] { display: none !important; }
.check input { margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; height: 34px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.panel-pad { padding: 20px 22px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td .main { font-weight: 600; }
td .meta { color: var(--muted); font-size: 13px; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.mono-id { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.exp-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; }
.exp-link:hover { text-decoration: underline; }
.exp-link .ext { width: 13px; height: 13px; flex: none; }
.doc-link { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; }
.doc-link:hover { text-decoration: underline; }
.doc-link .ext { width: 11px; height: 11px; flex: none; }

.lvl { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12.5px; font-weight: 700; line-height: 20px; }
.lvl.HIGH { background: var(--high-bg); color: var(--high); }
.lvl.MEDIUM { background: var(--medium-bg); color: var(--medium); }
.lvl.LOW { background: var(--low-bg); color: var(--low); }
.counts { display: inline-flex; gap: 4px; text-decoration: none; }
.counts .lvl { min-width: 26px; text-align: center; padding: 1px 6px; }
.counts .zero { opacity: .35; }

.status-select { height: 30px; font-size: 13px; padding: 0 6px; }
.tag { display: inline-block; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 12.5px; color: var(--muted); line-height: 20px; }
.scanning { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 13px; }
.scanning::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- opposition window (the one bold element) ---------- */
.win { width: 150px; }
.win-track { position: relative; height: 8px; border-radius: 4px; background: var(--line); }
.win-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.win-tick { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); opacity: .55; }
.win-label { margin-top: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.win-label b { color: var(--ink); }
.u-proxima .win-fill { background: var(--medium); }
.u-urgente .win-fill { background: var(--high); }
.u-urgente .win-label b { color: var(--high); }
.u-vencida .win-fill { background: var(--faint); }
.u-vencida .win-label { text-decoration: line-through; }

.timeline { position: relative; }
.tl-axis { display: grid; grid-template-columns: 260px 1fr; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.tl-axis .ticks { position: relative; height: 18px; }
.tl-axis .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-row { display: grid; grid-template-columns: 260px 1fr; align-items: center; min-height: 46px; border-top: 1px solid var(--line);
  text-decoration: none; color: inherit; }
.tl-row:hover { background: var(--surface-2); }
.tl-label { padding: 6px 12px 6px 0; min-width: 0; }
.tl-label .main { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label .meta { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-lane { position: relative; height: 46px; }
.tl-bar { position: absolute; top: 17px; height: 12px; border-radius: 6px; background: var(--accent); opacity: .9; }
.tl-bar.HIGH { background: var(--high); }
.tl-bar.MEDIUM { background: var(--medium); }
.tl-bar.LOW { background: var(--low); }
.tl-internal { position: absolute; top: 12px; width: 2px; height: 22px; background: var(--ink); opacity: .5; }
.tl-days { position: absolute; top: 14px; font-size: 12px; font-weight: 700; white-space: nowrap; padding-left: 8px; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--ink); opacity: .45; pointer-events: none; }
.tl-today-label { position: absolute; top: -20px; transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--ink); }
.tl-overlay { position: absolute; top: 24px; bottom: 0; left: 260px; right: 0; pointer-events: none; }
@media (max-width: 860px) {
  .tl-axis, .tl-row { grid-template-columns: 130px 1fr; }
  .tl-overlay { left: 130px; }
}

.stat-line { display: flex; flex-wrap: wrap; gap: 28px; margin: 0 0 24px; }
.stat-line a { text-decoration: none; color: var(--ink); }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 14px; }
.stat.high b { color: var(--high); }
.stat.medium b { color: var(--medium); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 16px; }
.empty p { max-width: 52ch; margin: 0 auto 16px; }
.note { font-size: 13px; color: var(--muted); }
.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--medium-bg); color: var(--ink); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.info { background: var(--accent-soft); }
.notice.error { background: var(--high-bg); }

.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px; color: var(--muted); font-size: 13px; }

/* ---------- drawer ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(17, 21, 29, .32); z-index: 30; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 31;
  box-shadow: var(--shadow); display: flex; flex-direction: column; animation: enter .18s ease; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 22px; }
.drawer-body { padding: 18px 22px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.drawer section h3 { color: var(--muted); font-size: 13px; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vs > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.vs .name { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.vs .who { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.status-buttons button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input[type=text] { width: 100%; }
.win.large { width: 100%; }
.win.large .win-track { height: 10px; }
.log { font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.log div { padding: 6px 10px; border-left: 3px solid var(--line-strong); background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.log .warning { border-left-color: var(--medium); }
.log .error { border-left-color: var(--high); }
@keyframes enter { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 40; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px;
  display: flex; gap: 12px; align-items: flex-start; animation: enter .18s ease; }
.toast a { color: inherit; font-weight: 700; white-space: nowrap; }
.toast.error { background: var(--high); color: #fff; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; font-size: 16px; line-height: 1; }

.skeleton { color: var(--faint); padding: 24px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- ignored words ---------- */
.words-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 960px) { .words-grid { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 9px; border: 1px solid var(--line-strong); border-radius: 14px;
  font-size: 13px; background: var(--surface-2); }
.chip.added { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 10px; }
.chip button:hover { color: var(--high); background: var(--high-bg); }
table.compact td { padding: 7px 8px; }

/* ---------- registration term & brand panel ---------- */
.vig-bad { color: var(--high); }
.vig-warn { color: var(--medium); }
.mini-alerts { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); }
.mini-alert { display: grid; grid-template-columns: 64px 1fr 150px; gap: 10px; align-items: center; padding: 9px 12px;
  text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.mini-alert:first-child { border-top: 0; }
.mini-alert:hover { background: var(--surface-2); }
@media (max-width: 560px) { .mini-alert { grid-template-columns: 56px 1fr; } .mini-alert .win { grid-column: 1 / -1; width: 100%; } }
.renew-list { display: flex; flex-direction: column; gap: 8px; }
.renew-list a { text-decoration: none; color: inherit; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.renew-list a:hover .main { text-decoration: underline; }

td .vig-warn, .meta.vig-warn { color: var(--medium); }
td .vig-bad { color: var(--high); }

.user-box { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 0; border-top: 1px solid var(--line); font-size: 13px; min-width: 0; }
.user-box .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box .btn.link { align-self: flex-start; font-size: 13px; }
@media (max-width: 860px) { .user-box { order: 2; border-top: 0; padding: 0; flex-direction: row; align-items: center; gap: 8px; } .user-box .meta { display: none; } }
