* { box-sizing: border-box; }
html, body { height: 100%; }

:root{
  --bg0: #0b0f14;
  --bg1: #0f1621;
  --surface: rgba(255,255,255,.06);
  --surface-2: rgba(255,255,255,.08);
  --stroke: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.60);
  --shadow: 0 18px 60px rgba(0,0,0,.55);

  --accent: #7c3aed;
  --accent-2: #a78bfa;

  --radius: 18px;
  --radius-sm: 14px;
}

html[data-theme="light"]{
  --bg0: #eef2ff;
  --bg1: #f8fafc;
  --surface: rgba(255,255,255,.72);
  --surface-2: rgba(255,255,255,.86);
  --stroke: rgba(17,24,39,.10);
  --text: #0b1220;
  --muted: rgba(17,24,39,.60);
  --shadow: 0 18px 60px rgba(2,6,23,.14);
}

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial;
  background:
    radial-gradient(1200px 800px at 12% 10%, rgba(124,58,237,.35) 0, rgba(124,58,237,0) 55%),
    radial-gradient(900px 600px at 60% 10%, rgba(167,139,250,.18) 0, rgba(167,139,250,0) 60%),
    radial-gradient(900px 900px at 50% 75%, rgba(15,23,42,.35) 0, rgba(15,23,42,0) 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
}

a{ color: inherit; text-decoration: none; }

.bg-layer{
  position: fixed;
  inset: -40px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity .18s ease;
  z-index: -2;
}

html[data-bg-enabled="1"] .bg-layer{
  opacity: 1;
}

.app{
  height: 100%;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  padding: 18px;
  transition: grid-template-columns .18s ease;
}
html[data-sidebar="collapsed"] .app{
  grid-template-columns: 88px 1fr;
}

.sidebar{
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 14px 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-width: 0;
}

.sb-logo{
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
}
.logo-dot{
  width: 34px; height: 34px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent));
  box-shadow: 0 10px 30px rgba(124,58,237,.35);
}
.logo-text{
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  max-width: 140px;
}
html[data-sidebar="collapsed"] .logo-text{ display: none; }

.sb-nav{
  display: grid;
  gap: 8px;
  padding: 6px;
  align-content: start; /* do not stretch menu items vertically */
}
.sb-item{
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  width: 100%;
  background: transparent; /* avoid default button background */
  appearance: none;
}
.sb-item svg{ width: 20px; height: 20px; flex: none; opacity: .95; }
.sb-item .label{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-sidebar="collapsed"] .sb-item .label{ display: none; }
html[data-sidebar="collapsed"] .sb-item{ justify-content: center; padding: 0; }
html[data-sidebar="collapsed"] .sb-logo{ justify-content: center; padding: 0; }
.sb-item:hover{
  color: var(--text);
  background: rgba(124,58,237,.10);
  border: 1px solid rgba(124,58,237,.20);
}
.sb-item.active{
  color: var(--text);
  background: rgba(124,58,237,.16);
  border: 1px solid rgba(124,58,237,.30);
}

.sb-bottom{ padding: 6px; display: grid; gap: 8px; }
/* Collapse button arrow direction */
.sb-bottom [data-action="toggle-sidebar"] svg{
  transform: rotate(180deg); /* expanded -> points left */
  transition: transform .18s ease;
}
html[data-sidebar="collapsed"] .sb-bottom [data-action="toggle-sidebar"] svg{
  transform: rotate(0deg); /* collapsed -> points right */
}

.main{
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--stroke);
}
.title{
  display: flex;
  align-items: center;
  gap: 12px;
}
.title h1{
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.search{
  display: none;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.12);
  color: var(--muted);
  min-width: 260px;
}
html[data-theme="light"] .search{ background: rgba(255,255,255,.55); }
@media (min-width: 980px){
  .search{ display: flex; }
}
.search input{
  all: unset;
  width: 100%;
  font-size: 14px;
  color: var(--text);
}
.search svg{ width: 18px; height: 18px; opacity: .9; }

.actions{ display: flex; align-items: center; gap: 10px; }

