:root {
  --bg: #07101d;
  --surface: rgba(15, 28, 46, 0.84);
  --surface-solid: #0f1c2e;
  --surface-raised: #13243a;
  --border: rgba(142, 169, 201, 0.16);
  --border-strong: rgba(142, 169, 201, 0.28);
  --text: #eef6ff;
  --muted: #91a5bd;
  --blue: #45a7ff;
  --blue-soft: rgba(69, 167, 255, 0.14);
  --green: #36d89a;
  --green-soft: rgba(54, 216, 154, 0.13);
  --amber: #ffbd52;
  --amber-soft: rgba(255, 189, 82, 0.13);
  --red: #ff6b72;
  --red-soft: rgba(255, 107, 114, 0.13);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "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 14% 0%, rgba(26, 93, 151, 0.18), transparent 34rem),
    linear-gradient(180deg, #07101d 0%, #091423 55%, #08111f 100%);
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { color: inherit; }

.page-glow {
  position: fixed;
  z-index: -1;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
}
.page-glow-one { top: 8rem; right: -10rem; background: var(--blue); }
.page-glow-two { bottom: 4rem; left: -12rem; background: var(--green); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 5vw;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 16, 29, 0.78);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(69, 167, 255, 0.45);
  border-radius: 11px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(145deg, #168af0, #4fc7ff);
  box-shadow: 0 8px 24px rgba(27, 145, 240, 0.28);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-badge, .mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}
.status-badge { padding: 8px 12px; font-size: 12px; }
.mini-badge { padding: 5px 9px; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.online, .mini-badge.success { color: var(--green); border-color: rgba(54, 216, 154, 0.25); background: var(--green-soft); }
.status-badge.offline, .mini-badge.failed { color: var(--red); border-color: rgba(255, 107, 114, 0.25); background: var(--red-soft); }
.status-badge.busy, .mini-badge.running { color: var(--amber); border-color: rgba(255, 189, 82, 0.25); background: var(--amber-soft); }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.42; }
.button-ghost { border-color: var(--border); background: rgba(255, 255, 255, 0.035); }
.button-ghost:hover:not(:disabled) { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.07); }
.button-primary { color: #03111e; font-weight: 700; background: var(--blue); }
.button-danger { color: #1c0909; font-weight: 700; background: var(--red); }

.shell { width: min(1180px, 90vw); margin: 0 auto; padding: 60px 0 34px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.7fr); align-items: center; gap: 54px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: 0.15em; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(38px, 5.6vw, 66px); line-height: 1.07; letter-spacing: -0.05em; }
.hero h1 span { color: var(--blue); }
.hero-description { max-width: 650px; margin: 24px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.hero-status { padding: 22px; }
.hero-status-head, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-status-head { color: var(--muted); font-size: 12px; }
.hero-clock { padding: 28px 0 22px; text-align: center; }
.hero-clock strong { display: block; font-variant-numeric: tabular-nums; font-size: 34px; letter-spacing: 0.04em; }
.hero-clock span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.status-list { display: grid; gap: 10px; margin: 0; }
.status-list div { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); }
.status-list dt { color: var(--muted); font-size: 11px; }
.status-list dd { margin: 0; font-size: 12px; font-weight: 650; }

.token-panel { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 22px; padding: 22px 24px; border-color: rgba(255, 189, 82, 0.28); }
.token-panel h2, .section-heading h2, .schedule-card h2 { margin: 0; font-size: 18px; }
.token-panel p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.token-form { display: flex; gap: 9px; min-width: min(100%, 440px); }
.token-form input, .search-box, select {
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: rgba(5, 13, 24, 0.62);
  outline: none;
}
.token-form input { flex: 1; min-width: 150px; padding: 0 13px; }
.token-form input:focus, .search-box:focus-within, select:focus { border-color: rgba(69, 167, 255, 0.55); box-shadow: 0 0 0 3px rgba(69, 167, 255, 0.09); }

.service-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 17px;
  border: 1px solid rgba(255, 107, 114, 0.25);
  border-radius: 13px;
  color: #ffd5d7;
  background: var(--red-soft);
}
.service-alert-icon { display: grid; flex: 0 0 25px; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: var(--red); font-weight: 800; background: rgba(255, 107, 114, 0.13); }
.service-alert strong { display: block; font-size: 12px; }
.service-alert p { margin: 4px 0 0; color: #dcaeb4; font-size: 10px; line-height: 1.5; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric { display: flex; align-items: center; gap: 15px; min-height: 105px; padding: 19px; box-shadow: none; }
.metric-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 19px; font-weight: 800; }
.metric-total .metric-icon { color: var(--blue); background: var(--blue-soft); }
.metric-on .metric-icon { color: var(--green); background: var(--green-soft); }
.metric-off .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-error .metric-icon { color: var(--red); background: var(--red-soft); }
.metric small { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 5px; font-size: 27px; line-height: 1; }

.control-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 18px; margin-bottom: 18px; }
.action-card, .operation-card, .sites-card, .schedule-card { padding: 24px; }
.section-heading { margin-bottom: 19px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.action-list { display: grid; gap: 9px; }
.action-button {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.027);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.action-button:hover:not(:disabled) { transform: translateX(2px); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.055); }
.action-button:disabled { cursor: not-allowed; opacity: 0.4; }
.action-button strong, .action-button small { display: block; }
.action-button strong { font-size: 13px; }
.action-button small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.action-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-weight: 800; }
.action-icon.blue { color: var(--blue); background: var(--blue-soft); }
.action-icon.green { color: var(--green); background: var(--green-soft); }
.action-icon.amber { color: var(--amber); background: var(--amber-soft); }
.action-arrow { color: var(--muted); }
.action-danger:hover:not(:disabled) { border-color: rgba(255, 189, 82, 0.24); }
.risk-note { display: flex; gap: 9px; margin: 16px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.risk-note span { display: grid; flex: 0 0 17px; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: var(--amber); background: var(--amber-soft); }

.empty-state { display: grid; place-items: center; min-height: 222px; color: var(--muted); text-align: center; }
.empty-state span { font-size: 36px; opacity: 0.5; }
.empty-state p { margin: -35px 0 0; font-size: 12px; }
.operation-detail { min-height: 222px; }
.operation-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.16); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.operation-progress { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.operation-progress span { display: block; width: 100%; height: 100%; transform-origin: left; background: var(--green); }
.operation-progress span.running { width: 42%; background: var(--blue); animation: progress 1.5s ease-in-out infinite alternate; }
@keyframes progress { from { transform: translateX(-35%); } to { transform: translateX(170%); } }
.operation-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 24px 0 0; }
.operation-stats div { min-width: 0; }
.operation-stats dt { color: var(--muted); font-size: 10px; }
.operation-stats dd { overflow: hidden; margin: 4px 0 0; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.operation-error { margin: 18px 0 0; padding: 9px 11px; border-radius: 9px; color: var(--red); font-size: 10px; background: var(--red-soft); }

.sites-card { margin-bottom: 18px; overflow: hidden; }
.sites-heading { align-items: end; }
.table-tools { display: flex; gap: 9px; }
.search-box { display: flex; align-items: center; gap: 7px; min-width: 230px; padding: 0 10px; }
.search-box span { color: var(--muted); }
.search-box input { width: 100%; min-height: 36px; border: 0; color: var(--text); background: transparent; outline: none; }
.search-box input::placeholder { color: #60758d; }
select { min-height: 38px; padding: 0 30px 0 11px; }
.table-wrap { overflow-x: auto; margin: 0 -24px; }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th, td { padding: 14px 24px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
td { color: #c5d2e1; font-size: 11px; }
tbody tr { transition: background 130ms ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.site-name strong, .site-name small { display: block; }
.site-name strong { color: var(--text); font-size: 12px; }
.site-name small { margin-top: 3px; color: var(--muted); }
.state-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.state-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-chip.on { color: var(--green); background: var(--green-soft); }
.state-chip.off { color: var(--amber); background: var(--amber-soft); }
.state-chip.error { color: var(--red); background: var(--red-soft); }
.state-chip.unknown { color: var(--muted); background: rgba(145, 165, 189, 0.1); }
.result-ok { color: var(--green); }
.result-error { display: block; max-width: 280px; overflow: hidden; color: var(--red); text-overflow: ellipsis; white-space: nowrap; }
.table-empty { padding: 55px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.table-footer { display: flex; justify-content: space-between; padding-top: 15px; color: var(--muted); font-size: 10px; }

.schedule-card { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 30px; box-shadow: none; }
.schedule-card .eyebrow { margin-bottom: 5px; }
.schedule-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin: 0; }
.schedule-grid div { padding-left: 15px; border-left: 1px solid var(--border); }
.schedule-grid dt { color: var(--muted); font-size: 10px; }
.schedule-grid dd { margin: 5px 0 0; font-size: 11px; font-weight: 650; line-height: 1.45; }

.footer { display: flex; justify-content: space-between; width: min(1180px, 90vw); margin: 0 auto; padding: 0 0 34px; color: #62768e; font-size: 10px; }
.confirm-dialog { width: min(440px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 18px; color: var(--text); background: var(--surface-solid); box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(1, 7, 14, 0.72); backdrop-filter: blur(5px); }
.confirm-dialog form { padding: 28px; text-align: center; }
.confirm-icon { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 16px; border-radius: 14px; color: var(--amber); font-size: 22px; background: var(--amber-soft); }
.confirm-dialog h2 { margin: 0; font-size: 20px; }
.confirm-dialog p { margin: 12px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.confirm-warning { padding: 10px; border-radius: 10px; color: var(--amber); font-size: 10px; background: var(--amber-soft); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(380px, calc(100vw - 48px)); padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 11px; color: var(--text); font-size: 12px; background: var(--surface-raised); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 107, 114, 0.32); color: #ffd5d7; }
.hidden { display: none !important; }
.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) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero-status { max-width: 520px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .schedule-card { grid-template-columns: 1fr; }
  .schedule-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar { min-height: 64px; padding: 0 18px; }
  .brand small, #connectionText, #refreshButton { display: none; }
  .status-badge { width: 30px; height: 30px; justify-content: center; padding: 0; }
  .shell { width: min(100% - 28px, 1180px); padding-top: 38px; }
  .hero h1 { font-size: 39px; }
  .metrics { gap: 9px; }
  .metric { min-height: 92px; padding: 14px; }
  .metric-icon { width: 34px; height: 34px; }
  .metric strong { font-size: 23px; }
  .token-panel { align-items: stretch; flex-direction: column; }
  .token-form { min-width: 0; flex-wrap: wrap; }
  .token-form input { min-height: 40px; flex-basis: 100%; }
  .action-card, .operation-card, .sites-card, .schedule-card { padding: 18px; }
  .sites-heading { align-items: stretch; flex-direction: column; }
  .table-tools { flex-direction: column; }
  .search-box { min-width: 0; }
  .table-wrap { margin: 0 -18px; }
  th, td { padding-left: 18px; padding-right: 18px; }
  .schedule-grid { grid-template-columns: 1fr; }
  .table-footer, .footer { gap: 9px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
