:root {
  --bg: #f6f7f2;
  --paper: #ffffff;
  --paper-soft: #eef3ea;
  --ink: #17211b;
  --muted: #657167;
  --line: #d9dfd5;
  --green: #28684a;
  --green-2: #1e8a5b;
  --blue: #315f9e;
  --coral: #c56a4b;
  --amber: #b98219;
  --red: #b84646;
  --shadow: 0 18px 45px rgba(23, 33, 27, 0.11);
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(238, 243, 234, 0.9), rgba(246, 247, 242, 0) 360px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { justify-content: center; }

.site-header, header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 247, 242, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.nav-row, .row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand, .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  font-size: 20px;
}
.brand img { display: block; }
.nav-actions, .toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.text-link {
  color: var(--muted);
  font-weight: 650;
}
.text-link:hover { color: var(--ink); }
.lang-switch, .lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
}

.hero-shell {
  padding: 64px 0 48px;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  gap: 56px;
  align-items: center;
}
.hero-copy h1, .account-hero h1, .account-toolbar h1, .result-panel h1 {
  margin: 0;
  max-width: 780px;
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: 0;
}
.hero-lede {
  max-width: 640px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 18px;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.btn-primary, .btn-secondary, .btn-small, .btn-sm, .btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 750;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 24px rgba(40, 104, 74, .22);
}
.btn-primary:hover, .btn-secondary:hover, .btn-small:hover, .btn-download:hover {
  transform: translateY(-1px);
}
.btn-secondary, .btn-small, .btn-sm, .btn-download {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.btn-small, .btn-sm {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}
.btn-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--muted);
}

.hero-visual {
  position: relative;
  min-height: 430px;
}
.device-frame {
  position: absolute;
  border: 1px solid rgba(23, 33, 27, .12);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.device-mobile {
  width: 210px;
  height: 360px;
  left: 0;
  top: 28px;
  padding: 24px;
}
.device-desktop {
  width: 420px;
  height: 250px;
  right: 0;
  bottom: 24px;
  padding: 22px;
}
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green-2);
  box-shadow: 0 0 0 7px rgba(30, 138, 91, .13);
}
.visual-title { margin-top: 62px; font-size: 28px; font-weight: 850; }
.signal-bars { display: flex; align-items: end; gap: 6px; height: 64px; margin-top: 34px; }
.signal-bars i {
  width: 26px;
  border-radius: 4px 4px 0 0;
  background: var(--green);
}
.signal-bars i:nth-child(1) { height: 20px; background: var(--coral); }
.signal-bars i:nth-child(2) { height: 34px; background: var(--amber); }
.signal-bars i:nth-child(3) { height: 48px; background: var(--blue); }
.signal-bars i:nth-child(4) { height: 62px; }
.visual-line, .visual-footer {
  height: 10px;
  border-radius: 999px;
  background: var(--paper-soft);
  margin-top: 28px;
}
.visual-line.short { width: 62%; margin-top: 12px; }
.visual-tabs { display: flex; gap: 8px; margin-bottom: 26px; }
.visual-tabs span {
  width: 54px;
  height: 10px;
  border-radius: 999px;
  background: var(--line);
}
.visual-map {
  height: 128px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  position: relative;
}
.visual-map b {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
}
.visual-map b:nth-child(1) { left: 18%; top: 34%; background: var(--green); }
.visual-map b:nth-child(2) { left: 50%; top: 52%; background: var(--coral); }
.visual-map b:nth-child(3) { right: 16%; top: 24%; background: var(--amber); }

.info-band { padding: 28px 0 52px; }
.info-grid, .stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.info-card, .stat-card, .chart-card, .form-panel, .account-key-panel, .result-panel, .login-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(23, 33, 27, .06);
}
.info-card { padding: 24px; }
.info-card h2, .purchase-strip h2, .subscription-box h2, .legacy-box h2, .account-key-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}
.info-card p { margin: 0; color: var(--muted); }
.info-kicker { color: var(--green); font-weight: 850; font-size: 13px; }
.purchase-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px 0 72px;
  border-top: 1px solid var(--line);
}
.purchase-strip h2 { font-size: 30px; }

