/* ==========================================================================
   Hazen IAM console — neutral surface system
   base -> surface -> surface-2. No decorative gradients or container borders.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --base: light-dark(#f6f7f8, #17181a);
  --surface: light-dark(#ffffff, #1d1f23);
  --surface-2: light-dark(#f1f2f3, #0d0e10);
  --overlay: light-dark(#ffffff, #1d1f23);
  --hover: light-dark(#f1f2f3, #24262b);
  --pressed: light-dark(#e8eaec, #2a2c32);
  --mask: light-dark(rgba(13, 14, 16, 0.44), rgba(0, 0, 0, 0.62));

  --text: light-dark(#0d0e10, #f0f1f2);
  --text-2: light-dark(#5c6168, #a8adb4);
  --text-3: light-dark(#6b7078, #9aa0a8);
  --text-4: light-dark(#b4b8bd, #5a5f67);

  --brand: light-dark(#0d0e10, #f0f1f2);
  --on-brand: light-dark(#ffffff, #0d0e10);
  --accent: light-dark(#b753ff, #bb5cff);
  --accent-strong: light-dark(#9d2fe8, #a94df0);
  --ok: light-dark(#157f43, #47cf79);
  --warn: light-dark(#8a4b00, #f5b54a);
  --bad: light-dark(#b42318, #ff7a73);
  --info: light-dark(#0b5f8a, #5bc0eb);

  --shadow-1: 0 1px 2px rgba(13, 14, 16, 0.08);
  --shadow-2: 0 4px 16px rgba(13, 14, 16, 0.12);
  --shadow-3: 0 16px 48px rgba(13, 14, 16, 0.26);

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--base);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  appearance: none;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

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

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--text);
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 13px;
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: none;
  color: var(--on-brand);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

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

.num {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 12px;
  min-height: 100dvh;
  padding: 12px;
}

.sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100dvh - 24px);
  padding: 16px;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 4px;
  border-radius: var(--r-md);
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 15px;
  font-weight: 700;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 11px;
}

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

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms ease, color 140ms ease;
}

.nav-link:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.nav-label {
  padding: 0 12px;
  margin-bottom: 4px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms ease;
}

.sidebar-link:hover {
  background: var(--pressed);
}

.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: 11px;
}

.dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
}

.dot.is-warn {
  background: var(--warn);
}

.dot.is-muted {
  background: var(--text-4);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.topbar-title {
  display: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px 0 4px;
  border-radius: var(--r-pill);
  background: var(--surface);
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.user-badge-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.user-badge-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.user-badge-role {
  font-size: 10px;
  color: var(--text-2);
}

.identity-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity-switch .select {
  width: auto;
}

.content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0 40px;
  outline: none;
}

.app .mobile-only {
  display: none;
}

.drawer-scrim {
  display: none;
}

/* --------------------------------------------------------------------------
   Page frame
   -------------------------------------------------------------------------- */

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--r-lg);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-copy {
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions .select {
  width: auto;
}

.subsection {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.subsection-title {
  font-size: 13px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Grids and stats
   -------------------------------------------------------------------------- */

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--r-lg);
}

.stat-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-detail {
  color: var(--text-2);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.btn:hover {
  background: var(--pressed);
  color: var(--text);
}

.btn:active {
  background: var(--pressed);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--brand) 86%, var(--surface));
  color: var(--on-brand);
}

.btn-primary:active {
  background: var(--brand);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
  font-weight: 600;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--bad) 20%, transparent);
  color: var(--bad);
}

