:root {
  --bg: #f6f6f4; --card: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #ff4500; --accent-text: #ffffff; --high: #1f7a3d; --high-bg: #e3f4e8;
  --med: #8a5a00; --med-bg: #fbefd6; --low: #555; --low-bg: #ececec; --err: #b42318;
  --field: #ffffff; --chip: #f0efeb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --card: #1e1e1c; --text: #ecebe6; --muted: #9b9a94; --line: #33322f;
    --high: #6fd38f; --high-bg: #16301f; --med: #f0c060; --med-bg: #3a2e12; --low: #bbb; --low-bg: #2a2a28;
    --err: #ff8a80; --field: #262624; --chip: #2a2a27;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); }
.mt { margin-top: 24px; }
h1 { margin: 0 0 4px; font-size: 22px; }
h2 { margin: 0 0 8px; font-size: 17px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field);
}
textarea { resize: vertical; }
label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.check input { width: auto; }
button {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.ghost { background: transparent; border-color: transparent; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 10px; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--accent); }
nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
nav button { border: none; background: transparent; color: var(--muted); }
nav button.active { color: var(--text); background: var(--chip); }

.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.status-actions { display: flex; gap: 8px; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.row input { flex: 1; min-width: 160px; }
.row .narrow { flex: 0 1 200px; }
.savebar { display: flex; gap: 12px; align-items: center; margin-top: 16px; }

.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-row select, .filter-row input { width: auto; flex: 1 1 180px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { border-radius: 999px; font-size: 13px; padding: 4px 12px; }
.seg button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.lead { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.lead-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.lead h3 { margin: 6px 0; font-size: 16px; line-height: 1.35; }
.lead h3 a { text-decoration: none; }
.lead h3 a:hover { text-decoration: underline; }
.badge { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.fit-high { color: var(--high); background: var(--high-bg); }
.fit-medium { color: var(--med); background: var(--med-bg); }
.fit-low, .fit-no { color: var(--low); background: var(--low-bg); }
.reason { font-size: 13px; color: var(--muted); font-style: italic; }
.body { white-space: pre-wrap; font-size: 14px; max-height: 7.5em; overflow: hidden; position: relative; margin: 6px 0; overflow-wrap: anywhere; }
.body.open { max-height: none; }
.more { font-size: 13px; padding: 0; border: none; background: none; color: var(--accent); }
.links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; margin: 8px 0; }
.box { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.box-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.actions label.check { margin: 0 0 0 4px; font-size: 13px; }
.thread { display: grid; gap: 6px; }
.msg { padding: 8px 10px; border-radius: 8px; background: var(--chip); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { border-left: 3px solid var(--accent); }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table input { padding: 4px 8px; }
#tab-runs .card, #tab-keywords .card { overflow-x: auto; }
.examples { display: grid; gap: 8px; margin-top: 12px; }
.example { position: relative; background: var(--chip); border-radius: 8px; padding: 8px 34px 8px 10px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.example button { position: absolute; top: 4px; right: 4px; border: none; background: none; color: var(--muted); padding: 2px 6px; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px); }
.status-select { width: auto; padding: 3px 8px; font-size: 13px; }
