:root {
  --navy: #0f1b2d;
  --navy-2: #16273f;
  --accent: #2b6cb0;
  --accent-2: #3b82f6;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --muted: #64748b;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: radial-gradient(circle at top left, var(--navy-2), var(--navy) 70%);
}
.login-card {
  background: var(--card);
  padding: 40px 36px;
  border-radius: var(--radius);
  width: 360px;
  max-width: 100%;
  margin: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-logo {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; margin-bottom: 16px;
}
.login-logo.small { width: 36px; height: 36px; font-size: 14px; margin-bottom: 0; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--muted); }
.login-card input, .login-card select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--text);
}
.login-card input:focus, .login-card select:focus {
  outline: none; border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.error-text { color: var(--red); font-size: 13px; margin-bottom: 12px; }

/* ---------- buttons ---------- */
.btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 600; color: var(--text);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #275a92; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,0.15); color: #cbd5e1; }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- shell ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 230px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; padding: 20px 14px; flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.sidebar-title { font-weight: 700; font-size: 14px; }
.sidebar-subtitle { font-size: 11px; color: #94a3b8; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  text-align: left; background: transparent; border: none; color: #cbd5e1;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: var(--accent); color: #fff; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 10px; }
.admin-name { font-size: 12px; color: #94a3b8; margin-bottom: 10px; padding: 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: 18px; }
.content { padding: 24px 28px; overflow-y: auto; flex: 1; }

/* ---------- cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-header h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 4px 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-green { background: #dcfce7; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }
.badge-amber { background: #fef3c7; color: var(--amber); }
.badge-gray { background: #e2e8f0; color: var(--muted); }

.toggle {
  width: 38px; height: 22px; border-radius: 999px; background: #cbd5e1; position: relative;
  border: none; padding: 0; transition: background .15s;
}
.toggle.on { background: var(--green); }
.toggle span {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left .15s;
}
.toggle.on span { left: 18px; }

.empty-state { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,27,45,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 460px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 22px 24px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.modal input, .modal select, .modal textarea {
  display: block; width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.field-row { display: flex; gap: 10px; }
.field-row > label { flex: 1; }

.credential-box {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px 14px;
  font-size: 12px; font-family: 'SF Mono', Consolas, monospace; margin-top: 10px;
}

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 13px; z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}
