:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --brand: #2563eb;
  --focus-ring: rgba(100, 116, 139, .24);
  --focus-border: #98a2b3;
  --selection-bg: rgba(100, 116, 139, .18);
  --selection-text: var(--text);
  --sidebar-width: 252px;
  --sidebar-collapsed-width: 76px;
  --responsive-sidebar-height: 64px;
  --responsive-sidebar-height-sm: 56px;
  --motion-fast: .14s;
  --motion-base: .18s;
  --motion-slow: .24s;
  --motion-ease: cubic-bezier(.2, .8, .2, 1);
  --motion-pop: cubic-bezier(.16, 1, .3, 1);
  --accent-blue: #1e40af;
  --accent-yellow: #0369a1;
  --accent-green: #0e7490;
  --accent-violet: #4f46e5;
  --danger: #b42318;
  --warning: #946200;
  --success: #26755a;
  --shadow: 0 14px 32px rgba(15, 23, 42, .08);
  --shadow-soft: none;
  --font-family-base: Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-size-2xs: 11px;
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;
  --line-tight: 1.2;
  --line-snug: 1.3;
  --line-normal: 1.45;
  --line-relaxed: 1.5;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 500;
  --weight-bold: 600;
  --type-page-title-size: var(--font-size-2xl);
  --type-section-title-size: var(--font-size-lg);
  --type-subsection-title-size: var(--font-size-md);
  --type-body-size: var(--font-size-md);
  --type-label-size: var(--font-size-sm);
  --type-meta-size: var(--font-size-xs);
  --type-control-size: var(--font-size-md);
  --type-brand-size: var(--font-size-xl);
  --type-auth-title-size: var(--font-size-3xl);
  --type-kpi-size: var(--font-size-3xl);
}

:root[data-theme="dark"] {
  --bg: #101010;
  --surface: #181818;
  --surface-soft: #242424;
  --text: #eeeeee;
  --ink: #ffffff;
  --muted: #a3a3a3;
  --line: #333333;
  --primary: #d4d4d4;
  --primary-dark: #f5f5f5;
  --primary-soft: #242424;
  --brand: #d4d4d4;
  --focus-ring: rgba(245, 245, 245, .18);
  --focus-border: #737373;
  --selection-bg: rgba(245, 245, 245, .18);
  --selection-text: var(--ink);
  --accent-blue: #c7c7c7;
  --accent-yellow: #bdbdbd;
  --accent-green: #c7c7c7;
  --accent-violet: #b8b8b8;
  --danger: #d4d4d4;
  --warning: #bdbdbd;
  --success: #d4d4d4;
  --shadow: 0 18px 42px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, .22);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-family-base);
  font-size: var(--type-body-size);
  font-weight: var(--weight-regular);
  line-height: var(--line-normal);
  letter-spacing: 0;
  transition:
    background-color var(--motion-slow) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

:root[data-theme="dark"] body {
  background: var(--bg);
}

