/* =========================================================================
   Duo Dashboard - design system
   A quiet, precise "security console" aesthetic: dark chrome navigation,
   a light, high-legibility content area for dense admin tables, and a
   deterministic accent color per tenant carried through switcher, tables
   and a top accent bar - so which tenant you're acting on is always
   visible in peripheral vision (acting on the wrong tenant is a real,
   costly mistake in a multi-tenant admin tool).
   ========================================================================= */

:root {
  --bg: #F6F6F3;
  --surface: #FFFFFF;
  --surface-2: #FBFBFA;
  --border: #E3E3DF;
  --border-strong: #D2D2CC;
  --text: #1B1E1F;
  --text-muted: #676C70;
  --text-faint: #93989B;

  --chrome-bg: #12171A;
  --chrome-bg-2: #1B2226;
  --chrome-text: #C9D1D3;
  --chrome-text-dim: #7C8689;
  --chrome-border: #262E32;

  --accent: #2E6F6B;
  --accent-hover: #255956;
  --accent-soft: #E4EFEE;

  --status-active-bg: #E4F1E8;   --status-active-text: #256B41;
  --status-bypass-bg: #F6ECD9;   --status-bypass-text: #96701F;
  --status-disabled-bg: #EDEDEB; --status-disabled-text: #6C7074;
  --status-locked-bg: #F5E1E1;   --status-locked-text: #9C3D3D;
  --status-pending-bg: #EBE2F2;  --status-pending-text: #714D96;

  --danger: #B54646;
  --danger-hover: #983939;
  --danger-soft: #F5E1E1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 24, 25, 0.06);
  --shadow-md: 0 10px 28px rgba(20, 24, 25, 0.10);

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- Reset / base -------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; margin: 0 0 8px; color: var(--text); }
p { margin: 0 0 12px; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, dl { margin: 0; padding: 0; }
li { list-style: none; }
form { margin: 0; }
table { font-family: var(--font-sans); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--chrome-bg);
  color: var(--chrome-text);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--chrome-border);
  margin-bottom: 16px;
}
.brand-mark {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #7FD8C8;
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark--lg { width: 40px; height: 40px; color: var(--accent); }
.brand-mark--lg svg { width: 32px; height: 32px; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0.01em; color: #EDEFEF; }
/* The large variant sits on the light guest card, not the dark chrome, so it
   must override the chrome-tinted color it inherits from .brand-name. */
.brand-name--lg { font-size: 18px; font-weight: 700; color: var(--text); }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; }
.nav-section-label {
  margin: 18px 8px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--chrome-text-dim);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--chrome-text);
  font-size: 14px;
  font-weight: 500;
}
.nav-link:hover { background: var(--chrome-bg-2); text-decoration: none; color: #fff; }
.nav-link.is-active { background: rgba(127, 216, 200, 0.13); color: #9FE6D8; }
.nav-link__icon { font-size: 13px; width: 16px; text-align: center; opacity: 0.85; }

.sidebar__user { border-top: 1px solid var(--chrome-border); padding-top: 14px; margin-top: 12px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.user-chip__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-chip__name {
  font-size: 13px; font-weight: 600; color: #EDEFEF;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.sidebar__link { display: block; padding: 7px 8px; font-size: 13px; color: var(--chrome-text-dim); border-radius: 6px; }
.sidebar__link:hover { color: #fff; background: var(--chrome-bg-2); text-decoration: none; }

/* role pills inside the dark sidebar need brighter, dark-context colors */
.sidebar__user .role-pill--admin { background: rgba(224, 177, 92, 0.18); color: #E0B15C; }
.sidebar__user .role-pill--superuser { background: rgba(127, 216, 200, 0.16); color: #7FD8C8; }
.sidebar__user .role-pill--user { background: rgba(255, 255, 255, 0.10); color: #B7BCC0; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tenant-accent-bar { height: 3px; width: 100%; flex-shrink: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar__title { font-size: 22px; font-weight: 600; }
.topbar__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content { padding: 0 32px 40px; flex: 1; }
.page-lede { color: var(--text-muted); margin-bottom: 20px; }

/* --- Guest shell (login) --------------------------------------------- */
.guest-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--chrome-bg);
  position: relative; overflow: hidden;
  padding: 24px;
}
.guest-shell__pattern {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(127, 216, 200, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black 0%, transparent 75%);
}
.guest-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%; max-width: 380px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.guest-card__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.guest-card__lede { color: var(--text-muted); font-size: 13.5px; text-align: center; margin-bottom: 22px; }

/* --- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn--ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }

/* --- Forms --------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field__input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
textarea.field__input { resize: vertical; }
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field--error .field__input { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.field__help { color: var(--text-muted); font-size: 12.5px; margin-top: 5px; }
.field__static { padding: 9px 0; margin: 0; color: var(--text-muted); }
.field__checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 4px 0; }
.field__checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.field__checkbox--compact { font-size: 13.5px; }
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  max-height: 220px;
  overflow-y: auto;
}
.field__empty-note { color: var(--text-muted); font-size: 13px; margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.search-bar { display: flex; gap: 8px; margin-bottom: 20px; max-width: 480px; }
.search-bar .field__input { margin: 0; }

/* --- Cards ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card--narrow { max-width: 540px; }
.card--danger { border-color: rgba(181, 70, 70, 0.35); }
.card__title { font-size: 15px; margin-bottom: 14px; }
.card__intro { font-size: 13.5px; color: var(--text-muted); background: var(--surface-2); padding: 12px 14px; border-radius: 8px; margin-bottom: 20px; line-height: 1.6; }
.card__empty { color: var(--text-faint); font-size: 13.5px; margin: 0; }

/* --- Pills ------------------------------------------------------------ */
.role-pill {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.role-pill--admin { background: rgba(184, 134, 43, 0.16); color: #96701F; }
.role-pill--superuser { background: rgba(46, 111, 107, 0.14); color: #2E6F6B; }
.role-pill--user { background: rgba(103, 108, 112, 0.14); color: #676C70; }

.status-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.status-pill--active { background: var(--status-active-bg); color: var(--status-active-text); }
.status-pill--bypass { background: var(--status-bypass-bg); color: var(--status-bypass-text); }
.status-pill--disabled { background: var(--status-disabled-bg); color: var(--status-disabled-text); }
.status-pill--locked { background: var(--status-locked-bg); color: var(--status-locked-text); }
.status-pill--pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
/* These carry sentence-case Danish labels, not Duo's lowercase status
   keywords, so opt out of the .status-pill capitalize rule. */
.status-pill--import-create,
.status-pill--import-skip,
.status-pill--import-error { text-transform: none; }
.status-pill--import-create { background: var(--status-active-bg); color: var(--status-active-text); }
.status-pill--import-skip { background: var(--status-disabled-bg); color: var(--status-disabled-text); }
.status-pill--import-error { background: var(--status-locked-bg); color: var(--status-locked-text); }

/* --- CSV import: plan summary and per-row outcome --------------------- */
.import-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.import-summary__item {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 132px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
}
.import-summary__item--create { border-left-color: var(--status-active-text); }
.import-summary__item--skip { border-left-color: var(--status-disabled-text); }
.import-summary__item--error { border-left-color: var(--danger); }
.import-summary__count { font-size: 22px; font-weight: 700; line-height: 1.1; }
.import-summary__label { font-size: 12.5px; color: var(--text-muted); }

.row--error { background: rgba(181, 70, 70, 0.05); }
.row--muted { color: var(--text-muted); }
.row-note { display: block; font-size: 12.5px; color: var(--text-muted); }
.row-note--error { color: var(--danger); }
.import-confirm { margin-top: 22px; }

/* --- Flash messages / notices ----------------------------------------- */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.flash { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; border: 1px solid transparent; }
.flash--success { background: var(--status-active-bg); color: var(--status-active-text); border-color: rgba(37, 107, 65, 0.2); }
.flash--danger { background: var(--status-locked-bg); color: var(--status-locked-text); border-color: rgba(156, 61, 61, 0.25); }
.flash--warning { background: var(--status-bypass-bg); color: var(--status-bypass-text); border-color: rgba(150, 112, 31, 0.25); }
.flash--info { background: var(--accent-soft); color: var(--accent-hover); border-color: rgba(46, 111, 107, 0.2); }
.flash--password {
  display: flex; gap: 10px; align-items: flex-start;
  background: #FFF8E8; border: 1px solid #E8CE8F; color: #6B4E12;
  padding: 14px; border-radius: 10px;
}
.flash__icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.flash__title { font-weight: 700; margin: 0 0 4px; font-size: 13px; }
.flash__body { margin: 0; font-family: var(--font-mono); font-size: 13.5px; word-break: break-all; }

.notice { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; line-height: 1.55; }
.notice--warning { background: var(--status-bypass-bg); color: var(--status-bypass-text); }
.notice--danger { background: var(--status-locked-bg); color: var(--status-locked-text); }

/* --- Tables ------------------------------------------------------------ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table__actions-col { text-align: right; }
.action-row { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.mono--small { font-size: 11.5px; color: var(--text-muted); }
.table-note { color: var(--text-faint); font-size: 12.5px; }
.table-footnote { color: var(--text-muted); font-size: 13px; margin-top: 14px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell__name { font-weight: 600; }
.user-cell__meta { color: var(--text-muted); margin-top: 2px; }

.tenant-dots { display: flex; align-items: center; gap: 4px; }
.tenant-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.pagination__status { color: var(--text-muted); font-size: 13px; }

/* --- Tenant switcher (native <details>, no JS required) --------------- */
.tenant-switcher { position: relative; }
.tenant-switcher summary {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}
.tenant-switcher summary::-webkit-details-marker { display: none; }
.tenant-switcher summary:hover { border-color: var(--accent); }
.tenant-switcher__caret { color: var(--text-muted); font-size: 10px; margin-left: 2px; }
.tenant-switcher__menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 220px;
  padding: 6px;
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
}
.tenant-switcher__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.tenant-switcher__item:hover { background: var(--surface-2); }
.tenant-switcher__item.is-active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }

/* --- Tenant grid (dashboard overview cards) ---------------------------- */
.tenant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 8px; }
.tenant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: box-shadow 150ms ease, transform 150ms ease;
}
.tenant-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tenant-card__accent { height: 4px; width: 100%; }
.tenant-card__body { padding: 18px 18px 6px; flex: 1; }
.tenant-card__name { font-size: 16px; margin-bottom: 4px; }
.tenant-card__hostname { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.tenant-card__meta { font-size: 12.5px; color: var(--text-faint); margin: 0; }
.tenant-card form { padding: 14px 18px 18px; }

.quick-admin { display: flex; gap: 20px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.quick-admin__link { font-size: 13.5px; font-weight: 600; }

/* --- Detail grid / mini lists (Duo user detail page) -------------------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.detail-list > div { display: flex; flex-direction: column; gap: 3px; }
.detail-list dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.detail-list dd { margin: 0; font-size: 14px; }
.detail-list__wide { grid-column: 1 / -1; }
.detail-list__note { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.detail-list--compact { grid-template-columns: 1fr; margin-bottom: 20px; }

.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-list li { display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: none; padding-bottom: 0; }
.mini-list__title { font-weight: 600; font-size: 13.5px; }
.mini-list__meta { font-size: 12.5px; color: var(--text-muted); }

/* --- Empty states -------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state__code { font-family: var(--font-mono); font-size: 30px; font-weight: 600; display: block; margin-bottom: 10px; color: var(--text-faint); }
.empty-state h2 { font-size: 16px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); max-width: 380px; margin: 0 auto 18px; }

/* --- Responsive ------------------------------------------------------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    flex-direction: row; align-items: center;
    padding: 10px 12px; gap: 4px;
    overflow-x: auto;
  }
  .sidebar__brand { border-bottom: none; margin-bottom: 0; padding: 0 10px 0 0; margin-right: 4px; flex-shrink: 0; border-right: 1px solid var(--chrome-border); }
  .sidebar__nav { flex-direction: row; flex: none; }
  .nav-section-label { display: none; }
  .nav-link { white-space: nowrap; }
  .sidebar__user { border-top: none; margin-top: 0; padding-top: 0; display: flex; align-items: center; flex-shrink: 0; margin-left: 4px; padding-left: 10px; border-left: 1px solid var(--chrome-border); }
  .user-chip { padding: 0 6px 0 0; }
  .user-chip__text { display: none; }
  .sidebar__link { white-space: nowrap; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: 16px; }
  .detail-list { grid-template-columns: 1fr; }
  .tenant-switcher__menu { right: auto; left: 0; }
}

@media (max-width: 700px) {
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 640px; }
}

@media (max-width: 600px) {
  .action-row { flex-direction: column; align-items: flex-end; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
}
