:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3248;
  --primary: #4f7fff;
  --primary-hover: #6b93ff;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --sidebar-w: 230px;
  --radius: 10px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); min-height: 100vh; }

/* ── Helpers ── */
.hidden { display: none !important; }

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 30%, #1a2a5e 0%, #0f1117 70%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 360px;
  text-align: center;
  box-shadow: 0 24px 80px #0008;
}
.login-logo { font-size: 52px; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; line-height: 1.5; }
#google-btn-wrapper { display: flex; justify-content: center; margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 16px; }

/* ── App shell ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 24px; }
.sidebar-title { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s;
}
.signout-btn:hover { color: var(--danger); }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  position: relative;
}

/* ── Page ── */
.page { display: none; }
.page.active { display: block; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-value { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-card.loading .stat-value { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ── Table ── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { background: var(--surface2); }
th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.loading-row { text-align: center; color: var(--text-muted); padding: 32px !important; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #14532d44; color: var(--success); border: 1px solid #14532d; }
.badge-gray  { background: #1e293b;   color: var(--text-muted); border: 1px solid var(--border); }
.badge-blue  { background: #1e3a5f44; color: var(--primary);   border: 1px solid #1e3a5f; }
.badge-yellow{ background: #4a3a0044; color: #f59e0b;           border: 1px solid #4a3a00; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); background: var(--border); }
.btn-danger { background: #7f1d1d55; color: var(--danger); border: 1px solid #7f1d1d; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: color .15s; }
.btn-icon:hover { color: var(--primary); }
.btn-icon.danger:hover { color: var(--danger); }

/* ── Filter ── */
.filter-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border-color .15s;
}
.filter-input:focus { border-color: var(--primary); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #000a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 32px 80px #000a;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Menlo', 'Fira Code', monospace;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 32px #0007;
  z-index: 200;
  transition: opacity .3s;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }
