/* cfly-router admin (1.5) — standard app shell */
:root {
  --bg: #f4f4f5;
  --card: #fff;
  --sidebar-bg: #27272a;
  --sidebar-text: #e4e4e7;
  --sidebar-muted: #a1a1aa;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(37, 99, 235, 0.28);
  --sidebar-active-text: #93c5fd;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-divider: rgba(255, 255, 255, 0.08);
  --text: #18181b;
  --muted: #71717a;
  --nav-group-label: var(--sidebar-muted);
  --accent: #2563eb;
  --danger: #dc2626;
  --success: #16a34a;
  --topbar-h: 48px;
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 64px;
  --radius: 6px;
  --fold-tint-bg: #eff6ff;
  --fold-tint-border: #bfdbfe;
  --sidebar-current: var(--sidebar-w);
}
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
body.admin-app {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
html.sidebar-collapsed { --sidebar-current: var(--sidebar-collapsed-w); }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: #18181b;
  color: #fff;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 20;
}
.topbar-start {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.topbar-end {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.topbar-nav {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.topbar-nav a {
  color: #e4e4e7;
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}
.topbar-nav a:hover { color: #fff; }
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: #e4e4e7;
  cursor: pointer;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
}
.brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
  flex-shrink: 0;
}
.brand-version {
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  margin-left: 0.15rem;
}
.locale-menu {
  position: relative;
  display: inline-block;
}
.locale-menu-details {
  position: relative;
}
.locale-menu-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2rem;
  margin: 0;
  padding: 0 0.45rem 0 0.4rem;
  border: 1px solid #d4d4d8;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.locale-menu-trigger::-webkit-details-marker {
  display: none;
}
.locale-menu-icon {
  flex-shrink: 0;
  color: #71717a;
}
.locale-menu-current {
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.locale-menu-chevron {
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.15s ease;
}
.locale-menu-details[open] .locale-menu-chevron {
  transform: rotate(180deg);
}
.locale-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 300;
  min-width: 100%;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid #e4e4e7;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}
.locale-menu-list a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.locale-menu-list a:hover {
  background: #f4f4f5;
}
.locale-menu-list a.is-active {
  font-weight: 600;
  color: var(--accent);
  background: #eff6ff;
  pointer-events: none;
}
.topbar .locale-menu-trigger {
  border-color: #52525b;
  background: #3f3f46;
  color: #fff;
}
.topbar .locale-menu-icon {
  color: #d4d4d8;
}
.topbar .locale-menu-chevron {
  color: #e4e4e7;
}
.topbar .locale-menu-list {
  border-color: #e4e4e7;
}
.topbar-logout .btn-sm {
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  line-height: 1;
  box-sizing: border-box;
}
.login-locale {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.topbar-logout { margin: 0; }

.file-picker-field { margin-bottom: 0.5rem; }
.file-picker-heading {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}
.file-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
  width: 100%;
}
.file-picker input[type="file"] {
  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-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border: 1px solid #d4d4d8;
  border-radius: var(--radius);
  background: #fafafa;
  font-size: 0.875rem;
  cursor: pointer;
  flex-shrink: 0;
}
.file-picker:hover .file-picker-btn,
.file-picker:focus-within .file-picker-btn {
  border-color: var(--accent);
  background: #eff6ff;
}
.file-picker-name {
  color: var(--muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-current);
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  transition: width 0.2s ease;
  overflow: hidden;
}
.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 0.75rem 0 0.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.sidebar-nav:hover {
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
.sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}
.sidebar-footer {
  flex-shrink: 0;
  padding: 0.7rem 1rem 0.9rem;
  border-top: 1px solid var(--sidebar-divider);
  min-height: 2.75rem;
  display: flex;
  align-items: center;
}
.sidebar-version {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--sidebar-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-group {
  margin-top: 0.85rem;
  padding-top: 0.35rem;
}
.nav-group:first-child {
  margin-top: 0;
  padding-top: 0;
}
.nav-group + .nav-group {
  border-top: 1px solid var(--sidebar-divider);
}
.nav-group-label {
  padding: 0.35rem 1rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  white-space: nowrap;
  user-select: none;
}
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.12rem 0.5rem;
  padding: 0.45rem 0.75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar a.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar a.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}
.nav-icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html.sidebar-collapsed .nav-label { display: none; }
html.sidebar-collapsed .nav-group-label { display: none; }
html.sidebar-collapsed .nav-group {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
}
html.sidebar-collapsed .nav-group:first-child {
  margin-top: 0;
  padding-top: 0;
}
html.sidebar-collapsed .nav-group + .nav-group {
  border-top-color: var(--sidebar-divider);
}
html.sidebar-collapsed .sidebar a.nav-item {
  justify-content: center;
  margin: 0.15rem 0.45rem;
  padding: 0.5rem;
  gap: 0;
}
html.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 0.55rem 0.35rem 0.75rem;
}
html.sidebar-collapsed .sidebar-version {
  font-size: 0.65rem;
}

.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}
.content--panel {
  padding: 0;
  background: var(--card);
}
.page-panel {
  width: 100%;
  min-height: 100%;
  background: var(--card);
  padding: 1.25rem 1.5rem;
}
.page-inner {
  width: 100%;
}
.page-inner--narrow {
  max-width: 40rem;
}
.page-inner--medium {
  max-width: 56rem;
}
.page-panel .card {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
}

