/* ============================================================
   EmiGuard — modern clean light theme (indigo accent)
   Shared by dashboard / device / admin / dealer / login.
   Every legacy selector from the v1 "Prime Lock" theme is kept.
   ============================================================ */

:root{
  --bg:#f5f7fb;
  --surface:#ffffff;
  --border:#eaecf4;
  --border-soft:#eef0f6;
  --text:#101828;
  --text-2:#475467;
  --muted:#667085;
  --brand:#4f46e5;
  --brand-dark:#4338ca;
  --brand-soft:#eef2ff;
  --brand-border:#c7d2fe;
  --green:#059669;
  --red:#e11d48;
  --shadow:0 1px 2px rgba(16,24,40,.04), 0 16px 40px -28px rgba(16,24,40,.35);
}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  margin:0;background:var(--bg);color:var(--text);
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
}
::selection{background:#dbe4ff}
:focus-visible{outline:2px solid #6366f1;outline-offset:2px}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:#d0d5dd;border-radius:8px;border:2px solid transparent;background-clip:content-box}
::-webkit-scrollbar-thumb:hover{background:#b6bccc;background-clip:content-box;border:2px solid transparent}
::-webkit-scrollbar-track{background:transparent}

h1,h2,h3{color:var(--text);letter-spacing:-.02em}
h2{font-size:21px;font-weight:700;margin:18px 0 6px}
a{color:var(--brand-dark)}

.layout{display:flex;min-height:100vh}

/* ---- sidebar ---- */
.sidebar{
  width:236px;min-width:236px;background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;position:sticky;top:0;height:100vh;z-index:10;
}
.brand{
  display:flex;align-items:center;gap:9px;padding:16px 16px 12px;
  font-weight:800;color:#111827;font-size:17px;letter-spacing:-.01em;
}
.brand .mark{
  height:34px;width:auto;background:#fff;border-radius:9px;
  padding:3px;border:1px solid var(--border-soft);
}
.brand .ham{
  margin-left:auto;background:var(--brand-soft);color:var(--brand-dark);
  border-radius:8px;padding:3px 9px;font-size:13px;font-weight:700;
}
.nav{display:flex;flex-direction:column;gap:3px;padding:6px 12px}
.nav a{
  color:#556079;text-decoration:none;padding:10px 14px;border-radius:10px;
  font-size:14px;font-weight:500;display:flex;gap:10px;align-items:center;
  transition:background .13s ease,color .13s ease;
}
.nav a:hover{background:#f2f4fa;color:#111827}
.nav a.on{
  background:var(--brand-soft);color:var(--brand-dark);font-weight:700;
  box-shadow:inset 3px 0 0 var(--brand);
}
.nav .sp{flex:1}

/* ---- main ---- */
.main{flex:1;padding:0 24px 40px;min-width:0;max-width:1400px}
.topbar{display:flex;justify-content:flex-end;align-items:center;gap:10px;padding:14px 0 6px}
.topbar select,.topbar .date{
  background:var(--surface);border:1px solid var(--border);border-radius:10px;
  padding:8px 12px;font-size:13.5px;color:var(--text-2);
}
.topbar .date{display:inline-flex;gap:6px;align-items:center}
.userchip{
  background:var(--surface);border:1px solid var(--border);border-radius:999px;
  padding:6px 14px 6px 7px;display:flex;gap:8px;align-items:center;
  font-size:14px;font-weight:600;color:var(--text-2);
}
.userchip .av{
  width:28px;height:28px;border-radius:50%;
  background:linear-gradient(135deg,#6366f1,#4f46e5);color:#fff;
  display:inline-flex;align-items:center;justify-content:center;font-weight:800;font-size:13px;
}

/* ---- cards ---- */
.card{
  background:var(--surface);border:1px solid var(--border);border-radius:16px;
  padding:18px 20px;margin:14px 0;box-shadow:var(--shadow);
}
.card h3{margin:0 0 12px;font-size:15.5px;font-weight:700;color:#111827}

/* ---- forms & buttons ---- */
input,select,textarea{
  padding:10px 14px;border-radius:10px;border:1px solid #e2e6f0;background:#fff;
  color:var(--text);margin:4px;font-size:14px;font-family:inherit;
  transition:border-color .15s ease,box-shadow .15s ease;
}
input::placeholder,textarea::placeholder{color:#98a2b3}
input:focus,select:focus,textarea:focus{
  outline:none;border-color:#a5b4fc;box-shadow:0 0 0 3px rgba(99,102,241,.22);
}
button{
  padding:10px 18px;border-radius:10px;border:0;background:var(--brand);color:#fff;
  font-weight:600;font-size:14px;cursor:pointer;margin:4px;font-family:inherit;
  transition:background .13s ease,box-shadow .13s ease,transform .05s ease;
}
button:hover{background:var(--brand-dark);box-shadow:0 8px 18px -10px rgba(79,70,229,.75)}
button:active{transform:translateY(1px)}
button:disabled{opacity:.55;cursor:not-allowed;box-shadow:none}
button.red,button.warn{background:var(--red)}
button.red:hover,button.warn:hover{background:#be123c;box-shadow:0 8px 18px -10px rgba(225,29,72,.7)}
button.blue{background:#2563eb}
button.blue:hover{background:#1d4ed8}
button.ghost{
  background:#fff;color:var(--brand-dark);border:1px solid var(--brand-border);box-shadow:none;
}
button.ghost:hover{background:var(--brand-soft);border-color:#a5b4fc}
a.btnlink{
  display:inline-block;padding:8px 14px;border-radius:9px;background:var(--brand);
  color:#fff;font-weight:600;text-decoration:none;margin:2px;font-size:13px;
  transition:background .13s ease;
}
a.btnlink:hover{background:var(--brand-dark)}
a.btnlink.green{background:var(--green)}
a.btnlink.green:hover{background:#047857}
/* link styled as a button (admin actions) */
a.btn{
  display:inline-block;padding:10px 18px;border-radius:10px;background:var(--brand);
  color:#fff;font-weight:600;text-decoration:none;margin:4px;font-size:14px;
}
a.btn:hover{background:var(--brand-dark)}

/* ---- tables ---- */
table{width:100%;border-collapse:collapse;font-size:14px}
th{
  background:#f8fafc;color:var(--muted);text-align:left;font-size:11.5px;
  text-transform:uppercase;letter-spacing:.06em;font-weight:700;
}
td,th{padding:12px 10px;border-bottom:1px solid #eef1f6;vertical-align:top}
tbody tr:hover td{background:#f9fafb}
tbody tr:last-child td{border-bottom:0}
.locked{color:var(--red);font-weight:700}
.active{color:var(--green);font-weight:600}

/* ---- chips ---- */
.pill{
  font-size:12px;padding:3px 10px;border-radius:999px;background:#f2f4f7;
  color:var(--text-2);font-weight:600;
}
.badge{
  display:inline-block;border-radius:999px;padding:4px 11px;font-size:12px;font-weight:700;
  background:var(--brand-soft);color:var(--brand-dark);margin:2px 4px 2px 0;letter-spacing:.02em;
}
.badge.red{background:#fee2e2;color:#b91c1c}
.badge.green{background:#dcfce7;color:#15803d}
.badge.amber{background:#fef3c7;color:#b45309}
.ok{color:var(--green);font-weight:700}

/* ---- stats ---- */
.stats{display:flex;gap:12px;flex-wrap:wrap}
.stat{
  background:#f8f9fd;border:1px solid var(--border-soft);border-radius:14px;
  padding:14px 16px;text-align:center;min-width:112px;flex:1;
}
.stat b{font-size:24px;color:#111827;display:block;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.stat small{color:var(--muted);font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}

.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
#msg{color:#b45309;font-weight:600}

/* ---- tabs ---- */
.tabs{display:flex;gap:6px;flex-wrap:wrap}
.tab{
  padding:9px 16px;border-radius:10px;border:1px solid var(--border);background:#fff;
  color:var(--text-2);cursor:pointer;font-weight:600;font-size:13.5px;
  transition:background .13s ease,border-color .13s ease,color .13s ease;
}
.tab:hover{border-color:var(--brand-border);color:var(--brand-dark)}
.tab.on{background:var(--brand);border-color:var(--brand);color:#fff}

/* ---- grids & tiles ---- */
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}
.ctl{
  border:1px solid var(--border-soft);background:#fff;border-radius:12px;
  padding:12px 14px;display:flex;justify-content:space-between;align-items:center;gap:10px;
  transition:box-shadow .13s ease,border-color .13s ease;
}
.ctl:hover{border-color:#e4e7ec;box-shadow:0 6px 18px -14px rgba(16,24,40,.5)}
.tgl{border:1px solid var(--border);border-radius:10px;overflow:hidden;display:inline-flex}
.tgl button{
  background:#fff;color:var(--text-2);padding:6px 14px;font-size:13px;margin:0;
  border-radius:0;font-weight:600;
}
.tgl button:hover{background:#f8fafc}
.tgl button.on{background:var(--brand);color:#fff}
.tgl button.on:hover{background:var(--brand-dark)}
.kv{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px}
.kv div{border:1px solid var(--border-soft);background:#fafbff;border-radius:12px;padding:12px 14px}
.kv small{
  color:#98a2b3;font-size:11px;text-transform:uppercase;letter-spacing:.06em;
  font-weight:700;display:block;margin-bottom:3px;
}
.code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  background:#f8fafc;border:1px solid var(--border-soft);color:#344054;
  padding:8px 10px;border-radius:8px;word-break:break-all;font-size:13px;
}
.muted{color:var(--muted);font-size:13px;line-height:1.55}
.sel,.ra_tool{accent-color:var(--brand);width:16px;height:16px}

/* ---- legacy aliases ---- */
.sp{flex:1}

@media(max-width:800px){
  .sidebar{width:68px;min-width:68px}
  .sidebar .lbl,.brand .t,.brand .ham{display:none}
  .brand{justify-content:center;padding:14px 6px}
  .nav{padding:6px 8px}
  .nav a{justify-content:center;padding:11px 6px;gap:0}
  .main{padding:0 12px 28px}
  .topbar{flex-wrap:wrap;justify-content:center}
}
