:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: rgba(19, 25, 37, 0.82);
  --panel-solid: #131925;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #8f99aa;
  --cyan: #65e8ff;
  --cyan-dark: #0e7484;
  --orange: #ffb35c;
  --red: #ff6b75;
  --green: #71e6a3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(47, 138, 183, 0.2), transparent 34rem),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient {
  position: fixed;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
}
.ambient-one { left: -14rem; top: 30%; background: var(--cyan); }
.ambient-two { right: -16rem; bottom: -8rem; background: #6f66ff; }
.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 4vw, 2.2rem); }
h2 { margin-bottom: 0; font-size: 1.2rem; }
.muted { color: var(--muted); line-height: 1.6; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(100%, 27rem);
  padding: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: rgba(16, 22, 33, 0.88);
  box-shadow: 0 2rem 6rem rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1.5rem;
  border-radius: 0.9rem;
  color: #061014;
  background: var(--cyan);
  font-weight: 900;
  box-shadow: 0 0 2rem rgba(101, 232, 255, 0.25);
}
.stack { display: grid; gap: 1rem; margin-top: 1.8rem; }
.captcha-row { display: grid; grid-template-columns: 1fr 8.25rem; gap: 0.65rem; }
.captcha-image {
  overflow: hidden;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #0b111c;
}
.captcha-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
label span {
  display: block;
  margin-bottom: 0.45rem;
  color: #c4cad4;
  font-size: 0.78rem;
  font-weight: 650;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  outline: none;
  padding: 0.78rem 0.9rem;
  color: var(--text);
  background: rgba(7, 11, 18, 0.75);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(101, 232, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(101, 232, 255, 0.1);
}

.primary, .secondary, .ghost, .icon-button {
  border: 0;
  border-radius: 0.72rem;
  padding: 0.72rem 1rem;
  font-weight: 750;
}
.primary { color: #061014; background: var(--cyan); }
.primary:hover { background: #94f0ff; }
.secondary { color: var(--text); background: rgba(101, 232, 255, 0.1); border: 1px solid rgba(101, 232, 255, 0.25); }
.ghost { color: #c8ced8; background: rgba(255, 255, 255, 0.06); }
.wide { width: 100%; }
.form-error { min-height: 1.2em; margin: 0; color: var(--red); font-size: 0.82rem; }

.app-shell { width: min(100% - 3rem, 92rem); margin: 0 auto; padding-bottom: 3rem; }
.topbar {
  min-height: 7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.top-actions, .panel-actions { display: flex; align-items: center; gap: 0.65rem; }
.status-pill {
  padding: 0.45rem 0.7rem;
  border-radius: 10rem;
  color: var(--green);
  background: rgba(113, 230, 163, 0.1);
  font-size: 0.72rem;
  font-weight: 750;
}
.status-pill.off { color: var(--orange); background: rgba(255, 179, 92, 0.1); }
.user-pill { color: var(--cyan); background: rgba(101, 232, 255, 0.1); }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin: 0.5rem 0 1rem;
}
.metric-card {
  position: relative;
  overflow: hidden;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -1rem -2rem auto;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--cyan);
  filter: blur(35px);
  opacity: 0.18;
}
.metric-card.warning::after { background: var(--orange); }
.metric-card.danger::after { background: var(--red); }
.metric-card span, .metric-card small { color: var(--muted); font-size: 0.75rem; }
.metric-card strong { display: block; margin: 0.35rem 0 0.15rem; font-size: 1.7rem; }

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: var(--panel);
  box-shadow: 0 1.4rem 5rem rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.search input { min-width: 15rem; }
.sort-control select { min-width: 10rem; }
.expiry-cell { display: flex; align-items: center; gap: 0.5rem; }
.renew-button {
  border: 1px solid rgba(101, 232, 255, 0.22);
  border-radius: 0.45rem;
  padding: 0.3rem 0.5rem;
  color: var(--cyan);
  background: rgba(101, 232, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 750;
}
.renew-info { margin: 1.2rem 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 0.95rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
td { font-size: 0.84rem; }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.device-name { font-weight: 800; }
.ip-code { color: #bdd8e2; font-family: "SFMono-Regular", Consolas, monospace; }
.countdown { display: inline-flex; padding: 0.35rem 0.55rem; border-radius: 0.45rem; color: var(--green); background: rgba(113, 230, 163, 0.09); font-size: 0.75rem; font-weight: 750; }
.countdown.soon { color: var(--orange); background: rgba(255, 179, 92, 0.1); }
.countdown.expired { color: var(--red); background: rgba(255, 107, 117, 0.1); }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.row-actions button { border: 0; border-radius: 0.5rem; padding: 0.42rem 0.55rem; color: var(--muted); background: rgba(255,255,255,.05); }
.row-actions .delete:hover { color: var(--red); }
.empty { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.empty h3 { margin-bottom: 0.4rem; color: var(--text); }
.empty-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: 50%; background: rgba(101,232,255,.1); color: var(--cyan); font-size: 1.5rem; }

dialog {
  width: min(calc(100% - 2rem), 42rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  color: var(--text);
  background: var(--panel-solid);
  box-shadow: 0 2rem 8rem rgba(0,0,0,.55);
}
dialog::backdrop { background: rgba(3, 6, 12, 0.78); backdrop-filter: blur(5px); }
.dialog-card { padding: 1.35rem; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.icon-button { padding: 0.3rem 0.65rem; color: var(--muted); background: transparent; font-size: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.4rem 0 0.8rem; }
.form-grid .full { grid-column: 1 / -1; }
.dialog-actions { justify-content: flex-end; margin-top: 1rem; }
.wide-dialog { width: min(calc(100% - 2rem), 58rem); }
.log-note { margin: 1rem 0; }
.log-table-wrap { max-height: min(65vh, 36rem); overflow: auto; border: 1px solid var(--line); border-radius: 0.8rem; }
.log-table th, .log-table td { background: var(--panel-solid); }
.agent-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.2rem 0;
}
.agent-toolbar p { margin: 0; }
.agent-list { display: grid; gap: 0.7rem; }
.agent-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.025);
}
.agent-card h3 { margin-bottom: 0.25rem; font-size: 1rem; }
.agent-card p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.device-access {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}
.device-access legend { padding: 0 0.4rem; color: #c4cad4; font-size: 0.78rem; font-weight: 650; }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; max-height: 18rem; overflow-y: auto; }
.check-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem;
  border-radius: 0.65rem;
  background: rgba(255,255,255,.035);
}
.check-item input { width: auto; }
.check-item span { margin: 0; color: var(--text); }
.toast {
  position: fixed;
  z-index: 10;
  right: 1.2rem;
  bottom: 1.2rem;
  max-width: min(24rem, calc(100% - 2.4rem));
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #1a2230;
  box-shadow: 0 1rem 3rem rgba(0,0,0,.35);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .search input { min-width: 0; }
  .sort-control { flex: 1; }
  .sort-control select { min-width: 0; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 1.2rem, 92rem); }
  .topbar { min-height: 6rem; }
  .top-actions .status-pill { display: none; }
  .metrics { gap: 0.55rem; }
  .metric-card { padding: 0.9rem; }
  .metric-card strong { font-size: 1.35rem; }
  .panel { background: transparent; border: 0; overflow: visible; box-shadow: none; backdrop-filter: none; }
  .panel-head { padding: 0.8rem 0 1rem; border: 0; }
  .panel-actions button { flex: 1; }
  .table-wrap { overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 0.7rem; }
  tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--panel);
  }
  td { display: block; padding: 0; border: 0; white-space: normal; }
  td::before { content: attr(data-label); display: block; margin-bottom: 0.2rem; color: var(--muted); font-size: 0.65rem; }
  td:first-child,
  td[data-label="IP 地址"],
  td[data-label="使用者"],
  td[data-label="到期时间"],
  td[data-label="操作"] { grid-column: 1 / -1; }
  .row-actions { justify-content: stretch; }
  .row-actions button { flex: 1; padding: 0.6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .agent-toolbar, .agent-card { align-items: stretch; flex-direction: column; }
  .check-list { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem; }
}