.btn-sm {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.btn-lg {
  height: 40px;
  padding: 0 20px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

/* Controls nested in a sunken surface are raised one level so they stay visible. */
.role-card .btn-ghost,
.permission-row .btn-ghost,
.secret-block .btn-ghost,
.notice .btn-ghost {
  background: var(--surface);
}

.role-card .btn-ghost:hover,
.permission-row .btn-ghost:hover,
.secret-block .btn-ghost:hover,
.notice .btn-ghost:hover {
  background: var(--pressed);
}

.permission-row .select {
  background: var(--surface);
}

.permission-row .select:hover {
  background: var(--pressed);
}

.table .btn-ghost:hover,
.list-row .btn-ghost:hover {
  background: var(--pressed);
}

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

.input,
.select,
.textarea {
  width: 100%;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.input,
.select {
  height: 32px;
  padding: 0 12px;
}

.select {
  padding-right: 32px;
  cursor: pointer;
}

.textarea {
  min-height: 88px;
  padding: 8px 12px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover,
.textarea:hover {
  background: var(--hover);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.input[readonly] {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: not-allowed;
  opacity: 0.7;
}

.input[type="date"],
.input[type="datetime-local"] {
  color-scheme: inherit;
}

.input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.input.is-invalid {
  box-shadow: 0 0 0 2px var(--bad);
}

.checkbox {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.field-hint {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.field-error {
  color: var(--bad);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.form-actions-extra {
  margin-right: auto;
  color: var(--text-2);
  font-size: 12px;
}

.form-actions-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-field {
  flex: 1;
  min-width: 200px;
}

.filter-field-narrow {
  flex: 0 0 160px;
  min-width: 0;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.search-input {
  width: 240px;
}

/* Switch */

.switch-row {
  position: relative;
}

.switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 24px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--pressed);
  transition: background-color 140ms ease;
}

.switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform 140ms ease;
}

.switch-input:checked + .switch-label .switch-track {
  background: var(--accent);
}

.switch-input:checked + .switch-label .switch-thumb {
  transform: translateX(16px);
}

.switch-input:focus-visible + .switch-label .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-input:disabled + .switch-label {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.switch-text {
  font-size: 13px;
  font-weight: 500;
}

.switch-description {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.switch-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   Badges / chips
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}

.badge-bad {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
}

.badge-warn {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
}

.badge-info {
  background: color-mix(in srgb, var(--info) 14%, transparent);
  color: var(--info);
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text-2);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--r-md);
}

.table {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table caption {
  text-align: left;
}

.table th {
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.table th:first-child {
  border-top-left-radius: var(--r-md);
  border-bottom-left-radius: var(--r-md);
}

.table th:last-child {
  border-top-right-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
}

.table td {
  padding: 12px;
  vertical-align: top;
}

.table tbody tr {
  transition: background-color 140ms ease;
}

.table tbody tr:hover {
  background: var(--hover);
}

.table-compact th {
  padding: 8px 12px;
}

.table-compact td {
  padding: 8px 12px;
}

.table-actions-head {
  text-align: right;
}

.row-title {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.row-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-cell .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.identity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.identity-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
}

.identity-issuer {
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  line-height: 20px;
}

.permission-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 320px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.event-type {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
}

.audit-details summary {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.audit-details pre {
  max-width: 440px;
  max-height: 240px;
  margin: 8px 0 0;
  padding: 8px 12px;
  overflow: auto;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--r-md);
  transition: background-color 140ms ease;
}

.list-row:hover {
  background: var(--hover);
}

.list-main {
  min-width: 0;
  flex: 1;
}

.list-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.list-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Services
   -------------------------------------------------------------------------- */

.service {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.service-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.service-head-main {
  min-width: 0;
  flex: 1;
}

.service-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.service-title h2 {
  font-size: 15px;
  font-weight: 600;
}

.endpoints {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.endpoint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.endpoint-label {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.endpoint-value {
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

a.endpoint-value {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--text-4);
}

a.endpoint-value:hover {
  text-decoration-color: var(--accent);
}

.inline-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs {
  display: inline-flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  padding: 4px;
  overflow-x: auto;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.tab {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------------------
   Roles and permission editor
   -------------------------------------------------------------------------- */

.role-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.role-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.role-card-head h3 {
  font-size: 14px;
  font-weight: 600;
}

.role-card-head .mono {
  display: block;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 11px;
}

.role-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.role-stats > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-stat-value {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.role-stat-allow {
  color: var(--ok);
}

.role-stat-deny {
  color: var(--bad);
}

.role-stat-label {
  color: var(--text-2);
  font-size: 11px;
}

.role-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-2);
  font-size: 12px;
}

.permission-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.permission-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.permission-editor-head h3 {
  font-size: 13px;
  font-weight: 600;
}

.permission-editor-head p {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.permission-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permission-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.permission-row-index {
  display: grid;
  place-items: center;
  height: 32px;
  width: 32px;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.permission-row-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px;
  gap: 8px;
}

.role-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-2);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Guest capability picker
   -------------------------------------------------------------------------- */

.choice-fieldset {
  margin: 0;
  padding: 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.choice-fieldset legend {
  padding: 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface);
}

.choice.is-selected {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
}

.choice-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.choice-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  cursor: pointer;
}

.choice-name {
  font-size: 13px;
  font-weight: 600;
}

.choice-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-2);
  font-size: 11px;
}

.choice-resource {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.choice-resource .select {
  width: auto;
}

/* --------------------------------------------------------------------------
   Code entry / secrets
   -------------------------------------------------------------------------- */

.code-input {
  height: 56px;
  padding: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.42em;
}

.code-input::placeholder {
  color: var(--text-3);
}

.secret {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.secret-note {
  color: var(--text-2);
  font-size: 12px;
}

.secret-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.secret-label {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.secret-value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.secret-block .btn {
  align-self: flex-start;
}

/* --------------------------------------------------------------------------
   Notices, states, spinner
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.notice a {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--text-4);
}

.notice a:hover {
  text-decoration-color: var(--accent);
}

.notice-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.notice-info .notice-title {
  color: var(--info);
}

.notice-warning .notice-title {
  color: var(--warn);
}

.notice-danger .notice-title {
  color: var(--bad);
}

.notice-success .notice-title {
  color: var(--ok);
}

.notice-action {
  margin-top: 8px;
}

.global-notice {
  margin-bottom: 12px;
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
}

.state-title {
  font-size: 14px;
  font-weight: 600;
}

.state-text {
  max-width: 48ch;
  color: var(--text-2);
  font-size: 13px;
}

.state-action {
  margin-top: 4px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentColor 24%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinner-lg {
  width: 24px;
  height: 24px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--mask);
  animation: fade-in 160ms ease;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  background: var(--overlay);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: rise-in 160ms ease;
}

.modal-sm {
  max-width: 400px;
}

.modal-md {
  max-width: 520px;
}

.modal-lg {
  max-width: 640px;
}

.modal-xl {
  max-width: 840px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

.modal-note {
  color: var(--text-2);
  font-size: 13px;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--overlay);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: 13px;
  animation: rise-in 160ms ease;
}

.toast-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-2);
}

.toast-success .toast-dot {
  background: var(--ok);
}

.toast-error .toast-dot,
.toast-warning .toast-dot {
  background: var(--bad);
}

.toast-warning .toast-dot {
  background: var(--warn);
}

.toast-info .toast-dot {
  background: var(--info);
}

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.toast-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Portal
   -------------------------------------------------------------------------- */

.portal-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.portal-section-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.portal-section-note {
  color: var(--text-2);
  font-size: 12px;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.portal-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 16px;
  color: var(--text);
  transition: background-color 140ms ease;
}

a.portal-card:hover,
a.portal-card:focus-visible {
  background: var(--surface-2);
}

.portal-card.is-disabled {
  opacity: 0.6;
}

.portal-card-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.portal-card-avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.portal-card-title {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.portal-card-sub {
  color: var(--text-3);
  font-size: 11px;
}

.portal-card-arrow {
  flex: none;
  color: var(--text-3);
  font-size: 15px;
  transition: color 140ms ease;
}

a.portal-card:hover .portal-card-arrow {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Full page states, auth, redeem
   -------------------------------------------------------------------------- */

.fullpage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
  padding: 24px;
  background: var(--base);
}

.fullpage-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--r-xl);
}

.fullpage-card h1 {
  font-size: 19px;
  font-weight: 600;
}

.fullpage-card p {
  color: var(--text-2);
  font-size: 13px;
}

.fullpage-action {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.boot-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--base);
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
}

.auth-main {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--r-xl);
}

.auth-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}

.auth-footnote {
  color: var(--text-2);
  font-size: 11px;
  text-align: center;
}

.identity-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.identity-option:hover:not(:disabled) {
  background: var(--pressed);
}

.identity-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.identity-option-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.identity-option-name {
  font-size: 13px;
  font-weight: 600;
}

.identity-option-meta {
  color: var(--text-2);
  font-size: 12px;
}

.identity-option-arrow {
  color: var(--text-2);
  font-size: 13px;
}

.redeem-card {
  max-width: 400px;
}

.redeem-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.redeem-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.redeem-result-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 12px;
}

.redeem-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.redeem-result-row span:first-child {
  color: var(--text-2);
}

.redeem-preparing {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Settings details
   -------------------------------------------------------------------------- */

.detail-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  font-size: 13px;
}

.detail-label {
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}

.detail-value {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile .avatar {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.profile-name {
  font-size: 15px;
  font-weight: 600;
}

.health-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--warn);
}

.health-dot.is-ok {
  background: var(--ok);
}

.health-dot.is-bad {
  background: var(--bad);
}

.health-status strong {
  font-size: 13px;
  font-weight: 600;
}

.settings-identity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-identity-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Member apps, sessions and operation details
   -------------------------------------------------------------------------- */

.impact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.impact-grid span {
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sync-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.choice-resources {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.choice-resource-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.resource-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 12px;
  cursor: pointer;
}

.check-inline .mono {
  color: var(--text-2);
}

.share-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.share-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.share-value {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.batch-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.batch-cap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface);
}

.batch-cap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.load-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 4px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar-title {
    display: inline;
  }

  .app {
    display: block;
    padding: 0;
  }

  .input,
  .select {
    height: 36px;
    font-size: 16px;
  }

  .textarea {
    font-size: 16px;
  }

  .input.code-input {
    height: 56px;
    font-size: 24px;
  }

  .btn {
    height: 36px;
  }

  .btn-sm {
    height: 32px;
  }

  .tab {
    height: 32px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 120;
    width: 264px;
    height: 100dvh;
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 200ms;
  }

  .sidebar.is-open {
    visibility: visible;
    transform: none;
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: block;
    padding: 0;
    border: 0;
    background: var(--mask);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  .drawer-scrim.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .app .mobile-only {
    display: inline-flex;
  }

  .main {
    padding: 0 12px 24px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 56px;
    margin: 0 -12px;
    padding: 0 12px;
    background: color-mix(in srgb, var(--base) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .content {
    padding-bottom: 24px;
  }

  .grid-2,
  .role-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-topbar {
    padding: 12px 16px;
  }

  .auth-main {
    padding: 16px;
    align-items: flex-start;
  }

  .auth-card {
    padding: 20px;
  }
}

@media (max-width: 720px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-input {
    width: 100%;
  }

  .form-grid,
  .form-grid-3,
  .permission-row-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .permission-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .permission-row-index {
    display: none;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .modal {
    max-height: calc(100dvh - 16px);
  }

  .modal-head {
    padding: 16px 16px 0;
  }

  .modal-body {
    padding: 12px 16px;
  }

  .modal-foot {
    padding: 0 16px 16px;
  }

  .user-badge-copy {
    display: none;
  }

  .user-badge {
    padding: 0 4px;
  }

  .topbar-actions {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 12px;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .topbar-title {
    display: none;
  }

  .topbar-actions .badge-info {
    display: none;
  }
}

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

/* --------------------------------------------------------------------------
   Overlays — 设置 and 管理后台 open as floating panels over the portal
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: var(--mask);
  cursor: default;
}

.overlay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(86vh, 920px);
  background: var(--overlay);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}

.overlay-card-wide {
  width: min(1180px, 100%);
}

.overlay-card:focus,
.overlay-card:focus-visible {
  outline: none;
}

.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
}

.overlay-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.overlay-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.overlay-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
}

.overlay-close:hover {
  background: var(--hover);
  color: var(--text);
}

.overlay-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.overlay-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 176px;
  flex: none;
  padding: 4px 12px 16px;
  overflow-y: auto;
}

.overlay-nav-link {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}

.overlay-nav-link:hover {
  background: var(--hover);
  color: var(--text);
}

.overlay-nav-link.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.overlay-content {
  flex: 1;
  min-width: 0;
  padding: 4px 24px 24px;
  overflow-y: auto;
}

.overlay-foot {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
}

.overlay-foot::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--pressed);
}

.settings-stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .overlay {
    padding: 12px;
  }

  .overlay-card {
    max-height: 92vh;
  }

  .overlay-body {
    flex-direction: column;
    overflow-y: auto;
  }

  .overlay-nav {
    flex-direction: row;
    width: auto;
    padding: 0 16px 8px;
    overflow-x: auto;
  }

  .overlay-content {
    padding: 0 16px 16px;
    overflow: visible;
  }

  .overlay-head {
    padding: 16px 16px 8px;
  }

  .overlay-foot {
    padding: 12px 16px 16px;
  }
}

/* --------------------------------------------------------------------------
   Top pill tabs + 管理 layout (2026-11-11)
   -------------------------------------------------------------------------- */
.app { grid-template-columns: minmax(0, 1fr); }
.drawer-scrim, .sidebar { display: none; }
.main { min-width: 0; }

.pill-tabs { display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.pill-tab { display: inline-flex; align-items: center; height: 36px; padding: 0 22px; border-radius: var(--r-pill); color: var(--text-2); font-size: 14px; font-weight: 500; transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease; }
.pill-tab:hover { color: var(--text); }
.pill-tab.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }

.manage-layout { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 16px; align-items: start; }
.manage-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.manage-nav-link { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--r-md); color: var(--text-2); font-size: 13px; font-weight: 500; }
.manage-nav-link:hover { background: var(--hover); color: var(--text); }
.manage-nav-link.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.manage-main { min-width: 0; }
@media (max-width: 900px) {
  .manage-layout { grid-template-columns: minmax(0, 1fr); }
  .manage-nav { position: static; flex-direction: row; overflow-x: auto; }
  .manage-nav-link { white-space: nowrap; }
}

.settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar { width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 0; }
.topbar-left { gap: 16px; }
.brand { padding: 0; }

/* Page content settles in when switching tabs; the frame itself never moves. */
@keyframes content-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page {
  animation: content-in 200ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
  .pill-tab { transition: none; }
}

/* Fixed content frame: the right column never changes width between sections. */
.main > .content { width: 100%; max-width: 1280px; margin: 0 auto; }

/* --------------------------------------------------------------------------
   /login — same neutral language as the console shell
   -------------------------------------------------------------------------- */
.auth-page { min-height: 100dvh; display: flex; flex-direction: column; background: var(--base); }
.auth-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 0; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 24px 16px 120px; }
.auth-card { display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 400px; padding: 32px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-2); }
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.auth-sub { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.auth-footnote { color: var(--text-3); font-size: 11px; text-align: center; }
.identity-list { display: flex; flex-direction: column; gap: 8px; }
.identity-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text); text-align: left; transition: background-color 140ms ease; }
.identity-option:hover { background: var(--pressed); }
.identity-option-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.identity-option-name { font-size: 14px; font-weight: 600; }
.identity-option-meta { color: var(--text-2); font-size: 11px; }
.identity-option-arrow { color: var(--text-3); }
.auth-card .btn-lg { min-height: 44px; }

/* Top bar: brand | centered tabs | user menu */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; width: 100%; max-width: 1280px; margin: 0 auto; padding: 12px 48px; }
.topbar-left { justify-self: start; }
.pill-tabs { justify-self: center; }
.topbar-actions { justify-self: end; }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 48px 48px; }
.manage-layout { grid-template-columns: 176px minmax(0, 1fr); gap: 32px; }

.user-menu { position: relative; }
.user-menu-trigger { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: var(--r-pill); background: var(--surface); }
.user-menu-trigger:hover { background: var(--hover); }
.user-menu-name { font-size: 13px; font-weight: 600; }
.user-menu-caret { color: var(--text-3); font-size: 12px; }
.user-menu-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; display: flex; flex-direction: column; gap: 2px; min-width: 200px; padding: 8px; background: var(--overlay); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.user-menu-section { display: flex; flex-direction: column; gap: 6px; padding: 4px 8px 8px; }
.user-menu-label { color: var(--text-3); font-size: 11px; font-weight: 600; }
.user-menu-item { display: flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: var(--r-md); color: var(--text); font-size: 13px; text-align: left; }
.user-menu-item:hover:not(:disabled) { background: var(--hover); }
.user-menu-item:disabled { color: var(--text-4); cursor: default; }
@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 8px 16px; }
  .pill-tabs { overflow-x: auto; }
  .user-menu-name { display: none; }
  .content { padding: 16px 16px 40px; }
}


/* 管理：标题横跨整宽，窄栏与内容区在标题下方顶端对齐 */
.manage-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); column-gap: 32px; align-items: start; }
.manage-nav { grid-column: 1; grid-row: 1; position: sticky; top: 16px; }
.manage-main { grid-column: 2; min-width: 0; }

