/* Shared styles for the login page and the dashboard (externalized so a strict
   CSP needs no 'unsafe-inline'). */
* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", Tahoma, sans-serif; background: #0f172a; color: #e2e8f0;
  margin: 0; padding: 24px;
}
.wrap { max-width: 1000px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; color: #cbd5e1; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #94a3b8; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.badge.admin { background: #1e3a8a; color: #bfdbfe; }
.badge.viewer { background: #334155; color: #cbd5e1; }

.status { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: bold;
  padding: 14px 18px; border-radius: 10px; background: #1e293b; margin-bottom: 16px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #64748b; }
.dot.on { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.dot.off { background: #ef4444; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.card { background: #1e293b; border-radius: 10px; padding: 16px; text-align: center; }
.card .n { font-size: 26px; font-weight: bold; color: #38bdf8; }
.card .l { font-size: 13px; color: #94a3b8; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; background: #1e293b; border-radius: 10px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid #334155; font-size: 14px; white-space: nowrap; }
th { background: #334155; }
.empty { color: #64748b; text-align: center; padding: 20px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.in { background: #064e3b; color: #6ee7b7; }
.out { background: #4c1d24; color: #fca5a5; }
.thumb { height: 36px; width: 36px; object-fit: cover; border-radius: 6px; border: 1px solid #334155; vertical-align: middle; }
.muted { color: #64748b; font-size: 12px; }
.sub { color: #94a3b8; font-size: 12px; }

button { background: #2563eb; color: #fff; border: 0; border-radius: 8px; padding: 12px 20px; font-size: 15px; cursor: pointer; margin: 16px 0 8px; }
button:hover { background: #1d4ed8; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { font-size: 13px; padding: 8px 14px; margin: 0 0 8px; }
.btn-danger { background: #b91c1c; } .btn-danger:hover { background: #991b1b; }
.btn-green { background: #16a34a; } .btn-green:hover { background: #15803d; }
.btn-gray { background: #334155; } .btn-gray:hover { background: #475569; }

pre { background: #020617; border-radius: 8px; padding: 12px; font-size: 13px; max-height: 200px; overflow: auto; direction: ltr; text-align: left; }
.tablewrap { overflow-x: auto; }
.panel { background: #1e293b; border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.fld { font-size: 13px; color: #94a3b8; display: block; margin-bottom: 10px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: #0f172a; color: #e2e8f0; border: 1px solid #334155; border-radius: 6px;
  padding: 8px; font-family: inherit; font-size: 13px; margin-top: 4px; direction: rtl;
}
textarea { resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.hidden { display: none !important; }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #1e293b;
  border: 1px solid #334155; color: #e2e8f0; padding: 12px 18px; border-radius: 8px; font-size: 14px;
  z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-color: #b91c1c; }
.toast.ok { border-color: #16a34a; }

/* ===== App shell (sidebar layout) ===== */
.app { max-width: 1200px; margin: 0 auto; }
.topbar { background: #1e293b; border-radius: 12px; padding: 12px 18px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 18px; font-weight: bold; }
.nav-toggle { display: none; background: #334155; margin: 0; padding: 6px 12px; font-size: 18px; border-radius: 8px; }

.layout { display: flex; gap: 16px; align-items: flex-start; }
.sidebar { width: 220px; flex-shrink: 0; background: #1e293b; border-radius: 12px; padding: 10px; position: sticky; top: 16px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; color: #cbd5e1;
  text-decoration: none; font-size: 14px; margin-bottom: 4px; transition: background .12s; }
.nav-item .ic { font-size: 16px; }
.nav-item:hover { background: #334155; }
.nav-item.active { background: #2563eb; color: #fff; font-weight: bold; }

.main { flex: 1; min-width: 0; } /* min-width:0 lets wide tables scroll instead of overflowing */
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 19px; margin: 0 0 16px; }
.sec { font-size: 15px; color: #cbd5e1; margin: 22px 0 10px; }

@media (max-width: 760px) {
  body { padding: 12px; }
  .nav-toggle { display: inline-block; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; display: none; }
  .sidebar.open { display: block; }
}

/* login page */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #1e293b; border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; }
.login-card h1 { text-align: center; }
.login-card .err { color: #fca5a5; font-size: 13px; min-height: 18px; margin: 6px 0; text-align: center; }
.login-card button { width: 100%; }