h1,
.type-page-title {
  font-size: var(--type-page-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  letter-spacing: 0;
}

strong,
b {
  font-weight: var(--weight-semibold);
}

h2,
.type-section-title {
  font-size: var(--type-section-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
  letter-spacing: 0;
}

h3,
.type-subsection-title {
  font-size: var(--type-subsection-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
  letter-spacing: 0;
}

.type-body {
  font-size: var(--type-body-size);
  font-weight: var(--weight-regular);
  line-height: var(--line-normal);
  letter-spacing: 0;
}

.type-subtext {
  color: var(--muted);
  font-size: var(--type-body-size);
  font-weight: var(--weight-regular);
  line-height: var(--line-normal);
  letter-spacing: 0;
}

.type-label {
  font-size: var(--type-label-size);
  font-weight: var(--weight-semibold);
  line-height: var(--line-snug);
  letter-spacing: 0;
}

.type-meta {
  color: var(--muted);
  font-size: var(--type-meta-size);
  font-weight: var(--weight-regular);
  line-height: var(--line-normal);
  letter-spacing: 0;
}

.type-kpi {
  font-size: var(--type-kpi-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  letter-spacing: 0;
}

a {
  color: inherit;
  transition:
    color var(--motion-base) var(--motion-ease),
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

button,
input,
select,
textarea {
  accent-color: var(--focus-border);
  font: inherit;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .11), rgba(14, 116, 144, .08), rgba(79, 70, 229, .08)),
    var(--bg);
  transition:
    background-color var(--motion-slow) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-theme-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 4;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.auth-wrapper {
  width: min(100%, 440px);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h1 {
  margin: 0;
  font-size: var(--type-auth-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  text-align: center;
}

.auth-brand {
  display: grid;
  justify-items: center;
}

.auth-logo-wrap {
  place-items: center;
  width: min(260px, 100%);
  max-width: 260px;
  height: 86px;
  margin-bottom: 2px;
}

.auth-logo-wrap .brand-logo {
  height: 86px;
  object-position: center;
}

.auth-subtitle {
  margin: 8px 0 22px;
  color: var(--muted);
  text-align: center;
}

.auth-context {
  margin: -8px 0 20px;
  color: var(--muted);
  font-size: var(--type-body-size);
}

.auth-feedback {
  margin: -6px 0 18px;
  color: var(--muted);
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
  text-align: center;
}

.auth-feedback-error {
  color: var(--danger);
}

.auth-feedback-success {
  color: var(--success);
}

.auth-form,
.user-admin-form,
.user-admin-invite-form,
.toolbar-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: var(--type-label-size);
  font-weight: var(--weight-semibold);
  line-height: var(--line-snug);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #d7dde3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: var(--type-control-size);
  line-height: var(--line-normal);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    outline-color var(--motion-base) var(--motion-ease);
}

textarea {
  resize: vertical;
  line-height: var(--line-relaxed);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--focus-border);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--focus-border);
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: #344054;
  font: inherit;
  font-size: var(--type-control-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  cursor: pointer;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

input[type="file"]:hover::file-selector-button,
input[type="file"]:focus::file-selector-button,
input[type="file"]:active::file-selector-button {
  border-color: var(--line);
  background: var(--surface-soft);
  color: #344054;
}

button,
.small-btn,
.table-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: var(--type-control-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

button:hover,
.small-btn:hover,
.table-action-link:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus,
summary:focus,
[tabindex]:not([tabindex="-1"]):focus {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: #344054;
  box-shadow: none;
}

.secondary-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

.danger-btn:hover {
  background: #8f1d14;
  color: #fff;
}

.is-loading {
  opacity: .72;
  pointer-events: none;
}

.btn-uniform {
  white-space: nowrap;
}

.icon-only-btn {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns var(--motion-slow) var(--motion-ease);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  color: var(--text);
  overflow: hidden;
  transition:
    background-color var(--motion-slow) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    padding var(--motion-slow) var(--motion-ease);
}

.brand {
  min-width: 0;
}

.brand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo-wrap {
  position: relative;
  display: grid;
  place-items: center start;
  flex: 1 1 auto;
  width: min(170px, 100%);
  min-width: 0;
  max-width: 170px;
  height: 54px;
  overflow: hidden;
  transition:
    width var(--motion-slow) var(--motion-ease),
    max-width var(--motion-slow) var(--motion-ease),
    height var(--motion-slow) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.brand-logo {
  display: block;
  width: 100%;
  min-width: 0;
  height: 54px;
  object-fit: contain;
  object-position: left center;
  border-radius: 0;
}

.brand-logo-dark {
  display: none;
}

:root[data-theme="dark"] .brand-logo-wrap.has-dark-logo .brand-logo-light {
  display: none;
}

:root[data-theme="dark"] .brand-logo-dark {
  display: block;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.brand-title {
  display: block;
  margin: 0;
  color: var(--text);
  font-size: var(--type-brand-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  transition:
    max-width var(--motion-slow) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-slow) var(--motion-ease);
}

.brand-vendor {
  display: block;
  max-width: 170px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--font-size-2xs);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  white-space: nowrap;
  transition:
    max-width var(--motion-slow) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-slow) var(--motion-ease);
}

.mobile-menu-disclosure {
  display: none;
  position: relative;
  margin-left: auto;
}

.sidebar-toggle,
.mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  list-style: none;
  box-shadow: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.sidebar-toggle:hover,
.mobile-menu-toggle:hover {
  background: var(--surface-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.sidebar-toggle {
  flex: 0 0 auto;
}

.mobile-menu-toggle::-webkit-details-marker {
  display: none;
}

.mobile-menu-list {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  width: min(260px, calc(100vw - 24px));
  max-height: min(64vh, 360px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform-origin: top right;
  animation: mobileMenuDrop var(--motion-base) var(--motion-pop);
}

.mobile-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 10px 11px;
  border-radius: 6px;
  color: #475467;
  font-size: var(--type-body-size);
  font-weight: var(--weight-medium);
  line-height: var(--line-tight);
  text-decoration: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.mobile-menu-item:hover,
.mobile-menu-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.mobile-menu-item:hover {
  transform: translateX(2px);
}

.mobile-menu-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.mobile-menu-icon {
  width: 18px;
  min-width: 18px;
  text-align: center;
}

.mobile-menu-label {
  min-width: 0;
}

@keyframes mobileMenuDrop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.side-menu {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.side-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 6px;
  color: #475467;
  font-size: var(--type-body-size);
  font-weight: var(--weight-medium);
  line-height: var(--line-tight);
  text-decoration: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    justify-content var(--motion-slow) var(--motion-ease),
    padding var(--motion-slow) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.side-menu-item:hover,
.side-menu-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.side-menu-item:hover {
  transform: translateX(2px);
}

.side-menu-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.side-menu-icon {
  width: 18px;
  min-width: 18px;
  text-align: center;
}

.side-menu-label {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  transition:
    max-width var(--motion-slow) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-slow) var(--motion-ease);
}

.sidebar-spacer {
  margin-top: auto;
  min-height: 1px;
}

@media (min-width: 1181px) {
  :root.sidebar-collapsed .app-shell {
    grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
  }

  :root.sidebar-collapsed .sidebar {
    padding: 18px 12px;
  }

  :root.sidebar-collapsed .brand-head {
    justify-content: center;
  }

  :root.sidebar-collapsed .brand-logo-wrap,
  :root.sidebar-collapsed .brand-copy {
    flex: 0 0 0;
    width: 0;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
  }

  :root.sidebar-collapsed .side-menu {
    padding-right: 0;
  }

  :root.sidebar-collapsed .side-menu-item {
    justify-content: center;
    gap: 0;
    padding: 11px;
  }

  :root.sidebar-collapsed .side-menu-item:hover {
    transform: none;
  }

  :root.sidebar-collapsed .side-menu-label {
    max-width: 0;
    opacity: 0;
    transform: translateX(-6px);
    pointer-events: none;
  }

  :root.sidebar-collapsed .side-menu-icon {
    width: 20px;
    min-width: 20px;
  }
}

.cell-note {
  display: block;
  color: var(--muted);
  font-size: var(--type-meta-size);
  line-height: var(--line-normal);
}

.content-area {
  min-width: 0;
  padding: 0;
}

.page-content {
  padding: 24px;
}

.session-bar {
  position: sticky;
  top: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 24px;
  border-bottom: 0;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: var(--type-body-size);
  transition:
    background-color var(--motion-slow) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.session-bar-group,
.session-actions,
.session-action-link,
.session-theme-btn {
  display: flex;
  align-items: center;
}

.session-bar-group {
  min-width: 0;
  gap: 8px;
}

.session-organization span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-organization {
  flex: 0 1 auto;
  justify-content: flex-start;
  margin-right: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--type-body-size);
  line-height: var(--line-snug);
  transition:
    color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.session-organization i {
  color: var(--muted);
  width: 16px;
  min-width: 16px;
  font-size: var(--type-body-size);
  line-height: var(--line-tight);
  text-align: center;
}

.session-organization span {
  max-width: 260px;
}

.session-actions {
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

.session-action-link,
.session-theme-btn,
.session-logout-btn {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: var(--type-control-size);
  line-height: var(--line-tight);
  white-space: nowrap;
}

.session-action-link i,
.session-theme-btn i,
.session-logout-btn i {
  width: 16px;
  min-width: 16px;
  font-size: var(--type-control-size);
  line-height: var(--line-tight);
  text-align: center;
}

.session-action-link,
.session-theme-btn {
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  font-weight: var(--weight-bold);
  text-decoration: none;
  box-shadow: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.session-action-link:hover,
.session-theme-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.session-logout-form {
  margin: 0;
}

.session-logout-btn {
  border-color: var(--line);
  background: #fff;
  color: #344054;
  font-weight: var(--weight-bold);
  box-shadow: none;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.session-logout-btn:hover {
  border-color: #f4c7c2;
  background: #fff4f2;
  color: #8f1d14;
  transform: translateY(-1px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  padding: 2px 0 4px;
}

.topbar-main {
  flex: 1 1 280px;
  min-width: 0;
}

.topbar h1 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: var(--type-page-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  gap: 7px;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.content-card,
.module-box,
.stat-card,
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.content-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.module-box {
  padding: 0;
  margin-top: 28px;
  border: 0;
  background: transparent;
}

.content-card > .module-box:first-child {
  margin-top: 0;
}

.grid-cards {
  display: grid;
  gap: 14px;
}

.dashboard-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.stat-card {
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-1px);
}

.stat-card::before {
  display: none;
}

.stat-label,
.dashboard-card-hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--type-label-size);
  line-height: var(--line-normal);
}

.stat-value {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: var(--type-kpi-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head-compact {
  margin-bottom: 8px;
}

.panel-head h2,
.panel-head h3,
.section-head h2,
.section-head h3 {
  margin: 0 0 4px;
  font-size: var(--type-section-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
}

.panel-head p,
.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.panel-head-actions,
.section-head-actions,
.toolbar-actions,
.cell-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.module-page-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.module-filter-grid,
.module-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}

.module-form-grid-wide {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.module-form-span {
  grid-column: 1 / -1;
}

.module-checkset {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 42px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid #d7dde3;
  border-radius: 6px;
  background: #fff;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.module-checkset legend {
  padding: 0 4px;
  color: #344054;
  font-size: var(--type-label-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
}

.module-checkset label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.module-checkset:focus-within {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.file-picker-field {
  gap: 8px;
}

.file-picker-title {
  display: block;
}

.file-picker-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 10px 4px 4px;
  border: 1px solid #d7dde3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.file-picker-control:hover {
  border-color: var(--focus-border);
  background: var(--surface-soft);
}

.file-picker-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: #344054;
  font-size: var(--type-control-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  white-space: nowrap;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--type-body-size);
  font-weight: var(--weight-regular);
  line-height: var(--line-normal);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-picker-field:focus-within .file-picker-control {
  border-color: var(--focus-border);
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.contextual-toolbar {
  margin-bottom: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.token-secret-box input,
.monospace-input {
  font-family: var(--font-family-mono);
}

.two-factor-private-panel {
  display: grid;
  grid-template-columns: 164px minmax(260px, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.two-factor-qr {
  width: 164px;
  min-height: 164px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.two-factor-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.inline-form {
  display: inline-flex;
}

.module-page-metric {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.module-page-metric:hover {
  transform: translateY(-1px);
}

.module-page-metric span {
  color: var(--muted);
  font-size: var(--type-meta-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
  text-transform: none;
}

.module-page-metric strong {
  color: var(--ink);
  font-size: var(--type-section-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
}

.module-page-empty {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed #cbd3dc;
  border-radius: 8px;
  background: var(--surface-soft);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.module-page-empty i {
  margin-top: 2px;
  color: var(--brand);
  font-size: var(--font-size-xl);
}

.module-page-empty h3 {
  margin: 0 0 4px;
}

.module-page-empty p {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state i {
  display: grid;
  place-items: center;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--font-size-2xl);
  text-align: center;
  transition:
    color var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.empty-state h3 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: var(--type-subsection-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.module-page-actions {
  margin-top: 16px;
}

.branding-layout {
  display: block;
}

.branding-form,
.branding-history {
  display: grid;
  gap: 16px;
}

.branding-section {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 0;
}

.branding-form-grid,
.branding-assets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 1fr));
  gap: 14px;
}

.branding-color-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.branding-color-grid input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.branding-asset-control {
  display: grid;
  gap: 8px;
}

.branding-current-asset {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 54px;
}

.branding-current-asset img {
  display: block;
  width: 118px;
  max-height: 52px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.branding-current-asset-small img {
  width: 48px;
  height: 48px;
}

.check-row {
  display: inline-flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 8px;
  color: #344054;
  font-size: var(--type-label-size);
  font-weight: var(--weight-semibold);
  line-height: var(--line-snug);
}

.branding-whitelabel-toggle {
  min-height: 42px;
}

.branding-history {
  margin-top: 20px;
}

.branding-swatch-list {
  display: inline-flex;
  gap: 6px;
}

.branding-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--primary);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

button:disabled,
.table-action-link:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
}

.tabs {
  display: flex;
  max-width: 100%;
  column-gap: 18px;
  row-gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tab-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 0 18px;
  border: 0;
  border-radius: 0;
  color: #475467;
  text-decoration: none;
  background: transparent;
  font-size: var(--type-body-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  white-space: nowrap;
  transition:
    color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.tab-link:hover,
.tab-link.is-active {
  background: transparent;
  color: var(--primary-dark);
  box-shadow: none;
}

.tab-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  height: 1px;
  background: transparent;
  opacity: 0;
  transform: scaleX(.72);
  transform-origin: left center;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.tab-link:hover::after,
.tab-link.is-active::after {
  background: var(--primary);
  opacity: 1;
  transform: scaleX(1);
}

.tab-link-label,
.tab-link-count {
  white-space: nowrap;
}

.tab-link-count {
  display: inline;
  color: var(--muted);
  font-size: var(--type-meta-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  transition: color var(--motion-base) var(--motion-ease);
}

.tab-link.is-active .tab-link-count {
  color: var(--primary-dark);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow-x: auto;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.data-table th {
  color: var(--muted);
  font-size: var(--type-label-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
  text-transform: none;
}

.data-table tbody tr {
  transition: background-color var(--motion-base) var(--motion-ease);
}

.data-table tbody tr:hover {
  background: #f9fbfb;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.list-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: var(--type-label-size);
  line-height: var(--line-normal);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: var(--type-label-size);
  line-height: var(--line-normal);
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #344054;
  background: #fff;
  text-decoration: none;
  font-weight: var(--weight-bold);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.pagination-link:hover {
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.pagination-link.is-disabled {
  opacity: .45;
  pointer-events: none;
}

.status-text {
  display: inline;
  font-size: var(--type-body-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-normal);
  transition: color var(--motion-base) var(--motion-ease);
}

.status-text--success {
  color: #117a4f;
}

.status-text--danger {
  color: #a61b35;
}

.status-text--warning {
  color: #946200;
}

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

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
  animation: surface-enter var(--motion-slow) var(--motion-pop);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.alert-error {
  background: #fff4f2;
  border-color: #f4c7c2;
  color: #8f1d14;
}

.alert-success {
  background: #effbf5;
  border-color: #bcebd0;
  color: #0b6843;
}

.user-admin-section {
  padding-top: 0;
  margin-top: 26px;
  border-top: 0;
}

.user-admin-section h2 {
  margin: 0 0 12px;
}

.user-admin-invite-form,
.rules-toolbar,
.event-log-filters {
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  align-items: end;
}

.user-admin-form-grid,
.rule-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.rule-form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.form-error-list {
  margin: 8px 0 0;
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.inline-action-form {
  display: inline-flex;
  margin: 0;
}

.inline-details {
  position: relative;
}

.inline-details summary {
  list-style: none;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.inline-edit-form {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
  display: grid;
  gap: 10px;
  width: min(320px, calc(100vw - 36px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.module-assignment-list {
  width: min(560px, calc(100vw - 36px));
  max-height: min(70vh, 620px);
  overflow: auto;
}

.module-assignment-item {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 120px auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 0;
  border-bottom: 0;
}

.module-assignment-item + .module-assignment-item {
  margin-top: 12px;
}

.module-assignment-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  color: var(--muted);
}

.event-path-cell {
  max-width: 220px;
  word-break: break-word;
}

.event-log-summary {
  color: var(--muted);
}

.summary-strip {
  margin: 0 0 14px;
  padding-bottom: 0;
  border-bottom: 0;
}

.filter-panel {
  margin-bottom: 18px;
  border-bottom: 0;
  padding-bottom: 0;
}

.filter-panel summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #344054;
  cursor: pointer;
  font-size: var(--type-body-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  list-style: none;
  transition:
    color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.filter-panel summary::-webkit-details-marker {
  display: none;
}

.filter-panel summary::before {
  content: "+";
  width: 16px;
  color: var(--muted);
  font-weight: var(--weight-bold);
  transition:
    color var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.filter-panel[open] summary {
  margin-bottom: 12px;
}

.filter-panel[open] summary::before {
  content: "-";
  transform: rotate(180deg);
}

.filter-panel .contextual-toolbar {
  margin-bottom: 0;
}

.filter-panel[open] > :not(summary),
.disclosure-section[open] > :not(summary) {
  transform-origin: top;
  animation: details-slide-in var(--motion-base) var(--motion-pop);
}

.disclosure-section summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: #344054;
  cursor: pointer;
  font-size: var(--type-body-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-tight);
  list-style: none;
  transition:
    color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.disclosure-section summary::-webkit-details-marker {
  display: none;
}

.disclosure-section summary::before {
  content: "+";
  width: 16px;
  color: var(--muted);
  transition:
    color var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.disclosure-section[open] summary {
  margin-bottom: 10px;
}

.disclosure-section[open] summary::before {
  content: "-";
  transform: rotate(180deg);
}

.event-detail {
  margin-top: 8px;
  color: #344054;
}

.event-detail summary {
  cursor: pointer;
  font-weight: var(--weight-bold);
  color: var(--primary-dark);
  transition: color var(--motion-base) var(--motion-ease);
}

.event-detail pre {
  max-width: 360px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: var(--font-family-mono);
  font-size: var(--type-meta-size);
  line-height: var(--line-normal);
  animation: details-slide-in var(--motion-base) var(--motion-pop);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.inline-details[open] .inline-edit-form {
  transform-origin: top right;
  animation: details-pop-in var(--motion-base) var(--motion-pop);
}

@keyframes details-slide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes details-pop-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes surface-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes backdrop-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.invitation-meta {
  padding: 12px;
  margin-bottom: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.password-field input {
  min-width: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid #bcebd0;
  border-radius: 6px;
  background: #effbf5;
  color: #0b6843;
  box-shadow: var(--shadow);
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease),
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: #f4c7c2;
  background: #fff4f2;
  color: #8f1d14;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 23, 23, .42);
  animation: backdrop-enter var(--motion-base) var(--motion-ease);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    opacity var(--motion-base) var(--motion-ease);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: min(100%, 420px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: dialog-enter var(--motion-slow) var(--motion-pop);
  transform-origin: center;
  transition:
    background-color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.modal-dialog h3 {
  margin: 0 0 8px;
  font-size: var(--type-section-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--line-snug);
}

.modal-dialog p {
  margin: 0;
  color: #344054;
  font-size: var(--type-body-size);
  line-height: var(--line-normal);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .session-bar,
:root[data-theme="dark"] .content-card,
:root[data-theme="dark"] .module-box,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .modal-dialog,
:root[data-theme="dark"] .inline-edit-form,
:root[data-theme="dark"] .contextual-toolbar,
:root[data-theme="dark"] .two-factor-private-panel,
:root[data-theme="dark"] .module-page-metric,
:root[data-theme="dark"] .module-page-empty,
:root[data-theme="dark"] .module-checkset,
:root[data-theme="dark"] .file-picker-control,
:root[data-theme="dark"] .tabs,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .invitation-meta,
:root[data-theme="dark"] .data-table tr,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

:root[data-theme="dark"] .auth-page {
  background:
    linear-gradient(135deg, #151515, #101010),
    var(--bg);
}

:root[data-theme="dark"] label,
:root[data-theme="dark"] .check-row,
:root[data-theme="dark"] .module-checkset legend,
:root[data-theme="dark"] .modal-dialog p,
:root[data-theme="dark"] .event-detail,
:root[data-theme="dark"] .filter-panel summary,
:root[data-theme="dark"] .disclosure-section summary,
:root[data-theme="dark"] .side-menu-item,
:root[data-theme="dark"] .mobile-menu-item,
:root[data-theme="dark"] .tab-link,
:root[data-theme="dark"] .pagination-link {
  color: var(--text);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #8a8a8a;
}

:root[data-theme="dark"] .cell-note,
:root[data-theme="dark"] .tab-link-count,
:root[data-theme="dark"] .list-meta,
:root[data-theme="dark"] .event-log-summary,
:root[data-theme="dark"] .auth-subtitle,
:root[data-theme="dark"] .auth-context,
:root[data-theme="dark"] .panel-head p,
:root[data-theme="dark"] .section-head p,
:root[data-theme="dark"] .empty-state p,
:root[data-theme="dark"] .session-organization {
  color: var(--muted);
}

:root[data-theme="dark"] .content-card {
  background: transparent;
}

:root[data-theme="dark"] .module-box {
  border: 0;
  background: transparent;
}

:root[data-theme="dark"] .contextual-toolbar {
  background: transparent;
}

:root[data-theme="dark"] .tabs {
  border: 0;
  background: transparent;
}

:root[data-theme="dark"] .sidebar {
  background: rgba(18, 18, 18, .96);
}

:root[data-theme="dark"] .mobile-menu-list {
  border-color: var(--line);
  background: var(--surface);
}

:root[data-theme="dark"] .session-bar {
  background: rgba(16, 16, 16, .94);
}

:root[data-theme="dark"] .mobile-menu-toggle,
:root[data-theme="dark"] .sidebar-toggle,
:root[data-theme="dark"] .secondary-btn,
:root[data-theme="dark"] .auth-theme-btn,
:root[data-theme="dark"] .session-action-link,
:root[data-theme="dark"] .session-theme-btn,
:root[data-theme="dark"] .session-logout-btn,
:root[data-theme="dark"] .pagination-link {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

:root[data-theme="dark"] .tab-link-count {
  color: var(--muted);
}

:root[data-theme="dark"] .tab-link:hover,
:root[data-theme="dark"] .tab-link.is-active {
  background: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .tab-link:hover::after,
:root[data-theme="dark"] .tab-link.is-active::after {
  background: var(--text);
}

:root[data-theme="dark"] .tab-link.is-active .tab-link-count {
  color: var(--text);
}

:root[data-theme="dark"] .side-menu-item:hover,
:root[data-theme="dark"] .side-menu-item.is-active,
:root[data-theme="dark"] .mobile-menu-item:hover,
:root[data-theme="dark"] .mobile-menu-item.is-active {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #3f3f3f;
}

:root[data-theme="dark"] .side-menu-item.is-active::before,
:root[data-theme="dark"] .mobile-menu-item.is-active::before {
  background: #d4d4d4;
}

:root[data-theme="dark"] .side-menu-icon,
:root[data-theme="dark"] .mobile-menu-icon,
:root[data-theme="dark"] .side-menu-item:nth-child(1) .side-menu-icon,
:root[data-theme="dark"] .side-menu-item:nth-child(2) .side-menu-icon,
:root[data-theme="dark"] .side-menu-item:nth-child(3) .side-menu-icon,
:root[data-theme="dark"] .side-menu-item:nth-child(4) .side-menu-icon,
:root[data-theme="dark"] .side-menu-item:nth-child(5) .side-menu-icon {
  color: #c7c7c7;
}

:root[data-theme="dark"] .secondary-btn:hover,
:root[data-theme="dark"] .auth-theme-btn:hover,
:root[data-theme="dark"] .mobile-menu-toggle:hover,
:root[data-theme="dark"] .sidebar-toggle:hover,
:root[data-theme="dark"] .session-action-link:hover,
:root[data-theme="dark"] .session-theme-btn:hover,
:root[data-theme="dark"] .session-logout-btn:hover,
:root[data-theme="dark"] .file-picker-action,
:root[data-theme="dark"] input[type="file"]::file-selector-button {
  background: #2a2a2a;
  color: var(--ink);
}

:root[data-theme="dark"] input[type="file"]::file-selector-button {
  border-color: var(--line);
}

:root[data-theme="dark"] button,
:root[data-theme="dark"] .small-btn,
:root[data-theme="dark"] .table-action-link {
  border-color: #d4d4d4;
  background: #d4d4d4;
  color: #111111;
}

:root[data-theme="dark"] button:hover,
:root[data-theme="dark"] .small-btn:hover,
:root[data-theme="dark"] .table-action-link:hover {
  background: #f5f5f5;
  color: #111111;
}

:root[data-theme="dark"] .mobile-menu-toggle:hover {
  background: #2a2a2a;
  color: var(--ink);
}

:root[data-theme="dark"] .sidebar-toggle:hover {
  background: #2a2a2a;
  color: var(--ink);
}

:root[data-theme="dark"] .secondary-btn,
:root[data-theme="dark"] .auth-theme-btn,
:root[data-theme="dark"] .mobile-menu-toggle,
:root[data-theme="dark"] .sidebar-toggle,
:root[data-theme="dark"] .session-action-link,
:root[data-theme="dark"] .session-theme-btn,
:root[data-theme="dark"] .session-logout-btn,
:root[data-theme="dark"] .pagination-link {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

:root[data-theme="dark"] .tab-link:hover,
:root[data-theme="dark"] .tab-link.is-active {
  background: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .danger-btn {
  border-color: #6b6b6b;
  background: #333333;
  color: var(--ink);
}

:root[data-theme="dark"] .danger-btn:hover {
  background: #444444;
  color: var(--ink);
}

:root[data-theme="dark"] button,
:root[data-theme="dark"] .small-btn,
:root[data-theme="dark"] .table-action-link {
  box-shadow: 0 8px 18px rgba(255, 255, 255, .06);
}

:root[data-theme="dark"] .secondary-btn,
:root[data-theme="dark"] .auth-theme-btn,
:root[data-theme="dark"] .mobile-menu-toggle,
:root[data-theme="dark"] .session-action-link,
:root[data-theme="dark"] .session-theme-btn,
:root[data-theme="dark"] .session-logout-btn {
  box-shadow: none;
}

:root[data-theme="dark"] .data-table th {
  background: var(--surface-soft);
  color: var(--muted);
}

:root[data-theme="dark"] .data-table tbody tr:hover {
  background: #202020;
}

:root[data-theme="dark"] .status-text--success,
:root[data-theme="dark"] .status-text--danger,
:root[data-theme="dark"] .status-text--warning {
  color: #d4d4d4;
}

:root[data-theme="dark"] .data-table td,
:root[data-theme="dark"] .data-table th {
  border-bottom-color: var(--line);
}

:root[data-theme="dark"] .empty-state i {
  border-color: var(--line);
  background: var(--primary-soft);
}

:root[data-theme="dark"] .branding-current-asset img,
:root[data-theme="dark"] .two-factor-qr {
  border-color: var(--line);
  background: var(--surface);
}

:root[data-theme="dark"] .alert-success {
  border-color: #3a3a3a;
  background: #202020;
  color: #e5e5e5;
}

:root[data-theme="dark"] .alert-error {
  border-color: #3a3a3a;
  background: #202020;
  color: #e5e5e5;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: var(--responsive-sidebar-height);
    height: var(--responsive-sidebar-height);
    display: grid;
    gap: 0;
    align-items: center;
    padding: 0 14px;
    border-right: 0;
    border-bottom: 0;
    overflow: visible;
  }

  .brand {
    height: 100%;
  }

  .brand-head {
    min-height: 0;
    height: 100%;
  }

  .brand-logo-wrap {
    width: min(150px, 100%);
    max-width: 150px;
    height: 42px;
    max-height: calc(var(--responsive-sidebar-height) - 20px);
    opacity: 1;
    transform: none;
  }

  .brand-logo {
    height: 100%;
  }

  .mobile-menu-disclosure {
    display: block;
    flex: 0 0 auto;
    align-self: center;
  }

  .sidebar-toggle {
    display: none;
  }

  .side-menu {
    display: none;
  }

  .sidebar-spacer {
    display: none;
  }

  .dashboard-kpi-grid,
  .module-page-grid,
  .module-filter-grid,
  .module-form-grid,
  .user-admin-invite-form,
  .rules-toolbar,
  .event-log-filters,
  .user-admin-form-grid,
  .rule-form-grid,
  .branding-form-grid,
  .branding-assets-grid {
    grid-template-columns: 1fr;
  }

  .branding-color-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .two-factor-private-panel {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .section-head {
    display: grid;
  }

  .topbar {
    display: flex;
    gap: 12px;
  }

  .session-bar {
    align-items: center;
    display: flex;
    gap: 10px;
    min-height: 48px;
    padding: 8px 14px;
  }

  .session-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .session-organization {
    justify-content: flex-start;
    margin-left: 0;
    min-width: 0;
    width: auto;
    flex: 1 1 auto;
  }

  .session-organization span {
    max-width: none;
  }

  .session-action-link,
  .session-theme-btn,
  .session-logout-btn {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
  }

  .session-logout-label {
    display: none;
  }

  .topbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .sidebar {
    gap: 0;
    min-height: var(--responsive-sidebar-height-sm);
    height: var(--responsive-sidebar-height-sm);
    padding: 0 12px;
  }

  .brand-head {
    min-height: 0;
    height: 100%;
  }

  .brand-logo-wrap {
    max-width: 132px;
    height: 38px;
    max-height: calc(var(--responsive-sidebar-height-sm) - 18px);
  }

  .brand-logo {
    height: 100%;
  }

  .brand-title {
    max-width: 150px;
  }

  .mobile-menu-list {
    right: -2px;
  }

  .mobile-menu-item {
    min-height: 36px;
    padding: 9px 10px;
  }

  .page-content {
    padding: 14px 12px;
  }

  .auth-card {
    padding: 14px;
  }

  .topbar h1 {
    font-size: var(--type-page-title-size);
  }

  .topbar {
    display: grid;
    gap: 10px;
  }

  .topbar-main {
    flex-basis: auto;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .branding-color-grid {
    grid-template-columns: 1fr;
  }

  .session-bar {
    gap: 8px;
    padding: 8px 12px;
  }

  .session-actions,
  .session-logout-form {
    width: auto;
  }

  .session-action-link,
  .session-theme-btn,
  .session-logout-btn {
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    justify-content: center;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }

  .table-wrap {
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow-x: visible;
  }

  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .data-table tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .data-table tr + tr {
    margin-top: 10px;
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(110px, 40%) minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: var(--type-meta-size);
    font-weight: var(--weight-bold);
    text-transform: none;
  }

  .cell-actions {
    justify-content: flex-start;
  }

  .inline-edit-form {
    left: 0;
    right: auto;
  }

  .pagination {
    justify-content: center;
    flex-wrap: wrap;
  }

  .modal-actions,
  .rule-form-footer,
  .module-assignment-item {
    display: grid;
  }

  .module-assignment-item {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-delay: 0ms !important;
    transition-duration: .01ms !important;
  }

  button:hover,
  .small-btn:hover,
  .mobile-menu-toggle:hover,
  .sidebar-toggle:hover,
  .mobile-menu-item:hover,
  .side-menu-item:hover,
  .session-action-link:hover,
  .session-theme-btn:hover,
  .session-logout-btn:hover,
  .table-action-link:hover,
  .pagination-link:hover,
  .stat-card:hover,
  .module-page-metric:hover {
    transform: none;
  }
}