main.login-main { max-width: 420px; margin: 4rem auto; padding: 0 1rem; }
body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 0;
}
.auth-topbar {
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid #e4e4e7;
}
.auth-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  width: 100%;
  box-sizing: border-box;
}
.auth-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.auth-topbar-brand:hover {
  color: var(--accent);
}
.auth-topbar-logo {
  flex-shrink: 0;
  display: block;
}
.auth-topbar-end {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
main.auth-main,
main.home-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  box-sizing: border-box;
}
.auth-card,
.home-card {
  padding: 2rem 1.75rem;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
}
.auth-brand,
.home-brand {
  text-align: center;
}
.auth-logo,
.home-logo {
  width: 4.5rem;
  height: 4.5rem;
  display: block;
  margin: 0 auto 1rem;
}
.auth-brand h1,
.home-brand h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}
.auth-tagline,
.home-tagline {
  margin: 0 auto;
  max-width: 22rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.auth-page .alert,
.home-page .alert {
  margin-top: 1rem;
  margin-bottom: 0;
}
.portal-auth-form {
  margin-top: 1rem;
}
.portal-auth-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.85rem;
}
.portal-auth-form label:first-child {
  margin-top: 0;
}
.portal-auth-form input,
.portal-auth-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #d4d4d8;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.portal-auth-form input:focus-visible,
.portal-auth-form textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--fold-tint-border);
}
@media (forced-colors: active) {
  .portal-auth-form input:focus-visible,
  .portal-auth-form textarea:focus-visible {
    outline: 2px solid Highlight;
    box-shadow: none;
  }
}
.portal-auth-form textarea {
  min-height: 4.5rem;
  resize: vertical;
}
.auth-submit {
  margin: 1.25rem 0 0;
}
.auth-submit .btn {
  width: 100%;
  padding: 0.6rem 1rem;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.home-actions .btn {
  width: 100%;
  text-align: center;
  padding: 0.6rem 1rem;
  text-decoration: none;
}
.auth-footer,
.home-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f4f4f5;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.auth-footer a,
.home-footer > a {
  color: var(--accent);
  text-decoration: none;
}
.auth-footer a:hover,
.home-footer > a:hover {
  text-decoration: underline;
}
.auth-footer-note {
  color: var(--muted);
}
.home-api-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Public portal landing (/) */
body.portal-landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.portal-topbar {
  background: var(--card);
  border-bottom: 1px solid #e4e4e7;
  flex-shrink: 0;
}
.portal-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  width: 100%;
  box-sizing: border-box;
}
.portal-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.portal-topbar-brand:hover {
  color: var(--accent);
}
.portal-topbar-logo {
  flex-shrink: 0;
  display: block;
}
.portal-topbar-end {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.portal-topbar-user {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-topbar-end .btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
}
.portal-topbar-link {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.portal-topbar-link:hover {
  color: var(--text);
}
.portal-topbar-link-primary {
  color: var(--accent);
  font-weight: 500;
}
.portal-topbar-link-primary:hover {
  color: #1d4ed8;
}
.portal-topbar-logout {
  margin: 0;
}
.portal-topbar-link-btn {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
}
.portal-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18vh 1.5rem 2rem;
  text-align: center;
}
.portal-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  align-content: start;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16vh 1.5rem 2rem;
  gap: 2rem;
  box-sizing: border-box;
}
.portal-split-intro {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 0.75rem 1rem 0;
  text-align: center;
}
.portal-split-intro .portal-hero-logo {
  margin: 0 0 1.25rem;
}
.portal-split-intro h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
}
.portal-split-intro .portal-hero-tagline {
  margin: 0;
  max-width: 26rem;
  text-align: center;
}
.portal-split-auth {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  padding-top: 0.25rem;
}
.portal-split-card {
  width: 100%;
  max-width: 400px;
  margin: 0;
}
.portal-split-card .auth-brand {
  text-align: left;
}
.portal-split-card .auth-brand h1 {
  font-size: 1.35rem;
}
.portal-landing .alert {
  margin-top: 1rem;
  margin-bottom: 0;
}
@media (max-width: 800px) {
  .portal-split {
    grid-template-columns: 1fr;
    padding-top: 1.5rem;
    gap: 1.25rem;
  }
  .portal-split-intro {
    align-items: center;
    text-align: center;
    padding: 0.5rem 0 0;
  }
  .portal-split-intro .portal-hero-logo {
    margin-left: auto;
    margin-right: auto;
  }
  .portal-split-intro .portal-hero-tagline {
    text-align: center;
  }
  .portal-split-card .auth-brand {
    text-align: center;
  }
}
.portal-hero-logo {
  display: block;
  margin: 0 auto 1.25rem;
}
.portal-hero h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
}
.portal-hero-tagline {
  margin: 0 auto 1.5rem;
  max-width: 26rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Logged-in user portal (/user/*) */
body.portal-app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.portal-user-topbar {
  display: block;
  flex-shrink: 0;
  padding: 0;
}
.portal-user-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  width: 100%;
  box-sizing: border-box;
}
/* Full-width scroll layer so the scrollbar sits at the viewport edge;
   page cards stay centered with max-width. */
.portal-user-main {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  margin: 0;
  padding: 1.5rem 1.25rem 2rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.portal-user-main > * {
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
}
.portal-user-main > .card:last-child {
  margin-bottom: 0;
}

.login-brand {
  text-align: center;
  margin-bottom: 1rem;
}
.login-logo {
  width: 4rem;
  height: 4rem;
  display: block;
  margin: 0 auto 0.75rem;
}
.login-brand h1 { margin: 0; }
.login-footer {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid #f4f4f5;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid #e4e4e7;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0 0 1rem;
  width: 100%;
}

.page-actions--back {
  margin-bottom: 0.75rem;
}
.page-header { margin-bottom: 1rem; }
.page-header h1 {
  margin-bottom: 0.35rem;
  font-size: 1.5rem;
}
.page-header .muted,
.page-header .hint { margin-bottom: 0; }
.detail-list {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.detail-list dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.detail-list dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}
.detail-value {
  display: inline-block;
  line-height: 1.5;
  padding-top: 0.1rem;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.form-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
/* Let nested POST forms participate in flex rows (table actions, form footers). */
td.row-actions form,
.form-actions form.inline,
.page-actions form.inline,
.page-actions form.inline-form {
  display: contents;
  margin: 0;
}
.pagination {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.pagination .muted {
  margin: 0;
  line-height: 1.2;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  background: #fafafa;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
}
tbody tr:hover { background: #fafafa; }
td.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.users-balance--low {
  color: var(--danger);
  font-weight: 600;
}
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #e4e4e7; }
table.data-table {
  border: 1px solid #e4e4e7;
}
table.data-table th,
table.data-table td {
  border: 1px solid #e4e4e7;
}
table.data-table thead th {
  text-align: center;
}
table.data-table td.cell-center {
  text-align: center;
}
table.data-table td.summary-cell {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.75rem; }
label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  max-width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0.6rem;
  margin-top: 0.25rem;
  border: 1px solid #d4d4d8;
  border-radius: var(--radius);
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-top: 0;
  padding: 0;
  flex-shrink: 0;
}
label:has(> input[type="checkbox"]) input[type="checkbox"] {
  margin-top: 0;
}

.toggle-row {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--fold-tint-bg);
  border: 1px solid var(--fold-tint-border);
  border-radius: var(--radius);
}
.toggle-row-sm {
  padding: 0.6rem 0.85rem;
}
label.toggle-row-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  color: var(--text);
}
/* On/off switch — track is a sibling span (inputs can't reliably paint ::after) */
.switch-wrap {
  position: relative;
  display: inline-block;
  width: 2.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  vertical-align: middle;
}
.switch-wrap input.toggle-check,
.admin-form .form-field .switch-wrap input.toggle-check,
.admin-form .toggle-inline .switch-wrap input.toggle-check {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  opacity: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  flex-shrink: 0;
}
.switch-wrap .switch-track {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #d4d4d8;
  box-shadow: inset 0 0 0 1px #a1a1aa;
  pointer-events: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.switch-wrap .switch-track::after {
  content: "";
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.switch-wrap input.toggle-check:checked + .switch-track {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.switch-wrap input.toggle-check:checked + .switch-track::after {
  transform: translateX(1rem);
}
.switch-wrap input.toggle-check:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.switch-wrap input.toggle-check:disabled + .switch-track {
  opacity: 0.5;
}
.toggle-row-text {
  flex: 1;
  min-width: 0;
}
.toggle-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.toggle-row-text .hint {
  margin: 0;
  display: block;
}

textarea { min-height: 80px; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0.45rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.25;
  min-height: 2.125rem;
}
button.btn {
  appearance: none;
  -webkit-appearance: none;
}
.btn-secondary { background: #71717a; }
.btn-danger { background: var(--danger); }
.alert { padding: 0.6rem 0.8rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.confirm-dialog[hidden] {
  display: none;
}
body.confirm-dialog-open {
  overflow: hidden;
}
.confirm-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.confirm-dialog-panel {
  position: relative;
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.confirm-dialog-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.confirm-dialog-message {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.secret-reveal {
  margin-bottom: 1.25rem;
}
.secret-reveal-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.secret-reveal-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.secret-reveal-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  background: #f4f4f5;
  color: var(--text);
  cursor: text;
}
.secret-reveal-input:focus {
  outline: none;
  border-color: #a1a1aa;
  background: #fff;
}
.secret-reveal-copy {
  flex-shrink: 0;
  align-self: center;
}
@media (max-width: 520px) {
  .secret-reveal-row {
    flex-direction: column;
  }
  .secret-reveal-copy {
    align-self: stretch;
  }
}
.inline { display: inline; }
.status-online { color: #16a34a; }
.status-circuit_open { color: #dc2626; }
.status-never_probed { color: #a1a1aa; }
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.dash-overview-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.dash-overview-panel .section-title {
  margin-top: 0;
}
.dash-overview-panel .dash-stats {
  margin-bottom: 0;
}
.dash-stats--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dash-overview-panels:has(.dash-overview-panel:only-child) {
  grid-template-columns: 1fr;
}
@media (max-width: 768px) {
  .dash-overview-panels {
    grid-template-columns: 1fr;
  }
}
.dash-stat {
  padding: 0.75rem 1rem;
  border: 1px solid #e4e4e7;
  border-radius: var(--radius);
  background: #fafafa;
}
.dash-stat-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
.dash-stat-value { font-size: 1.35rem; font-weight: 600; color: var(--text); }
.dash-stat-value--success { color: var(--success); }
.dash-stat-value--warn { color: #ca8a04; }
.dash-stat-value--danger { color: var(--danger); }
.dash-overview-panel .hint {
  margin-top: 0;
  margin-bottom: 0.75rem;
}
.dash-dashboard-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}
.dash-dashboard-panels--single {
  grid-template-columns: 1fr;
}
.dash-dashboard-panel .section-title {
  margin-top: 0;
}
.dash-dashboard-panel .dash-bar-chart {
  margin-bottom: 0;
}
.table-wrap {
  overflow-x: auto;
}
.dash-upstream-table {
  margin-bottom: 0;
}
.dash-upstream-name {
  font-size: 0.85rem;
  word-break: break-word;
}
.dash-expiry-section {
  margin: 0 0 1.25rem;
}
.dash-expiry-section .section-title {
  margin-top: 0;
}
.health-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}
.health-badge--online {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.health-badge--circuit {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.health-badge--probed {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.health-badge--muted {
  background: #f4f4f5;
  color: #71717a;
  border: 1px solid #e4e4e7;
}
@media (max-width: 768px) {
  .dash-dashboard-panels {
    grid-template-columns: 1fr;
  }
}
.dash-bar-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.dash-bar-chart-title {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.dash-bar-plot {
  padding: 0.85rem 1rem 0.65rem;
  border: 1px solid #e4e4e7;
  border-radius: var(--radius);
  background: #fff;
  background-image: linear-gradient(to top, #f4f4f5 1px, transparent 1px);
  background-size: 100% 25%;
}
.dash-bar-cols {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  height: 8.5rem;
  border-bottom: 2px solid #71717a;
}
.dash-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.dash-bar-slot {
  flex: 1;
  width: 100%;
  max-width: 2.75rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.dash-bar-value {
  margin-bottom: 0.2rem;
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-bar-fill {
  width: 100%;
  min-height: 0;
  background: #2563eb;
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.06);
}
.dash-bar-chart + .dash-bar-chart .dash-bar-fill {
  background: #7c3aed;
}
.dash-bar-label {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 768px) {
  .dash-bar-charts {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  .dash-bar-plot {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .dash-bar-cols {
    gap: 0.3rem;
  }
  .dash-bar-slot {
    max-width: 100%;
  }
  .dash-bar-value {
    font-size: 0.6rem;
  }
}
.hint { font-size: 0.8rem; color: var(--muted); }

.model-allow-fieldset { margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid #e4e4e7; border-radius: var(--radius); }
.token-api-endpoints { margin: 0.5rem 0 1rem; }
.token-api-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin: 0.4rem 0;
  line-height: 1.5;
}
.token-api-line .protocol-badge { margin-left: 0; }
.token-api-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem 0.25rem 0.2rem 0.5rem;
  background: #f4f4f5;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  max-width: 100%;
}
.token-api-chip--openai {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.token-api-chip--anthropic {
  background: #faf5ff;
  border-color: #e9d5ff;
}
.token-api-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}
.token-api-meta {
  font-size: 0.78rem;
  color: var(--muted);
}
.token-api-chip .copy-btn {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.token-api-chip .copy-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}
.token-api-chip .copy-btn.is-copied,
.token-api-chip .copy-btn.is-copy-failed {
  background: transparent;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.15rem 0.25rem;
  line-height: 0;
  vertical-align: middle;
  min-height: auto;
}
.copy-btn-icons {
  position: relative;
  width: 16px;
  height: 16px;
}
.copy-btn-icons svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
}
.copy-btn-icon--done {
  opacity: 0;
}
.copy-btn.is-copied {
  border-color: #16a34a;
  color: #16a34a;
}
.copy-btn.is-copied .copy-btn-icon--copy {
  opacity: 0;
}
.copy-btn.is-copied .copy-btn-icon--done {
  opacity: 1;
}
.copy-btn.is-copy-failed {
  border-color: #dc2626;
  color: #dc2626;
}
.token-model-group { margin-top: 0.5rem; border: 1px solid #e4e4e7; border-radius: var(--radius); background: #fafafa; }
.token-model-group-summary { cursor: pointer; padding: 0.5rem 0.75rem; list-style: none; }
.token-model-group-summary::-webkit-details-marker { display: none; }
.token-model-group-title { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.token-group-select-all-wrap { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; cursor: pointer; }
.token-model-group-body { padding: 0.25rem 0.75rem 0.75rem 1.75rem; border-top: 1px dashed #e4e4e7; }
.modality-badge {
  display: inline-block; margin-left: 0.25rem; padding: 0.05rem 0.35rem; font-size: 0.7rem;
  border-radius: 4px; background: #eef2ff; color: #4338ca; vertical-align: middle;
}
.model-protocol-group { margin-top: 0.75rem; }
.model-protocol-group:first-of-type { margin-top: 0.25rem; }
.model-protocol-group + .model-protocol-group { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px dashed #e4e4e7; }
.model-protocol-group-title { margin: 0 0 0.15rem; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.model-protocol-group-path { margin: 0 0 0.5rem; word-break: break-all; }
.model-checkbox { display: flex; align-items: flex-start; gap: 0.35rem; margin: 0.35rem 0; }
.model-checkbox-text { line-height: 1.4; }
.protocol-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.protocol-badge--openai { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.protocol-badge--anthropic { background: #faf5ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.portal-model-section {
  margin: 0 0 1.5rem;
}
.portal-model-section .section-title {
  margin-bottom: 0.75rem;
}
.portal-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}
.portal-model-card {
  border: 1px solid #e4e4e7;
  border-radius: var(--radius);
  background: #fafafa;
  padding: 0.9rem 1rem;
  min-width: 0;
}
.portal-model-card-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}
.portal-model-card-id {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-all;
}
.portal-model-card-desc {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
}
.portal-model-card-desc.muted {
  margin-bottom: 0.5rem;
  color: var(--muted);
}
.portal-model-card-price {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
  font-weight: 500;
}
.portal-model-card-price .muted {
  font-weight: 400;
  color: var(--muted);
}
.portal-model-card-tags {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.portal-model-card-tags .modality-badge {
  margin-left: 0;
}
.muted { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }
.url-list { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.url-list li { margin: 0.35rem 0; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--fold-tint-border);
  border-radius: var(--radius);
  background: var(--fold-tint-bg);
  line-height: 1.35;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0 0.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--fold-tint-border);
  border-radius: var(--radius);
  background: var(--fold-tint-bg);
}
.section-head .section-title {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.page-header h1.title-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.45rem;
}
.title-tab {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: inherit;
  line-height: inherit;
  padding-bottom: 0.12rem;
  border-bottom: 2px solid transparent;
}
.title-tab:hover {
  color: var(--accent);
}
.title-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  pointer-events: none;
  cursor: default;
}
.title-tab-sep {
  color: #d4d4d8;
  font-weight: 400;
  user-select: none;
}
.binding-block {
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #fafafa;
}
.binding-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.btn-sm { padding: 0.3rem 0.55rem; font-size: 0.8rem; min-height: 1.75rem; }

.fold-advanced {
  margin-top: 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  background: #fff;
}
.fold-advanced > summary {
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
  list-style: none;
}
.fold-advanced > summary::-webkit-details-marker { display: none; }
.fold-advanced > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}
.fold-advanced[open] > summary::before { transform: rotate(90deg); }
.fold-advanced[open] > summary { color: var(--text); border-bottom: 1px solid #e4e4e7; }
.fold-body { padding: 0.75rem 0.75rem 0.25rem; }
.binding-simple { margin-bottom: 0.25rem; }
.upstream-model-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.upstream-model-row .js-upstream-model-input { flex: 1; min-width: 12rem; }
.upstream-model-select { margin-top: 0.35rem; width: 100%; max-width: 32rem; }
.priority-row,
.select-mode-row,
.auth-header-row { display: none; }
.priority-row.is-visible,
.select-mode-row.is-visible,
.auth-header-row.is-visible { display: block; }
#model-advanced {
  margin-top: 0.5rem;
}
#model-advanced,
.binding-advanced {
  background: #fff;
  border-color: #d4d4d8;
}
#model-advanced > summary,
.binding-advanced > summary {
  background: #f4f4f5;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text);
}
#model-advanced:not([open]) > summary,
.binding-advanced:not([open]) > summary {
  border-radius: var(--radius);
}
#model-advanced .fold-body,
.binding-advanced .fold-body {
  background: #fafafa;
  border-radius: 0 0 var(--radius) var(--radius);
}
#model-advanced[open] > summary,
.binding-advanced[open] > summary {
  border-bottom: 1px solid #e4e4e7;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.filter-bar-create {
  margin-left: auto;
  flex-shrink: 0;
}
.filter-bar label { margin: 0; }
.filter-bar .filter-bar-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.5rem;
  align-items: center;
}
.filter-bar .form-label {
  padding-top: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  white-space: nowrap;
}
.filter-bar .form-field {
  min-width: 0;
}
.filter-bar .form-field select,
.filter-bar .form-field input:not([type="checkbox"]) {
  margin-top: 0;
  padding: 0.4rem 0.55rem;
  width: 100%;
}
.filter-bar .form-field.field-w-md > select,
.filter-bar .form-field.field-w-md > input:not([type="checkbox"]) {
  max-width: 14rem;
}
.filter-bar .form-field.field-w-sm > select,
.filter-bar .form-field.field-w-sm > input:not([type="checkbox"]) {
  max-width: 8rem;
}
.filter-bar .form-field.field-w-lg > select,
.filter-bar .form-field.field-w-lg > input:not([type="checkbox"]) {
  max-width: 28rem;
}
.filter-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.export-section {
  margin-bottom: 1.25rem;
}
.modality-fieldset {
  border: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.modality-fieldset legend {
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: normal;
}

/* Model new/edit form — horizontal label + field */
.admin-form .form-row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 0.5rem 1rem;
  align-items: start;
  margin: 0 0 1.25rem;
}
.admin-form .form-row[hidden] {
  display: none !important;
}
.admin-form .radio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}
.admin-form label.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  margin-top: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  width: auto;
  max-width: none;
}
.admin-form label.radio-inline input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  flex-shrink: 0;
  accent-color: var(--accent, #2563eb);
}
.admin-form .form-row:last-child {
  margin-bottom: 0;
}
.admin-form .form-label {
  padding-top: 0.42rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.admin-form .form-field {
  min-width: 0;
}
.admin-form .form-field.field-w-sm > input:not([type="checkbox"]):not([type="radio"]),
.admin-form .form-field.field-w-sm > select {
  max-width: 8rem;
}
.admin-form .form-field.field-w-md > input:not([type="checkbox"]):not([type="radio"]),
.admin-form .form-field.field-w-md > select {
  max-width: 14rem;
}
.admin-form .form-field.field-w-lg > input:not([type="checkbox"]):not([type="radio"]),
.admin-form .form-field.field-w-lg > select {
  max-width: 28rem;
}
.admin-form .form-field.field-w-xl > input:not([type="checkbox"]):not([type="radio"]),
.admin-form .form-field.field-w-xl > select,
.admin-form .form-field.field-w-xl > .upstream-model-row {
  max-width: 36rem;
}
.admin-form .form-field.field-w-xl > .upstream-model-select {
  max-width: 36rem;
}
.admin-form .form-field input:not([type="checkbox"]):not([type="radio"]),
.admin-form .form-field select,
.admin-form .form-field textarea {
  margin-top: 0;
  padding: 0.4rem 0.55rem;
  width: 100%;
}
.admin-form .form-field input[type="checkbox"],
.admin-form .form-field input[type="radio"] {
  width: auto;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.admin-form .form-field .hint {
  display: block;
  margin-top: 0.15rem;
  line-height: 1.35;
  color: var(--muted);
  font-size: 0.8rem;
}
.admin-form .form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 1.25rem;
  margin: 0 0 1.25rem;
}
.admin-form .form-grid-2 > .form-row {
  margin-bottom: 0;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.35rem 0.5rem;
}
.admin-form label.toggle-inline,
label.toggle-inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  margin: 0;
  width: auto;
  max-width: 100%;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.admin-form .toggle-inline .toggle-check,
.toggle-inline .toggle-check {
  margin: 0;
  flex-shrink: 0;
}
.admin-form .toggle-inline .hint,
.toggle-inline .hint {
  display: inline;
  margin: 0;
  font-size: 0.8rem;
}
.admin-form .fold-body > .form-row:first-child,
.admin-form .fold-body > .form-grid-2:first-child {
  margin-top: 0.25rem;
}
.admin-form .binding-simple > .form-row:first-child {
  margin-top: 0;
}
.admin-form .form-row-toggle .form-label {
  padding-top: 0.15rem;
}
.admin-form .form-row-inline-check {
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}
.admin-form .form-row-top .form-label,
.admin-form .form-row-modalities .form-label {
  padding-top: 0.15rem;
}
.admin-form .form-row-modalities .modality-hint {
  margin-top: 0.5rem;
}
.admin-form .form-row-modalities .checkbox-grid {
  margin-top: 0;
}
.admin-form .checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  margin-top: 0.5rem;
}
.admin-form .modality-hint {
  margin-top: 0;
  display: block;
}
.admin-form label.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: normal;
  margin: 0;
  width: auto;
  max-width: none;
  white-space: nowrap;
  cursor: pointer;
}
.admin-form .binding-block {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.admin-form .fold-body {
  padding: 0.6rem 0.75rem 0.2rem;
}
.admin-form .select-mode-row {
  display: none;
}
.admin-form .select-mode-row.is-visible {
  display: grid;
}
.admin-form .auth-header-row {
  display: none;
}
.admin-form .auth-header-row.is-visible {
  display: grid;
}
.admin-form .upstream-model-row .js-upstream-model-input {
  margin-top: 0;
}
.admin-form .upstream-model-select {
  margin-top: 0.35rem;
}
.admin-form.user-detail-form {
  margin-bottom: 1.25rem;
}
.admin-form .file-picker {
  margin-top: 0;
}

@media (max-width: 640px) {
  .admin-form .form-row,
  .admin-form .select-mode-row.is-visible,
  .admin-form .auth-header-row.is-visible {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .admin-form .form-label {
    padding-top: 0;
  }
  .admin-form .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .admin-form .form-field.field-w-sm > input:not([type="checkbox"]):not([type="radio"]),
  .admin-form .form-field.field-w-sm > select,
  .admin-form .form-field.field-w-md > input:not([type="checkbox"]):not([type="radio"]),
  .admin-form .form-field.field-w-md > select,
  .admin-form .form-field.field-w-lg > input:not([type="checkbox"]):not([type="radio"]),
  .admin-form .form-field.field-w-lg > select,
  .admin-form .form-field.field-w-xl > input:not([type="checkbox"]):not([type="radio"]),
  .admin-form .form-field.field-w-xl > select,
  .admin-form .form-field.field-w-xl > .upstream-model-row,
  .admin-form .form-field.field-w-xl > .upstream-model-select {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  html:not(.sidebar-collapsed) .admin-shell { flex-direction: column; }
  html:not(.sidebar-collapsed) .sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }
  html:not(.sidebar-collapsed) .sidebar a.nav-item {
    display: inline-flex;
    width: auto;
    margin: 0.15rem 0.35rem;
  }
}