/* 设置：左侧子选项 + 右侧卡片内容 */
.settings-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); column-gap: 32px; row-gap: 16px; align-items: start; }
.settings-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.settings-nav-link { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--r-md); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; text-align: left; }
.settings-nav-link:hover { background: var(--hover); color: var(--text); }
.settings-nav-link.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.settings-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-panel .is-hidden { display: none; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
}

/* 页头做成横贯整宽的长条卡片，与下方窄栏/内容卡片视觉对齐 */
.page-head { align-items: center; padding: 16px 24px; background: var(--surface); border-radius: var(--r-lg); }
.page-head .page-title { font-size: 20px; }
@media (max-width: 900px) { .page-head { padding: 12px 16px; } }

/* 切换分区时保持内容区高度稳定，避免加载瞬间页面塌陷/跳动 */
.content { min-height: calc(100dvh - 132px); }

/* 用户菜单：去掉浏览器默认按钮底色，禁用项不再出现灰块 */
.user-menu-item { background: transparent; }
.user-menu-item:hover:not(:disabled) { background: var(--hover); }
.user-menu-item:disabled { background: transparent; color: var(--text-4); }
.user-menu-pop { padding: 6px; min-width: 180px; }

/* --------------------------------------------------------------------------
   临时分享：仅追加本页作用域样式，沿用既有表面/间距/圆角语言
   -------------------------------------------------------------------------- */

