@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Sidebar (light – JumpCloud style) */
  --sidebar-bg:     #ffffff;
  --sidebar-w:      220px;
  --sidebar-text:   #374151;
  --sidebar-muted:  #9ca3af;
  --sidebar-active: rgba(0,150,178,0.10);
  --sidebar-hover:  #f3f4f6;
  --sidebar-border: #e5e7eb;

  /* Content area */
  --topbar-h:     52px;
  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --surface2:     #f8fafc;
  --panel:        #ffffff;
  --border:       #e2e8f0;
  --text:         #111827;
  --muted:        #6b7280;

  /* Accent */
  --accent:       #0096b2;
  --accent-dark:  #007a94;

  /* Semantics */
  --green:   #10b981;
  --red:     #ef4444;
  --yellow:  #f59e0b;
  --purple:  #8b5cf6;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────────────── LAYOUT ───────────────── */

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

/* ───────────────── SIDEBAR ───────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.sidebar-logo .logo-text span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-muted);
  padding: 14px 10px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 1px;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--accent-dark); }
.nav-item.active .nav-icon { color: var(--accent-dark); }

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  padding: 10px 8px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 5px;
}

.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .u-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .u-role { font-size: 10px; color: var(--muted); }

/* ───────────────── MAIN AREA ───────────────── */

.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ───────────────── TOPBAR ───────────────── */

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Page title row — like JumpCloud (title in content, not topbar) */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.page-title-actions { display: flex; align-items: center; gap: 10px; }

/* ───────────────── CONTENT ───────────────── */

.content { flex: 1; padding: 28px; }

/* ───────────────── BUTTONS ───────────────── */

button { font-family: inherit; }

button:not([class]),
button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
button:not([class]):hover,
button.primary:hover { background: var(--accent-dark); }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}
button.ghost:hover { background: var(--bg); }

button.danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
}
button.danger:hover { opacity: 0.88; }

button.sm { padding: 4px 10px; font-size: 12px; }

/* ───────────────── STAT CARDS ───────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(0,181,212,0.1);   color: var(--accent); }
.stat-icon.green  { background: rgba(16,185,129,0.1);  color: var(--green); }
.stat-icon.red    { background: rgba(239,68,68,0.1);   color: var(--red); }
.stat-icon.yellow { background: rgba(245,158,11,0.1);  color: var(--yellow); }
.stat-icon.purple { background: rgba(139,92,246,0.1);  color: var(--purple); }

.stat-value { font-size: 24px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ───────────────── CARD ───────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title { font-size: 14px; font-weight: 600; }

/* ───────────────── TABLES ───────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

table { width: 100%; border-collapse: collapse; }

thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tr.clickable { cursor: pointer; }
.td-main { font-weight: 500; }

/* ───────────────── STATUS ───────────────── */

.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online  { background: var(--green); box-shadow: 0 0 0 2px rgba(16,185,129,0.2); }
.status-dot.offline { background: var(--red); }
.status-dot.never   { background: var(--yellow); }

/* ───────────────── CHIPS ───────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500;
}

.chip-green  { background: rgba(16,185,129,0.1);  color: #059669; }
.chip-red    { background: rgba(239,68,68,0.1);   color: #dc2626; }
.chip-blue   { background: rgba(0,181,212,0.1);   color: var(--accent); }
.chip-yellow { background: rgba(245,158,11,0.1);  color: #d97706; }
.chip-gray   { background: rgba(100,116,139,0.1); color: var(--muted); }
.chip-purple { background: rgba(139,92,246,0.1);  color: #7c3aed; }

.badge-admin { background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }

/* ───────────────── PROGRESS BARS ───────────────── */

.bar-wrap { width: 80px; }
.bar-bg { background: var(--border); border-radius: 4px; height: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.bar-fill.warn   { background: var(--yellow); }
.bar-fill.danger { background: var(--red); }

/* ───────────────── FORMS ───────────────── */

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }

label { font-size: 12px; font-weight: 500; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,181,212,0.12);
}

input[type="checkbox"] { width: auto; }
textarea { resize: vertical; min-height: 70px; }
select option { background: #fff; color: var(--text); }

/* ───────────────── ALERTS ───────────────── */

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-info    { background: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1; }

/* ───────────────── MODAL ───────────────── */

.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,20,40,0.55);
  z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-bg.open { display: flex; }

.modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--text); }

.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ───────────────── TABS ───────────────── */

.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ───────────────── DETAIL GRID ───────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 24px;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.detail-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.detail-value { font-size: 14px; font-weight: 500; color: var(--text); }

/* ───────────────── SECTION CARD (portal) ───────────────── */

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.section-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.info-row { display: flex; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.info-row .info-label { color: var(--muted); width: 150px; flex-shrink: 0; }

/* ───────────────── CODE / QR ───────────────── */

.code-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin: 12px 0; }
.code-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-family: monospace; font-size: 13px; letter-spacing: 1px; text-align: center; }

