:root {
  --bg: #0b0f16;
  --bg2: #111826;
  --card: #131b2b;
  --card2: #172135;
  --line: #21304a;
  --text: #e6edf7;
  --muted: #8aa0bf;
  --acc: #3d8bff;
  --acc2: #22d3a6;
  --danger: #ff5c72;
  --warn: #ffb020;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #16233a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
input, select, button { font: inherit; color: inherit; }
textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: #0e1522;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(61,139,255,.15); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--acc); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12.5px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  background: rgba(10,15,24,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.logo {
  width: 18px; height: 18px; border-radius: 6px;
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  box-shadow: 0 0 18px rgba(61,139,255,.6);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.badge.on { color: #7df0cd; border-color: rgba(34,211,166,.5); background: rgba(34,211,166,.08); }
.badge.warn { color: var(--warn); border-color: rgba(255,176,32,.45); background: rgba(255,176,32,.08); }
.badge.off { color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: #172135; color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  transition: transform .05s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #1d2a44; border-color: #2d4064; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #2f7bff, #3d8bff); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(135deg, #3b86ff, #52a0ff); }
.btn.danger { color: #ffb3bd; border-color: rgba(255,92,114,.45); background: rgba(255,92,114,.08); }
.btn.danger:hover { background: rgba(255,92,114,.16); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.auth { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 30px 16px; }
.auth-card { width: min(460px, 100%); padding: 22px; }
.auth-title {
  margin: 0 0 14px; font-size: 20px; font-weight: 700; text-align: center; letter-spacing: .5px;
  background: linear-gradient(135deg, #7db4ff, #22d3a6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--text); border-color: rgba(61,139,255,.6); background: rgba(61,139,255,.12); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hint { color: var(--warn); font-size: 12.5px; margin: 4px 0 0; min-height: 16px; }
.turnstile { display: flex; justify-content: center; min-height: 0; }

.wrap { padding: 16px; max-width: 1420px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.stat span { color: var(--muted); font-size: 12px; display: block; }
.stat b { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.stat.rate b { font-size: 14px; color: var(--warn); }

.banner {
  border: 1px solid rgba(255,176,32,.35); background: rgba(255,176,32,.08);
  color: #ffd27a; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 13px;
}

.grid {
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-areas: "accounts ops" "redeem log";
  align-items: start;
}
.accounts { grid-area: accounts; }
.ops { grid-area: ops; }
.redeem { grid-area: redeem; }
.log-card { grid-area: log; }
.card { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.row-actions { display: flex; gap: 8px; }

.addrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 12px; }
.table-wrap { overflow: auto; max-height: 46vh; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid rgba(33,48,74,.7); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--card); z-index: 1; }
td { font-size: 13px; }
th.ck, td.ck { width: 30px; }
tr:hover td { background: rgba(61,139,255,.04); }
.acc-main { font-weight: 600; }
.acc-sub { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: #7df0cd; border-color: rgba(34,211,166,.4); background: rgba(34,211,166,.08); }
.pill.bad { color: #ffb3bd; border-color: rgba(255,92,114,.4); background: rgba(255,92,114,.08); }
.pill.busy { color: #9dc4ff; border-color: rgba(61,139,255,.4); background: rgba(61,139,255,.08); }
.row-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.row-x:hover { color: var(--danger); background: rgba(255,92,114,.1); }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.notes { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.note {
  font-size: 12.5px; color: #ffd27a; background: rgba(255,176,32,.08);
  border: 1px solid rgba(255,176,32,.3); border-radius: 10px; padding: 8px 10px;
  display: flex; justify-content: space-between; gap: 10px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { margin: 0; }
.check { flex-direction: row; align-items: center; gap: 8px; margin: 12px 0; color: var(--text); font-size: 13px; }
.btn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btn-grid .btn { padding: 9px 8px; font-size: 13px; }
.like-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; margin-top: 12px; }

.usage { margin-top: 12px; }
.usage-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-btn { background: transparent; border: 0; padding: 5px 10px; color: var(--muted); cursor: pointer; font-size: 12px; }
.seg-btn.active { background: rgba(61,139,255,.16); color: var(--text); }
.usage-box { font-size: 12.5px; color: var(--muted); background: #0e1522; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 64px; }
.usage-row { display: flex; justify-content: space-between; padding: 2px 0; }
.usage-row b { color: var(--text); font-weight: 600; }

.log { height: 240px; overflow: auto; background: #0b111c; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #b9cbe4; }
.log .t { color: #5f7595; margin-right: 6px; }
.log .ok { color: #7df0cd; }
.log .err { color: #ff9aa7; }
.log .warn { color: #ffd27a; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #1b2740; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: min(560px, 92vw); z-index: 50;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255,92,114,.5); background: #2a1620; }

@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "accounts" "ops" "redeem" "log"; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .wrap { padding: 10px; }
  .addrow { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .btn-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .like-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  table { font-size: 12px; }
  th:nth-child(6), td:nth-child(6) { display: none; }
}
