:root {
  --bg: #020617;
  --card: rgba(15, 23, 42, 0.92);
  --inset: #020617;
  --line: #1e293b;
  --line-strong: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --faint: #64748b;
  --emerald: #34d399;
  --emerald-deep: #059669;
  --teal: #2dd4bf;
  --amber: #fbbf24;
  --rose: #fb7185;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button, input, textarea, select { font: inherit; color: #f1f5f9; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
code { font-family: Consolas, ui-monospace, monospace; color: var(--emerald); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(2, 6, 23, 0.88);
  border-bottom: 1px solid rgba(6, 78, 59, 0.45);
  backdrop-filter: blur(10px);
}
.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.header-row, .footer-row, .toolbar, .runner-top, .card-head, .stat-line, .prefix-row, .formula {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-row { padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #059669, #34d399 55%, #2dd4bf);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.25);
}
.logo span {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; background: #020617; color: var(--emerald);
}
h1 { font-size: 18px; margin: 0; letter-spacing: -0.02em; }
.chip {
  display: inline-flex; align-items: center;
  margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; color: var(--emerald);
  background: rgba(6, 78, 59, 0.55); border: 1px solid rgba(16, 185, 129, 0.35);
}
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.pill, .btn, .tab, .filter, .icon-btn {
  border: 1px solid var(--line-strong);
  background: #0f172a;
  border-radius: 10px;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 650;
}
.pill.ok { color: #6ee7b7; background: rgba(6, 78, 59, 0.55); border-color: rgba(16, 185, 129, 0.4); }
.pill.wait { color: #fcd34d; background: rgba(120, 53, 15, 0.35); border-color: rgba(245, 158, 11, 0.35); }
.dot { width: 8px; height: 8px; border-radius: 99px; background: #fbbf24; position: relative; }
.pill.ok .dot { background: #34d399; }
.pill.ok .dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 99px;
  background: rgba(52, 211, 153, 0.7); animation: ping 1.4s infinite;
}
@keyframes ping { 70%, 100% { transform: scale(2); opacity: 0; } }

.btn, .filter, .tab {
  padding: 7px 12px; font-size: 12px; font-weight: 650; color: #e2e8f0;
}
.btn:hover, .filter:hover, .tab:hover { border-color: rgba(16, 185, 129, 0.45); }
.btn.primary {
  background: linear-gradient(90deg, #059669, #0d9488);
  border-color: transparent; color: white;
  box-shadow: 0 8px 20px rgba(6, 78, 59, 0.35);
}
.btn.amber { color: #fcd34d; background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.4); }
.btn.danger { color: #fda4af; background: rgba(136, 19, 55, 0.45); border-color: rgba(244, 63, 94, 0.4); }
.btn.good { background: #059669; border-color: transparent; color: white; }
.hidden { display: none !important; }

main { padding: 24px 0 40px; display: grid; gap: 18px; }
.banner, .card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.banner { padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.banner.safe { background: linear-gradient(90deg, rgba(6, 78, 59, 0.55), rgba(15, 23, 42, 0.9) 40%, rgba(19, 78, 74, 0.45)); border-color: rgba(16, 185, 129, 0.3); }
.banner.warn { background: rgba(120, 53, 15, 0.35); border-color: rgba(245, 158, 11, 0.45); color: #fde68a; }
.banner p, .note, .help { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.banner button.link, button.link, a.link {
  background: none; border: 0; color: var(--emerald); font-size: 12px; font-weight: 650; padding: 0;
}
.kicker { color: #6ee7b7; font-size: 12px; font-weight: 700; }

.layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.card { padding: 18px; position: relative; overflow: hidden; }
.card h2 { margin: 0; font-size: 14px; }
.card-head { align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs, .modal-tabs { display: flex; padding: 4px; background: var(--inset); border: 1px solid var(--line); border-radius: 12px; }
.tab { border: 0; color: var(--muted); background: transparent; }
.tab.active { background: #059669; color: white; }

textarea,
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="hidden"]),
select {
  width: 100%;
  background: #020617;
  color: #f1f5f9;
  -webkit-text-fill-color: #f1f5f9;
  caret-color: #34d399;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
textarea::placeholder,
input::placeholder {
  color: #64748b;
  -webkit-text-fill-color: #64748b;
  opacity: 1;
}
textarea { min-height: 132px; resize: vertical; font-family: Consolas, ui-monospace, monospace; font-size: 12px; }
textarea:focus, input:focus, select:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
.field-label { display: flex; justify-content: space-between; margin: 14px 0 8px; font-size: 12px; color: #cbd5e1; }
.range-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center; }
.range-row input, .range-row select { flex: 1 1 160px; width: auto; min-width: 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card h1 { margin: 0; }
.login-card label { display: block; margin-top: 14px; font-size: 12px; color: #cbd5e1; }
.login-card input { display: block; width: 100%; margin-top: 6px; }
.login-card button { width: 100%; margin-top: 18px; }
.form-fields { display: grid; gap: 12px; margin-top: 14px; }
.form-fields label { display: grid; gap: 6px; font-size: 12px; color: #cbd5e1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.status.active { color: #6ee7b7; background: rgba(6, 78, 59, 0.8); border-color: rgba(16, 185, 129, 0.4); }
.status.off { color: #fcd34d; background: rgba(120, 53, 15, 0.65); border-color: rgba(245, 158, 11, 0.4); }
.status.ban { color: #fda4af; background: rgba(136, 19, 55, 0.65); border-color: rgba(244, 63, 94, 0.4); }
.error { color: #fda4af; font-size: 12px; }
.icon-btn { padding: 4px 6px; color: var(--muted); }
.drop {
  margin-top: 14px; border: 2px dashed var(--line); border-radius: 14px;
  padding: 28px 16px; text-align: center; background: rgba(2, 6, 23, 0.45); cursor: pointer;
}
.drop:hover { border-color: rgba(16, 185, 129, 0.5); }
.drop strong { display: block; font-size: 13px; }
.stat-line { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: #cbd5e1; }
.counts { display: flex; flex-wrap: wrap; gap: 12px; }
.sample { font-family: Consolas, monospace; font-size: 11px; color: var(--faint); background: var(--inset); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.sample b { color: var(--emerald); font-weight: 700; }
.bad { color: var(--amber); }
.good { color: var(--emerald); }

.guard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.mini {
  background: rgba(2, 6, 23, 0.7); border: 1px solid rgba(30, 41, 59, 0.9);
  border-radius: 14px; padding: 12px;
}
.mini-top, .ends { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.mini-top b { font-family: Consolas, monospace; }
.ends { color: var(--faint); font-size: 10px; margin-top: 4px; }
input[type="range"] { width: 100%; accent-color: #10b981; }
.score { text-align: right; }
.score b { font-family: Consolas, monospace; font-size: 16px; }
.tag { font-size: 10px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; color: #cbd5e1; }
.prefix-row, .formula { margin-top: 12px; padding: 8px 10px; border-radius: 12px; background: rgba(2, 6, 23, 0.45); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.prefix-row input { width: 72px; padding: 6px 8px; font-family: Consolas, monospace; color: var(--emerald); }
.slider-row { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--faint); }

.runner { overflow: hidden; }
.runner.live::before, .runner.cool::before {
  content: ""; display: block; height: 4px; margin: -18px -18px 14px;
}
.runner.live::before { background: linear-gradient(90deg, #10b981, #2dd4bf, #059669); }
.runner.cool::before { background: #fbbf24; }
.runner-copy h3 { margin: 0; font-size: 14px; }
.batch-no { font-family: Consolas, monospace; font-size: 11px; color: var(--muted); border: 1px solid var(--line); background: var(--inset); border-radius: 8px; padding: 2px 6px; }
.progress-meta { display: flex; justify-content: space-between; font-family: Consolas, monospace; font-size: 12px; color: var(--muted); margin-top: 14px; }
.track { height: 12px; background: var(--inset); border: 1px solid var(--line); border-radius: 99px; padding: 2px; margin-top: 6px; }
.bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #10b981, #2dd4bf); transition: width 0.3s ease; }
.bar.cool { background: #fbbf24; }
.log {
  margin-top: 14px; display: flex; gap: 8px; align-items: flex-start;
  background: var(--inset); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-family: Consolas, ui-monospace, monospace; font-size: 12px; color: #cbd5e1;
}
.log span { color: var(--faint); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: #0f172a; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin-top: 4px; font-family: Consolas, monospace; font-size: 24px; }
.kpi .hint { color: var(--faint); font-size: 11px; }
.kpi.valid { border-color: rgba(6, 78, 59, 0.8); }
.kpi.valid .label, .kpi.valid strong { color: var(--emerald); }
.kpi.miss { border-color: rgba(120, 53, 15, 0.7); }
.kpi.miss .label, .kpi.miss strong { color: var(--amber); }
.kpi.bad { border-color: rgba(136, 19, 55, 0.65); }
.kpi.bad .label, .kpi.bad strong { color: var(--rose); }

.table-card { padding: 0; }
.toolbar { flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--line); background: rgba(2, 6, 23, 0.35); }
.search { max-width: 280px; padding-left: 12px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { background: transparent; color: var(--muted); }
.filter.active { background: #1e293b; color: white; }
.filter.active.valid { background: rgba(6, 78, 59, 0.8); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.filter.active.miss { background: rgba(120, 53, 15, 0.55); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }
.filter.active.bad { background: rgba(136, 19, 55, 0.55); color: #fda4af; border-color: rgba(244, 63, 94, 0.4); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; background: rgba(2, 6, 23, 0.8); }
td { padding: 10px 12px; border-top: 1px solid rgba(30, 41, 59, 0.7); font-family: Consolas, ui-monospace, monospace; color: #cbd5e1; }
tr.checking { background: rgba(6, 78, 59, 0.25); }
.status {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px;
  font-family: "Segoe UI", sans-serif; font-size: 10px; font-weight: 700; border: 1px solid var(--line);
}
.status.valid { color: #6ee7b7; background: rgba(6, 78, 59, 0.8); border-color: rgba(16, 185, 129, 0.4); }
.status.miss { color: #fcd34d; background: rgba(120, 53, 15, 0.65); border-color: rgba(245, 158, 11, 0.4); }
.status.bad { color: #fda4af; background: rgba(136, 19, 55, 0.65); border-color: rgba(244, 63, 94, 0.4); }
.status.run { color: #99f6e4; background: rgba(19, 78, 74, 0.7); border-color: rgba(45, 212, 191, 0.4); }
.status.wait { color: var(--muted); background: #1e293b; }
.empty { text-align: center; color: var(--faint); font-family: "Segoe UI", sans-serif; padding: 28px !important; }
.wa {
  display: inline-flex; gap: 4px; text-decoration: none; color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.1);
  border-radius: 8px; padding: 4px 8px; font-family: "Segoe UI", sans-serif;
}

footer { border-top: 1px solid #0f172a; color: var(--faint); font-size: 12px; padding: 16px 0 24px; }
.footer-row button { background: none; border: 0; color: #94a3b8; padding: 0; }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.75); display: grid; place-items: center; padding: 16px; }
.dialog { width: min(440px, 100%); background: #0f172a; border: 1px solid #334155; border-radius: 18px; box-shadow: var(--shadow); }
.dialog.wide { width: min(680px, 100%); max-height: min(90vh, 820px); display: flex; flex-direction: column; }
.dialog-head, .dialog-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 16px; background: rgba(2, 6, 23, 0.6); }
.dialog-head { border-bottom: 1px solid var(--line); }
.dialog-foot { border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }
.dialog-body { padding: 16px; overflow: auto; }
.dialog h3 { margin: 0; font-size: 14px; }
.callout, .guide, .meta {
  border-radius: 12px; padding: 12px; margin-bottom: 12px; font-size: 12px; line-height: 1.5;
}
.callout { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.35); color: #fde68a; }
.guide { background: var(--inset); border: 1px solid var(--line); color: #cbd5e1; }
.guide h4 { margin: 0 0 6px; }
.meta { background: var(--inset); border: 1px solid var(--line); font-family: Consolas, monospace; }
.meta div { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0; color: var(--muted); }
.qr-box { background: white; border-radius: 16px; padding: 12px; display: grid; place-items: center; min-height: 230px; }
.qr-box img { width: 220px; height: 220px; }
.pair-code { text-align: center; border: 1px solid rgba(16, 185, 129, 0.4); border-radius: 12px; padding: 14px; background: var(--inset); }
.pair-code b { display: block; letter-spacing: 0.3em; font-size: 26px; color: var(--emerald); font-family: Consolas, monospace; }
.row { display: flex; gap: 8px; }
.center { text-align: center; }
.stack { display: grid; gap: 8px; }
.error { color: #fda4af; font-size: 12px; }

@media (max-width: 980px) {
  .layout, .guard-grid, .kpis { grid-template-columns: 1fr; }
  .header-row, .toolbar, .runner-top, .banner, .footer-row { align-items: flex-start; flex-direction: column; }
}