.qr-wrap { display: flex; justify-content: center; margin: 16px 0; }
.qr-wrap img { border-radius: 8px; border: 4px solid white; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* ───────────────── MISC ───────────────── */

.muted { color: var(--muted); }

code {
  font-family: 'Fira Mono', monospace;
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--text);
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: monospace;
}

h2 { font-size: 20px; font-weight: 600; color: var(--text); }
h3 { font-size: 15px; font-weight: 600; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ───────────────── LOGIN PAGES (JumpCloud style) ───────────────── */

.login-page-bg {
  min-height: 100vh;
  background: #deedf6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Top-left corner crosslink */
.lp-corner-link {
  position: fixed;
  top: 18px; left: 22px;
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500;
  color: #374151;
  text-decoration: none;
}
.lp-corner-link:hover { color: #111; text-decoration: none; }
.lp-corner-link svg { width: 14px; height: 14px; }

/* Bottom-right branding */
.lp-corner-brand {
  position: fixed;
  bottom: 18px; right: 22px;
  display: flex; align-items: center; gap: 7px;
  opacity: 0.45;
}
.lp-corner-brand span {
  font-size: 12px; font-weight: 700;
  color: #374151; letter-spacing: -0.2px;
}

/* Card */
.lp-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 36px 32px 32px;
  width: 308px;
}

/* Logo at top of card (admin only) */
.lp-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 9px; margin-bottom: 16px;
}
.lp-logo-text {
  font-size: 19px; font-weight: 700;
  color: #111827; letter-spacing: -0.3px;
}

/* Card title */
.lp-title {
  font-size: 18px; font-weight: 700;
  color: #111827; text-align: center;
  margin-bottom: 22px;
}

/* Fields */
.lp-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: #6b7280; margin-bottom: 5px;
}

.lp-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px; color: #111827;
  background: #fff; outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 12px;
}
.lp-input:focus {
  border-color: #0096b2;
  box-shadow: 0 0 0 3px rgba(0,150,178,0.12);
}
.lp-input::placeholder { color: #9ca3af; }

/* Remember me */
.lp-remember {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 16px;
}
.lp-remember input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: #0096b2; cursor: pointer;
  flex-shrink: 0;
}
.lp-remember label {
  font-size: 13px; color: #374151;
  cursor: pointer; margin: 0;
}

/* Button */
.lp-btn {
  width: 100%; padding: 11px;
  background: #0096b2; color: #fff;
  border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
  letter-spacing: 0.1px;
}
.lp-btn:hover { background: #007a94; }

/* Error */
.lp-error {
  background: #fef2f2; border: 1px solid #fecaca;
  color: #dc2626; padding: 9px 12px;
  border-radius: 6px; font-size: 13px;
  margin-bottom: 16px;
}

/* ───────────────── DASHBOARD HOME ───────────────── */

.welcome-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.welcome-greeting {
  font-size: 19px; font-weight: 600;
  color: var(--text); margin-bottom: 14px;
}

.welcome-stats {
  display: flex; flex-wrap: wrap;
  gap: 0; border-top: 1px solid var(--border);
  padding-top: 14px;
}

.welcome-stat {
  display: flex; flex-direction: column;
  align-items: flex-start;
  padding: 0 24px 0 0;
  margin-right: 24px;
  border-right: 1px solid var(--border);
}
.welcome-stat:last-child { border-right: none; }

.welcome-stat-num {
  font-size: 22px; font-weight: 700;
  color: var(--accent); line-height: 1;
  text-decoration: none;
}
.welcome-stat-num:hover { color: var(--accent-dark); text-decoration: underline; }
.welcome-stat-label {
  font-size: 12px; color: var(--muted);
  margin-top: 3px;
}

/* Alert cards grid */
.alert-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.alert-card-icon {
  position: absolute; top: 14px; right: 14px;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.alert-card-icon.ok   { color: #10b981; }
.alert-card-icon.warn { color: #f59e0b; }
.alert-card-icon.info { color: #0096b2; }
.alert-card-icon.err  { color: #ef4444; }

.alert-card-num {
  font-size: 26px; font-weight: 700;
  color: var(--text); line-height: 1;
  margin-bottom: 6px;
}
.alert-card-label {
  font-size: 12px; color: var(--muted);
  line-height: 1.4;
}

/* Notification panels */
.notif-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.notif-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.notif-panel-title {
  font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 14px;
  display: flex; justify-content: space-between;
  align-items: center;
}
.notif-panel-count {
  font-size: 13px; font-weight: 700;
  color: var(--text);
}

.notif-item {
  display: flex; justify-content: space-between;
  align-items: center; padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.notif-item:last-child { border-bottom: none; }
.notif-item-label { color: var(--accent); cursor: pointer; }
.notif-item-label:hover { text-decoration: underline; }
.notif-item-val { font-weight: 600; color: var(--text); font-size: 13px; }
