:root {
  --bg: #f4f6fa; --panel: #fff; --text: #0f1b33; --muted: #5b6782; --line: #e3e8f0;
  --brand: #2563eb; --brand-ink: #fff; --navy: #0a1633; --navy-2: #13254f; --cyan: #00ddee; --hv-blue: #3d7cf9; --tdv: #ff6319; --ok: #0f8a4b; --warn: #b26a00; --bad: #c62828; --soft: #eef3ff;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,27,51,.06), 0 4px 16px rgba(15,27,51,.06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--brand); }
code { background: var(--soft); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .error { color: var(--bad); }

.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; text-decoration: none; color: #fff; }
.brand__logo { height: 30px; width: auto; display: block; }
.brand__name { font-weight: 700; font-size: 15px; letter-spacing: .02em; padding-left: 12px; border-left: 1px solid #ffffff33; color: #fff; }
.brand__via { display: inline-flex; align-items: center; gap: 6px; color: #ffffffb3; font-size: 12px; white-space: nowrap; }
.brand__via img, .tdv-inline { height: 14px; width: auto; filter: brightness(0) invert(1); opacity: .9; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: linear-gradient(100deg, var(--navy) 0%, var(--navy-2) 70%, #173a7a 100%); color: #fff; flex-wrap: wrap; box-shadow: 0 2px 0 0 var(--tdv); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: #ffffffb3; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button:hover { background: #ffffff14; color: #fff; }
.tabs button.is-active { background: #ffffff1f; color: #fff; box-shadow: inset 0 -2px 0 var(--cyan); }
.count:not(:empty) { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--tdv); color: #fff; font-size: 11.5px; line-height: 18px; text-align: center; }
.top__status { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.top__user { white-space: nowrap; color: #ffffffb3; }
.top__user .link { color: var(--cyan); }
.top .chip { background: #ffffff1a; color: #ffffffd9; }
.top .chip--ok { background: #22c55e2e; color: #86efac; } .top .chip--warn { background: #f59e0b2e; color: #fcd34d; } .top .chip--bad { background: #ef44442e; color: #fca5a5; } .top .chip--info { color: #93c5fd; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip--ok { color: var(--ok); background: #e8f6ee; } .chip--warn { color: var(--warn); background: #fff4e0; } .chip--bad { color: var(--bad); background: #fdecec; } .chip--info { color: var(--brand); }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius); display: flex; gap: 12px; align-items: center; }
.banner--warn { background: #fff4e0; color: #6b4000; } .banner--info { background: var(--soft); color: #1d3a7a; }

main { padding: 16px 20px 80px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input[type=search] { min-width: 240px; }
textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #0b4fd633; border-color: var(--brand); }

.btn { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #c7d0df; background: #fafbfd; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: linear-gradient(135deg, var(--hv-blue), #1d4ed8); border-color: #1d4ed8; color: var(--brand-ink); }
.btn--primary:hover:not(:disabled) { background: #1d4ed8; }
.btn--block { display: block; width: 100%; text-align: center; text-decoration: none; padding: 11px 14px; }
.btn--danger { color: var(--bad); } .btn--sm { padding: 4px 10px; font-size: 12.5px; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }

.tablewrap { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #fafcff; }
.grid tr.is-sel { background: #f2f6ff; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .chk { width: 34px; }
.grid--log td { font-size: 12.5px; }
.ord { font-weight: 700; } .sub { color: var(--muted); font-size: 12px; }
.warnline { color: var(--warn); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.tt { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card label { display: block; margin: 8px 0; }
.card label > input:not([type=checkbox]), .card label > select { display: block; width: 100%; margin-top: 4px; }
.inp { display: flex; align-items: center; gap: 6px; margin-top: 4px; } .inp input { width: 110px; }
.switch { display: flex !important; gap: 10px; align-items: flex-start; }
.switch input { margin-top: 3px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; } .row--end { justify-content: flex-end; }
.row select { flex: 1; min-width: 200px; }
.rules { display: grid; gap: 6px; margin-bottom: 10px; }
.rule { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.rule.is-off { opacity: .5; }
.rule__n { color: var(--muted); font-weight: 700; text-align: center; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }

.drawer { position: fixed; inset: 0; z-index: 30; background: rgba(15,27,51,.35); display: flex; justify-content: flex-end; }
.drawer__panel { width: min(560px, 100%); height: 100%; background: var(--panel); display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font-size: 18px; }
.drawer__body { padding: 16px 18px 40px; overflow-y: auto; }
.drawer h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.form2 label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.form2 .full { grid-column: 1 / -1; }
.form2 .check, .actions .check { flex-direction: row; color: var(--text); font-size: 13px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.items { margin: 0; padding-left: 18px; color: var(--muted); }
.result { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #e8f6ee; color: #0b5a32; }
.result--bad { background: #fdecec; color: #8a1c1c; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; position: sticky; bottom: -40px; background: var(--panel); padding: 12px 0; }
.hist { margin: 4px 0 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
pre { white-space: pre-wrap; word-break: break-word; background: var(--soft); padding: 8px; border-radius: 6px; max-height: 300px; overflow: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
.toast--bad { background: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% 10%, #1b3a7a 0%, transparent 60%), linear-gradient(160deg, var(--navy) 0%, #050b1c 100%); }
.login__card { width: min(380px, 100%); background: #0f1d40e6; border: 1px solid #ffffff1a; padding: 32px 28px; border-radius: 16px; box-shadow: 0 20px 60px #0008; display: grid; gap: 12px; color: #fff; border-top: 3px solid var(--tdv); }
.login__logo { height: 44px; width: auto; justify-self: start; }
.login__title { margin: 6px 0 0; font-size: 22px; }
.login__sub { margin: 0 0 8px; color: #ffffffa6; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.login__form { display: grid; gap: 10px; }
.login__card label { display: grid; gap: 4px; font-size: 13px; color: #ffffffa6; }
.login__card input { background: #0a1633; border-color: #ffffff2e; color: #fff; }
.login__card .btn:not(.btn--primary) { background: #ffffff14; border-color: #ffffff2e; color: #fff; }
.login__card .muted { color: #ffffff8c; }
.login__or { display: flex; align-items: center; gap: 10px; color: #ffffff73; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }
.login__or::before, .login__or::after { content: ""; flex: 1; height: 1px; background: #ffffff26; }

@media (max-width: 900px) { .brand__via { display: none; } }
@media (max-width: 700px) {
  .top { padding: 10px 12px; } main { padding: 12px 12px 80px; }
  input[type=search] { min-width: 0; flex: 1; }
  .form2 { grid-template-columns: 1fr; }
}
