:root {
  color-scheme: dark;
  --bg: #080b10;
  --bg-soft: #0d1118;
  --panel: #111720;
  --panel-2: #151d28;
  --line: #263141;
  --line-soft: #1c2633;
  --text: #ecf2f8;
  --muted: #8e9baa;
  --muted-2: #647181;
  --green: #42d392;
  --green-soft: rgba(66, 211, 146, .12);
  --amber: #f4b860;
  --amber-soft: rgba(244, 184, 96, .12);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, .11);
  --blue: #65a7ff;
  --blue-soft: rgba(101, 167, 255, .12);
  --purple: #b89cff;
  --radius: 14px;
  --shadow: 0 16px 48px rgba(0, 0, 0, .26);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(59, 130, 246, .15), transparent 30rem),
    radial-gradient(circle at 92% 0%, rgba(66, 211, 146, .08), transparent 27rem),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(38, 49, 65, .84);
  background: rgba(8, 11, 16, .86);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #07120e;
  background: linear-gradient(135deg, #66e6ae, #45a8ff);
  box-shadow: 0 8px 24px rgba(66, 211, 146, .18);
  font-weight: 900;
}
.brand-title { font-size: 15px; font-weight: 750; letter-spacing: .02em; }
.brand-sub { color: var(--muted-2); font-size: 11px; margin-top: 2px; }

.nav { display: flex; gap: 5px; }
.nav a {
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
}
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); border-color: var(--line); background: var(--panel-2); }

