:root {
  color-scheme: dark;
  --black: #050505;
  --surface: #0d0d0d;
  --surface-raised: #141414;
  --line: #292929;
  --line-strong: #464646;
  --text: #f5f5f2;
  --muted: #969692;
  --danger: #d9a6a2;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: clip; color: var(--text); background: var(--black); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
a { color: inherit; }
.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

.topbar { display: flex; min-height: 78px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 780; letter-spacing: -0.02em; text-decoration: none; }
.brand img, .auth-logo { object-fit: cover; object-position: 50% 42%; }
.brand img { width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 50%; }
.top-actions { display: flex; gap: 8px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(58px, 7vw, 92px); font-weight: 740; line-height: 0.92; letter-spacing: -0.068em; }
h2 { margin-bottom: 0; font-size: 26px; line-height: 1.15; letter-spacing: -0.035em; }
.eyebrow, .compact { margin-bottom: 13px; color: #b5b5b0; font-size: 11px; font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }

.auth-stage { display: grid; min-height: calc(100vh - 78px); grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.62fr); gap: clamp(48px, 9vw, 120px); align-items: center; padding: 58px 0 82px; }
.auth-copy p:last-child { max-width: 590px; color: var(--muted); font-size: 18px; line-height: 1.55; }
.auth-panel, .subscription-panel, .account-panel, .devices-panel, .topup-panel, .history-panel { border: 1px solid var(--line); background: var(--surface); }
.auth-panel { padding: 34px; border-radius: var(--radius); }
.auth-logo { display: block; width: 88px; height: 88px; margin-bottom: 24px; border: 1px solid var(--line-strong); border-radius: 50%; }
.auth-panel h2 { margin-bottom: 10px; }
.muted { color: var(--muted); line-height: 1.5; }
.status-line { min-height: 22px; margin: 10px 0; color: var(--danger); font-size: 13px; }
.status-line.ok { color: var(--text); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: #73736f; font-size: 11px; }
.divider::before, .divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }

form { display: grid; gap: 9px; }
label { margin-top: 5px; color: #c5c5c0; font-size: 12px; font-weight: 650; }
input { width: 100%; height: 50px; padding: 0 15px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: #080808; transition: border-color 150ms ease; }
input:focus { border-color: #777; }

.primary, .secondary, .ghost, .bot-link, .support-link { border: 0; font-size: 14px; font-weight: 720; text-align: center; text-decoration: none; cursor: pointer; }
.primary, .secondary { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; padding: 0 20px; border-radius: 9px; }
.primary { margin-top: 10px; color: #101010; background: var(--text); border: 1px solid var(--text); }
.primary:hover { background: #d8d8d4; border-color: #d8d8d4; }
.secondary { border: 1px solid var(--line-strong); background: transparent; }
.secondary:hover { background: var(--surface-raised); }
.ghost { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; color: #c3c3be; background: transparent; }
.ghost:hover { border-color: var(--line-strong); color: var(--text); }
.bot-link { display: block; margin-top: 18px; color: var(--muted); font-size: 13px; }
.bot-link:hover, .support-link:hover { color: var(--text); }

.dashboard { padding: 64px 0 82px; }
.welcome { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 38px; }
.welcome > div:first-child { min-width: 0; }
.welcome h1 { max-width: 760px; margin-bottom: 0; font-size: clamp(46px, 5.4vw, 72px); }
.balance { min-width: 224px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.balance > span { display: block; color: var(--muted); font-size: 12px; }
.balance strong { display: block; margin-top: 6px; font-size: 24px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance strong span { display: inline; color: inherit; font-size: inherit; }
.balance-topup { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; margin-top: 14px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); font-size: 12px; font-weight: 720; text-decoration: none; }
.balance-topup:hover { background: var(--surface-raised); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.76fr); gap: 18px; }
.subscription-panel, .account-panel, .devices-panel, .topup-panel, .history-panel { border-radius: var(--radius); }
.subscription-panel, .account-panel, .devices-panel, .topup-panel, .history-panel { padding: 30px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.status { padding: 8px 11px; border: 1px solid #535353; border-radius: 999px; color: var(--text); background: #181818; font-size: 11px; font-weight: 730; white-space: nowrap; }
.status.inactive { color: var(--muted); border-color: var(--line); background: transparent; }

.subscription-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 32px 0 24px; }
.subscription-facts div { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #080808; }
.subscription-facts dt { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.subscription-facts dd { margin: 0; font-size: 14px; font-weight: 680; }
.action { margin-right: 7px; }
.account-row { display: flex; justify-content: space-between; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.account-row span { color: var(--muted); }
.account-row strong { max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.support-link { display: inline-flex; align-items: center; min-height: 42px; margin-top: 22px; color: #c9c9c4; }
.account-logout { width: 100%; margin-top: 12px; }
.devices-panel { margin-top: 18px; }
.devices-message { margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.devices-list { margin-top: 8px; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.device-row > div { min-width: 0; }
.device-name { display: block; overflow-wrap: anywhere; font-size: 14px; }
.device-detail { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.device-remove { flex: none; }
.device-remove:disabled, .devices-refresh:disabled { cursor: wait; opacity: 0.55; }
.devices-refresh { margin-top: 20px; }
.topup-panel { margin-top: 18px; }
.topup-copy { max-width: 620px; margin: 22px 0 0; color: var(--muted); line-height: 1.55; }
.topup-form { max-width: 620px; margin-top: 20px; }
.topup-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; padding: 0; border: 0; }
.topup-presets button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); background: transparent; font-size: 12px; font-weight: 720; cursor: pointer; }
.topup-presets button:hover { background: var(--surface-raised); }
.topup-submit { width: 100%; }
.topup-submit:disabled { cursor: wait; opacity: 0.62; }
.topup-bot-link { margin-top: 20px; }
.history-panel { margin-top: 18px; }
.history-list { margin-top: 22px; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.history-item:first-child { border-top: 0; }
.history-title { font-weight: 680; }
.history-meta { color: var(--muted); font-size: 11px; }
.history-amount { grid-row: 1 / 3; grid-column: 2; font-size: 15px; font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-amount.positive { color: var(--text); }
.history-amount.negative { color: #bababa; }
.history-toggle { width: 100%; min-height: 46px; margin-top: 14px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: transparent; font-size: 13px; font-weight: 720; cursor: pointer; }
.history-toggle:hover { background: var(--surface-raised); }
.empty { margin: 24px 0 0; color: var(--muted); }
footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 26px 0 42px; color: #666662; font-size: 11px; }
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: #92928e; text-decoration: none; }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 620px); }
  .auth-stage { display: block; min-height: auto; padding: 48px 0 64px; }
  .auth-copy { margin-bottom: 28px; }
  .auth-copy h1 { font-size: clamp(46px, 12vw, 66px); }
  .auth-copy p:last-child { font-size: 16px; }
  .dashboard { padding-top: 40px; }
  .welcome { align-items: stretch; flex-direction: column; }
  .balance { min-width: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .shell { width: calc(100% - 24px); }
  .brand span { font-size: 15px; }
  .brand img { width: 36px; height: 36px; }
  .top-actions .ghost { min-height: 36px; padding-inline: 12px; font-size: 12px; }
  .auth-copy h1 { overflow-wrap: anywhere; font-size: clamp(38px, 10.5vw, 46px); }
  .auth-panel, .subscription-panel, .account-panel, .devices-panel, .topup-panel, .history-panel { min-width: 0; padding: 23px; border-radius: 14px; }
  .auth-panel { display: grid; grid-template-columns: 58px minmax(0, 1fr); column-gap: 16px; }
  .auth-logo { grid-row: 1 / 4; width: 58px; height: 58px; margin: 0; }
  .auth-panel h2 { align-self: end; font-size: 23px; }
  .auth-panel .muted { min-width: 0; margin-bottom: 0; overflow-wrap: anywhere; }
  .auth-panel .status-line, .auth-panel .bot-link { grid-column: 1 / -1; }
  .auth-panel .bot-link { min-height: 46px; margin-top: 12px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: var(--text); }
  .welcome { gap: 18px; margin-bottom: 22px; }
  .welcome .compact { margin-bottom: 8px; }
  .welcome h1 { max-width: 100%; overflow-wrap: anywhere; font-size: clamp(34px, 10vw, 44px); line-height: 0.98; letter-spacing: -0.052em; }
  .balance { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 16px; padding: 16px 18px; }
  .balance > span { align-self: end; }
  .balance strong { grid-row: 1; grid-column: 2; align-self: center; margin: 0; font-size: 23px; }
  .balance-topup { grid-column: 1 / -1; width: 100%; margin-top: 9px; }
  .panel-heading { gap: 14px; }
  .subscription-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 24px 0 18px; }
  .subscription-facts div { min-height: 84px; padding: 14px; }
  .subscription-facts dd { overflow-wrap: anywhere; }
  .action { display: flex; width: 100%; margin: 9px 0 0; }
  .account-row { padding: 15px 0; }
  .devices-panel, .topup-panel, .history-panel { margin-top: 14px; }
  .device-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .device-remove { width: 100%; }
  .topup-copy { margin-top: 16px; font-size: 14px; }
  .topup-form { margin-top: 16px; }
  .topup-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topup-bot-link { width: 100%; margin-top: 16px; }
  .history-list { margin-top: 14px; }
  .history-item { gap: 7px 12px; padding: 14px 0; }
  .history-title { font-size: 14px; }
  .history-meta { font-size: 10px; }
  .history-amount { font-size: 14px; }
  footer { align-items: flex-start; flex-direction: column; }
  .footer-links { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: no-preference) {
  .auth-panel, .dashboard { animation: reveal 320ms ease-out both; }
  @keyframes reveal { from { opacity: 0; transform: translateY(10px); } }
}