.site-footer, footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--muted);
}
.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 27, .55);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  width: min(620px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  font-size: 20px;
}
.modal-box h2 { margin: 0 0 8px; font-size: 30px; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}
label { display: grid; gap: 6px; font-weight: 700; }
.key-list-header, .key-row-title, .order-total, .account-key-head, .device-row, .section-header, .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.key-list-header { margin: 18px 0 10px; font-weight: 850; }
.key-list { display: grid; gap: 10px; }
.key-config-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.key-row-title, .key-row-total { grid-column: 1 / -1; }
.key-row-total { color: var(--green); font-weight: 850; }
.order-total {
  margin: 18px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

.account-page, .result-page { padding: 44px 0 80px; }
.account-hero, .account-toolbar {
  margin-bottom: 24px;
}
.account-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}
.account-toolbar h1 { font-size: 32px; overflow-wrap: anywhere; }
.form-panel, .account-key-panel, .result-panel {
  padding: 24px;
  margin-bottom: 18px;
}
.form-panel form { display: grid; gap: 14px; max-width: 420px; }
.notice {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
}
.notice-danger { border-color: rgba(184, 70, 70, .35); color: var(--red); background: #fff3f0; }
.account-key-list { display: grid; gap: 18px; }
.account-key-panel { display: grid; gap: 20px; }
.key-code, .key-box {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--ink);
  padding: 8px 10px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.badge-active, .badge-online { background: rgba(30, 138, 91, .12); color: var(--green); }
.badge-revoked, .badge-offline, .badge-disabled, .badge-expired { background: rgba(184, 70, 70, .11); color: var(--red); }
.subscription-box, .legacy-box {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.copy-row input { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.platform-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.platform-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--green);
  font-weight: 750;
}
.account-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.account-actions form {
  display: grid;
  gap: 8px;
  align-content: start;
}
.account-actions small { color: var(--muted); }
.device-list { display: grid; gap: 10px; }
.device-row { padding: 12px 0; border-top: 1px solid var(--line); }
.result-page { max-width: 760px; }
.result-panel { text-align: center; }
.result-panel h1 { font-size: 40px; margin: 14px auto; }
.key-box {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  text-align: left;
}
.checkmark-wrap svg { overflow: visible; }
.checkmark-circle {
  fill: none;
  stroke: rgba(30, 138, 91, .18);
  stroke-width: 6;
}
.checkmark-check {
  fill: none;
  stroke: var(--green);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pulse-wrap {
  width: 76px;
  height: 76px;
  position: relative;
  margin: 0 auto;
}
.pulse-ring, .pulse-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.pulse-ring {
  border: 2px solid rgba(49, 95, 158, .22);
  animation: pulse 1.7s ease-out infinite;
}
.pulse-ring:nth-child(2) { animation-delay: .5s; }
.pulse-dot {
  inset: 28px;
  background: var(--blue);
}
@keyframes pulse {
  from { transform: scale(.7); opacity: 1; }
  to { transform: scale(1.12); opacity: 0; }
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: opacity .18s ease;
}
.toast-hide { opacity: 0; }

/* Admin */
.admin-body {
  background: #111713;
  color: #e8eee7;
}
.admin-body .site-header, .admin-body header {
  background: rgba(17, 23, 19, .92);
  border-color: #29332b;
}
.admin-body .container { width: min(1280px, calc(100% - 32px)); }
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#app { display: none; min-height: 100vh; flex-direction: column; }
.login-box {
  width: min(420px, 100%);
  padding: 28px;
  background: #18211b;
  border-color: #334137;
}
.login-box input, .admin-body input, .admin-body select {
  background: #111713;
  color: #e8eee7;
  border-color: #334137;
}
#login-error { display: none; color: #ffaaa0; margin: 10px 0; }
.admin-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 60px;
  gap: 20px;
  flex: 1;
}
.admin-sidebar {
  border: 1px solid #29332b;
  border-radius: var(--radius);
  background: #18211b;
  padding: 12px;
  align-self: start;
}
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #b7c3b9;
  padding: 8px 10px;
  text-align: left;
}
.sidebar-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.sidebar-link.active, .sidebar-link:hover {
  background: #223027;
  border-color: #3b4d40;
  color: #fff;
}
.admin-content { min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: grid; gap: 18px; }
.admin-body .chart-card, .admin-body .stat-card {
  background: #18211b;
  border-color: #29332b;
  color: #e8eee7;
}
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.stat-card { padding: 18px; }
.stat-label, .stat-sub, .refresh-note { color: #9cab9f; font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 850; margin-top: 4px; }
.chart-card { padding: 18px; overflow: hidden; }
.chart-wrap { height: 290px; }
.time-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.time-btn {
  border: 1px solid #334137;
  background: #111713;
  color: #b7c3b9;
  border-radius: var(--radius);
  padding: 6px 9px;
}
.time-btn.active { background: var(--green); color: #fff; }
.load-bar-wrap {
  height: 8px;
  background: #111713;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.load-bar { height: 100%; border-radius: 999px; background: var(--green); }
.load-warn { background: var(--amber); }
.load-crit { background: var(--red); }
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid #29332b;
  text-align: left;
  vertical-align: top;
}
th { color: #9cab9f; font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.add-server-form { display: none; margin: 16px 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.form-field.full { grid-column: 1 / -1; }
.form-label { color: #9cab9f; font-size: 13px; margin-bottom: 6px; }
.form-actions, .add-key-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.mono { font-family: "SFMono-Regular", Consolas, monospace; }
.btn-add { background: rgba(30, 138, 91, .18); color: #9bf0bb; border-color: rgba(30, 138, 91, .35); }
.btn-del { background: rgba(184, 70, 70, .18); color: #ffaaa0; border-color: rgba(184, 70, 70, .35); }
.btn-copy, .btn-ghost { background: #111713; color: #e8eee7; border-color: #334137; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 30px; }
  .hero-copy h1 { font-size: 40px; }
  .hero-visual { min-height: 320px; }
  .device-mobile { width: 170px; height: 292px; }
  .device-desktop { width: min(340px, 88vw); height: 210px; }
  .info-grid, .stats-grid, .account-actions { grid-template-columns: 1fr; }
  .purchase-strip, .account-toolbar { align-items: start; flex-direction: column; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .container { width: min(100% - 24px, 1120px); }
  .nav-row { min-height: 64px; }
  .hero-shell { padding-top: 36px; }
  .hero-copy h1, .account-hero h1, .result-panel h1 { font-size: 34px; }
  .copy-row, .key-config-row { grid-template-columns: 1fr; }
  .hero-actions, .toolbar-actions { width: 100%; }
  .hero-actions > *, .toolbar-actions > *, .purchase-strip .btn-primary { width: 100%; }
  .sidebar-nav { grid-template-columns: 1fr; }
}
