:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #141a2b;
  --muted: #64708a;
  --line: #e2e7f1;
  --accent: #3d5afe;
  --accent-ink: #ffffff;
  --ok: #128a5b;
  --ok-bg: #e5f7ef;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --off: #b7bfd0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 26, 43, .05), 0 10px 30px rgba(20, 26, 43, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 500px at 80% -10%, #e8ecff 0%, transparent 60%), var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4rem; }
h1 { font-size: 1.55rem; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; margin-top: 1.5rem; }
code { background: #eef1f8; border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.text-online { color: var(--ok); }
.text-danger { color: var(--danger); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(61, 90, 254, .16); }
.topnav { display: flex; align-items: center; gap: .75rem; }
.user-name { color: var(--muted); font-size: .88rem; }
.inline-form { display: inline-flex; margin: 0; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.6rem clamp(1rem, 4vw, 2rem) 3rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 1.4rem; border-top: 1px solid var(--line); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head h1 { margin-bottom: .15rem; }
.back-link { display: inline-block; font-size: .85rem; margin-bottom: .5rem; }
.status-block { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.4rem; }
.stats.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .8rem; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.device-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
.device-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 12px 34px rgba(20, 26, 43, .12); }
.device-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: .9rem; }
.device-card-head h2 { margin: 0; }
.device-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .9rem; margin: 0; }
.device-meta div { min-width: 0; }
.device-meta dt { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.device-meta dd { margin: 0; font-size: .88rem; overflow-wrap: anywhere; }

.chip { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: capitalize; border: 1px solid transparent; white-space: nowrap; }
.chip-online { color: var(--ok); background: var(--ok-bg); border-color: #b9e6d1; }
.chip-offline, .chip-never, .chip-unknown { color: #5b6376; background: #eef1f7; border-color: #dfe4ee; }
.chip-revoked { color: var(--danger); background: var(--danger-bg); border-color: #f3c9c9; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--off); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.map { height: 340px; border-radius: 10px; overflow: hidden; background: #e7ebf5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M0 20h40M20 0v40' stroke='%23d5dbe8' stroke-width='1'/%3E%3C/svg%3E"); border: 1px solid var(--line); margin-bottom: .7rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.table tbody tr:hover { background: #fafbff; }

.stack { display: flex; flex-direction: column; gap: .85rem; }
.stack label { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 500; }
.stack input[type="text"], .stack input[type="email"], .stack input[type="password"], .stack input[type="number"], .stack input[type="search"], .stack select,
.add-device input, .search-input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-weight: 400;
}
.stack input:focus, .stack select:focus, .add-device input:focus, .search-input:focus { outline: 2px solid rgba(61, 90, 254, .28); border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.toggle { flex-direction: row !important; align-items: flex-start; gap: .65rem !important; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fbfcff; }
.toggle input { margin-top: .25rem; width: 16px; height: 16px; accent-color: var(--accent); }
.toggle span { display: flex; flex-direction: column; gap: .1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 9px; padding: .58rem .9rem; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; transition: background .12s ease, border-color .12s ease, transform .08s ease; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #2f4de0; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #c9d1e2; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d9ac; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a91f1f; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }

.alert { border-radius: 10px; padding: .7rem .9rem; font-size: .88rem; margin: .6rem 0 1rem; border: 1px solid transparent; }
.alert-error { background: var(--danger-bg); color: #8f1d1d; border-color: #f3c9c9; }
.alert-warn { background: var(--warn-bg); color: #7a4a00; border-color: #f0d9ac; }

.auth-wrap { display: flex; justify-content: center; padding-top: 4vh; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.8rem; box-shadow: 0 20px 60px rgba(20, 26, 43, .12); }
.auth-head { text-align: center; margin-bottom: 1.2rem; }
.auth-head h1 { font-size: 1.3rem; }
.logo-mark { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto .8rem; display: grid; place-items: center; background: linear-gradient(135deg, #3d5afe, #8e5cff); color: #fff; font-weight: 800; letter-spacing: -.03em; box-shadow: 0 8px 20px rgba(61, 90, 254, .35); }

.add-device { display: flex; gap: .5rem; flex-wrap: wrap; }
.add-device input { min-width: 220px; width: auto; }

.empty-state { text-align: center; padding: 3rem 1rem; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

.token-label { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin: 1rem 0 .35rem; }
.token-row { display: flex; gap: .5rem; align-items: stretch; }
.token { flex: 1; padding: .7rem .8rem; background: #f7f9ff; border: 1px solid var(--line); border-radius: 9px; font-size: .85rem; overflow-wrap: anywhere; }
.steps { padding-left: 1.2rem; margin: .5rem 0; }
.steps li { margin-bottom: .45rem; }

.search-input { max-width: 240px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.media-tile { position: relative; display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f0f3fa; aspect-ratio: 1 / 1; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-video { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; height: 100%; color: var(--muted); padding: .5rem; text-align: center; }
.media-video .play { width: 40px; height: 40px; border-radius: 50%; background: rgba(61, 90, 254, .12); color: var(--accent); display: grid; place-items: center; }
.media-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: .35rem .45rem; font-size: .68rem; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.media-tile:hover { text-decoration: none; }

.danger-zone { border-color: #f3c9c9; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .8rem 0; border-top: 1px solid var(--line); }
.danger-row p { margin: .15rem 0 0; }

@media (max-width: 640px) {
  .user-name { display: none; }
  .page-head { align-items: flex-start; }
  .status-block { align-items: flex-start; }
  .device-meta { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .add-device { width: 100%; }
  .add-device input { flex: 1; min-width: 0; }
}

/* --- Landing / download page -------------------------------------------- */
.topnav a { font-size: .9rem; }
.topnav a.btn { text-decoration: none; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  padding: 2.2rem 0 3rem;
}
.hero-copy h1 {
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  letter-spacing: -.035em;
  margin: .6rem 0 1rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  background: #e9edff;
  color: #2f45c9;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  border: 1px solid #d5dcff;
}
.lead { font-size: 1.05rem; color: #3d4763; max-width: 62ch; margin: 0 0 1.4rem; }
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.btn-lg { padding: .78rem 1.25rem; font-size: .98rem; border-radius: 11px; }

.release-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: .8rem 1rem;
  margin: 0 0 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.release-meta dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.release-meta dd { margin: .1rem 0 0; font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.checksum { margin: .4rem 0 1rem; font-size: .82rem; }
.checksum summary { cursor: pointer; color: var(--muted); }
.checksum code { display: block; margin-top: .4rem; overflow-wrap: anywhere; }
.notice {
  font-size: .85rem;
  color: #6b5300;
  background: #fff9e8;
  border: 1px solid #f1e2b0;
  border-radius: 10px;
  padding: .7rem .85rem;
  margin: 0;
}

.hero-visual { display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.phone {
  width: min(280px, 78vw);
  aspect-ratio: 9 / 18.5;
  background: linear-gradient(160deg, #1a2033, #0d1120);
  border-radius: 40px;
  padding: 10px;
  box-shadow: 0 30px 70px rgba(20, 26, 43, .28), inset 0 0 0 2px rgba(255,255,255,.06);
  position: relative;
}
.phone-notch {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: 84px; height: 18px; background: #0d1120; border-radius: 999px; z-index: 2;
}
.phone-screen {
  height: 100%;
  border-radius: 31px;
  background: #f7f9ff;
  overflow: hidden;
  padding: .9rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.mini-top { display: flex; align-items: center; gap: .4rem; padding-top: 1.1rem; font-size: .2rem; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #128a5b; box-shadow: 0 0 0 0 rgba(18,138,91,.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(18,138,91,0); } 100% { box-shadow: 0 0 0 0 rgba(18,138,91,0); } }
.mini-title { font-weight: 700; font-size: .72rem; }
.mini-chip { margin-left: auto; font-size: .58rem; font-weight: 700; color: #128a5b; background: #e5f7ef; border-radius: 999px; padding: .12rem .4rem; }
.mini-map {
  position: relative; flex: 1; min-height: 150px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(140deg, #e8eee7, #dfe8f6);
  border: 1px solid #e2e7f1;
}
.mini-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.55) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.55) 1px, transparent 1px);
  background-size: 26px 26px;
}
.mini-road { position: absolute; background: #fff; border-radius: 999px; box-shadow: 0 0 0 1px rgba(200,208,224,.6); }
.road-a { width: 150%; height: 9px; left: -25%; top: 42%; transform: rotate(-14deg); }
.road-b { width: 9px; height: 150%; left: 58%; top: -25%; transform: rotate(18deg); }
.road-c { width: 120%; height: 5px; left: -10%; top: 72%; transform: rotate(8deg); opacity: .8; }
.mini-pin {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -100%);
  width: 18px; height: 18px; border-radius: 50% 50% 50% 0; background: var(--accent);
  rotate: -45deg; box-shadow: 0 4px 10px rgba(61,90,254,.5);
}
.mini-pin i { position: absolute; inset: 5px; background: #fff; border-radius: 50%; }
.mini-map-label { position: absolute; left: .4rem; bottom: .4rem; font-size: .56rem; font-weight: 600; background: rgba(255,255,255,.9); border-radius: 999px; padding: .15rem .4rem; color: #38415c; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.mini-stats div { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .35rem .3rem; text-align: center; }
.mini-stats strong { display: block; font-size: .62rem; }
.mini-stats span { font-size: .5rem; color: var(--muted); }
.mini-row { display: flex; align-items: center; gap: .35rem; font-size: .58rem; color: #404a63; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .32rem .45rem; }
.mini-dot { width: 7px; height: 7px; border-radius: 50%; }
.mini-dot.on { background: var(--ok); }
.mini-dot.off { background: var(--off); }
.preview-label { font-size: .78rem; color: var(--muted); }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.feature h2 { font-size: 1rem; margin: .7rem 0 .35rem; }
.feature p { margin: 0; color: var(--muted); font-size: .88rem; }
.feature-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #e9edff; color: var(--accent); }
.feature-icon svg { width: 22px; height: 22px; }

.consent {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.5rem 2.2rem;
  background: linear-gradient(150deg, #10162a, #1c2340);
  color: #eef1ff; border-radius: 18px; padding: 1.8rem; margin-bottom: 2rem;
  box-shadow: 0 20px 50px rgba(16, 22, 42, .25);
}
.consent h2 { font-size: 1.35rem; margin-bottom: .7rem; }
.consent .muted { color: #b7c0e0; }
.consent .btn-ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); color: #fff; margin-top: .8rem; }
.consent .btn-ghost:hover { background: rgba(255,255,255,.14); }
.consent-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.consent-columns h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: #aab4d8; margin-bottom: .5rem; }
.check-list, .cross-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.check-list li, .cross-list li { position: relative; padding-left: 1.3rem; margin-bottom: .45rem; color: #dfe5fb; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: #5ee0a8; font-weight: 700; }
.cross-list li::before { content: "✕"; position: absolute; left: 0; color: #ff8f8f; font-weight: 700; }

.steps-section { margin-bottom: 2rem; }
.steps-section > h2 { margin-bottom: 1rem; }
.steps-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; counter-reset: step; }
.steps-cards li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.steps-cards h3 { font-size: .95rem; margin: .6rem 0 .3rem; }
.steps-cards p { margin: 0; font-size: .85rem; }
.step-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #e9edff; color: var(--accent); font-weight: 800; font-size: .9rem; }

.faq { margin-bottom: 1rem; }
.faq h2 { margin-bottom: .8rem; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; margin-bottom: .6rem; }
.faq summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.faq p { margin: .6rem 0 0; color: var(--muted); font-size: .88rem; }

.prose { max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.2rem, 4vw, 2.2rem); box-shadow: var(--shadow); }
.prose h1 { font-size: 1.8rem; }
.prose h2 { margin-top: 1.6rem; font-size: 1.05rem; }
.prose p, .prose li { color: #3d4763; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .35rem; }
.prose .table { margin: .8rem 0; }
.prose .table td, .prose .table th { font-size: .84rem; }

.footer-links { display: flex; justify-content: center; gap: 1.1rem; flex-wrap: wrap; margin-bottom: .5rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 1.2rem; }
  .hero-visual { order: -1; }
  .phone { width: min(230px, 70vw); }
  .consent { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .consent-columns { grid-template-columns: 1fr; }
  .topnav { gap: .45rem; }
  .topnav > a:not(.btn) { font-size: .82rem; }
  .topnav .user-name { display: none; }
  .brand { font-size: .9rem; }
}