.main { padding: 30px 0 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { font-size: clamp(25px, 3vw, 36px); margin: 7px 0 7px; letter-spacing: -.035em; }
.lead { max-width: 780px; color: var(--muted); margin: 0; line-height: 1.65; font-size: 14px; }

.toolbar, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.toolbar { justify-content: flex-end; }

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 12px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: border-color .15s, background .15s, opacity .15s, transform .15s;
}
.btn:hover { border-color: #43536a; background: #1a2430; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { color: #06120e; border-color: #49d99b; background: var(--green); }
.btn.primary:hover { background: #64e2ad; }
.btn.danger { color: #ffdbe1; border-color: rgba(251,113,133,.34); background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.status-dot.busy { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }

.grid { display: grid; gap: 16px; }
.config-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(21,29,40,.94), rgba(15,21,29,.94));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-title { margin: 0; font-size: 15px; font-weight: 760; }
.panel-desc { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 5px 0 0; }
.panel-body { padding: 20px; }
.panel-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); background: rgba(8,11,16,.22); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 16px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 7px; color: #bac5d1; font-size: 12px; font-weight: 650; }
.hint { color: var(--muted-2); font-size: 11px; font-weight: 450; }
.input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #0b1017;
  padding: 9px 10px;
  transition: border-color .15s, box-shadow .15s;
}
.input, select { height: 39px; }
textarea { min-height: 86px; resize: vertical; line-height: 1.5; }
.input:focus, select:focus, textarea:focus { border-color: rgba(101,167,255,.7); box-shadow: 0 0 0 3px rgba(101,167,255,.1); }
.input::placeholder, textarea::placeholder { color: #465263; }
.checkline { display: flex; align-items: center; gap: 9px; min-height: 39px; color: #c7d0da; font-size: 13px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--green); }
.inline-note { color: var(--muted); font-size: 11px; line-height: 1.55; margin-top: 6px; }
.clearline { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; margin-top: 7px; }
.clearline input { accent-color: var(--red); }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { min-height: 108px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(17,23,32,.84); }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.metric-value { margin-top: 12px; font-size: 27px; font-weight: 790; letter-spacing: -.04em; }
.metric-value.small { font-size: 16px; letter-spacing: 0; margin-top: 17px; }
.metric-meta { color: var(--muted-2); font-size: 11px; margin-top: 6px; }
.metric.good .metric-value { color: var(--green); }
.metric.warn .metric-value { color: var(--amber); }
.metric.bad .metric-value { color: var(--red); }

.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, .75fr); gap: 16px; align-items: start; }
.side-stack { display: grid; gap: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #0b1017;
  cursor: pointer;
  font-size: 12px;
}
.chip:hover, .chip.active { color: var(--text); border-color: #4a5c72; background: var(--panel-2); }
.chip-count { min-width: 20px; padding: 1px 6px; border-radius: 999px; text-align: center; color: #b9c6d4; background: rgba(255,255,255,.06); font-variant-numeric: tabular-nums; }

.table-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; }
.selection { color: var(--muted); font-size: 12px; }
.table-wrap { overflow: auto; max-height: 610px; border: 1px solid var(--line-soft); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: #111821; font-weight: 680; }
tbody tr:hover td { background: rgba(255,255,255,.022); }
tbody tr.selected-row td { background: rgba(101,167,255,.055); }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: #dce4ec; }
.cell-sub { max-width: 300px; overflow: hidden; text-overflow: ellipsis; color: var(--muted-2); }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 7px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.badge.ready, .badge.imported, .badge.done { color: var(--green); border-color: rgba(66,211,146,.25); background: var(--green-soft); }
.badge.cooling_quota, .badge.running, .badge.started, .badge.queued, .badge.waiting_email, .badge.solving_captcha { color: var(--amber); border-color: rgba(244,184,96,.25); background: var(--amber-soft); }
.badge.auth_dead, .badge.suspect_dead, .badge.error, .badge.failed, .badge.protocol_error { color: var(--red); border-color: rgba(251,113,133,.25); background: var(--red-soft); }
.badge.probation, .badge.cooling_other, .badge.partial { color: var(--blue); border-color: rgba(101,167,255,.25); background: var(--blue-soft); }
.badge.quarantine, .badge.cancelled, .badge.stopped { color: var(--purple); border-color: rgba(184,156,255,.25); background: rgba(184,156,255,.1); }

.log-list { display: grid; gap: 0; max-height: 360px; overflow: auto; }
.log-item { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.log-item:last-child { border-bottom: 0; }
.log-top { display: flex; justify-content: space-between; gap: 12px; }
.log-title { color: #d6dfe8; font-size: 12px; line-height: 1.5; }
.log-time { flex: 0 0 auto; color: var(--muted-2); font-size: 10px; }
.log-detail { margin-top: 5px; color: var(--muted-2); font-size: 10px; line-height: 1.5; word-break: break-word; }
.registration-log-head { align-items: center; }
.registration-log {
  max-height: 430px;
  min-height: 112px;
  overflow: auto;
  padding: 10px 0;
  background: #080c12;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.registration-log-line {
  display: grid;
  grid-template-columns: 152px 138px minmax(140px, 220px) minmax(300px, 1fr);
  gap: 10px;
  align-items: start;
  padding: 7px 16px;
  color: #cbd5df;
  font-size: 11px;
  line-height: 1.5;
}
.registration-log-line:hover { background: rgba(255,255,255,.025); }
.registration-log-time { color: var(--muted-2); white-space: nowrap; }
.registration-log-status { color: var(--amber); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.registration-log-status.imported, .registration-log-status.success, .registration-log-status.completed { color: var(--green); }
.registration-log-status.error, .registration-log-status.failed, .registration-log-status.protocol_error { color: var(--red); }
.registration-log-status.cancelled, .registration-log-status.stopped, .registration-log-status.stopping { color: var(--purple); }
.registration-log-session { color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.registration-log-message { color: #d8e0e8; word-break: break-word; }
.registration-log-line.single { grid-template-columns: 152px 138px minmax(300px, 1fr); }
.empty { padding: 30px 12px; text-align: center; color: var(--muted-2); font-size: 12px; }

.banner { display: none; margin-bottom: 16px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--panel); font-size: 12px; line-height: 1.55; }
.banner.show { display: block; }
.banner.error { color: #ffd5dc; border-color: rgba(251,113,133,.35); background: var(--red-soft); }
.banner.success { color: #c9f8e3; border-color: rgba(66,211,146,.3); background: var(--green-soft); }
.banner.warn { color: #ffe5bd; border-color: rgba(244,184,96,.3); background: var(--amber-soft); }

.token-dialog { width: min(430px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--panel); box-shadow: 0 30px 90px rgba(0,0,0,.55); padding: 0; }
.token-dialog::backdrop { background: rgba(0,0,0,.68); backdrop-filter: blur(4px); }
.dialog-body { padding: 20px; }
.dialog-title { font-size: 16px; font-weight: 760; margin-bottom: 7px; }
.dialog-desc { color: var(--muted); font-size: 12px; line-height: 1.55; margin-bottom: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.footer-note { margin-top: 20px; color: var(--muted-2); font-size: 11px; line-height: 1.6; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.good-text { color: var(--green); }
.bad-text { color: var(--red); }
.warn-text { color: var(--amber); }
.nowrap { white-space: nowrap; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 22px, 1480px); }
  .topbar-inner { min-height: 60px; gap: 10px; }
  .brand-sub { display: none; }
  .brand-title { font-size: 13px; }
  .nav a { padding: 7px 8px; }
  .token-label { display: none; }
  .main { padding-top: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .config-grid, .form-grid, .side-stack { grid-template-columns: 1fr; }
  .wide, .field.full { grid-column: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 94px; }
  .metric-value { font-size: 23px; }
  .panel-head, .panel-body { padding: 16px; }
  .table-tools { align-items: flex-start; flex-direction: column; }
  .registration-log-line, .registration-log-line.single { grid-template-columns: 1fr; gap: 2px; padding: 9px 14px; }
  .registration-log-session { margin-top: 2px; }
}
