:root{
  --bg:#0b0f14;
  --card:#121824;
  --muted:#8aa0b7;
  --text:#e8f0fb;
  --accent:#4f8cff;
  --danger:#ff4d6d;
  --ok:#21c48b;
  --border:rgba(255,255,255,.10);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(79,140,255,.20), transparent 60%),
              radial-gradient(900px 600px at 90% 10%, rgba(33,196,139,.18), transparent 55%),
              var(--bg);
}

a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

.container{ max-width:1200px; margin:0 auto; padding:24px; }

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.row{ display:flex; gap:16px; flex-wrap:wrap; }
.col{ flex:1; }

.topbar{
  position:sticky; top:0; z-index:50;
  backdrop-filter: blur(10px);
  background: rgba(11,15,20,.65);
  border-bottom: 1px solid var(--border);
}
.topbar-inner{ display:flex; align-items:center; justify-content:space-between; padding:14px 24px; gap:16px; max-width:1200px; margin:0 auto; }

.brand{ display:flex; align-items:center; gap:12px; min-width:220px; }
.brand img{ width:46px; height:46px; border-radius:12px; object-fit:cover; border:1px solid var(--border); background: rgba(255,255,255,.08); }
.brand .title{ display:flex; flex-direction:column; line-height:1.1; }
.brand .title strong{ font-size:14px; }
.brand .title span{ font-size:12px; color:var(--muted); }

.nav{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:center; }
.nav button{
  background: rgba(255,255,255,.06);
  border:1px solid var(--border);
  color:var(--text);
  padding:10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight:600;
}
.nav button.active{ border-color: rgba(79,140,255,.55); background: rgba(79,140,255,.18); }
.nav button:hover{ background: rgba(255,255,255,.10); }

.right{ display:flex; align-items:center; gap:10px; }
.badge{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--border);
  padding:6px 10px;
  border-radius:999px;
  background: rgba(255,255,255,.04);
}
.btn{
  background: rgba(79,140,255,.22);
  border:1px solid rgba(79,140,255,.45);
  color:var(--text);
  padding:10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{ background: rgba(79,140,255,.28); }
.btn.secondary{ background: rgba(255,255,255,.06); border-color: var(--border); }
.btn.danger{ background: rgba(255,77,109,.18); border-color: rgba(255,77,109,.50); }

h1,h2,h3{ margin:0 0 10px; }
h1{ font-size:22px; }
h2{ font-size:18px; }
h3{ font-size:14px; color: var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:.08em; }

.form{
  display:flex; flex-direction:column; gap:12px;
}
.field{ display:flex; flex-direction:column; gap:6px; }
label{ font-size:12px; color:var(--muted); }
input,select,textarea{
  width:100%;
  background: rgba(255,255,255,.06);
  border:1px solid var(--border);
  color: var(--text);
  padding:10px 12px;
  border-radius: 12px;
  outline:none;
}
select option{
  background: #0b0f14;
  color: var(--text);
}
textarea{ min-height:100px; resize:vertical; }

.grid{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap:16px;
}
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
  .brand{ min-width:auto; }
}
.list{
  display:flex; flex-direction:column; gap:10px;
}
.list-item{
  padding:12px;
  border:1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  cursor:pointer;
}
.list-item:hover{ background: rgba(255,255,255,.06); }
.list-item .meta{ display:flex; justify-content:space-between; gap:10px; font-size:12px; color:var(--muted); }
.list-item.inactive{ border-color: rgba(255,77,109,.55); background: rgba(255,77,109,.10); }

.kv{ display:grid; grid-template-columns: 160px 1fr; gap:10px; }
hr.sep{ border:none; border-top:1px solid var(--border); margin:14px 0; }

.qr-preview{
  width: 260px; height: 260px;
  border-radius: 16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.qr-preview canvas, .qr-preview img{ max-width:100%; max-height:100%; }

.small{ font-size:12px; color:var(--muted); }
.toast{
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18,24,36,.92);
  border:1px solid var(--border);
  padding:10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  display:none;
  z-index: 9999;
}

.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 14px;
}
.table th, .table td{
  text-align:left;
  padding:10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th{ color: var(--muted); font-weight:700; }
.table tr:hover td{ background: rgba(255,255,255,.03); }

/* Login logo */
.login-logo{
  width: 96px;
  height: 96px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;

  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  padding: 8px;
}

@media (max-width: 480px){
  .login-logo{
    width: 72px;
    height: 72px;
    padding: 6px;
  }
  .brand img{ width:38px; height:38px; border-radius:10px; }
}

.chart-box{
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-box canvas{
  display: block;
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 980px){
  .chart-box{ height: 220px; }
}

.chart-box{ min-height: 0; }
#view_analytics .card{ min-width: 0; }

/* KPIs */
.kpis{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:10px;
  margin: 10px 0 14px;
}
.kpi{
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(255,255,255,.04);
}
.kpi .label{
  font-size:12px;
  color: var(--muted);
}
.kpi .value{
  font-size:18px;
  font-weight:800;
  margin-top:4px;
  line-height:1.1;
}
@media (max-width: 980px){
  .kpis{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Accordion blocks */
details.accordion{
  border:1px solid var(--border);
  border-radius:16px;
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  margin-top: 12px;
}
details.accordion summary{
  cursor:pointer;
  list-style:none;
  font-weight:800;
}
details.accordion summary::-webkit-details-marker{ display:none; }
details.accordion[open] summary{ margin-bottom:10px; }

/* Heatmap */
.heatmap-wrap{
  overflow:auto;
  padding-top: 6px;
}
.heatmap{
  display:grid;
  grid-template-columns: 70px repeat(24, 18px);
  grid-auto-rows: 18px;
  gap:4px;
  align-items:center;
}
.heatmap .hlabel{
  font-size:12px;
  color: var(--muted);
  text-align:center;
}
.heatmap .hlabel:first-child{
  text-align:left;
  padding-left:2px;
}
.heatmap .cell{
  width:18px;
  height:18px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.04);
  position:relative;
}
.heatmap .cell:hover::after{
  content: attr(data-tip);
  position:absolute;
  top:-34px;
  left:50%;
  transform:translateX(-50%);
  white-space:nowrap;
  background: rgba(0,0,0,.72);
  color:#fff;
  font-size:12px;
  padding:4px 8px;
  border-radius:10px;
  pointer-events:none;
  z-index:10;
}
