:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1c2430; --muted: #667085; --border: #e1e5eb;
  --brand: #4f46e5; --brand-dark: #3b34c4; --ok: #118a4b; --bad: #c22b2b; --warn: #a15c07;
  --code-bg: #f1f3f7;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code-bg); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 0; }

.topbar { background: #151a2c; color: #fff; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 52px; }
.topbar a { color: #cfd5ea; }
.brand { font-weight: 700; font-size: 17px; color: #fff !important; letter-spacing: .2px; }
.brand span { color: #8b85ff; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: #262d4a; color: #fff; text-decoration: none; }
.topbar form { margin: 0; }
.link-btn { background: none; border: 0; color: #cfd5ea; cursor: pointer; font: inherit; }
.envbar { background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; gap: 6px; align-items: center; height: 44px; }
.envbar .project { font-weight: 600; margin-right: 12px; }
.envbar a { padding: 4px 12px; border-radius: 999px; color: var(--muted); border: 1px solid transparent; }
.envbar a.active { background: #eceafd; color: var(--brand-dark); font-weight: 600; }
.envbar a:hover { text-decoration: none; border-color: var(--border); }

main { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #fafbfc; }
.table-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.btn { display: inline-block; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 7px; cursor: pointer; font: inherit; }
.btn:hover { background: #f3f4f8; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 2px 6px; }
.icon-btn:hover:not([disabled]) { color: var(--bad); }
.icon-btn[disabled] { opacity: .3; cursor: default; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--code-bg); color: var(--muted); }
.badge.exp { background: #fff1d6; color: var(--warn); }
.badge.on { background: #dcf5e7; color: var(--ok); }

.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; background: #c4c9d4; cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .12s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 19px; }

input[type=text], input:not([type]), input[type=number], input[type=password], select, textarea {
  font: inherit; padding: 6px 9px; border: 1px solid #cdd3dd; border-radius: 6px; background: #fff; color: var(--text);
}
textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input:not([type=checkbox]), .field select { width: 100%; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.search { display: flex; gap: 8px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: #e8f0fe; border: 1px solid #c7d7fb; }
.messages li.error { background: #fdeaea; border-color: #f4bcbc; color: #8b1d1d; }
.messages li.success { background: #e3f6ea; border-color: #b6e3c6; color: #0d6b3a; }

.rule-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fcfcfd; }
.rule-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.clause, .serve { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.clause-label { color: var(--muted); width: 34px; }
.clause .attr { width: 170px; }
.clause .values { flex: 1; min-width: 160px; }
.negate { color: var(--muted); font-size: 12.5px; }
.rollout { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.weight input { width: 80px; margin: 0 4px 0 6px; }
.total.ok { color: var(--ok); } .total.bad { color: var(--bad); font-weight: 600; }
.test-result { margin-top: 10px; white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 12.5px; padding: 10px; border-radius: 6px; background: var(--code-bg); }
.test-result:empty { display: none; }
.test-result.ok { border-left: 3px solid var(--ok); }
.test-result.bad { border-left: 3px solid var(--bad); }
.targets textarea { height: 64px; }

.login { max-width: 360px; margin: 80px auto; }
.diff td { vertical-align: top; }
.sig { color: var(--ok); font-weight: 600; }
.nosig { color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--bad); }
.bar { height: 8px; background: var(--code-bg); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand); }
