:root {
  --bg:      #0f0f17;
  --bg2:     #16161f;
  --bg3:     #1e1e2e;
  --surface: #1a1a2a;
  --border:  #2a2a3e;
  --accent:  #6366f1;
  --accent2: #818cf8;
  --text:    #e2e8f0;
  --muted:   #64748b;
  --success: #22c55e;
  --danger:  #ef4444;
  --warn:    #f59e0b;
  --google:  #4285f4;
  --ms:      #00a4ef;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

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

/* ── Shared inputs & buttons ─────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; width: 100%;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-ghost    { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-google   { background: var(--google); color: #fff; width: 100%; }
.btn-microsoft{ background: var(--ms);    color: #fff; width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-full { width: 100%; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 30%, #1a1040 0%, var(--bg) 70%);
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-logo img { height: 28px; }
.login-logo span { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.login-logo .gate-badge { font-size: 10px; background: var(--accent); color: #fff; border-radius: 4px; padding: 2px 6px; font-weight: 600; letter-spacing: .05em; }
.login-title  { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-tenant { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.form-error   { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 20px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.fed-buttons { display: flex; flex-direction: column; gap: 8px; }

/* ── Admin layout ─────────────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-logo { padding: 20px 16px 12px; display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-text { font-weight: 700; font-size: 15px; }
.sidebar-logo .gate-tag  { font-size: 9px; background: var(--accent); color: #fff; border-radius: 3px; padding: 2px 5px; font-weight: 700; letter-spacing: .06em; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  border-radius: 8px; margin: 1px 8px; width: calc(100% - 16px);
  transition: background .12s, color .12s;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent)22; color: var(--accent2); }
.nav-item svg    { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer  { margin-top: auto; padding: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar    { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar h1 { font-size: 16px; font-weight: 600; }
.content   { flex: 1; overflow-y: auto; padding: 24px; }
.content.hidden { display: none; }

/* ── Cards & tables ───────────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title  { font-size: 14px; font-weight: 600; }
.card-body   { padding: 20px; }

table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border)66; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3)44; }

code { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px; word-break: break-all; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #22c55e22; color: var(--success); }
.badge-blue   { background: #6366f122; color: var(--accent2); }
.badge-muted  { background: var(--bg3); color: var(--muted); }
.badge-orange { background: #f59e0b22; color: var(--warn); }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .4; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 16px; font-weight: 600; }
.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-close  { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.modal-close:hover { color: var(--text); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Tenant selector ───────────────────────────────────────────────────── */
.tenant-pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px;
  font-size: 12px; font-weight: 500; cursor: pointer; margin-right: 6px; margin-bottom: 6px;
}
.tenant-pill.active { border-color: var(--accent); color: var(--accent2); background: var(--accent)18; }
.tenant-pill:hover:not(.active) { border-color: var(--muted); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toastContainer { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,.4); animation: slideIn .2s ease; min-width: 240px; }
.toast.success { border-color: var(--success)66; }
.toast.error   { border-color: var(--danger)66; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.tag-input-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; font-size: 12px; }
.tag-remove { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.tag-remove:hover { color: var(--danger); }
