:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #16202b;
  --muted: #62707f;
  --line: #e2e8f0;
  --brand: #0b3d66;
  --brand-2: #1769aa;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #94a3b8;
  --shadow: 0 1px 3px rgba(16, 32, 43, .08), 0 4px 16px rgba(16, 32, 43, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.45;
}
.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sub { font-size: 12px; opacity: .9; border-left: 1px solid rgba(255,255,255,.35); padding-left: 12px; }
.partner-chip { background: #fff; border-radius: 10px; padding: 5px 9px; display: inline-flex; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.partner-chip img { height: 26px; width: auto; display: block; }

.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* Search */
.search-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.search-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.search-row { display: flex; gap: 10px; }
#search {
  flex: 1; min-width: 0;
  padding: 14px 44px 14px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 12px; outline: none;
}
#search:focus { border-color: var(--brand-2); }
#search-btn {
  padding: 0 22px; font-size: 16px; font-weight: 600; color: #fff;
  background: var(--brand-2); border: 0; border-radius: 12px; cursor: pointer;
}
#search-btn:active { transform: translateY(1px); }
.link-btn { background: none; border: 0; color: var(--brand-2); font-size: 14px; font-weight: 600; cursor: pointer; padding: 8px 0; }
#back-btn { margin-top: 10px; }
.search-row { position: relative; }
.clear-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 50%; background: #e2e8f0; color: #475569; font-size: 20px; line-height: 1; cursor: pointer; }

/* List */
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 10px; }
.list-head h2 { font-size: 15px; color: var(--muted); margin: 0; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.device-list { display: flex; flex-direction: column; gap: 10px; }
.device-row {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1.5px solid transparent;
}
.device-row:active { border-color: var(--brand-2); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.15); }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 4px rgba(217,119,6,.15); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }
.device-main { flex: 1; min-width: 0; }
.device-serial { font-weight: 800; font-size: 16px; word-break: break-all; text-transform: uppercase; letter-spacing: .01em; }
.device-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.device-meta b { color: var(--ink); font-weight: 800; text-transform: uppercase; }
.device-when { text-align: right; font-size: 12px; color: var(--muted); flex: none; }
.chev { color: var(--gray); font-size: 20px; flex: none; }

/* Search-action row (check an exact / brand-new device) */
.search-action {
  background: #eef6fc; border: 1.5px dashed var(--brand-2); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 10px;
}
.search-action .sa-icon { font-size: 18px; }
.search-action .sa-text { flex: 1; font-size: 14px; color: var(--brand); }
.search-action .sa-text b { text-transform: uppercase; }

/* Identity block (on-site proof) */
.idcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border: 2px solid var(--brand); }
.id-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.id-item { min-width: 0; }
.id-item.full { grid-column: 1 / -1; }
.id-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.id-v { font-size: 18px; font-weight: 800; text-transform: uppercase; word-break: break-all; line-height: 1.2; margin-top: 2px; }
.id-clock { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; align-items: baseline; gap: 8px; }
.id-clock .id-k { white-space: nowrap; }
.id-clock .clock-v { font-size: 16px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }

/* Footer partner logos */
.partners-foot { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 10px; opacity: .9; }
.partners-foot img { height: 26px; width: auto; }

/* Detail */
#detail { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.banner {
  border-radius: var(--radius); padding: 18px; color: #fff; box-shadow: var(--shadow);
}
.banner.green { background: linear-gradient(120deg, #15803d, #16a34a); }
.banner.amber { background: linear-gradient(120deg, #b45309, #d97706); }
.banner.red { background: linear-gradient(120deg, #b91c1c, #dc2626); }
.banner-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.banner-title { font-size: 20px; font-weight: 800; }
.banner-msg { margin-top: 8px; font-size: 15px; opacity: .96; }
.live-pill { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.22); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.id-line { font-size: 13px; color: var(--muted); padding: 0 4px; word-break: break-all; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px; }
.card h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 14px 0 6px; }

/* Checklist */
.check { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check-icon { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-size: 16px; font-weight: 800; }
.check-icon.ok { background: var(--green); }
.check-icon.pending { background: var(--amber); }
.check-icon.fail { background: var(--red); }
.check-icon.unknown { background: var(--gray); }
.check-body { flex: 1; min-width: 0; }
.check-label { font-weight: 700; font-size: 15px; }
.check-msg { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* Graph */
.graph-controls { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.graph-controls select, .graph-controls .range-btn {
  font-size: 13px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.range-group { display: inline-flex; gap: 4px; }
.range-btn { cursor: pointer; }
.range-btn.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.chart-wrap { padding: 8px 0 16px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }
.chart-stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); padding-bottom: 12px; flex-wrap: wrap; }
.chart-stats b { color: var(--ink); }

/* Month selector fallback */
.month-fallback { padding: 14px 0; }
.month-fallback .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.month-fallback input { padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; }
.month-fallback button { padding: 10px 16px; border: 0; border-radius: 10px; background: var(--brand-2); color: #fff; font-weight: 600; }

.notice { font-size: 14px; color: var(--muted); padding: 16px 4px; text-align: center; }
.spinner { text-align: center; color: var(--muted); padding: 28px 0; }

.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 22px 16px 40px; }
.logout-link { color: var(--brand-2); font-weight: 600; text-decoration: none; }

@media (min-width: 620px) {
  .device-serial { font-size: 17px; }
}

/* ---------- Login gate ---------- */
.login-body {
  min-height: 100vh; margin: 0;
  background: linear-gradient(150deg, #0b3d66 0%, #1769aa 70%, #1e88c7 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.login-vidyutt { height: 46px; width: auto; }
.login-card { width: 100%; background: #fff; border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 24px 20px; }
.login-title { font-size: 19px; font-weight: 800; margin: 0 0 4px; color: var(--ink); text-align: center; }
.login-sub { font-size: 13px; color: var(--muted); margin: 0 0 18px; text-align: center; }
.login-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 6px; }
.login-card input {
  width: 100%; padding: 14px; font-size: 16px; border: 1.5px solid var(--line);
  border-radius: 12px; outline: none; letter-spacing: .03em;
}
.login-card input:focus { border-color: var(--brand-2); }
.login-btn {
  width: 100%; margin-top: 20px; padding: 15px; font-size: 16px; font-weight: 700; color: #fff;
  background: var(--brand-2); border: 0; border-radius: 12px; cursor: pointer;
}
.login-btn:active { transform: translateY(1px); }
.login-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 6px; }
.login-partners { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; padding-top: 4px; }
.login-partners img { height: 34px; width: auto; }
