:root{
  color-scheme: light;
  --bg:#eef3f8;
  --panel:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#d8e1eb;
  --blue:#2563eb;
  --green:#059669;
  --red:#dc2626;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:var(--bg);
  color:var(--text);
}
button,a,input{font:inherit}
button:disabled{opacity:.6;cursor:wait}
.home,.tracker{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:12px;
}
.home section,.phone-card,.panel,.tools{
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--panel);
  box-shadow:0 10px 28px rgba(15,23,42,.07);
}
.home section{
  width:min(680px,100%);
  padding:22px;
}
.eyebrow{
  display:inline-flex;
  margin-bottom:5px;
  color:var(--blue);
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}
h1{margin:0 0 7px;font-size:clamp(22px,4vw,34px);line-height:1.05}
p{margin:0 0 12px;color:var(--muted);line-height:1.45}
.button,button{
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid var(--line);
  border-radius:7px;
  padding:0 11px;
  background:#fff;
  color:var(--text);
  text-decoration:none;
  cursor:pointer;
  font-size:13px;
}
.primary{border-color:var(--blue);background:var(--blue);color:#fff}
.danger{border-color:#fecaca;background:#fff1f2;color:var(--red)}
.actions{display:flex;gap:10px;flex-wrap:wrap}
.phone-card{
  width:min(440px,100%);
  padding:16px;
}
.muted,.hint{font-size:13px}
.hint{margin-top:16px}
.notice{
  display:grid;
  gap:3px;
  margin-top:10px;
  padding:9px 10px;
  border-radius:8px;
  background:#fff7ed;
  color:#9a3412;
}
.notice strong{font-size:12px}
.notice span{font-size:12px;line-height:1.45}
.auto-pair{
  padding:8px 10px;
  border:1px solid #bbf7d0;
  border-radius:8px;
  background:#f0fdf4;
  color:#166534;
  font-size:12px;
  font-weight:800;
}
.form{display:grid;gap:8px;margin:12px 0}
label{display:grid;gap:4px}
label span{font-size:11px;font-weight:800;color:#475569}
input{
  width:100%;
  height:38px;
  border:1px solid var(--line);
  border-radius:7px;
  padding:0 10px;
  outline:0;
  font-size:13px;
}
input:focus{border-color:var(--blue);box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.hidden{display:none!important}
.connected{
  display:flex;
  align-items:center;
  gap:8px;
  margin:10px 0;
  padding:9px;
  border-radius:8px;
  background:#ecfdf5;
  color:#065f46;
}
.connected strong,.connected small{display:block}
.live-dot{
  width:12px;
  height:12px;
  border-radius:50%;
  background:var(--green);
  box-shadow:0 0 0 6px rgba(5,150,105,.12);
}
.status-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:6px;
  margin:10px 0;
}
.status-grid div{
  min-width:0;
  padding:8px;
  border:1px solid var(--line);
  border-radius:8px;
}
.status-grid small,.status-grid strong{display:block}
.status-grid small{color:var(--muted);font-size:11px}
.status-grid strong{margin-top:4px;font-size:13px;overflow:hidden;text-overflow:ellipsis}
.dashboard{min-height:100vh;padding:12px}
.dash-header,.tools,.panel-title,.pair-box{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.dash-header h1{font-size:24px}
.admin-form,.pair-box{display:flex;gap:8px}
.admin-form input{width:160px}
.tools{
  margin:10px 0;
  padding:10px;
}
.link-panel{margin-bottom:10px}
.link-list{display:grid;gap:6px}
.link-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#f8fafc;
}
.link-row strong,.link-row small{display:block}
.link-row small{margin-top:3px;color:var(--muted);font-size:12px;word-break:break-all}
.link-row a{color:var(--blue);text-decoration:none;font-size:13px;font-weight:800}
.pair-box{flex:1}
.pair-box div strong,.pair-box div small{display:block}
.pair-box div small{color:var(--muted)}
.pair-result{
  min-width:130px;
  padding:7px 10px;
  border-radius:8px;
  background:#eff6ff;
  color:#1d4ed8;
  text-align:center;
}
.pair-result strong,.pair-result small{display:block}
.pair-result strong{font-size:22px;letter-spacing:.08em}
.dash-grid{
  display:grid;
  grid-template-columns:minmax(300px,.8fr) minmax(420px,1.2fr);
  gap:10px;
}
.panel{padding:10px}
.panel-title{margin-bottom:8px}
.panel-title a{color:var(--blue);text-decoration:none;font-size:13px}
.device-list,.history{display:grid;gap:6px}
.device{
  width:100%;
  display:flex;
  justify-content:space-between;
  text-align:left;
  padding:8px 10px;
}
.device.active{border-color:var(--blue);background:#eff6ff}
.device strong,.device small,.device b{display:block}
.device small{margin-top:3px;color:var(--muted);font-size:11px}
.device b{color:var(--green);font-size:12px}
.device em{
  display:block;
  margin-top:5px;
  color:var(--red);
  font-size:11px;
  font-style:normal;
  font-weight:800;
}
.live-map{
  width:100%;
  height:340px;
  border-radius:8px;
  background:#e2e8f0;
  overflow:hidden;
}
.history-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:7px;
  color:var(--text);
  text-decoration:none;
}
.history-row small{color:var(--muted)}
.empty{
  padding:18px;
  border:1px dashed var(--line);
  border-radius:10px;
  color:var(--muted);
  text-align:center;
}
@media (max-width:800px){
  .dash-header,.tools,.pair-box,.admin-form{align-items:stretch;flex-direction:column}
  .dash-grid{grid-template-columns:1fr}
  .status-grid{grid-template-columns:1fr}
  .history-row{display:grid}
  .live-map{height:260px}
}

body:has(.dashboard){
  background:
    radial-gradient(circle at top left, rgba(37,99,235,.16), transparent 30%),
    linear-gradient(135deg,#eef4ff 0%,#f8fafc 46%,#eefdf7 100%);
}
.dashboard{
  max-width:1480px;
  margin:0 auto;
  animation:pageIn .35s ease both;
}
@keyframes pageIn{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:translateY(0)}
}
.dash-header{
  min-height:58px;
  padding:8px 2px 12px;
}
.dash-header h1{
  margin:0;
  letter-spacing:0;
}
.top-strip{
  display:grid;
  grid-template-columns:minmax(280px,.8fr) minmax(320px,1.2fr);
  gap:10px;
  margin-bottom:10px;
}
.menu-card{
  border:1px solid rgba(148,163,184,.32);
  border-radius:10px;
  background:rgba(255,255,255,.82);
  box-shadow:0 12px 30px rgba(15,23,42,.06);
  overflow:hidden;
  backdrop-filter:blur(10px);
}
.menu-card summary,.history-panel summary{
  min-height:38px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:0 12px;
  color:#172033;
  font-size:13px;
  font-weight:850;
  cursor:pointer;
  list-style:none;
}
.menu-card summary::-webkit-details-marker,.history-panel summary::-webkit-details-marker{display:none}
.menu-card summary::after,.history-panel summary::after{
  content:"⌄";
  color:#64748b;
  transition:transform .18s ease;
}
.menu-card[open] summary::after,.history-panel[open] summary::after{transform:rotate(180deg)}
.menu-body{
  display:grid;
  gap:8px;
  padding:0 10px 10px;
  animation:dropIn .18s ease both;
}
@keyframes dropIn{
  from{opacity:0;transform:translateY(-4px)}
  to{opacity:1;transform:translateY(0)}
}
.dash-grid{
  grid-template-columns:minmax(0,1fr) 340px;
  align-items:start;
}
.side-stack{
  display:grid;
  gap:10px;
}
.map-panel{
  min-height:calc(100vh - 170px);
  display:flex;
  flex-direction:column;
}
.live-map{
  flex:1;
  min-height:620px;
  border:1px solid rgba(148,163,184,.34);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.45);
}
.panel,.tools{
  background:rgba(255,255,255,.86);
  backdrop-filter:blur(10px);
}
.device{
  transition:transform .16s ease,border-color .16s ease,background .16s ease;
}
.device:hover{
  transform:translateY(-1px);
  border-color:#93c5fd;
  background:#f8fbff;
}
.device.active{
  border-color:#2563eb;
  background:linear-gradient(135deg,#eff6ff,#ffffff);
}
.pair-box{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
}
.pair-result{
  display:grid;
  grid-template-columns:auto 1fr auto auto;
  align-items:center;
  gap:8px;
  min-width:0;
  text-align:left;
}
.pair-result strong{font-size:20px}
.pair-result button{
  min-height:30px;
  padding:0 9px;
  font-size:12px;
}
.history-panel{
  padding:0;
}
.history-panel .history{
  padding:0 10px 10px;
  max-height:360px;
  overflow:auto;
}
.history-panel summary span{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#64748b;
  font-size:11px;
}
@media (max-width:980px){
  .top-strip,.dash-grid{grid-template-columns:1fr}
  .side-stack{grid-row:auto}
  .map-panel{min-height:auto}
  .live-map{min-height:430px}
}
@media (max-width:560px){
  .dashboard{padding:8px}
  .pair-box,.pair-result{grid-template-columns:1fr}
  .admin-form{width:100%}
  .admin-form input{width:100%}
  .live-map{min-height:360px}
}
