/* streaming-lb admin panel — dark, dense, dependency-free. */
:root {
  --bg: #0f1218; --panel: #161b24; --panel2: #1c232e; --line: #2a3340;
  --fg: #e6edf3; --muted: #8b98a8; --accent: #4f9dff; --accent2: #2b6fd1;
  --ok: #3fb950; --warn: #d29922; --err: #f85149; --block: #f85149;
  --radius: 8px; --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
code { font-family: var(--mono); background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* --- unified dropdowns (dark theme + custom caret) --- */
select {
  -webkit-appearance: none; appearance: none;
  background-color: var(--panel2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath fill='%238b98a8' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 6px;
  padding: 6px 28px 6px 9px;
  height: 32px;
  cursor: pointer;
}
select:hover { border-color: #3a4757; }
select:focus { outline: none; border-color: var(--accent); }
select.block { color: var(--block); }
select option { background: var(--panel2); color: var(--fg); }

/* --- login --- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login-card { width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 22px; }
.login-card label, .modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-card input, .modal-card input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 6px; padding: 9px 10px; font-size: 14px;
}
.login-card button {
  background: var(--accent2); color: #fff; border: 0; border-radius: 6px; padding: 10px; font-weight: 600;
}
.err { color: var(--err); font-size: 12px; margin: 0; }

/* --- topbar --- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.platforms { display: flex; gap: 4px; }
.platforms button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 5px 12px; border-radius: 6px; text-transform: capitalize;
}
.platforms button.active { background: var(--panel2); color: var(--fg); border-color: var(--line); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.dirty { background: #3a2c10; color: var(--warn); border-color: #5a4416; }

.btn {
  background: var(--panel2); color: var(--fg); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }

/* --- layout --- */
.layout { display: grid; grid-template-columns: 1fr 460px; gap: 0; height: calc(100vh - 53px); }
.col { overflow: auto; }
.col.editor { border-right: 1px solid var(--line); }

.tabs { display: flex; gap: 2px; padding: 8px 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tabs button {
  background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; font-size: 13px;
}
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.panel { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.filter, .code-input { background: var(--panel2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 5px 9px; }
.code-input { text-transform: uppercase; width: 70px; text-align: center; font-family: var(--mono); }

/* --- tables --- */
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.grid td { padding: 5px 8px; border-bottom: 1px solid var(--panel2); vertical-align: middle; }
.grid tr:hover td { background: var(--panel); }
.grid input[type=text], .grid input:not([type]) {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 5px; padding: 5px 7px; width: 100%; min-width: 60px;
}
.grid select { width: 100%; min-width: 60px; }
.grid input.code { text-transform: uppercase; font-family: var(--mono); width: 60px; text-align: center; }
.grid td.center { text-align: center; }

.iconbtn { background: transparent; border: 0; color: var(--muted); font-size: 15px; padding: 2px 6px; border-radius: 4px; }
.iconbtn:hover { color: var(--err); background: var(--panel2); }

/* --- toggle switch --- */
.switch { position: relative; display: inline-block; width: 38px; height: 20px; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: background .15s; pointer-events: none; }
.switch .slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--accent2); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 2px var(--accent); }
/* dim the identity of a disabled server row, but keep its toggle bright */
.grid tr.off td input[type=text], .grid tr.off td input:not([type]) { color: var(--muted); opacity: .6; }

/* --- buckets --- */
.bucket {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px;
}
.bucket-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bucket-head input.bid { width: 130px; font-family: var(--mono); background: var(--panel2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 8px; height: 32px; }
.bucket-head select { width: auto; min-width: 120px; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 20px; background: var(--panel2); color: var(--muted); }
/* members sit in an indented list under the bucket head */
.members { display: flex; flex-direction: column; gap: 6px; }
.member-row { display: flex; align-items: center; gap: 8px; }
.member-row select { flex: 1 1 auto; min-width: 0; }
.member-row input { background: var(--panel2); border: 1px solid var(--line); color: var(--fg); border-radius: 5px; padding: 6px 8px; height: 32px; }
.member-row .weight { flex: 0 0 64px; width: 64px; text-align: right; font-family: var(--mono); }
.member-row .on { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.member-row .pct { flex: 0 0 42px; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--accent); }
.member-row .unit { flex: 0 0 auto; color: var(--muted); margin-left: -4px; font-size: 12px; }
.member-row .iconbtn { flex: 0 0 auto; }
.members-total { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.members-total .sum-ok { font-family: var(--mono); color: var(--ok); }
.members-total .sum-warn { font-family: var(--mono); color: var(--warn); }
.pct { font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* --- global redirect tab --- */
#redirectStatus { margin-bottom: 12px; }
.redirect-on { background: #2a1416; border: 1px solid #5a2226; color: #ffb4ac; border-radius: 6px; padding: 10px 12px; font-size: 13px; font-family: var(--mono); }
.redirect-off { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
#redirectTable tr.redirect-row-on td { background: #2a1416; }
#redirectTable code { font-size: 13px; }

/* --- meta form --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 8px 10px;
}
.form-grid select { width: 100%; height: 38px; }
.checkline { flex-direction: row !important; align-items: center; gap: 8px; }
.checkline input { width: auto; }

/* --- preview / conf --- */
.conf {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto;
  white-space: pre; max-height: calc(100vh - 220px); color: #cbd5e1;
}
#validation .v { border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
#validation .v.err { background: #2a1416; border: 1px solid #5a2226; color: #ffb4ac; }
#validation .v.warn { background: #2a2410; border: 1px solid #5a4c16; color: #f0d58a; }
#validation .v ul { margin: 6px 0 0; padding-left: 18px; }

/* --- simulator --- */
.sim-input { display: flex; gap: 8px; margin-bottom: 12px; }
.sim-out { font-family: var(--mono); font-size: 12px; }
.sim-out .box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.sim-out .k { color: var(--muted); }
.sim-out .outcome { font-size: 14px; margin-top: 6px; }
.sim-out .outcome.block { color: var(--block); }
.sim-out .outcome.ok { color: var(--ok); }
.sim-out ul { margin: 6px 0 0; padding-left: 16px; color: var(--accent); }

/* --- history --- */
.hist { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; background: var(--panel); }
.hist .meta { font-size: 12px; }
.hist .meta .rev { font-family: var(--mono); color: var(--accent); }
.hist .meta .ts { color: var(--muted); }
.hist.current { border-color: var(--ok); }
.hist .current-tag { font-size: 10px; color: var(--ok); text-transform: uppercase; }

/* --- toast --- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 18px; z-index: 50; max-width: 70vw; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }
.toast pre { margin: 6px 0 0; font-size: 11px; white-space: pre-wrap; color: var(--muted); }

@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; height: auto; } .col.side { border-top: 1px solid var(--line); } }
