:root {
  color-scheme: dark;
  --bg: #090c11;
  --surface: #11161e;
  --surface-2: #171d27;
  --line: rgba(255,255,255,.09);
  --text: #f4f7fb;
  --muted: #929cab;
  --accent: #86f6c7;
  --accent-dark: #072d21;
  --danger: #ff8d8d;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(74, 222, 168, .09), transparent 28rem),
    radial-gradient(circle at 90% 80%, rgba(80, 120, 255, .08), transparent 30rem),
    var(--bg);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(1080px, calc(100% - 32px)); min-height: 100vh; margin: auto; display: grid; place-items: center; padding: 32px 0; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; color: #07110d; background: var(--accent); border-radius: 9px; font-weight: 900; }

.login-card { width: min(100%, 440px); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(17,22,30,.88); box-shadow: 0 30px 80px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.login-copy { margin: 64px 0 32px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 6vw, 48px); line-height: 1.03; letter-spacing: -.045em; }
.login-copy p:last-child, .hint { color: var(--muted); }
label { display: block; margin-bottom: 8px; color: #c8ced8; font-size: 13px; font-weight: 650; }
input { width: 100%; height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--text); background: #0c1118; transition: border-color .2s, box-shadow .2s; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(134,246,199,.1); }
.primary { width: 100%; height: 52px; margin-top: 12px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 12px; color: #06150f; background: var(--accent); font-weight: 800; }
.primary:disabled { opacity: .6; cursor: wait; }
.error { min-height: 22px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.privacy { margin: 26px 0 0; color: #6f7886; font-size: 12px; }

.dashboard { width: 100%; align-self: start; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.ghost { padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; color: #cfd5df; background: transparent; }
.ghost:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.04); }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 68px 0 36px; }
.hero h1 { margin-bottom: 8px; }
.account-email { margin: 0; color: var(--muted); }
.status { flex: none; margin-bottom: 8px; padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status.active { color: var(--accent); background: rgba(134,246,199,.11); }
.status.inactive { color: var(--danger); background: rgba(255,141,141,.1); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { min-height: 125px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 16px; background: rgba(17,22,30,.72); }
.stat-card.wide { grid-column: 1 / -1; min-height: 146px; }
.stat-card > span, .stat-head > span, .stat-foot { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 20px; letter-spacing: -.02em; }
.stat-head, .stat-foot { display: flex; justify-content: space-between; gap: 16px; }
.stat-head strong { color: var(--accent); font-size: 14px; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: #252c36; }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s ease; }

.connections { margin-top: 56px; }
.apps { margin-top: 56px; padding-bottom: 48px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 27px; letter-spacing: -.035em; }
.count { color: var(--muted); font-size: 13px; }
.hint { margin: 10px 0 24px; }
.connections-list { display: grid; gap: 10px; }
.connection { min-width: 0; padding: 17px 18px; display: grid; grid-template-columns: minmax(0,1fr) 180px auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.protocol { height: 39px; padding: 0 12px; display: grid; place-items: center; justify-self: center; border-radius: 9px; color: var(--accent); background: var(--accent-dark); font-size: 11px; font-weight: 900; white-space: nowrap; }
.connection-main { min-width: 0; }
.connection-name { margin-bottom: 2px; font-weight: 750; }
.connection-actions { display: flex; gap: 8px; }
.copy, .qr-button { height: 39px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface-2); font-size: 13px; font-weight: 700; }
.copy:hover, .qr-button:hover { border-color: var(--accent); color: var(--accent); }
.empty { padding: 36px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.apps-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.app-card { min-width: 0; padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.app-info { min-width: 0; display: flex; align-items: center; gap: 12px; }
.app-info > div { min-width: 0; display: flex; flex-direction: column; }
.app-info strong { letter-spacing: -.01em; }
.app-info span:not(.app-letter) { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.app-letter { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-dark); font-size: 12px; font-weight: 900; }
.store-links { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.store-links a { color: #cbd3de; font-size: 12px; font-weight: 700; text-decoration: none; }
.store-links a:hover { color: var(--accent); }
.loading { display: flex; gap: 7px; }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse .9s infinite alternate; }
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 10px; opacity: 0; transform: translateY(8px); pointer-events: none; background: #202833; box-shadow: 0 12px 30px rgba(0,0,0,.3); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.qr-dialog { width: min(440px, calc(100% - 28px)); padding: 22px; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: #11161e; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.qr-dialog::backdrop { background: rgba(3,6,10,.78); backdrop-filter: blur(5px); }
.qr-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.qr-head h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.dialog-close { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 24px; line-height: 1; }
.dialog-close:hover { color: var(--text); }
.qr-image-wrap { position: relative; display: grid; place-items: center; margin-top: 20px; min-height: 384px; padding: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.qr-image-wrap img { display: none; width: 100%; height: auto; aspect-ratio: 1; }
.qr-image-wrap.loaded { border-color: transparent; background: #fff; }
.qr-image-wrap.loaded img { display: block; }
.qr-image-wrap.loaded .qr-loader { display: none; }
.qr-loader { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; }
.qr-spinner { width: 32px; height: 32px; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.qr-image-wrap.error .qr-spinner { display: none; }
.qr-hint { margin: 16px 2px 0; color: var(--muted); font-size: 13px; }
@keyframes pulse { to { opacity: .25; transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1080px); padding: 12px 0 28px; }
  .login-card { padding: 24px; border-radius: 19px; }
  .login-copy { margin: 48px 0 27px; }
  .hero { align-items: start; padding-top: 48px; }
  .hero h1 { font-size: 36px; }
  .status { margin-top: 6px; }
  .stats-grid { grid-template-columns: 1fr; }
  .connection { grid-template-columns: minmax(0,1fr) auto; }
  .connection-actions { grid-column: 1 / -1; }
  .copy, .qr-button { flex: 1; }
  .apps-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