.sharing-fieldset {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sharing-fieldset-note {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.sharing-resource-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.sharing-resource {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface);
}

.sharing-resource-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.sharing-resource-name {
  font-size: 13px;
  font-weight: 600;
}

.sharing-resource-state {
  color: var(--text-3);
  font-size: 11px;
}

.sharing-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sharing-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.sharing-option:hover {
  background: var(--pressed);
}

.sharing-option.is-selected {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
}

.sharing-option .checkbox {
  accent-color: var(--accent);
}

.sharing-counter {
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sharing-session {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sharing-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sharing-presets-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.sharing-presets .btn.is-active {
  background: var(--brand);
  color: var(--on-brand);
}

.sharing-presets .btn.is-active:hover {
  background: color-mix(in srgb, var(--brand) 86%, var(--surface));
  color: var(--on-brand);
}

.sharing-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sharing-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sharing-summary-label {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.sharing-summary-value {
  font-size: 13px;
  font-weight: 600;
}

.sharing-summary-note {
  grid-column: 1 / -1;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.sharing-advanced,
.sharing-availability {
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sharing-advanced summary,
.sharing-availability summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.sharing-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.sharing-reason-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.sharing-reason-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}

.sharing-reason-name {
  font-weight: 600;
}

.sharing-reason-text {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.sharing-content-tags .badge {
  white-space: normal;
  text-align: left;
}

.sharing-content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sharing-content-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sharing-content-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}

.sharing-content-actions {
  color: var(--text-2);
  font-size: 12px;
  text-align: right;
}

.sharing-secret-summary {
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sharing-secret-actions {
  display: flex;
}

.sharing-secret-actions .btn {
  height: 40px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 14px;
  font-weight: 600;
}

.sharing-secret-actions .btn:hover {
  background: color-mix(in srgb, var(--brand) 86%, var(--surface));
  color: var(--on-brand);
}

.sharing-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sharing-detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sharing-detail-title {
  font-size: 13px;
  font-weight: 600;
}

.sharing-detail-note {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

/* 分享活动：统计卡片与一次性链接展示，沿用既有表面/间距语言 */
.campaign-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.campaign-stats .stat {
  padding: 12px;
  background: var(--surface-2);
}

.campaign-link {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

a.campaign-link {
  color: var(--info);
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 720px) {
  .sharing-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .sharing-content-list li {
    flex-direction: column;
    gap: 4px;
  }

  .sharing-content-actions {
    text-align: left;
  }

  .campaign-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   Responsive portal, management cards and touch-friendly forms
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .topbar {
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }

  .content {
    padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .modal-backdrop {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .main {
    padding: 0;
  }

  .manage-layout,
  .settings-layout,
  .settings-stack {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .manage-nav,
  .manage-main {
    grid-column: auto;
    grid-row: auto;
  }

  .manage-nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 8px;
    overflow: visible;
  }

  .manage-nav-link,
  .settings-nav-link {
    min-height: 44px;
    justify-content: center;
  }

  .manage-nav > details {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .manage-nav > details[open] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .manage-nav summary {
    grid-column: 1 / -1;
    justify-content: flex-start;
    cursor: pointer;
  }

  .manage-nav summary::before {
    content: "＋";
    margin-right: 8px;
  }

  .manage-nav details[open] > summary::before {
    content: "−";
  }

  .settings-nav {
    gap: 4px;
    padding: 8px;
  }

  .settings-nav-link {
    flex: 1 0 auto;
    text-align: center;
  }

  .btn,
  .btn-sm,
  .tab,
  .pill-tab,
  .input,
  .select,
  .user-menu-trigger,
  .user-menu-item,
  .sharing-option {
    min-height: 44px;
    height: auto;
  }

  .input,
  .select {
    height: 44px;
  }

  .input,
  .select,
  .textarea {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }

  .btn {
    min-width: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .check-inline,
  .sharing-advanced summary,
  .sharing-availability summary,
  .audit-details summary {
    min-height: 44px;
  }

  .checkbox {
    width: 20px;
    height: 20px;
  }

  .user-menu-name {
    display: none;
  }

  .user-menu-pop {
    max-width: calc(100vw - 32px);
  }

  .settings-panel,
  .service-head-main,
  .profile > div,
  .batch-cap-head,
  .check-inline {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }

  .topbar-left {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
    gap: 8px;
  }

  .brand-copy {
    display: flex;
  }

  .brand-sub {
    display: none;
  }

  .brand {
    min-height: 44px;
  }

  .topbar-actions .badge-info {
    display: inline-flex;
  }

  .pill-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    gap: 4px;
  }

  .pill-tab {
    flex: 1;
    justify-content: center;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .content {
    padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .page {
    gap: 16px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
  }

  .page-head .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-head .page-title {
    font-size: 20px;
  }

  .page-actions .btn,
  .card-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    white-space: normal;
  }

  .card,
  .stat {
    padding: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-head {
    flex-direction: column;
    align-items: stretch;
  }

  .service-head .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .filter-field,
  .filter-field-narrow,
  .search-input {
    min-width: 0;
    width: 100%;
  }

  .filter-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .filter-actions .btn {
    flex: 1;
  }

  .table-simple,
  .table-cards {
    min-width: 0;
  }

  .table-cards,
  .table-cards tbody {
    display: block;
    width: 100%;
  }

  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-cards tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .table-cards tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border-radius: var(--r-md);
    background: var(--surface-2);
  }

  .table-cards td {
    display: block;
    min-width: 0;
    padding: 0;
    overflow-wrap: anywhere;
  }

  .table-cards td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
  }

  .table-cards td:first-child,
  .table-cards td:nth-child(2),
  .table-cards td:last-child {
    grid-column: 1 / -1;
  }

  .table-cards .row-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .table-cards .row-actions .btn {
    flex: 1 1 auto;
  }

  .table-cards .badge {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .audit-details summary,
  .permission-chip-list {
    max-width: 100%;
  }

  .table-scroll {
    position: relative;
  }

  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .detail-value {
    width: 100%;
    text-align: left;
  }

  .auth-topbar {
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  }

  .auth-main {
    flex: 1;
    align-content: start;
    padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 24px;
  }

  .modal-backdrop {
    place-items: end center;
    padding: env(safe-area-inset-top) 0 0;
  }

  .modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .modal-lg,
  .modal-xl {
    height: 100%;
  }

  .modal-head {
    flex: none;
    padding: 16px 16px 0;
  }

  .modal-head .btn {
    min-width: 44px;
    flex: none;
  }

  .modal-title,
  .modal-sub,
  .sharing-content-name,
  .sharing-resource-name {
    overflow-wrap: anywhere;
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overscroll-behavior: contain;
  }

  .modal-body-safe {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .modal-foot,
  .modal-body .form-actions {
    flex: none;
    flex-wrap: wrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--overlay);
  }

  .modal-body .form-actions {
    position: sticky;
    bottom: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .form-actions-buttons {
    width: 100%;
  }

  .form-actions-buttons .btn,
  .form-actions > .btn,
  .modal-foot > .btn {
    flex: 1;
  }

  .form-actions-extra {
    width: 100%;
  }

  .sharing-presets .btn {
    flex: 1;
  }

  .sharing-option {
    flex: 1;
    justify-content: center;
  }

  .toast-region {
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: auto;
  }
}

/* Consistent sizing and actions for content and authentication cards. */
.fullpage-card {
  min-width: min(360px, 100%);
  min-height: 280px;
  padding: 24px;
  gap: 24px;
}

.role-card,
.service {
  min-width: min(360px, 100%);
}

.fullpage-card {
  width: min(360px, 100%);
  justify-content: center;
}

.fullpage-action,
.role-card-foot,
.service .card-actions {
  width: 100%;
}

.fullpage-action,
.role-card-foot,
.service .card-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.fullpage-action > .btn,
.role-card-foot > .btn,
.service .card-actions > .btn {
  flex: 1 1 0;
  justify-content: center;
}

.role-card-foot {
  margin-top: auto;
}

.grid-2,
.stats,
.campaign-stats {
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.campaign-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .campaign-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.auth-main {
  grid-template-columns: minmax(0, 1fr);
}

.login-card {
  width: min(360px, 100%);
  justify-self: center;
  align-items: stretch;
  text-align: center;
}

.login-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 16px;
}

@media (max-width: 640px) {
  .fullpage-card {
    width: min(320px, 100%);
    min-width: min(320px, 100%);
    min-height: 240px;
  }
}

/* Match the production authentication card. */
.login-card {
  width: 400px;
  max-width: 100%;
  min-width: 0;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(13, 14, 16, 0.04), 0 8px 24px rgba(13, 14, 16, 0.06);
}

@media (prefers-color-scheme: dark) {
  .login-card {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.36);
  }
}

@media (max-width: 480px) {
  .login-card {
    width: 100%;
    padding: 24px;
  }
}

@media (max-height: 760px) and (min-width: 481px) {
  .login-card {
    padding: 24px;
  }
}
