:root{
  --bg:#f4f6f9;
  --primary:#2563eb;
  --primary-dark:#1d4ed8;
  --sidebar:#1e293b;
  --success:#16a34a;
  --warning:#d97706;
  --danger:#dc2626;
  --muted:#64748b;
  --white:#ffffff;
  --border:#e2e8f0;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg);
  color:#0f172a;
  font-family:"Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color:transparent;
  padding-bottom:24px;
}

/* ---------- Topbar & Drawer ---------- */
.topbar{
  position:sticky; top:0; z-index:50;
  background:var(--sidebar);
  color:white;
  display:flex; align-items:center; gap:10px;
  padding:12px 14px;
}
.topbar .brand{ font-weight:700; font-size:16px; flex:1; }
.topbar .user-chip{ font-size:13px; color:#cbd5e1; white-space:nowrap; }
.icon-btn{
  background:none; border:none; color:white; font-size:20px; cursor:pointer;
  padding:4px 8px; border-radius:6px;
}
.icon-btn:hover{ background:rgba(255,255,255,0.1); }

.drawer{
  position:fixed; top:0; left:0; bottom:0; width:270px;
  background:var(--sidebar); color:white; z-index:100;
  transform:translateX(-100%);
  transition:transform .25s ease;
  display:flex; flex-direction:column;
  padding:10px 0;
  overflow-y:auto;
}
.drawer.open{ transform:translateX(0); }
.drawer-header{ display:flex; align-items:center; justify-content:space-between; padding:10px 16px 16px; }
.drawer-title{ font-weight:700; font-size:17px; }
.drawer-link{
  display:block; padding:13px 20px; color:#e2e8f0; text-decoration:none; font-size:15px;
  border-left:4px solid transparent;
}
.drawer-link:hover{ background:rgba(255,255,255,0.06); }
.drawer-link.active{ background:rgba(37,99,235,0.25); border-left-color:var(--primary); color:white; font-weight:600; }
.drawer-link.logout{ color:#fca5a5; }
.drawer-spacer{ flex:1; }
.overlay{
  position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:90;
  display:none;
}
.overlay.show{ display:block; }

/* ---------- Layout ---------- */
.content{ max-width:900px; margin:0 auto; padding:18px 14px 40px; }
.content-full{ max-width:none; padding:0; }
.page-title{ font-size:22px; margin:6px 0 16px; }
.section-title{ font-size:17px; margin:22px 0 10px; color:#1e293b; }
.muted{ color:var(--muted); }
.hint{ color:var(--muted); font-size:12.5px; margin-top:10px; }

/* ---------- Flash messages ---------- */
.flash-wrap{ margin-bottom:14px; }
.flash{ padding:10px 14px; border-radius:8px; margin-bottom:8px; font-size:14px; }
.flash-success{ background:#dcfce7; color:#166534; border:1px solid #86efac; }
.flash-error{ background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; }

/* ---------- Cards ---------- */
.card{
  background:white; border:1px solid var(--border); border-radius:12px;
  padding:16px; margin-bottom:16px; box-shadow:0 1px 2px rgba(0,0,0,0.03);
}
.card h2{ font-size:16px; margin:0 0 12px; }

.card-grid{
  display:grid; grid-template-columns:1fr; gap:12px;
}
@media(min-width:640px){
  .card-grid{ grid-template-columns:repeat(2, 1fr); }
}
@media(min-width:960px){
  .card-grid{ grid-template-columns:repeat(3, 1fr); }
}

.item-card{
  background:white; border:1px solid var(--border); border-radius:12px; padding:14px;
}
.item-card-title{ font-weight:700; font-size:15px; margin-bottom:8px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.item-card-row{ display:flex; justify-content:space-between; font-size:13.5px; padding:3px 0; gap:10px; }
.item-card-row span:first-child{ color:var(--muted); }
.item-card-warning{
  margin-top:8px; padding:8px 10px; background:#fff7ed; border:1px solid #fed7aa;
  color:#c2410c; border-radius:8px; font-size:12.5px; font-weight:600;
}
.item-card-actions{ display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; }
.item-card-actions form{ margin:0; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  border:none; border-radius:8px; padding:10px 16px; font-size:14px; font-weight:600;
  cursor:pointer; text-decoration:none; background:var(--primary); color:white;
}
.btn:hover{ background:var(--primary-dark); }
.btn-block{ width:100%; }
.btn-sm{ padding:7px 12px; font-size:13px; }
.btn-outline{ background:white; color:var(--primary); border:1px solid var(--primary); }
.btn-outline:hover{ background:#eff6ff; }
.btn-danger{ background:var(--danger); }
.btn-danger:hover{ background:#b91c1c; }

/* ---------- Forms ---------- */
form label{ display:block; font-size:13px; font-weight:600; color:#334155; margin:10px 0 4px; }
form input[type=text], form input[type=password], form select{
  width:100%; padding:10px 12px; border:1px solid #cbd5e1; border-radius:8px; font-size:14px;
  background:white;
}
form input[type=file]{
  width:100%; padding:10px 12px; border:1px dashed #cbd5e1; border-radius:8px; font-size:13px;
  background:#f8fafc;
}
.form-row{ display:grid; grid-template-columns:1fr; gap:4px; }
@media(min-width:640px){
  .form-row{ grid-template-columns:1fr 1fr; gap:14px; }
}
.form-card button{ margin-top:14px; }
.filter-form{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.filter-form input, .filter-form select{ width:auto; flex:1 1 160px; }
.checkbox-inline{ display:flex; align-items:center; gap:6px; font-size:13px; font-weight:500; color:#334155; white-space:nowrap; }
.checkbox-inline input{ width:auto; }
.inline-form{ display:flex; gap:8px; margin-top:10px; }
.inline-form input{ flex:1; }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; background:white; border:1px solid var(--border); border-radius:12px; margin-bottom:16px; }
.table{ width:100%; border-collapse:collapse; font-size:13.5px; min-width:480px; }
.table th{ background:var(--primary-dark); color:white; text-align:left; padding:10px 12px; font-weight:600; white-space:nowrap; }
.table td{ padding:9px 12px; border-bottom:1px solid var(--border); }
.table tr:last-child td{ border-bottom:none; }

/* ---------- Badges ---------- */
.badge{ font-size:11px; font-weight:700; padding:2px 9px; border-radius:999px; color:white; }
.badge-aktif{ background:var(--success); }
.badge-maintenance{ background:var(--warning); }
.badge-rusak{ background:var(--danger); }
.badge-nonaktif{ background:var(--muted); }
.badge-admin{ background:var(--primary); }
.badge-staff{ background:var(--muted); }
.badge-viewer{ background:#0891b2; }

/* ---------- Dashboard stats ---------- */
.stats-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media(min-width:640px){ .stats-grid{ grid-template-columns:repeat(4, 1fr); } }
.stat-card{ border-radius:12px; padding:16px; color:white; }
.stat-blue{ background:var(--primary); }
.stat-teal{ background:#0891b2; }
.stat-orange{ background:var(--warning); }
.stat-red{ background:var(--danger); }
.stat-value{ font-size:26px; font-weight:800; line-height:1.1; }
.stat-label{ font-size:12.5px; margin-top:4px; opacity:0.95; }

.realtime-indicator{ font-size:12.5px; color:var(--muted); margin:12px 2px 0; display:flex; align-items:center; gap:6px; }
.dot{ width:9px; height:9px; border-radius:50%; background:var(--success); display:inline-block; }
.dot-off{ background:var(--danger); }
.dot-pulse{ box-shadow:0 0 0 4px rgba(22,163,74,0.25); }

.quick-actions{ display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
@media(min-width:640px){ .quick-actions{ grid-template-columns:repeat(4,1fr); } }
.quick-btn{
  background:white; border:1px solid var(--border); border-radius:12px; padding:18px 8px;
  text-align:center; text-decoration:none; color:#0f172a; font-size:26px;
  display:flex; flex-direction:column; align-items:center; gap:8px;
}
.quick-btn span{ font-size:12.5px; font-weight:600; color:#334155; }
.quick-btn:hover{ border-color:var(--primary); }

/* ---------- Scan / detail rows ---------- */
.scan-input-row{ display:flex; gap:8px; margin-bottom:10px; }
.scan-input-row input{ flex:1; }
#reader{ margin:10px 0; border-radius:10px; overflow:hidden; }
.detail-row{ display:flex; justify-content:space-between; font-size:14px; padding:6px 0; border-bottom:1px dashed var(--border); gap:10px; }
.detail-row:last-child{ border-bottom:none; }
.detail-row span:first-child{ color:var(--muted); }

/* ---------- Footer ---------- */
.app-footer{
  text-align:center; font-size:12px; color:var(--muted);
  padding:18px 14px 26px; max-width:900px; margin:0 auto;
}
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--sidebar); padding:20px; }
.login-card{
  background:white; border-radius:16px; padding:32px 26px; width:100%; max-width:380px;
  text-align:center; box-shadow:0 10px 40px rgba(0,0,0,0.3);
}
.login-logo{ font-size:40px; }
.login-card h1{ font-size:20px; margin:8px 0 2px; }
.login-card form{ text-align:left; margin-top:16px; }
.login-card .hint{ margin-top:16px; }

/* ---------- QR preview ---------- */
.qr-preview-card{
  background:white; border:1px solid var(--border); border-radius:14px; padding:20px;
  text-align:center; max-width:380px; margin:0 auto;
}
.qr-image{ max-width:100%; border-radius:8px; }
.qr-code-value{ font-weight:700; font-size:16px; margin:10px 0 16px; }
.qr-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