.btn{
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover{ filter: brightness(1.03); }
.btn:active{ transform: translateY(1px); }
.btn svg{ width: 18px; height: 18px; }

.btn-primary{
  background: linear-gradient(135deg, rgba(124,58,237,.95), rgba(167,139,250,.95));
  border-color: rgba(167,139,250,.35);
  box-shadow: 0 12px 30px rgba(124,58,237,.30);
}

.content{
  padding: 18px;
  overflow: auto;
}

.grid{
  display: grid;
  gap: 16px;
  grid-template-columns: 1.2fr .8fr;
}
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

.panel{
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  padding: 16px;
}
.panel h2{
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .02em;
}

.stats{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat{
  border-radius: 16px;
  background: rgba(0,0,0,.10);
  border: 1px solid var(--stroke);
  padding: 14px;
  min-height: 92px;
}
html[data-theme="light"] .stat{ background: rgba(255,255,255,.55); }
.stat .k{ font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.stat .v{ font-size: 22px; font-weight: 850; letter-spacing: -0.02em; }
.stat .ico{
  width: 34px; height: 34px;
  border-radius: 14px;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(124,58,237,.25);
  display: grid; place-items: center;
  margin-left: auto;
  margin-top: -32px;
}
.stat .ico svg{ width: 18px; height: 18px; }

.profile{
  display: grid;
  gap: 12px;
}
.avatar{
  width: 52px; height: 52px;
  border-radius: 18px;
  background: radial-gradient(circle at 30% 30%, rgba(167,139,250,.9), rgba(124,58,237,.9));
  border: 1px solid rgba(255,255,255,.16);
}
.profile .name{ font-weight: 850; font-size: 16px; }
.profile .role{ color: var(--muted); font-size: 12px; margin-top: -8px; }
.pill{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(124,58,237,.25);
  color: var(--text);
  font-weight: 800;
}

/* Auth page layout */
.auth{
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card{
  width: min(420px, 100%);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 20px;
}
.auth-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.auth-brand{ display: flex; align-items: center; gap: 10px; }
.auth-brand .logo-dot{ width: 28px; height: 28px; border-radius: 11px; }
.auth-title{ margin: 0; font-size: 18px; letter-spacing: -0.01em; font-weight: 850; }

.form{ display: grid; gap: 12px; margin-top: 10px; }
.field{ display: grid; gap: 6px; }
.field span{ font-size: 13px; color: var(--muted); }
input{
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  outline: none;
  background: rgba(0,0,0,.12);
  color: var(--text);
  font-size: 15px;
}
html[data-theme="light"] input{ background: rgba(255,255,255,.55); }
input:focus{
  border-color: rgba(167,139,250,.45);
  box-shadow: 0 0 0 4px rgba(124,58,237,.18);
}
.password-row{ display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.alert{
  background: rgba(239,68,68,.14);
  border: 1px solid rgba(239,68,68,.25);
  color: rgba(255,255,255,.92);
  padding: 10px 12px;
  border-radius: 14px;
  margin: 10px 0 10px;
}
html[data-theme="light"] .alert{ color: #7f1d1d; }

/* Dashboard 1:1 blocks */
.dash{
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
}
@media (max-width: 1080px){
  .dash{ grid-template-columns: 1fr; }
}

.dash-left{
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 16px;
  align-content: start;
}
@media (max-width: 980px){
  .dash-left{ grid-template-columns: 1fr; }
}

.cards-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.card-mini{
  border-radius: 16px;
  background: rgba(0,0,0,.10);
  border: 1px solid var(--stroke);
  padding: 14px;
  min-height: 92px;
}
html[data-theme="light"] .card-mini{ background: rgba(255,255,255,.55); }
.card-mini .top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-mini .label2{ font-size: 12px; color: var(--muted); }
.card-mini .value2{ margin-top: 8px; font-size: 22px; font-weight: 860; letter-spacing: -0.02em; }
.mini-ico{
  width: 34px; height: 34px;
  border-radius: 14px;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(124,58,237,.25);
  display: grid; place-items: center;
}
.mini-ico svg{ width: 18px; height: 18px; }

.panel-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.dots{
  width: 30px; height: 30px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  display: grid; place-items: center;
  color: var(--muted);
}
.dots:after{ content:"···"; letter-spacing: 2px; margin-top: -3px; }

.devices{
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: center;
}
@media (max-width: 560px){
  .devices{ grid-template-columns: 1fr; }
}
.donut{
  width: 170px;
  height: 170px;
  margin: 0 auto;
  position: relative;
}
.donut svg{ width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .center{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
.donut .center .big{ font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.donut .center .small{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.legend{
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.lg-item{ display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lg-left{ display: inline-flex; align-items: center; gap: 10px; }
.dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(124,58,237,.12);
}
.dot.l2{ background: rgba(167,139,250,.95); box-shadow: 0 0 0 4px rgba(167,139,250,.10); }
.dot.l3{ background: rgba(255,255,255,.45); box-shadow: 0 0 0 4px rgba(255,255,255,.06); }

.proj{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
}
.bars{
  height: 120px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  align-items: end;
  padding: 6px 2px;
}
.bar{
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.16);
}
.bar.ac{ background: linear-gradient(180deg, rgba(167,139,250,.95), rgba(124,58,237,.95)); border-color: rgba(167,139,250,.30); }

.rev-period{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 560px){
  .rev-period{ grid-template-columns: 1fr; }
}
.ring{
  border-radius: 16px;
  background: rgba(0,0,0,.10);
  border: 1px solid var(--stroke);
  padding: 12px;
  display: grid;
  justify-items: center;
  gap: 8px;
}
html[data-theme="light"] .ring{ background: rgba(255,255,255,.55); }
.ring svg{ width: 86px; height: 86px; transform: rotate(-90deg); }
.ring .amt{ font-weight: 900; letter-spacing: -0.02em; }
.ring .cap{ font-size: 12px; color: var(--muted); margin-top: -4px; }

.mapwrap{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.map{
  border-radius: 16px;
  background: rgba(0,0,0,.10);
  border: 1px solid var(--stroke);
  height: 140px;
  position: relative;
  overflow: hidden;
}
html[data-theme="light"] .map{ background: rgba(255,255,255,.55); }
.map svg{ width: 100%; height: 100%; opacity: .85; }
.pin{
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 999px;
  background: rgba(124,58,237,.95);
  box-shadow: 0 0 0 5px rgba(124,58,237,.16);
}
.pin.p1{ left: 44%; top: 44%; }
.pin.p2{ left: 64%; top: 38%; background: rgba(167,139,250,.95); box-shadow: 0 0 0 5px rgba(167,139,250,.12); }
.pin.p3{ left: 28%; top: 58%; background: rgba(255,255,255,.55); box-shadow: 0 0 0 5px rgba(255,255,255,.08); }

.locbars{ display: grid; gap: 10px; }
.loc{ display: grid; grid-template-columns: 70px 1fr 44px; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.track{
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.12);
  overflow: hidden;
}
html[data-theme="light"] .track{ background: rgba(2,6,23,.05); border-color: rgba(2,6,23,.08); }
.fill{ height: 100%; border-radius: 999px; background: linear-gradient(90deg, rgba(124,58,237,.95), rgba(167,139,250,.95)); }

.side{
  display: grid;
  gap: 16px;
  align-content: start;
}
.plan{
  padding: 16px;
}
.plan-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.plan-top .tag{ font-size: 12px; color: var(--muted); }
.plan-top .tag span{ color: var(--accent-2); font-weight: 800; }
.avatar2{
  width: 56px; height: 56px;
  border-radius: 22px;
  background: radial-gradient(circle at 30% 30%, rgba(167,139,250,.9), rgba(124,58,237,.9));
  border: 1px solid rgba(255,255,255,.16);
}
.plan-mid{ display: grid; justify-items: center; gap: 10px; padding: 10px 0 2px; }
.plan-mid .nm{ font-weight: 900; }
.plan-mid .rl{ margin-top: -8px; font-size: 12px; color: var(--muted); }
.upgrade{ width: 100%; }

.money{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
}
.money .m{ text-align: center; }
.money .m .v{ font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.money .m .k{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.divider{
  width: 1px;
  background: var(--stroke);
  margin: 0 auto;
}

.msgs .head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* Settings */
.chk{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  color: var(--text);
  user-select: none;
}
html[data-theme="light"] .chk{ background: rgba(255,255,255,.55); }
.chk input{ width: 16px; height: 16px; margin: 0; }

.bg-options{ margin-top: 12px; display: grid; gap: 12px; }
.bg-grid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.bg-tile{
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.bg-tile .thumb{
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
}
.bg-tile.active{
  border-color: rgba(167,139,250,.55);
  box-shadow: 0 0 0 4px rgba(124,58,237,.18);
}
.bg-toggles{
  display: grid;
  gap: 10px;
}
.link{ font-size: 12px; color: var(--muted); }
.msglist{ display: grid; gap: 12px; }
.msg{
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
}
.ava{
  width: 40px; height: 40px;
  border-radius: 16px;
  background: rgba(255,255,255,.10);
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.ava img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.msg .t{ font-size: 13px; font-weight: 800; }
.msg .p{ font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.msg .d{ font-size: 11px; color: var(--muted); }

