:root {
  --bg: #0b1219;
  --bg-soft: #111c26;
  --card: #16232f;
  --line: #24333f;
  --text: #e8f1f5;
  --muted: #8fa3b0;
  --mint: #34d399;
  --mint-dim: #1f9d74;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 85% -10%, #123a30 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.right { text-align: right; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(52, 211, 153, .06), transparent 40%), var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--mint), #0ea5e9);
  color: #06231a; font-weight: 800; font-size: 20px;
  box-shadow: 0 8px 24px rgba(52, 211, 153, .25);
}
.small-brand .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }

label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 12.5px; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  background: #0d1720;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--mint-dim); box-shadow: 0 0 0 3px rgba(52, 211, 153, .12); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

button {
  border: 1px solid var(--line);
  background: #12202b;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  transition: .15s ease;
}
button:hover { border-color: #33495a; transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary { background: linear-gradient(180deg, var(--mint), var(--mint-dim)); color: #04231a; border-color: transparent; font-weight: 650; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
button.block { width: 100%; padding: 11px; }
button.tiny { padding: 4px 9px; font-size: 12px; border-radius: 8px; }

/* shell */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 25, .85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); }
.tab.active { color: var(--text); border-color: var(--line); background: #14222e; }
.who { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #101c26; font-size: 12px; color: var(--muted);
}
.quota-bar {
  display: flex; gap: 22px; flex-wrap: wrap;
  padding: 10px 22px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px;
  background: #0e1821;
}
.quota-bar b { color: var(--text); font-weight: 600; }
.quota-bar .bar { display: inline-block; width: 90px; height: 6px; background: #1b2a36; border-radius: 4px; margin-left: 8px; vertical-align: middle; overflow: hidden; }
.quota-bar .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), #38bdf8); }

main { padding: 22px; max-width: 1200px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head.sub { margin-top: 26px; }
.panel-head h3 { margin: 0; font-size: 15px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.card h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .meta { color: var(--muted); font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: #101c26;
}
.badge.online { color: #6ee7b7; border-color: rgba(52, 211, 153, .45); background: rgba(52, 211, 153, .1); }
.badge.pending { color: var(--warn); border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08); }
.badge.blocked { color: var(--danger); border-color: rgba(248, 113, 113, .4); background: rgba(248, 113, 113, .08); }
.badge.auditing { color: #7dd3fc; border-color: rgba(56, 189, 248, .4); background: rgba(56, 189, 248, .08); }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.switch input { width: 34px; height: 18px; margin: 0; appearance: none; background: #1c2b37; border-radius: 999px; position: relative; cursor: pointer; transition: .2s; }
.switch input:checked { background: var(--mint-dim); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #dbe9f1; transition: .2s; }
.switch input:checked::after { left: 18px; }
.note { font-size: 12px; color: var(--danger); }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; background: #12202b; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table a { color: var(--mint); text-decoration: none; cursor: pointer; }
.input-row { display: flex; gap: 8px; margin-top: 6px; }
.input-row input { margin-top: 0; }
.input-row button { white-space: nowrap; }
.picker-wrap { max-height: 46vh; }
.crumbs { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--mint); cursor: pointer; text-decoration: none; }

/* forms */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-form .span2 { grid-column: span 2; }
.form-actions { grid-column: span 2; display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
@media (max-width: 640px) {
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2, .form-actions { grid-column: span 1; }
  main { padding: 14px; }
}

/* modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 8, 12, .72);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px;
  overflow: auto;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal.wide { max-width: 860px; }
.modal.audit { max-width: 520px; text-align: center; }

/* audit animation */
.audit-anim { position: relative; height: 120px; margin: 8px 0 18px; overflow: hidden; border-radius: 14px; background: radial-gradient(circle at 50% 60%, rgba(52, 211, 153, .16), transparent 62%), #0c1620; border: 1px solid var(--line); }
.orb {
  position: absolute; left: 50%; top: 55%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a7f3d0, #10b981 55%, #065f46);
  box-shadow: 0 0 40px rgba(52, 211, 153, .55);
  animation: pulse 1.6s ease-in-out infinite;
}
.orb.small { width: 18px; height: 18px; margin: -9px 0 0 -9px; left: 32%; top: 38%; animation-delay: .4s; background: radial-gradient(circle at 35% 30%, #bae6fd, #0ea5e9 60%, #0c4a6e); box-shadow: 0 0 20px rgba(56, 189, 248, .5); }
.scanline {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  animation: scan 2s linear infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.12); opacity: .7; } }
@keyframes scan { 0% { top: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: 100%; opacity: 0; } }

.progress { height: 8px; border-radius: 999px; background: #0d1720; border: 1px solid var(--line); overflow: hidden; }
.progress-in { height: 100%; width: 4%; background: linear-gradient(90deg, var(--mint), #38bdf8); transition: width .5s ease; }
.audit-stage { margin: 12px 0 8px; font-size: 13px; }
.steps { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 12px; color: var(--muted); }
.steps li { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: #0f1a24; }
.steps li.active { color: #6ee7b7; border-color: rgba(52, 211, 153, .5); }
.steps li.done { color: var(--muted); border-color: rgba(52, 211, 153, .25); }
.steps li.failed { color: var(--danger); border-color: rgba(248, 113, 113, .45); }
.findings { text-align: left; max-height: 220px; overflow: auto; padding-left: 0; list-style: none; margin: 10px 0 0; }
.findings li { border: 1px solid var(--line); border-left: 3px solid var(--danger); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #101a24; font-size: 12.5px; }
.findings li.high { border-left-color: var(--warn); }
.findings li.medium, .findings li.low { border-left-color: #38bdf8; }
.findings b { display: block; margin-bottom: 2px; }
#audit-verdict.pass { color: var(--mint); }
#audit-verdict.fail { color: var(--danger); }

/* admin lock */
.admin-lock { border: 1px dashed var(--line); border-radius: var(--radius); padding: 20px; }
.admin-lock input { max-width: 320px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #12202b; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; z-index: 90;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5); max-width: 80vw;
}
.toast.error { border-color: rgba(248, 113, 113, .55); color: #fecaca; }
