:root {
  --bg: #0f1115; --panel: #1a1a2e; --field: #0d1117; --border: #2a2d3a;
  --text: #e0e0e0; --muted: #8b90a0; --accent: #4f8cff; --ok: #3ddc84; --warn: #f5b942; --bad: #ff5c5c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
body { display: flex; flex-direction: column; min-height: 100vh; }
header { padding: 14px 20px 6px; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
.tag { margin: 2px 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.banner { margin: 10px 20px; padding: 12px 14px; border-radius: 8px; background: #2a2340; border: 1px solid #5a4a8a; }
.banner.warn { background: #3a2f1a; border-color: #8a6a2a; }
.banner button { margin-left: 10px; }
main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 8px 20px 16px; }
section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.folder { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.folder .right { margin-left: auto; }
button, select, input[type=text], input[type=number] {
  background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font: inherit;
}
input[type=text], input[type=number] { min-width: 60px; }
input[type=number] { width: 70px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rulesHead, .previewHead { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.spacer { flex: 1; }
#ruleList { display: flex; flex-direction: column; gap: 6px; }
#ruleList:empty::after { content: "No rules yet. Add one above."; color: var(--muted); }
.rule { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--field); border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.rule.dragging { opacity: .5; }
.rule .grip { cursor: grab; color: var(--muted); user-select: none; }
.rule .ruleLabel { font-weight: 600; min-width: 130px; }
.rule .params { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.rule .params label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.rule .ruleError { color: var(--bad); font-size: 12px; }
.rule button { padding: 2px 8px; }
.preview { flex: 1; display: flex; flex-direction: column; min-height: 240px; }
.tableWrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 8px; max-height: 60vh; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: #22243a; }
td:first-child { color: var(--muted); width: 1%; }
tr.same td { color: var(--muted); }
tr.ok td.new { color: var(--ok); }
tr.invalid td.st, tr.collision td.st { color: var(--bad); font-weight: 600; }
tr.invalid td.new, tr.collision td.new { color: var(--bad); }
#progress { position: relative; height: 22px; background: var(--field); border-radius: 6px; margin-bottom: 8px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
#progressText { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }
footer { padding: 6px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
