:root {
  --bg: #0b0d12;
  --bg-elev: #11141b;
  --bg-soft: #161a23;
  --border: #232936;
  --border-soft: #1c2230;
  --text: #e6e8ee;
  --text-dim: #9aa1b1;
  --text-muted: #6b7384;
  --accent: #02A388;
  --accent-soft: rgba(2, 163, 136, 0.12);
  --danger: #ef4f5b;
  --ok: #4ec9a9;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button { font-family: inherit; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #016b5a);
  color: #ffffff;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 0.5px;
}

.brand-name { font-weight: 600; }
.brand-tag { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.disabled { color: var(--text-muted); cursor: not-allowed; pointer-events: none; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-email { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }

.main {
  padding: 32px 40px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.page-title { margin: 0 0 6px; font-size: 26px; font-weight: 600; }
.page-subtitle { margin: 0; color: var(--text-dim); }
.page-actions { display: flex; gap: 8px; }

.widget-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.widget {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.widget-wide { grid-column: span 3; }

.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.widget-head h2 { font-size: 14px; margin: 0; font-weight: 600; }

.pill {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-soft);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}

.widget-body { flex: 1; display: flex; align-items: center; }
.widget-empty { color: var(--text-muted); font-size: 14px; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { background: #1d2230; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #03c0a1; }
.btn-ghost { background: transparent; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(2, 163, 136, 0.08), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(78, 201, 169, 0.05), transparent 60%),
    var(--bg);
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-title { margin: 0 0 4px; font-size: 22px; }
.login-subtitle { margin: 0 0 24px; color: var(--text-dim); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.field input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #181d27;
}

.login-footer {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.flash {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-error { border-color: rgba(239, 79, 91, 0.4); color: #fca5ac; }
.flash-floating {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px; }
  .widget-grid { grid-template-columns: 1fr; }
  .widget-wide { grid-column: span 1; }
}

/* --- SSO + magic link login --- */
.sso-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 4px;
}

.sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, #2a2f3d);
  background: #fff;
  color: #1f2330;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}
.sso-btn:hover:not(:disabled) {
  background: #f2f4f8;
  border-color: #c9cfdb;
}
.sso-btn:active:not(:disabled) { transform: translateY(1px); }
.sso-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.sso-btn-microsoft {
  background: #2F2F2F;
  color: #fff;
  border-color: #2F2F2F;
}
.sso-btn-microsoft:hover:not(:disabled) {
  background: #1d1d1d;
  border-color: #1d1d1d;
}

.sso-btn-google {
  background: #fff;
  color: #1f1f1f;
  border-color: #dadce0;
}

.sso-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--text-muted, #8a90a0);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border, #2a2f3d);
}

.login-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted, #8a90a0);
  text-align: center;
}

.login-password {
  margin-top: 18px;
  border-top: 1px solid var(--border, #2a2f3d);
  padding-top: 14px;
}
.login-password > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim, #b6bccc);
  list-style: none;
  outline: none;
  user-select: none;
}
.login-password > summary::-webkit-details-marker { display: none; }
.login-password > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 120ms ease;
}
.login-password[open] > summary::before {
  content: "▾ ";
}
.login-form-password { margin-top: 12px; }
