:root {
  --paper: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #eef0eb;
  --ink: #151815;
  --muted: #697069;
  --line: #dfe3dc;
  --line-strong: #c8cec5;
  --signal: #16794b;
  --signal-strong: #0d5d38;
  --signal-soft: #e0f1e7;
  --amber: #a75c00;
  --amber-soft: #fff0d8;
  --danger: #b42318;
  --danger-soft: #fde8e7;
  --info: #2868a9;
  --shadow: 0 10px 30px rgba(23, 32, 25, .07);
  --sidebar: 244px;
}

[data-theme="dark"] {
  --paper: #111411;
  --surface: #181c18;
  --surface-2: #202520;
  --ink: #edf1eb;
  --muted: #9da69c;
  --line: #303730;
  --line-strong: #475047;
  --signal: #54c98b;
  --signal-strong: #82dbaa;
  --signal-soft: #183a28;
  --amber: #f0a94f;
  --amber-soft: #3c2b18;
  --danger: #ff7d73;
  --danger-soft: #422320;
  --info: #75ade4;
  --shadow: 0 14px 36px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.mono { font-family: "JetBrains Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.site-nav {
  height: 66px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 91%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.site-nav-inner {
  max-width: 1180px;
  height: 100%;
  margin: auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; font-weight: 760; }
.brand-mark {
  width: 31px; height: 31px; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); border-radius: 6px; font-size: 14px;
}
.brand small { color: var(--signal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-links a { padding: 8px 11px; color: var(--muted); text-decoration: none; font-weight: 560; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn, .btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 650;
  transition: background .16s, border-color .16s, transform .16s;
}
.icon-btn { width: 38px; padding: 0; }
.btn:hover, .icon-btn:hover { border-color: var(--ink); }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn-primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn-primary:hover { background: var(--signal-strong); border-color: var(--signal-strong); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 38%, var(--line)); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 12px; }
.btn svg, .icon-btn svg { width: 16px; height: 16px; }
.tooltip { position: relative; }
.tooltip::after { content: attr(aria-label); position: absolute; right: 0; top: calc(100% + 7px); white-space: nowrap; background: var(--ink); color: var(--paper); padding: 5px 8px; border-radius: 4px; font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: .15s; }
.tooltip:hover::after { opacity: 1; transform: none; }

.lang-select, .field, .select, .textarea {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}
.field:focus, .select:focus, .textarea:focus { border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 14%, transparent); }
.textarea { padding: 11px; resize: vertical; min-height: 96px; }

.hero {
  max-width: 1180px;
  min-height: calc(100vh - 120px);
  margin: auto;
  padding: 86px 24px 44px;
  position: relative;
  display: grid;
  align-content: center;
}
.hero-grid { display: block; position: relative; }
.hero-grid > div:first-child { position: relative; z-index: 2; max-width: 695px; }
.eyebrow { color: var(--signal); font-size: 12px; font-weight: 800; text-transform: uppercase; margin-bottom: 18px; }
.hero h1 { font-size: clamp(48px, 6.2vw, 78px); line-height: 1.01; margin: 0 0 24px; max-width: 760px; font-weight: 790; letter-spacing: 0; }
.hero-copy { color: var(--muted); font-size: 18px; line-height: 1.72; max-width: 620px; margin: 0 0 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions .btn { min-height: 46px; padding: 0 20px; }
.service-strip { display: flex; gap: 22px; align-items: center; margin-top: 38px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.live-dot { width: 8px; height: 8px; background: var(--signal); border-radius: 50%; box-shadow: 0 0 0 5px var(--signal-soft); display: inline-block; margin-right: 7px; animation: live 2.2s infinite; }
@keyframes live { 50% { box-shadow: 0 0 0 9px transparent; } }

.route-map { min-height: 470px; width: 430px; position: absolute; z-index: 1; right: 0; top: 50%; transform: translateY(-50%); border-left: 1px solid var(--line-strong); padding-left: 44px; display: flex; flex-direction: column; justify-content: center; opacity: .82; }
.route-map::before { content: ""; position: absolute; left: -1px; top: 14%; bottom: 14%; width: 1px; background: linear-gradient(var(--line), var(--signal), var(--line)); }
.route-node { border: 1px solid var(--line); background: var(--surface); padding: 16px; border-radius: 7px; margin: 7px 0; position: relative; box-shadow: var(--shadow); }
.route-node::before { content: ""; position: absolute; left: -45px; top: 50%; width: 44px; border-top: 1px solid var(--line-strong); }
.route-node::after { content: ""; position: absolute; left: -49px; top: calc(50% - 4px); width: 7px; height: 7px; border-radius: 50%; background: var(--signal); }
.route-node.active { border-color: color-mix(in srgb, var(--signal) 42%, var(--line)); transform: translateX(10px); }
.node-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; }
.node-meta { display: flex; gap: 14px; color: var(--muted); font-size: 11px; margin-top: 7px; }
.status-pill { font-size: 10px; color: var(--signal); background: var(--signal-soft); padding: 4px 7px; border-radius: 999px; font-weight: 800; text-transform: uppercase; }

.band { border-top: 1px solid var(--line); padding: 76px 24px; }
.band-inner { max-width: 1180px; margin: auto; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 30px; }
.section-head h2 { font-size: 34px; margin: 0 0 8px; }
.section-head p { margin: 0; color: var(--muted); line-height: 1.6; max-width: 560px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.feature { min-height: 190px; padding: 26px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.feature-icon { width: 34px; height: 34px; color: var(--signal); margin-bottom: 28px; }
.feature h3 { margin: 0 0 9px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); line-height: 1.65; font-size: 13px; }
.metric-band { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--surface); }
.metric { padding: 28px; border-right: 1px solid var(--line); }
.metric:last-child { border: 0; }
.metric strong { display: block; font-size: 29px; margin-bottom: 6px; }
.metric span { color: var(--muted); font-size: 12px; }
.product-preview { width: 100%; height: auto; display: block; border: 1px solid var(--line-strong); border-radius: 7px; box-shadow: var(--shadow); }

.footer { border-top: 1px solid var(--line); padding: 34px 24px; }
.footer-inner { max-width: 1180px; margin: auto; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.footer-links { display: flex; gap: 20px; }
.footer a { text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 35; }
.sidebar .brand { height: 66px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.side-nav { padding: 16px 10px; flex: 1; overflow-y: auto; }
.side-label { padding: 15px 10px 6px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.side-link { width: 100%; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 11px; border-radius: 5px; cursor: pointer; font-weight: 600; text-align: left; }
.side-link svg { width: 17px; height: 17px; }
.side-link:hover { color: var(--ink); background: var(--surface-2); }
.side-link.active { color: var(--signal-strong); background: var(--signal-soft); }
.side-user { padding: 14px; border-top: 1px solid var(--line); }
.user-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: 800; }
.user-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.app-main { grid-column: 2; min-width: 0; }
.app-topbar { height: 66px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 25; padding: 0 24px; display: flex; align-items: center; gap: 12px; }
.app-topbar h1 { font-size: 17px; margin: 0; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.mobile-menu { display: none; }
.app-content { padding: 28px; max-width: 1460px; margin: auto; }
.page { display: none; }
.page.active { display: block; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 24px; }
.page-head h2 { margin: 0 0 6px; font-size: 25px; }
.page-head p { margin: 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 18px; min-height: 116px; }
.stat-card .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.stat-card .value { font-size: 26px; font-weight: 760; margin: 15px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .sub { font-size: 11px; color: var(--muted); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); gap: 18px; }
.panel { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; overflow: hidden; }
.panel-head { min-height: 54px; border-bottom: 1px solid var(--line); padding: 0 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 17px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); }
td { padding: 13px; border-bottom: 1px solid var(--line); font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.tag { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; background: var(--surface-2); font-size: 10px; font-weight: 750; }
.tag.ok { color: var(--signal); background: var(--signal-soft); }
.tag.warn { color: var(--amber); background: var(--amber-soft); }
.tag.bad { color: var(--danger); background: var(--danger-soft); }
.progress { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--signal); border-radius: inherit; transition: width .35s; }
.quota-row { margin-bottom: 20px; }
.quota-meta { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 11px; }
.empty { padding: 42px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 32px; height: 32px; margin-bottom: 10px; }
.key-list, .model-list { display: grid; gap: 10px; }
.key-item, .model-item { border: 1px solid var(--line); border-radius: 6px; padding: 14px; display: flex; align-items: center; gap: 14px; background: var(--surface); }
.key-main, .model-main { min-width: 0; flex: 1; }
.key-title, .model-title { font-weight: 700; margin-bottom: 5px; }
.key-preview, .model-meta { font-size: 11px; color: var(--muted); }
.key-actions { display: flex; gap: 6px; }
.toggle { width: 38px; height: 21px; appearance: none; background: var(--line-strong); border-radius: 99px; position: relative; cursor: pointer; transition: .2s; }
.toggle::after { content: ""; width: 15px; height: 15px; position: absolute; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle:checked { background: var(--signal); }
.toggle:checked::after { transform: translateX(17px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-field { display: grid; gap: 6px; }
.form-field label { font-size: 11px; color: var(--muted); font-weight: 700; }
.form-field .field, .form-field .select, .form-field .textarea { width: 100%; }
.code-block { background: #121612; color: #d9e5d9; border-radius: 6px; overflow: auto; padding: 15px; font-size: 11px; line-height: 1.75; }
.notice { border-left: 3px solid var(--signal); background: var(--signal-soft); padding: 12px 14px; color: var(--signal-strong); font-size: 12px; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { width: min(350px, calc(100vw - 36px)); background: var(--ink); color: var(--paper); border-radius: 6px; padding: 12px 14px; box-shadow: var(--shadow); animation: toast-in .2s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 9, .58); z-index: 80; display: none; align-items: center; justify-content: center; padding: 18px; }
.modal-backdrop.open { display: flex; }
.modal { width: min(470px, 100%); max-height: calc(100vh - 36px); overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-actions { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.secret-box { padding: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; word-break: break-all; font-size: 11px; }
.payment-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.payment-method { position: relative; }
.payment-method input { position: absolute; opacity: 0; pointer-events: none; }
.payment-method .method-box { min-height: 68px; border: 1px solid var(--line-strong); border-radius: 6px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; cursor: pointer; font-weight: 700; }
.payment-method svg { width: 19px; height: 19px; }
.payment-method input:checked + .method-box { border-color: var(--signal); color: var(--signal-strong); background: var(--signal-soft); }
.payment-amount { font-size: 30px; font-weight: 800; text-align: center; margin: 12px 0; }
.countdown { color: var(--amber); font-size: 12px; text-align: center; margin-top: 10px; }
.announcement-page { min-height: calc(100vh - 70px); }
.announcement-page .section-head h1 { font-size: 40px; margin: 8px 0; }
.announcement-page .section-head p { color: var(--muted); }
.announcement-list { display: grid; gap: 12px; max-width: 960px; }
.announcement-item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--signal); border-radius: 6px; padding: 22px; }
.announcement-item.maintenance { border-left-color: var(--amber); }
.announcement-item.warning { border-left-color: var(--danger); }
.announcement-item.campaign { border-left-color: #2d6cdf; }
.announcement-item h2 { margin: 12px 0 10px; font-size: 20px; }
.announcement-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.announcement-meta time { margin-left: auto; }
.announcement-content { color: var(--muted); line-height: 1.75; white-space: normal; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(400px, .9fr) minmax(500px, 1.1fr); }
.auth-panel { padding: 30px clamp(30px, 6vw, 90px); display: flex; flex-direction: column; background: var(--surface); }
.auth-panel .brand { margin-bottom: auto; }
.auth-box { max-width: 430px; width: 100%; margin: 64px auto; }
.auth-box h1 { font-size: 35px; margin: 0 0 10px; }
.auth-box > p { color: var(--muted); margin: 0 0 28px; line-height: 1.6; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); padding: 3px; border-radius: 6px; margin-bottom: 20px; }
.segmented button { min-height: 36px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 700; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn { margin-top: 6px; min-height: 44px; }
.field-action { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.field-action .btn { margin: 0; min-width: 112px; padding-inline: 14px; }
.auth-text-button { border: 0; padding: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; justify-self: end; }
.auth-text-button:hover { text-decoration: underline; }
.auth-aside { background: #182019; color: #eff5ef; padding: 50px clamp(34px, 6vw, 90px); display: flex; align-items: center; position: relative; overflow: hidden; }
.auth-aside::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.045) 1px,transparent 1px), linear-gradient(90deg,rgba(255,255,255,.045) 1px,transparent 1px); background-size: 42px 42px; }
.auth-aside-content { position: relative; max-width: 530px; }
.auth-aside h2 { font-size: 42px; line-height: 1.15; margin: 0 0 20px; }
.auth-aside p { color: #aebcaf; line-height: 1.7; font-size: 16px; }
.auth-stat { margin-top: 40px; border-top: 1px solid #344337; display: grid; grid-template-columns: repeat(3,1fr); }
.auth-stat div { padding: 18px 12px 0 0; }
.auth-stat strong { display: block; font-size: 22px; margin-bottom: 5px; }
.auth-stat span { color: #94a496; font-size: 11px; }

@media (max-width: 960px) {
  .route-map { right: -80px; opacity: .28; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-band { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 720px) {
  .site-nav-inner { padding: 0 15px; gap: 10px; }
  .nav-links { display: none; }
  .nav-actions { margin-left: auto; }
  .nav-actions .lang-select { width: 74px; }
  .hero { padding: 54px 18px 34px; }
  .hero h1 { font-size: 45px; }
  .hero-copy { font-size: 16px; }
  .route-map { display: none; }
  .band { padding: 54px 18px; }
  .section-head { align-items: start; flex-direction: column; }
  .feature-grid { grid-template-columns: 1fr; }
  .metric-band { grid-template-columns: 1fr 1fr; }
  .metric { padding: 20px; }
  .footer-inner { align-items: start; flex-direction: column; gap: 18px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .app-shell { display: block; }
  .app-main { grid-column: auto; }
  .mobile-menu { display: inline-flex; }
  .app-topbar { padding: 0 14px; }
  .top-actions .lang-select { width: 70px; }
  .app-content { padding: 18px 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 14px; min-height: 105px; }
  .stat-card .value { font-size: 21px; }
  .page-head { align-items: start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .payment-methods { grid-template-columns: 1fr; }
  .payment-method .method-box { min-height: 48px; flex-direction: row; }
  .key-item { align-items: flex-start; flex-wrap: wrap; }
  .key-actions { width: 100%; justify-content: flex-end; }
  .auth-panel { padding: 22px 20px; }
  .auth-box { margin: 48px auto; }
  .field-action { grid-template-columns: 1fr; }
  .field-action .btn { width: 100%; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  .hero h1 { font-size: 39px; }
  .hero-actions { display: grid; }
  .stats-grid { grid-template-columns: 1fr; }
  .metric-band { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
}
