:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1f2328; --muted: #6b6f76; --line: #e3e1dc;
  --accent: #2f5bd3; --accent-ink: #ffffff; --accent-soft: #e8eefc;
  --good: #1f7a4d; --good-soft: #e3f4ea; --warn: #9a5b00; --warn-soft: #fdf0d9;
  --bad: #b3261e; --bad-soft: #fbe5e3; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --panel: #1d2024; --ink: #e7e8ea; --muted: #9aa0a8; --line: #2d3137;
    --accent: #7c9cff; --accent-ink: #0d1020; --accent-soft: #232b45;
    --good: #5cc98e; --good-soft: #17301f; --warn: #f0b45a; --warn-soft: #33270f;
    --bad: #ff8a80; --bad-soft: #3a1d1b; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; align-items: flex-start; }
.right { text-align: right; }

button, .btn, select, input, textarea {
  font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: .45rem .7rem;
}
button, .btn { cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: transparent; }
button:disabled { opacity: .55; cursor: progress; }
input, textarea, select { width: auto; }
textarea { width: 100%; resize: vertical; }
input[type=search] { min-width: 0; }
#add-url { width: 100%; margin-bottom: .5rem; }

header.top {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .01em; }
nav button { border: none; background: none; padding: .4rem .7rem; border-radius: 6px; color: var(--muted); }
nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fetch { display: flex; gap: .6rem; align-items: center; }

main { padding: 14px 16px 40px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > .card { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.filters input[type=search] { flex: 1 1 220px; }
.chk { display: flex; align-items: center; gap: .35rem; font-size: .9rem; }

.split { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 1rem; align-items: start; margin-top: .4rem; }
.job-list { display: flex; flex-direction: column; gap: .45rem; max-height: calc(100vh - 170px); overflow: auto; padding-right: 4px; }
.job {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .75rem;
  cursor: pointer; display: grid; grid-template-columns: 44px 1fr; gap: .65rem;
}
.job:hover { border-color: var(--muted); }
.job.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.job.dim { opacity: .6; }
.job .t { font-weight: 600; line-height: 1.3; }
.job .e { color: var(--muted); font-size: .88rem; }
.job .m { font-size: .82rem; color: var(--muted); display: flex; gap: .7rem; flex-wrap: wrap; margin-top: .2rem; }
.job .quick { display: flex; gap: .3rem; margin-top: .4rem; }
.job .quick button { padding: .15rem .5rem; font-size: .8rem; }

.score { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  background: var(--accent-soft); color: var(--accent); }
.score.hi { background: var(--good-soft); color: var(--good); }
.score.lo { background: var(--warn-soft); color: var(--warn); }
.score.x { background: var(--bad-soft); color: var(--bad); }

.pill { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .78rem; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
  position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.detail.empty { display: grid; place-items: center; min-height: 240px; }
.detail h1 { font-size: 1.25rem; margin: 0 0 .15rem; line-height: 1.3; }
.detail .close { display: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin: .8rem 0; }
.fact { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; }
.fact b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.reasons { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .85rem; color: var(--muted); }
.desc { white-space: pre-wrap; font-size: .9rem; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: .7rem; background: var(--bg); }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.aifit { border-left: 3px solid var(--accent); padding: .5rem .8rem; background: var(--accent-soft); border-radius: 6px; font-size: .9rem; }
.aifit ul { margin: .2rem 0; padding-left: 1.1rem; }

.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.step { border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; display: flex; flex-direction: column; gap: .35rem; }
.step .n { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.step .bt { display: flex; gap: .3rem; flex-wrap: wrap; }
.step .bt button { font-size: .8rem; padding: .2rem .5rem; }
.step.done { border-color: var(--good); }
.output { border: 1px solid var(--line); border-radius: 8px; margin-top: .6rem; }
.output summary { cursor: pointer; padding: .5rem .7rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.output .md { padding: 0 .9rem .8rem; font-size: .9rem; overflow-x: auto; }
.md table { border-collapse: collapse; font-size: .85rem; margin: .5rem 0; }
.md th, .md td { border: 1px solid var(--line); padding: .25rem .45rem; vertical-align: top; text-align: left; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .7rem; overflow-x: auto; padding-bottom: .5rem; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; min-height: 200px; }
.col h3 { margin: 0 0 .5rem; display: flex; justify-content: space-between; font-size: .9rem; }
.col .job { grid-template-columns: 1fr; padding: .5rem .6rem; margin-bottom: .45rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.kpi .v { font-size: 1.6rem; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: .82rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .88rem; }
table.data th, table.data td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.range { position: relative; height: 10px; background: var(--bg); border-radius: 5px; min-width: 120px; }
.range i { position: absolute; top: 0; bottom: 0; background: var(--accent-soft); border-radius: 5px; }
.range b { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--accent); border-radius: 2px; }
.range .floor { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px dashed var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }

#cv-text { min-height: 70vh; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#cfg-text { min-height: 55vh; }
.bookmarklet { display: inline-block; padding: .3rem .7rem; border: 1px dashed var(--accent); border-radius: 8px; text-decoration: none; font-weight: 600; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: .55rem 1rem; border-radius: 8px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); z-index: 50; }
#toast.on { opacity: 1; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .job-list { max-height: none; overflow: visible; }
  .detail, .detail.empty { position: fixed; inset: 0; top: 0; max-height: none; border-radius: 0; z-index: 30; display: none; }
  .detail.open { display: block; }
  .detail .close { display: inline-block; float: right; }
  .grid2 { grid-template-columns: 1fr; }
  header.top { gap: .4rem; }
  nav { order: 3; width: 100%; overflow-x: auto; white-space: nowrap; }
}
.sortby { font-weight: 600; color: var(--muted); }
