/* Smooth scroll for canvas */
.tb-canvas-scroll {
  scroll-behavior: smooth;
}

#transcriptBuilderRoot.tb-left-collapsed .tb-left {
  width: 0;
  min-width: 0;
  padding: 0;
}

#transcriptBuilderRoot.tb-left-collapsed .tb-left-content {
  display: none;
}

#transcriptBuilderRoot.tb-props-open .tb-props {
  transform: translateX(0);
}

@media (max-width: 1200px) {
  .tb-panels {
    flex: 1;
  }
  .tb-left {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 15;
    transform: translateX(0);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 18px rgba(0, 0, 0, 0.12);
  }
  #transcriptBuilderRoot.tb-left-collapsed .tb-left {
    transform: translateX(-110%);
  }
  .tb-props {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 15;
    box-shadow: -6px 0 18px rgba(0, 0, 0, 0.15);
    width: 280px;
  }
  .tb-center {
    padding-right: 16px;
  }
}
/* INCRIPT SaaS UI - app.css (no external frameworks) */

:root {
  /* Sizing + motion */
  --header-height: 64px;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 72px;
  --radius: 12px;
  --transition: 180ms ease;

  /* Shadow */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.08);

  /* Gradient theme (unified across admin) */
  --primary-gradient: linear-gradient(90deg, #3b82f6, #8b5cf6);
  --header-gradient: linear-gradient(135deg, #f3e8ff 0%, #e9f1ff 100%);
  --header-gradient-dark: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(59, 130, 246, 0.12) 100%);
  --metric-icon-gradient: linear-gradient(135deg, #60a5fa, #a78bfa);
}

/* Themes: applied via body class */
body.theme-light {
  color-scheme: light;

  --bg: #f5f7fb;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.10);

  --card: #ffffff;
  --surface-hover: rgba(15, 23, 42, 0.05);
  --input-bg: #ffffff;

  --brand: #0f172a;
  --brand-contrast: #ffffff;

  --topbar-bg: rgba(255, 255, 255, 0.92);
  --topbar-border: rgba(15, 23, 42, 0.10);

  --sidebar-bg: #0F172A;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-fg: rgba(226, 232, 240, 0.88);
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-icon-bg: transparent;
  --sidebar-mark-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(99, 102, 241, 0.12);
  --sidebar-active-border: #6366f1;
}

body.theme-dark {
  color-scheme: dark;

  --bg: #070b14;
  --text: #e5e7eb;
  --muted: rgba(226, 232, 240, 0.70);
  --border: rgba(226, 232, 240, 0.12);

  --card: #0b1526;
  --surface-hover: rgba(226, 232, 240, 0.08);
  --input-bg: rgba(7, 11, 20, 0.65);

  --brand: #e5e7eb;
  --brand-contrast: #0b1220;

  --topbar-bg: rgba(11, 18, 32, 0.88);
  --topbar-border: rgba(226, 232, 240, 0.10);

  --sidebar-bg: #0F172A;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-fg: rgba(226, 232, 240, 0.88);
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-icon-bg: transparent;
  --sidebar-mark-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(99, 102, 241, 0.12);
  --sidebar-active-border: #6366f1;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* Topbar – full-width gradient (unified theme) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--header-gradient);
  border-bottom: 1px solid #E2E8F0;
  backdrop-filter: blur(10px);
  z-index: 50;
}

body.theme-dark .app-header {
  background: var(--header-gradient-dark);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.app-header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 24px;
}

/* Left — title block */
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1 1 auto;
}

.header-title-block {
  min-width: 0;
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  color: #0F172A;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 13px;
  color: #64748B;
  margin: 4px 0 0;
  line-height: 1.3;
}

body.theme-dark .header-title {
  color: var(--text);
}

body.theme-dark .header-subtitle {
  color: var(--muted);
}

/* Campus dropdown highlight — make it stand out in the header */
.header-campus-highlight {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 16px;
  padding: 8px 14px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
}
body.theme-dark .header-campus-highlight {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
}
.header-campus-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
body.theme-dark .header-campus-label {
  color: var(--text);
}
.header-campus-select {
  width: auto;
  min-width: 180px;
  max-width: 240px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

/* Right — action icons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  color: #475569;
  padding: 0;
  position: relative;
}

.header-icon-btn:hover {
  background: #F1F5F9;
  border-color: #E2E8F0;
  color: #334155;
}

body.theme-dark .header-icon-btn {
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(226, 232, 240, 0.9);
}

body.theme-dark .header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.header-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: inherit;
}

/* Profile avatar — circular with initial */
.header-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #E2E8F0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  padding: 0;
}

.header-avatar-btn:hover {
  background: #F1F5F9;
  border-color: #E2E8F0;
}

body.theme-dark .header-avatar-btn {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .header-avatar-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.header-avatar-initial {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  line-height: 1;
}

body.theme-dark .header-avatar-initial {
  color: rgba(226, 232, 240, 0.95);
}


.icon-btn,
.avatar-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.icon-btn:hover,
.avatar-btn:hover {
  background: var(--surface-hover);
}

.icon-btn:active,
.avatar-btn:active {
  transform: translateY(0.5px);
}

.profile-menu {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 80;
}

.menu-dropdown.is-open { display: block; }

/* Notification bell */
.notification-bell-wrap {
  position: relative;
}
.notification-bell-wrap .icon-btn.notification-bell,
.notification-bell-wrap .header-icon-btn.notification-bell {
  text-decoration: none;
}
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: #dc2626;
  border-radius: 9px;
}
.notification-dropdown {
  min-width: 320px;
  max-width: 380px;
  max-height: 360px;
  padding: 0;
}
.notification-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.notification-dropdown-header a { font-size: 13px; }
.notification-dropdown-list {
  overflow-y: auto;
  max-height: 280px;
}
.notification-dropdown-empty {
  padding: 24px 14px;
  text-align: center;
}
.notification-dropdown-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.notification-dropdown-item:hover { background: var(--surface-hover); }
.notification-dropdown-item-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
}
.notification-dropdown-item-time { font-size: 12px; }

.avatar--user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar--user svg {
  display: block;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.menu-item:hover { background: var(--surface-hover); }

.menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-item--logout {
  color: var(--danger, #c62828);
}

/* Transcript Builder — Canvas ALWAYS visible. Edit = default; Preview = mode toggle only. */
body.tb-builder-page {
  overflow: hidden;
}
body.tb-builder-page .app-main.main-content {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  padding-top: calc(var(--header-height) + 12px);
}

/* Stack fills main; transcript builder row takes remaining space */
body.tb-builder-page .stack.tb-builder-page-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 0 0 1fr;
  grid-template-columns: 1fr;
  overflow: hidden;
}

body.tb-builder-page .stack.tb-builder-page-shell > .admin-page-header {
  grid-row: 1;
}

body.tb-builder-page .stack.tb-builder-page-shell > #tbValidationOverlay,
body.tb-builder-page .stack.tb-builder-page-shell > #tbValidationModal {
  grid-row: 2 / 3;
}

body.tb-builder-page .stack.tb-builder-page-shell > #transcriptBuilderRoot {
  grid-row: 4;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.tb-builder-page #transcriptBuilderRoot.tb-doc {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body.tb-builder-page .tb-editor {
  flex: 1;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Canvas area: absolute fill so it always shows */
body.tb-builder-page .tb-center {
  position: relative;
  min-height: 400px;
}

body.tb-builder-page .tb-canvas-wrapper {
  position: absolute;
  inset: 0;
  min-height: 300px;
}

body.tb-builder-page .tb-center .tb-canvas-scroll {
  min-height: 260px;
}

.tb-doc {
  display: block;
  overflow-x: auto;
}

/* Compact spacing: header, tabs, canvas */
.stack:has(.tb-doc) .admin-page-header {
  padding: 12px 16px;
}

.tb-editor {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: calc(100vh - var(--header-height) - 140px);
  height: calc(100vh - var(--header-height) - 140px);
  gap: 0;
  overflow-x: auto;
}

/* Toolbar: tabs only (zoom moved to canvas); compact. */
.tb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  flex-shrink: 0;
  margin-bottom: 8px;
}

.tb-tab-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0;
}

.tb-tab {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.tb-tab:hover {
  background: var(--surface-hover);
}

.tb-tab.is-active {
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 600;
}

.tb-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon-only buttons (Transcript Builder) */
.tb-doc .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tb-doc .icon-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}
.tb-doc .icon-btn.danger:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.1);
  color: var(--danger, #b91c1c);
  border-color: rgba(185, 28, 28, 0.3);
}
.tb-doc .icon-btn.primary:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary, #3b82f6);
  border-color: rgba(59, 130, 246, 0.3);
}
.tb-doc .icon-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.tb-doc .icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Column action group: show on row hover */
.tb-course-col-row {
  transition: background 0.12s;
}
.tb-course-col-row:hover .tb-col-actions {
  opacity: 1;
}
.tb-col-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
}
@media (hover: none) {
  .tb-col-actions { opacity: 1; }
}

/* Body: left panel + right panel (canvas). Canvas always visible. */
.tb-panels {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-top: 0;
  gap: 12px;
  position: relative;
}

.tb-left {
  width: 260px;
  min-width: 220px;
  max-width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  height: 100%;
  position: relative;
}

.tb-left-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
}

/* Center: canvas (takes remaining space). */
.tb-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tb-center .tb-canvas-scroll {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: none;
  max-width: 100%;
  overflow: auto;
  display: block;
  visibility: visible;
}

/* Right: Selected field properties ~10%. */
.tb-props {
  width: 250px;
  flex: 0 0 250px;
  max-width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  position: relative;
  height: 100%;
  padding: 0;
}

.tb-props-inner {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tb-panel-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.tb-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

.tb-section-title {
  font-weight: 500;
  margin-bottom: 8px;
}

.tb-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 6px;
}

.tb-field {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--card);
  cursor: grab;
  user-select: none;
  margin-bottom: 8px;
  font-size: 13px;
}
.tb-field:hover { background: var(--surface-hover); }
.tb-dragging .tb-field { cursor: grabbing; }

.tb-custom-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tb-custom-add-row {
  width: 100%;
}

.tb-custom-add-row input.form-control {
  width: 100%;
  box-sizing: border-box;
}

.tb-custom-add-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tb-custom-add-actions .form-control {
  flex: 1;
  min-width: 0;
}

.tb-custom-add-actions .btn {
  flex-shrink: 0;
}

.tb-custom-list {
  margin-top: 10px;
  min-height: 32px;
}

.tb-custom-list.tb-custom-list-empty { min-height: 0; }

.tb-custom-list .tb-field,
.tb-custom-list .tb-field-custom {
  margin-bottom: 8px;
  display: block;
}

.tb-custom-list .tb-field:last-child,
.tb-custom-list .tb-field-custom:last-child { margin-bottom: 0; }

.tb-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tb-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 500;
}
.tb-tab.is-active { background: var(--surface-hover); }
.tb-tabpanel { display: none; }
.tb-tabpanel.is-active { display: block; }

/* Email settings / generic tabs */
.tabs { display: flex; gap: 0; list-style: none; margin: 0 0 1rem; padding: 0; border-bottom: 1px solid var(--border, #e0e0e0); }
.tabs .tab { display: inline-block; padding: 0.5rem 1rem; color: var(--text-muted, #666); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab:hover { color: var(--text, #111); }
.tabs .tab.tab--active { color: var(--primary, #2563eb); font-weight: 500; border-bottom-color: var(--primary, #2563eb); }

/* Email template editor: placeholder chips (drag-and-drop / click-to-insert) */
.template-placeholder-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.template-placeholder-chip {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.template-placeholder-chip:hover { background: var(--surface-hover, #f0f0f0); border-color: var(--primary, #2563eb); }
.template-placeholder-chip.template-placeholder-chip--dragging { opacity: 0.7; }
@media (max-width: 768px) {
  .email-template-editor-layout { grid-template-columns: 1fr !important; }
}

.tb-topbar {
  position: sticky;
  top: var(--header-height);
  z-index: 60;
  background: var(--topbar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(10px);
}

.tb-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-form-row { margin-bottom: 10px; }
.tb-form-row label { display:block; font-size: 12px; margin-bottom: 6px; }
.tb-move-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.tb-grid-2 { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tb-pages-control { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tb-logo-drop-zone {
  margin-top: 8px;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  background: var(--bg);
}
.tb-logo-drop-zone.is-drag-over { border-color: var(--primary); background: var(--card); }
.tb-checklist { display:grid; grid-template-columns: 1fr; gap: 6px; }
.tb-checklist label { display:flex; gap:8px; align-items:center; font-size: 13px; }

/* Canvas wrapper: prominence and zoom at bottom-right */
.tb-canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 12px;
}

.tb-canvas-scroll {
  border-radius: 12px;
  background: transparent;
  padding: 16px 0;
  overflow: auto;
  max-width: 100%;
  width: 100%;
  flex: 1;
  min-height: 0;
  align-self: stretch;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.tb-zoom-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.tb-zoom-label {
  font-size: 12px;
  min-width: 40px;
  text-align: center;
  color: var(--text-muted, #64748b);
}
.tb-zoom-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.tb-zoom-btn:hover {
  background: var(--surface-hover);
}
.tb-zoom-inline input[type="range"] {
  width: 80px;
}

.tb-dock {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  display: none;
}
.tb-dock.is-open { display: block; }
.tb-dock-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}
.tb-dock-body {
  padding: 14px;
  max-height: 360px;
  overflow: auto;
}

.tb-panel-section + .tb-panel-section {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}
.tb-panel-subtitle {
  font-weight: 600;
  margin-bottom: 10px;
}

/* Drag cues (fields drag while canvas visible) */
.tb-dragging .tb-section-drop {
  outline: 2px dashed rgba(59, 130, 246, 0.25);
  outline-offset: 4px;
}
.tb-section-drop.is-drag-over {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.45);
}

.tb-section-drop.is-drag-over::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: var(--tb-drop-left, 0%);
  width: var(--tb-drop-width, 0%);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 10px;
  pointer-events: none;
}

.tb-canvas-scroll .tb-zoom-wrap {
  display: block;
  flex-shrink: 0;
  overflow: visible;
}

.tb-pages-scale {
  display: inline-block;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
}

/* Canvas scroll container — no overflow on builder page (handled by inner scroll) */
.stack:has(.tb-doc):not(.tb-builder-page-shell) {
  overflow: auto;
}

.tb-pages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  contain: layout paint;
  width: max-content;
  margin: 0 auto;
  padding: 0 12px;
}

.tb-page {
  width: var(--tb-page-w, 794px);
  height: var(--tb-page-h, 1123px);
  background: #fff;
  color: #111;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  position: relative;
  overflow-y: auto;
  overflow-x: visible;
}

.tb-page-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: 12px;
  overflow: visible;
}

.tb-page-bg-iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
  vertical-align: top;
}

.tb-page-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: var(--tb-mt, 24px) var(--tb-mr, 24px) var(--tb-mb, 24px) var(--tb-ml, 24px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-x: visible;
  min-height: 0;
  min-width: 0;
}

/* Margin guides: dotted rectangle based on Page Setup margins; design mode only */
.tb-margin-guides {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 2px dotted #b91c1c;
  border-radius: 10px;
  pointer-events: none;
  margin: var(--tb-mt, 24px) var(--tb-mr, 24px) var(--tb-mb, 24px) var(--tb-ml, 24px);
}
.tb-preview-mode .tb-margin-guides {
  display: none;
}

@media print {
  .tb-margin-guides {
    display: none !important;
  }
}

.tb-header-zone,
.tb-footer-zone {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  height: 90px;
  background: rgba(148, 163, 184, 0.08);
  pointer-events: none;
}
.tb-header-zone { top: 0; }
.tb-footer-zone { bottom: 0; }

/* Letterhead header: top of transcript (recommended 794 × 120 px); minimal spacing */
.letterhead-header-wrap {
  width: 100%;
  max-height: 120px;
  margin-top: 2px;
  margin-bottom: 2px;
  pointer-events: none;
  flex-shrink: 0;
}
.letterhead-header-img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 120px;
  object-fit: contain;
  object-position: top;
}

/* Letterhead footer: anchored at bottom of page regardless of content height */
.letterhead-footer-wrap {
  width: 100%;
  max-height: 80px;
  margin-top: auto;
  pointer-events: none;
  flex-shrink: 0;
}
.letterhead-footer-img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 80px;
  object-fit: contain;
  object-position: bottom;
}

.tb-doc-title {
  text-align: left;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 14px;
  margin-top: 0;
}

.tb-doc-sub {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(15, 23, 42, 0.72);
  margin-top: 0;
}

.tb-transcript-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.tb-transcript-row .tb-field-block[data-item-type="logo"] {
  flex: 0 0 auto;
  max-width: 140px;
}
.tb-transcript-row .tb-field-block[data-item-type="document_title"] {
  flex: 1;
  min-width: 0;
}

.tb-section-block {
  border-top: 1px solid rgba(15, 23, 42, 0.12);
  /* padding-top: var(--tb-section-gap, 6px); */
}

/* Reserve bottom margin so course table doesn't run to page edge */
.tb-section-block:last-of-type {
  padding-bottom: var(--tb-mb, 24px);
}

/* First section (e.g. Header) sits right under letterhead with minimal gap */
.tb-section-block:first-of-type {
  border-top-color: transparent;
  padding-top: 0;
}

.tb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}

.tb-section-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tb-section-actions {
  display: flex;
  gap: 4px;
}

.tb-section-drop {
  border: 1px dashed rgba(15, 23, 42, 0.22);
  border-radius: 4px;
  padding: 2px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  min-height: 28px;
}

.tb-grid {
  display: grid;
  width: 100%;
  gap: var(--tb-field-gap, 10px) var(--tb-field-gap, 10px);
  grid-template-columns: repeat(var(--tb-cols, 1), minmax(0, 1fr));
  box-sizing: border-box;
}

.tb-grid.one-col { --tb-cols: 1; grid-template-columns: minmax(0, 1fr); }
.tb-grid.two-col { --tb-cols: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tb-grid.three-col { --tb-cols: 3; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tb-field-block.is-insert-before {
  box-shadow: inset 0 3px 0 0 rgba(59, 130, 246, 0.55);
}
.tb-field-block.is-insert-after {
  box-shadow: inset 0 -3px 0 0 rgba(59, 130, 246, 0.55);
}

.tb-section-append-drop {
  margin-top: 0;
  padding: 2px 3px;
  border: 1px dashed rgba(15, 23, 42, 0.22);
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.04);
  font-size: 11px;
  color: rgba(15, 23, 42, 0.55);
  text-align: center;
  min-height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tb-section-append-drop.is-drag-over {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: rgba(15, 23, 42, 0.8);
}
/* Preserve layout space in preview so spacing matches canvas (visibility hides but keeps dimensions) */
.tb-preview-mode .tb-section-append-drop { visibility: hidden; pointer-events: none; }
.tb-preview-mode .tb-section-drop.is-drag-over::after { display: none; }
.tb-preview-mode .tb-field-block.is-selected { outline: none; }
.tb-preview-mode .tb-section-actions { display: none; }
.tb-preview-mode .tb-section-header:not(.tb-section-show-in-pdf) { display: none; }
.tb-preview-mode .tb-section-header.tb-section-show-in-pdf { pointer-events: none; }
.tb-preview-mode .tb-section-drop { border-color: transparent; }

.tb-field-block {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 4px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.92);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.tb-field-block.is-selected {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

.tb-field-block.tb-field-inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25em;
}
.tb-field-block.tb-field-inline .lbl {
  margin-bottom: 0;
}
.tb-field-block.tb-field-inline .lbl::after {
  content: ": ";
}
.tb-field-block .lbl {
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.60);
  margin-bottom: 1px;
}
.tb-field-block .lbl.tb-lbl-serif { font-family: Georgia, 'Times New Roman', serif; }
.tb-field-block .lbl.tb-lbl-sans { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
.tb-field-block .lbl.tb-lbl-mono { font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace; }
.tb-field-block .lbl.tb-lbl-size-small { font-size: 10px; }
.tb-field-block .lbl.tb-lbl-size-default { font-size: 11px; }
.tb-field-block .lbl.tb-lbl-size-large { font-size: 12px; }
.tb-field-block .val {
  font-size: 11px;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.92);
  min-height: 14px;
  padding: 1px 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: break-word;
  word-break: break-word;
}
.tb-field-block .val table {
  max-width: 100%;
  table-layout: fixed;
  overflow-wrap: break-word;
  word-break: break-word;
}
.tb-doc:not(.tb-preview-mode) .tb-field-block .val {
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}
.tb-doc:not(.tb-preview-mode) .tb-field-block .val:empty::before {
  content: "—";
  color: rgba(15, 23, 42, 0.35);
  font-weight: 500;
}
.tb-field-block .val.tb-val-size-small { font-size: 12px; }
.tb-field-block .val.tb-val-size-default { font-size: 13px; }
.tb-field-block .val.tb-val-size-large { font-size: 15px; }

.tb-field-block[data-span="1"] { grid-column: span 1; }
.tb-field-block[data-span="2"] { grid-column: span 2; }
.tb-field-block[data-span="3"] { grid-column: span 3; }

.tb-course-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 11px;
  word-wrap: break-word;
}
.tb-course-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.65);
  border-bottom: 1px solid rgba(15, 23, 42, 0.18);
  padding: 2px 4px;
  overflow-wrap: break-word;
}
.tb-course-table tbody td {
  padding: 2px 4px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.10);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 0;
}

/* Note: Fields/Page/Assets panels are docked (NOT modal) */
/* Preview modal */
.tb-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 160;
}
body.theme-dark .tb-preview-overlay { background: rgba(0,0,0,0.55); }
.tb-preview-overlay.is-open { opacity: 1; pointer-events: auto; }

.tb-preview-modal {
  position: fixed;
  inset: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 170;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.tb-preview-modal.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.tb-preview-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}
.tb-preview-body { padding: 12px; overflow: hidden; height: calc(100% - var(--header-height)); }
.tb-preview-body .tb-canvas-scroll { max-height: none; height: 100%; }

/* Validation modal: shown only when user tries to mark ready or save returns errors */
.tb-validation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 160;
}
.tb-validation-overlay.is-open { opacity: 1; pointer-events: auto; }
.tb-validation-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 94vw);
  max-height: 70vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 170;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
}
.tb-validation-modal.is-open { opacity: 1; pointer-events: auto; }
.tb-validation-modal-inner { display: flex; flex-direction: column; max-height: 70vh; }
.tb-validation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(220, 38, 38, 0.08);
  border-radius: 12px 12px 0 0;
}
.tb-validation-modal-header h3 { color: rgba(185, 28, 28, 0.95); }
.tb-validation-close {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
}
.tb-validation-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  font-size: 13px;
}

.tb-data { overflow-x: auto; overflow-y: visible; }
.tb-data .tb-data-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.tb-data .tb-data-title { font-weight: 500; margin-bottom: 8px; }

.tb-data .admin-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}
.tb-data .admin-table {
  min-width: min-content;
}

/* Right-side Courses drawer (Transcript Builder) */
.tb-courses-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 88%;
  max-width: 1280px;
  min-width: 360px;
  background: var(--card);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  border-left: 1px solid var(--border);
}
.tb-courses-drawer.is-open {
  transform: translateX(0);
}
.tb-courses-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tb-courses-drawer__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.tb-courses-drawer__close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tb-courses-drawer__close:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.tb-courses-drawer__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}
.tb-courses-drawer__body .tb-form-row { margin-bottom: 10px; }
.tb-courses-drawer__body .admin-table-wrap { max-height: 50vh; overflow-y: auto; overflow-x: auto; }

/* Course row editor: wider Term / Grade columns (keys from builder, class tb-col-<key>) */
.tb-courses-drawer__body .admin-table.tb-courses-editor-table .tb-col-term,
.tb-courses-drawer__body .admin-table.tb-courses-editor-table .tb-col-grade_or_marks {
  min-width: 10.5rem;
}
.tb-courses-drawer__body .admin-table.tb-courses-editor-table .tb-col-term .form-control,
.tb-courses-drawer__body .admin-table.tb-courses-editor-table .tb-col-grade_or_marks .form-control {
  width: 100%;
  min-width: 9.5rem;
  box-sizing: border-box;
}

.tb-courses-drawer__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.tb-courses-drawer-trigger {
  cursor: pointer;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  text-align: center;
  margin-top: 8px;
}
.tb-courses-drawer-trigger:hover {
  background: var(--border);
}

@media (max-width: 640px) {
  .tb-topbar { flex-wrap: wrap; }
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
  transition: width var(--transition);
  z-index: 40;
  overflow: hidden;
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
}

.sidebar-nav .sidebar-toggle.nav-item--toggle {
  width: 100%;
  justify-content: flex-start;
  cursor: pointer;
  border: none;
  text-align: left;
  font: inherit;
}

.nav-item--toggle .nav-label {
  width: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--sidebar-fg-active);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--sidebar-mark-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  font-size: 12px;
  color: var(--sidebar-fg-active);
}

.sidebar-brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  border-color: var(--sidebar-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-fg-active);
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.10); }

.nav-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(226, 232, 240, 0.60);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.sidebar-header .nav-section-title {
  flex: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  color: var(--sidebar-fg);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.app-sidebar a.nav-item:hover,
.app-sidebar a.nav-item {
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-fg-active);
}

.nav-item.nav-item--active {
  background: var(--primary-gradient);
  border-left-color: transparent;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.25);
}

/* Ensure active nav text and icon are white (overrides page-specific .nav-item color) */
body .app-sidebar .nav-item.nav-item--active,
body .app-sidebar .nav-item.nav-item--active .nav-label,
body .app-sidebar .nav-item.nav-item--active .nav-icon {
  color: #fff;
}

.nav-icon {
  width: 20px;
  height: 20px;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex: 0 0 20px;
  font-size: 14px;
  line-height: 1;
}

.nav-icon::before {
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
}

.nav-icon--dashboard::before { content: "⊞"; }
.nav-icon--org::before { content: "◉"; font-size: 10px; }
.nav-icon--users::before { content: "👤"; font-size: 12px; }
.nav-icon--contract::before { content: "📄"; font-size: 12px; }
.nav-icon--credit::before { content: "$"; font-weight: 600; }
.nav-icon--rule::before { content: "≡"; font-weight: 600; }
.nav-icon--payment::before { content: "💳"; font-size: 12px; }
.nav-icon--folder::before { content: "📁"; font-size: 12px; }
.nav-icon--requests::before { content: "📋"; font-size: 12px; }
.nav-icon--tx::before { content: "⇄"; font-weight: 600; }
.nav-icon--chart::before { content: "📊"; font-size: 12px; }
.nav-icon--ticket::before { content: "🎫"; font-size: 12px; }
.nav-icon--bell::before { content: "🔔"; font-size: 12px; }
.nav-icon--settings::before { content: "⚙"; font-size: 12px; }

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main – gradient continues from header into content for cohesive look */
.app-main {
  padding: 32px;
  padding-top: calc(var(--header-height) + 24px);
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition);
  min-height: 100%;
  flex: 1 0 auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: linear-gradient(180deg, #f3e8ff 0%, #eef4ff 40%, #f8fafc 100%);
}

body.theme-dark .app-main {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.06) 30%, var(--bg) 100%);
}

/* Collapsed sidebar */
.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); }
.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed-width); }
.sidebar-collapsed .nav-item { justify-content: center; gap: 0; }
.sidebar-collapsed .nav-label { opacity: 0; width: 0; }
.sidebar-collapsed .nav-section-title { opacity: 0; height: 0; margin: 0; overflow: hidden; }
.sidebar-collapsed .nav-item--toggle .nav-label { width: 0; }
.sidebar-collapsed .sidebar-brand-text { opacity: 0; width: 0; overflow: hidden; }
.sidebar-collapsed .nav-icon { opacity: 1; visibility: visible; flex: 0 0 auto; min-width: 24px; min-height: 24px; }

/* Standalone pages (auth/public) */
.standalone-main {
  flex: 1 0 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

/* Global footer – all portals (matches sidebar background) */
.global-footer {
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--sidebar-bg);
  font-size: 12px;
  color: var(--sidebar-fg);
}

.global-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.global-footer-left {
  order: 1;
  flex: 1 1 0;
  min-width: 0;
}

.global-footer-center {
  order: 2;
  flex: 0 0 auto;
  text-align: center;
}

.global-footer-right {
  order: 3;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.global-footer-link {
  color: var(--sidebar-fg);
  transition: color var(--transition);
}

.global-footer-link:hover {
  color: var(--sidebar-fg-active);
}

.global-footer-sep {
  color: rgba(255, 255, 255, 0.4);
  user-select: none;
}

@media (max-width: 640px) {
  .global-footer-inner {
    flex-direction: column;
    text-align: center;
    padding: 12px 16px;
  }

  .global-footer-left,
  .global-footer-center,
  .global-footer-right {
    order: unset;
    flex: none;
    justify-content: center;
  }

  .global-footer-center {
    text-align: center;
  }
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
}

/* Tab-based auth page: centered card, gradient background */
.auth-wrap--tabs {
  max-width: 480px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
[data-layout="auth"] .standalone-main {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: #f4f7fb;
  background-image:
    radial-gradient(circle at 80% 10%, rgba(99, 102, 241, 0.2) 0%, rgba(167, 139, 250, 0.08) 30%, transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(34, 211, 238, 0.2) 0%, rgba(99, 102, 241, 0.06) 35%, transparent 45%),
    linear-gradient(180deg, #f4f7fb 0%, #eef2f7 100%);
  overflow: hidden;
}
[data-layout="auth"] .standalone-main > * {
  position: relative;
  z-index: 1;
}
.auth-tabs-card {
  width: 100%;
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
}
.auth-tabs-card__top {
  text-align: center;
  margin-bottom: 24px;
}
.auth-tabs-logo {
  display: block;
  max-height: 44px;
  max-width: 140px;
  margin: 0 auto 16px;
}
.auth-tabs-brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.auth-tabs-welcome {
  font-size: 20px;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.auth-tabs-subtext {
  font-size: 14px;
  color: #64748B;
  margin: 0;
  line-height: 1.45;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
}
.auth-tabs__tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  background: #E5E7EB;
  color: #4B5563;
}
.auth-tabs__tab:hover {
  background: #D1D5DB;
  color: #374151;
}
.auth-tabs__tab--active {
  background: #0F172A;
  color: #fff;
}
.auth-tabs__tab:focus-visible {
  outline: 2px solid #0F172A;
  outline-offset: 2px;
}
.auth-tabs__tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.auth-tabs__tab-icon svg {
  flex-shrink: 0;
}
.auth-tabs-divider {
  height: 1px;
  background: #E5E7EB;
  margin: 20px 0 24px;
}
.auth-tabs-alert {
  margin-bottom: 16px;
}
.auth-tabs-panel {
  animation: auth-tabs-fade 0.25s ease;
}
.auth-tabs-panel--active {
  display: block;
}
@keyframes auth-tabs-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.auth-tabs-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-tabs-form--request {
  gap: 14px;
}
.auth-tabs-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-tabs-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.auth-tabs-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-tabs-input-wrap .auth-tabs-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  pointer-events: none;
}
.auth-tabs-input-wrap .auth-tabs-input {
  padding-left: 40px;
}
.auth-tabs-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.auth-tabs-input::placeholder {
  color: #9CA3AF;
}
.auth-tabs-input:focus {
  outline: none;
  border-color: #0F172A;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}
.auth-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.auth-tabs-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4B5563;
  cursor: pointer;
}
.auth-tabs-checkbox__input {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  accent-color: #0F172A;
}
.auth-tabs-checkbox__label {
  user-select: none;
}
.auth-tabs-link {
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  text-decoration: none;
}
.auth-tabs-link:hover {
  text-decoration: underline;
}
.auth-tabs-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.02s ease;
}
.auth-tabs-btn--primary {
  background: #0F172A;
  color: #fff;
  margin-top: 4px;
}
.auth-tabs-btn--primary:hover {
  background: #1E293B;
}
.auth-tabs-btn:active {
  transform: scale(0.99);
}
.auth-tabs-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #E5E7EB;
  font-size: 13px;
  text-align: center;
}
.auth-tabs-footer a {
  font-weight: 600;
  color: #0F172A;
  text-decoration: none;
}
.auth-tabs-footer a:hover {
  text-decoration: underline;
}
.auth-tabs-footer-sep {
  margin: 0 8px;
  color: #9CA3AF;
}
.auth-tabs-helper {
  font-size: 12px;
  color: #64748B;
  margin: 0 0 4px;
  line-height: 1.5;
}
.auth-tabs-required {
  color: #b91c1c;
}
.auth-tabs-request-result {
  margin-bottom: 16px;
}
.auth-tabs-request-section {
  margin-bottom: 20px;
}
.auth-tabs-request-section:last-of-type {
  margin-bottom: 16px;
}
.auth-tabs-request-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 6px;
}
.auth-tabs-request-section-desc {
  font-size: 12px;
  color: #64748B;
  margin: 0 0 12px;
  line-height: 1.45;
}
.auth-tabs-request-form .auth-tabs-divider {
  margin: 16px 0 20px;
}
.auth-tabs-request-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.auth-tabs-request-form .auth-tabs-field {
  margin-bottom: 0;
}
.auth-tabs-field--full {
  grid-column: 1 / -1;
}
.auth-tabs-request-form .auth-tabs-helper {
  margin: 16px 0 8px;
}
@media (max-width: 480px) {
  .auth-wrap--tabs {
    max-width: 90%;
  }
  .auth-tabs-card {
    padding: 24px 20px;
  }
  .auth-tabs__tab {
    padding: 8px 12px;
    font-size: 13px;
  }
  .auth-tabs__tab-icon {
    display: none;
  }
  .auth-tabs-request-grid {
    grid-template-columns: 1fr;
  }
}

/* Register organization: wider card and form grid */
.auth-wrap--register {
  max-width: 560px;
}
.auth-card-register .card-body {
  padding: 28px 32px;
}
.auth-register-header {
  margin-bottom: 4px;
}
.auth-register-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  margin-top: 8px;
}
.auth-register-field--full {
  grid-column: 1 / -1;
}
.auth-register-submit {
  grid-column: 1 / -1;
  margin-top: 8px;
}
@media (max-width: 520px) {
  .auth-register-grid {
    grid-template-columns: 1fr;
  }
  .auth-card-register .card-body {
    padding: 20px 18px;
  }
}

/* Mandatory field asterisk */
.form-label-required {
  color: #b91c1c;
  font-weight: 600;
}

/* Password field with show/hide toggle */
.auth-password-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-password-wrap:focus-within {
  border-color: rgba(59, 130, 246, 0.60);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}
.auth-password-wrap:has(.is-invalid) {
  border-color: rgba(220, 38, 38, 0.55);
}
.auth-password-wrap .form-control {
  border: none;
  border-radius: 10px 0 0 10px;
  flex: 1;
  min-width: 0;
}
.auth-password-wrap .form-control:focus {
  box-shadow: none;
}
.auth-password-toggle {
  padding: 10px 14px;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0 10px 10px 0;
  background: var(--input-bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.auth-password-toggle:hover {
  color: var(--text);
  background: var(--card);
}
.auth-password-section .auth-password-wrap {
  margin-bottom: 8px;
}
.auth-password-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 22px;
}
.auth-password-strength-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.auth-password-strength-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.2s, background 0.2s;
}
.auth-password-strength-fill[data-strength="0"] { width: 25%; background: #dc2626; }
.auth-password-strength-fill[data-strength="1"] { width: 50%; background: #ea580c; }
.auth-password-strength-fill[data-strength="2"] { width: 75%; background: #ca8a04; }
.auth-password-strength-fill[data-strength="3"] { width: 100%; background: #16a34a; }
.auth-password-strength-text {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
}
.auth-password-requirements {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.auth-password-requirements li {
  position: relative;
  padding-left: 18px;
}
.auth-password-requirements li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.auth-password-requirements li.auth-password-requirement--met::before {
  background: #16a34a;
}
.auth-password-requirements li.auth-password-requirement--met {
  color: var(--text);
}

/* Split layout: allow wider card so two columns sit side-by-side */
.auth-wrap--split {
  max-width: 720px;
}

/* Split login: brand above card, then two-column card (login | request transcript) */
.auth-split-header {
  text-align: center;
  margin-bottom: 20px;
}
.auth-split-header .auth-brand {
  margin-bottom: 0;
}
.auth-logo-img {
  display: block;
  max-height: 48px;
  max-width: 160px;
  margin: 0 auto;
}

.auth-wrap .auth-card-split { width: 100%; }
.auth-wrap .auth-card-split__body { padding: 0; }
.auth-card-split__inner {
  display: flex;
  flex-wrap: nowrap;
  min-height: 320px;
}
.auth-login-col,
.auth-request-tracker-col {
  flex: 1 1 0;
  min-width: 0;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-login-col-head { margin-bottom: 2px; }
.auth-login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.auth-login-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}
.auth-divider {
  width: 1px;
  min-height: 240px;
  align-self: stretch;
  background: var(--border);
  flex-shrink: 0;
}
.auth-request-tracker-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.auth-request-tracker-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
  flex: 1 0 auto;
}
.auth-request-tracker-note {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
}
.auth-request-tracker-note strong { font-weight: 700; }
.auth-login-links {
  font-size: 13px;
  margin-top: 4px;
}
.auth-login-links a { color: var(--text); font-weight: 600; text-decoration: underline; }
.auth-login-links-sep { margin: 0 6px; color: var(--muted); }

/* Login problems page */
.auth-login-problems-content { margin: 8px 0 20px; }
.auth-login-problems-section { margin-bottom: 18px; }
.auth-login-problems-section:last-of-type { margin-bottom: 0; }
.auth-login-problems-heading { font-size: 14px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.auth-login-problems-section p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: var(--text); }
.auth-login-problems-section ul { margin: 0 0 8px; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--text); }

/* Login problems / Can't sign in? recovery page */
.auth-wrap--problems {
  padding: 24px 16px 40px;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.recovery-page {
  width: 100%;
  max-width: 600px;
}

/* Header */
.recovery-page__header {
  margin-bottom: 24px;
  text-align: center;
}
.recovery-page__title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.25;
}
.recovery-page__subtitle {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

/* Primary action cards */
.recovery-page__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.recovery-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px 20px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.recovery-card:hover {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
  transform: translateY(-1px);
}
.recovery-card:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}
.recovery-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary, #2563eb);
}
.recovery-card__icon svg {
  flex-shrink: 0;
}
.recovery-card__content {
  min-width: 0;
}
.recovery-card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.recovery-card__desc {
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  margin: 0;
}
.recovery-card__arrow {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary, #2563eb);
  opacity: 0.9;
}
.recovery-card:hover .recovery-card__arrow {
  opacity: 1;
}

/* Divider */
.recovery-page__divider {
  border: none;
  border-top: 1px solid var(--border, #e2e8f0);
  margin: 0 0 20px;
}

/* Secondary help section */
.recovery-page__help {
  margin-bottom: 28px;
}
.recovery-page__help-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 14px;
}
.recovery-page__help-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.recovery-help-item {
  padding: 12px 14px;
  background: var(--bg, #f8fafc);
  border-radius: 8px;
  border: 1px solid transparent;
}
.recovery-help-item__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}
.recovery-help-item__icon {
  display: inline-flex;
  color: var(--muted);
  flex-shrink: 0;
}
.recovery-help-item__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
  padding-left: 24px;
}
.recovery-page__link {
  color: var(--primary, #2563eb);
  font-weight: 500;
  text-decoration: underline;
}
.recovery-page__link:hover {
  text-decoration: none;
}
.recovery-page__link:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

/* Footer */
.recovery-page__footer {
  text-align: center;
}
.recovery-page__back {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.recovery-page__back:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
body.theme-dark .recovery-page__back:hover {
  background: rgba(255, 255, 255, 0.06);
}
.recovery-page__back:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 480px) {
  .auth-wrap--problems { padding: 20px 12px 32px; }
  .recovery-page__header { margin-bottom: 20px; }
  .recovery-page__title { font-size: 22px; }
  .recovery-card {
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 16px;
  }
  .recovery-card__arrow { grid-column: 2; justify-self: start; margin-top: 2px; }
  .recovery-help-item__text { padding-left: 0; }
}

@media (max-width: 640px) {
  .auth-card-split__inner { flex-direction: column; min-height: 0; }
  .auth-divider { width: 100%; height: 1px; min-height: 0; align-self: center; margin: 0 20px; }
  .auth-login-col,
  .auth-request-tracker-col { min-width: 0; padding: 24px 20px; }
}

/* Transcript request modal (login page) */
.transcript-request-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.transcript-request-modal[hidden] {
  display: none !important;
}
.transcript-request-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: default;
}
.transcript-request-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
}
.transcript-request-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.transcript-request-modal-title {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.transcript-request-section {
  margin-bottom: 24px;
}
.transcript-request-section:last-of-type { margin-bottom: 20px; }
.transcript-request-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary, #2563eb);
  margin: 0 0 6px;
}
.transcript-request-section-desc {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.5;
}
.transcript-form-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  align-items: start;
}
.transcript-form-label {
  font-size: 14px;
  color: var(--text);
  padding-top: 10px;
}
.transcript-form-label .required { color: #b91c1c; }
.transcript-form-input { margin: 0; }
.transcript-form-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  grid-column: 2;
}
.transcript-request-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.transcript-request-modal-cancel {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
@media (max-width: 480px) {
  .transcript-form-grid {
    grid-template-columns: 1fr;
  }
  .transcript-form-label { padding-top: 0; }
  .transcript-form-input-group { grid-column: 1; }
}

.auth-brand {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 750;
  margin-bottom: 10px;
}

/* Content primitives */
.page-title {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body { padding: 18px; }

.stack { display: grid; gap: 14px; }

.form-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.form-control:focus {
  border-color: rgba(59, 130, 246, 0.60);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

.is-invalid { border-color: rgba(220, 38, 38, 0.55); }

.invalid-feedback {
  margin-top: 6px;
  font-size: 12px;
  color: #b91c1c;
}

.form-row { display: grid; gap: 12px; }

/* Report filter forms: flex wrap, actions right-aligned */
.card .card-body:has(> form.report-filters) {
  max-width: 100%;
  box-sizing: border-box;
}

form.report-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

form.report-filters .report-filters-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Direct filter cells only (not nested wrappers) */
form.report-filters .report-filters-fields > div:not(.report-filters-apply) {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: min(240px, 100%);
  box-sizing: border-box;
}

form.report-filters .report-filters-fields .form-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

form.report-filters .report-filters-apply {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  box-sizing: border-box;
}

form.report-filters .report-filters-fields .form-control,
form.report-filters .report-filters-fields input.form-control,
form.report-filters .report-filters-fields select.form-control,
form.report-filters .report-filters-fields textarea.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Nested Apply inside .report-filters-fields: keep on end of filter row, not full-width band */
form.report-filters .report-filters-fields > .report-filters-apply {
  margin-left: auto;
  flex: 0 0 auto;
  max-width: none;
  min-width: 0;
}

/*
 * Transcript storage activity + Financial Reports: same filter card UI.
 * Form is a column so the grid always gets full card width (no squeeze vs. Apply/Clear).
 * Row 1: four equal columns; row 2: fifth field + compact per page; actions on their own row, right-aligned.
 */
form.report-filters.report-filters--storage-layout {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

form.report-filters.report-filters--storage-layout .report-filters-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  width: 100%;
  max-width: 100%;
  flex: none;
  min-width: 0;
  box-sizing: border-box;
}

form.report-filters.report-filters--storage-layout .report-filters-fields > div:not(.report-filters-apply) {
  flex: unset;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

form.report-filters.report-filters--storage-layout .report-filters-fields > div:not(.report-filters-apply):last-child {
  max-width: 140px;
}

form.report-filters.report-filters--storage-layout .report-filters-fields .form-control,
form.report-filters.report-filters--storage-layout .report-filters-fields input.form-control,
form.report-filters.report-filters--storage-layout .report-filters-fields select.form-control {
  min-width: 0;
  max-width: 100%;
}

form.report-filters.report-filters--storage-layout .report-filters-apply {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
  justify-content: flex-end;
  flex-wrap: wrap;
  box-sizing: border-box;
}

@media (max-width: 1024px) {
  form.report-filters.report-filters--storage-layout .report-filters-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  form.report-filters.report-filters--storage-layout .report-filters-fields {
    grid-template-columns: 1fr;
  }

  form.report-filters.report-filters--storage-layout .report-filters-fields > div:not(.report-filters-apply):last-child {
    max-width: none;
  }
}

/* Filter layout utilities (optional markup) */
.filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.filter-item {
  flex: 1 1 180px;
  min-width: 150px;
  max-width: 100%;
  box-sizing: border-box;
}

.filter-date {
  flex: 0 0 160px;
  max-width: 180px;
  min-width: 0;
  box-sizing: border-box;
}

.filter-sm {
  flex: 0 0 110px;
  max-width: 130px;
  min-width: 0;
  box-sizing: border-box;
}

.filter-lg {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 100%;
  box-sizing: border-box;
}

.filters-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
  justify-content: flex-end;
  align-items: center;
  box-sizing: border-box;
}

.filters-container input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
.filters-container select,
.filters-container textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 36px;
}

.filters-container textarea {
  height: auto;
  min-height: 36px;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-section {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 20px;
}
.form-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.form-section-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.btn:active { transform: translateY(0.5px); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.btn-icon .action-icon {
  display: block;
}

.btn-sm.btn-icon {
  padding: 6px;
}

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

.btn-primary:hover { filter: brightness(0.95); }

.btn-text {
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}
.btn-text:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.btn-secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Admin reporting: secondary buttons and pagination */
.admin-reporting-page .btn:not(.btn-primary) {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.admin-reporting-page .btn:not(.btn-primary):hover {
  background: var(--surface-hover);
}
.admin-reporting-page .pagination-wrap .btn {
  text-decoration: none;
}

/* Let wide tables scroll inside wrappers instead of stretching the layout */
.admin-reporting-page .card > .card-body {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-reporting-page > .card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Grid stack children default to min-width:auto and can force page overflow */
.stack.admin-reporting-page {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Internal user permissions (add/edit) */
.permissions-section {
  margin-top: 4px;
}
.permissions-section .permissions-intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.45;
}
.permissions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 640px) {
  .permissions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 960px) {
  .permissions-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.permission-module {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.permission-module:hover {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.permission-module-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.permission-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.permission-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg, rgba(0, 0, 0, 0.02));
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}
.permission-option:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.06);
}
.permission-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand, #2563eb);
  cursor: pointer;
  flex-shrink: 0;
}
.permission-option input:checked + .permission-option-label {
  font-weight: 600;
  color: var(--text);
}
.permission-option:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.08);
}
.permission-option-label {
  color: var(--text);
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.alert-success {
  border-color: rgba(34, 197, 94, 0.4);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.14) 100%);
  color: #166534;
  border-left: 4px solid #22c55e;
}

.alert-danger {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.08);
}

.alert-warning {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.10);
}

/* Transcript AI confidence: red <0.6, yellow 0.6–0.8, green >0.8 */
.confidence-low { background: rgba(220, 38, 38, 0.08); }
.confidence-mid { background: rgba(245, 158, 11, 0.12); }
.confidence-high { background: rgba(34, 197, 94, 0.08); }
.confidence-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 500;
}
.confidence-badge.confidence-low { background: rgba(220, 38, 38, 0.2); color: #b91c1c; }
.confidence-badge.confidence-mid { background: rgba(245, 158, 11, 0.25); color: #b45309; }
.confidence-badge.confidence-high { background: rgba(34, 197, 94, 0.2); color: #15803d; }

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

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.85em; font-weight: 500; }
.badge-success { background: rgba(34, 197, 94, 0.2); color: #15803d; }
.badge-warning { background: rgba(245, 158, 11, 0.25); color: #b45309; }
.badge-danger { background: rgba(220, 38, 38, 0.2); color: #b91c1c; }

/* Utility widths */
.narrow {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* Wide form layout: use horizontal space, multi-column sections */
.form-page-wide {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/* Settings / Profile page */
.settings-page {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: 0 4px;
  gap: 20px;
}

.settings-page__header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.settings-page__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  flex-shrink: 0;
}

.settings-page__header-text {
  flex: 1;
  min-width: 0;
}

.settings-page__title {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.settings-page__subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.settings-page__back {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.settings-page__back:hover {
  color: var(--primary);
}

.settings-page__alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.settings-page__alert--success {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.settings-page__alert--error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.settings-page__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 20px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 4px;
}

.settings-page__tab {
  padding: 10px 18px;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  font-weight: 500;
}

.settings-page__tab:hover {
  color: var(--text);
  background: var(--surface);
}

.settings-page__tab--active {
  color: var(--primary);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 1px 2px rgba(59, 130, 246, 0.08);
}

.settings-page__panel {
  display: none;
}

.settings-page__panel--active {
  display: block;
}

.settings-page__alert {
  margin: 0;
}

.settings-page__card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.settings-page--modern .settings-page__card {
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-page__card--timezone {
  overflow: hidden;
  border-radius: 12px;
  padding: 0;
}

.settings-page__card-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
  border-bottom: 1px solid var(--border);
}

.settings-page__card-head--timezone {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.settings-page__card-head-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-page__timezone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.settings-page__timezone-value-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.settings-page__timezone-now {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  font-size: 0.9rem;
}

.settings-page__timezone-edit-btn {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  min-width: 44px;
  height: 40px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: var(--card);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.settings-page__timezone-edit-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2);
}

.settings-page__timezone-edit-btn-text {
  white-space: nowrap;
}

.settings-page__timezone-edit {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.settings-page__timezone-edit-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.settings-page__timezone-edit .timezone-combobox {
  width: 100%;
  min-width: 0;
}

.settings-page__timezone-update-row {
  flex-shrink: 0;
}

.settings-page__timezone-now-label {
  font-weight: 600;
  color: var(--text);
}

.settings-page__timezone-now-gmt {
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  font-weight: 500;
}

.settings-page__timezone-now-time {
  color: var(--muted);
  font-size: 0.85rem;
}

.settings-page__card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  flex-shrink: 0;
}

.settings-page__card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.settings-page__card-desc {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.settings-page__card-body {
  padding: 24px;
}

.settings-page__card-body--timezone {
  padding: 20px 24px;
}

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

.settings-page__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-page__fields--vertical {
  grid-template-columns: 1fr;
}

.settings-page__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-page__hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.settings-page__submit {
  align-self: flex-start;
  padding: 10px 20px;
  font-weight: 600;
  border-radius: 10px;
}

.settings-page__select {
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
}

/* Searchable timezone dropdown — stays inside card, matches input width */
.timezone-combobox {
  position: relative;
  width: 100%;
  min-width: 0;
}

.timezone-combobox__input {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.timezone-combobox__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.timezone-combobox__arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.6rem;
  color: var(--muted);
}

.timezone-combobox__list {
  position: relative;
  width: 100%;
  margin: 6px 0 0;
  padding: 6px 0;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  z-index: 1;
}

.timezone-combobox__option {
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: normal;
  line-height: 1.4;
  word-break: break-word;
  transition: background 0.15s ease;
}

.timezone-combobox__option:hover {
  background: var(--surface);
}

.timezone-combobox__option:focus {
  background: var(--surface);
  outline: none;
}

.timezone-combobox__option--empty {
  color: var(--muted);
  cursor: default;
}

.form-control--readonly {
  opacity: 0.85;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .settings-page__header {
    flex-direction: column;
    align-items: flex-start;
  }
  .settings-page__fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .settings-page__card-head--timezone {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-page__timezone-row {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-page__timezone-edit-btn {
    align-self: flex-start;
  }
}

.form-sections-grid {
  display: grid;
  gap: 20px;
}
@media (min-width: 768px) {
  .form-sections-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.form-section-full-width {
  grid-column: 1 / -1;
}
@media (min-width: 600px) {
  .form-page-wide .form-row {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Minimal hover affordance on cards/rows */
.clickable {
  transition: transform var(--transition), box-shadow var(--transition);
}
.clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.06), 0 10px 22px rgba(0, 0, 0, 0.06);
}

/* Admin tables (minimal, responsive) */
.admin-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Reporting subpages: same pattern as transcript storage — title first, exports on the next row, left-aligned */
.admin-reporting-page > .admin-page-header {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.admin-reporting-page > .admin-page-header > div:last-child:not(:only-child) {
  justify-content: flex-start;
}

.tb-sticky-action-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.admin-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-table-wrap {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table thead th {
  padding: 12px 10px;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.admin-table thead th a.admin-th-sort {
  color: var(--text);
  text-decoration: none;
}
.admin-table thead th a.admin-th-sort:hover {
  text-decoration: underline;
  color: var(--primary);
}

.admin-table tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  vertical-align: top;
}

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

.admin-table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.08);
}

body.theme-dark .admin-table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.10);
}

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

/* Financial report: scroll inside wrapper only (same intent as .table-wrapper) */
.admin-table-wrap.admin-table-wrap--financial-report {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.admin-table--financial-report {
  width: 100%;
  min-width: 56rem;
  table-layout: fixed;
  font-size: 12px;
}

.admin-table--financial-report thead th,
.admin-table--financial-report tbody td {
  padding: 8px 6px;
  vertical-align: middle;
}

.admin-table--financial-report thead th {
  font-size: 11px;
  white-space: normal;
}

.admin-table--financial-report thead th a {
  white-space: normal !important;
}

.admin-table--financial-report .fin-th-type,
.admin-table--financial-report .fin-td-type {
  width: 5.5rem;
  text-align: center;
}

.admin-table--financial-report .fin-th-id,
.admin-table--financial-report .fin-td-id {
  width: 3.25rem;
}

.admin-table--financial-report .fin-th-gateway,
.admin-table--financial-report .fin-td-gateway,
.admin-table--financial-report .fin-th-status,
.admin-table--financial-report .fin-td-status {
  width: 4.5rem;
}

.admin-table--financial-report .fin-th-org,
.admin-table--financial-report .fin-td-org {
  width: 9rem;
}

.admin-table--financial-report .fin-th-campus,
.admin-table--financial-report .fin-td-campus {
  width: 7rem;
}

.admin-table--financial-report .fin-th-plan,
.admin-table--financial-report .fin-td-plan {
  width: 10rem;
}

.admin-table--financial-report .fin-th-credits,
.admin-table--financial-report .fin-td-credits {
  width: 3.25rem;
  text-align: right;
}

.admin-table--financial-report .fin-th-amount,
.admin-table--financial-report .fin-td-amount {
  width: 5.5rem;
  text-align: right;
}

.admin-table--financial-report .fin-th-discount,
.admin-table--financial-report .fin-td-discount,
.admin-table--financial-report .fin-th-granted,
.admin-table--financial-report .fin-td-granted {
  width: 4rem;
  text-align: center;
}

.admin-table--financial-report .fin-th-created,
.admin-table--financial-report .fin-td-created {
  width: 8.5rem;
  font-variant-numeric: tabular-nums;
}

.admin-table--financial-report .fin-th-initiated,
.admin-table--financial-report .fin-td-initiated {
  width: 8rem;
}

/* nowrap / ellipsis on body cells only — headers stay wrap-friendly */
.admin-table--financial-report tbody .fin-td-type,
.admin-table--financial-report tbody .fin-td-id,
.admin-table--financial-report tbody .fin-td-gateway,
.admin-table--financial-report tbody .fin-td-status {
  white-space: nowrap;
}

.admin-table--financial-report tbody .fin-td-org,
.admin-table--financial-report tbody .fin-td-campus,
.admin-table--financial-report tbody .fin-td-plan,
.admin-table--financial-report tbody .fin-td-initiated {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table--financial-report tbody .fin-td-credits,
.admin-table--financial-report tbody .fin-td-amount,
.admin-table--financial-report tbody .fin-td-discount,
.admin-table--financial-report tbody .fin-td-granted,
.admin-table--financial-report tbody .fin-td-created {
  white-space: nowrap;
}

.admin-table--financial-report .fin-td-id code {
  font-size: 11px;
}

/* Credit consumption logs: fixed columns, header/body alignment, long text */
.admin-table-wrap--consumption-log {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table--consumption-log {
  table-layout: fixed;
  width: 100%;
  min-width: 44rem;
}

.admin-table--consumption-log thead th {
  padding: 12px 14px;
  vertical-align: bottom;
  line-height: 1.35;
  white-space: normal;
}

.admin-table--consumption-log .consumption-th-sort:hover {
  text-decoration: underline;
  color: var(--primary);
}

.admin-table--consumption-log tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-table--consumption-log .consumption-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: 100%;
  text-decoration: none;
  color: inherit;
}

.admin-table--consumption-log .consumption-th-sort__icon {
  flex-shrink: 0;
  font-size: 0.82em;
  opacity: 0.8;
  line-height: 1;
}

.admin-table--consumption-log .col-ts {
  width: 11.5rem;
  min-width: 10rem;
  text-align: left;
}

.admin-table--consumption-log .col-student {
  width: 26%;
  min-width: 9rem;
  text-align: left;
}

.admin-table--consumption-log .col-credits {
  width: 5.25rem;
  min-width: 4.75rem;
  text-align: center;
}

.admin-table--consumption-log .col-actor {
  width: 24%;
  min-width: 9rem;
  text-align: left;
}

.admin-table--consumption-log .col-campus {
  width: 18%;
  min-width: 8rem;
  text-align: left;
}

.admin-table--consumption-log .col-credits .consumption-th-sort {
  justify-content: center;
  width: 100%;
}

@media (max-width: 640px) {
  .admin-table--consumption-log {
    min-width: 36rem;
  }
}

/* Transcript storage activity (admin reporting): fixed layout, column alignment, ellipsis */
.admin-table-wrap--transcript-storage {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table--transcript-storage {
  table-layout: fixed;
  width: 100%;
  min-width: 52rem;
}

.admin-table--transcript-storage col.tsa-col-file { width: 22%; }
.admin-table--transcript-storage col.tsa-col-student-name { width: 13%; }
.admin-table--transcript-storage col.tsa-col-student-id { width: 9%; }
.admin-table--transcript-storage col.tsa-col-program { width: 15%; }
.admin-table--transcript-storage col.tsa-col-campus { width: 13%; }
.admin-table--transcript-storage col.tsa-col-storage-date { width: 14%; }
.admin-table--transcript-storage col.tsa-col-stored-by { width: 14%; }

.admin-table--transcript-storage thead th {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.35;
  white-space: normal;
}

.admin-table--transcript-storage tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.4;
}

.admin-table--transcript-storage .tsa-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: 100%;
  text-decoration: none;
  color: inherit;
}

.admin-table--transcript-storage .tsa-th-sort:hover {
  text-decoration: underline;
  color: var(--primary);
}

.admin-table--transcript-storage .tsa-th-sort__icon {
  flex-shrink: 0;
  font-size: 0.82em;
  opacity: 0.85;
  line-height: 1;
}

.admin-table--transcript-storage .tsa-th-sort--end {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  text-align: right;
}

.admin-table--transcript-storage th.tsa-th-file,
.admin-table--transcript-storage td.tsa-td-file,
.admin-table--transcript-storage th.tsa-th-student-name,
.admin-table--transcript-storage td.tsa-td-student-name,
.admin-table--transcript-storage th.tsa-th-program,
.admin-table--transcript-storage td.tsa-td-program,
.admin-table--transcript-storage th.tsa-th-campus,
.admin-table--transcript-storage td.tsa-td-campus,
.admin-table--transcript-storage th.tsa-th-stored-by,
.admin-table--transcript-storage td.tsa-td-stored-by {
  text-align: left;
}

.admin-table--transcript-storage th.tsa-th-student-id,
.admin-table--transcript-storage td.tsa-td-student-id {
  text-align: center;
}

.admin-table--transcript-storage th.tsa-th-storage-date,
.admin-table--transcript-storage td.tsa-td-storage-date {
  text-align: right;
}

.admin-table--transcript-storage td.tsa-td-file .tsa-cell-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.admin-table--transcript-storage td.tsa-td-student-name,
.admin-table--transcript-storage td.tsa-td-program,
.admin-table--transcript-storage td.tsa-td-campus,
.admin-table--transcript-storage td.tsa-td-stored-by {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-table--transcript-storage td.tsa-td-storage-date {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .admin-table--transcript-storage {
    min-width: 44rem;
  }
}

/* Credit purchase history (admin reporting): fixed widths, alignment, ellipsis */
.admin-table-wrap--credit-purchase-history {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table--credit-purchase-history {
  table-layout: fixed;
  width: 100%;
  min-width: 58rem;
}

.admin-table--credit-purchase-history col.cph-col-date { width: 220px; }
.admin-table--credit-purchase-history col.cph-col-credits { width: 100px; }
.admin-table--credit-purchase-history col.cph-col-amount { width: 140px; }
.admin-table--credit-purchase-history col.cph-col-method { width: 140px; }
.admin-table--credit-purchase-history col.cph-col-invoice { width: 120px; }

.admin-table--credit-purchase-history thead th {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.35;
  white-space: normal;
}

.admin-table--credit-purchase-history tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.4;
}

.admin-table--credit-purchase-history .cph-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: 100%;
  text-decoration: none;
  color: inherit;
}

.admin-table--credit-purchase-history .cph-th-sort:hover {
  text-decoration: underline;
  color: var(--primary);
}

.admin-table--credit-purchase-history .cph-th-sort__icon {
  flex-shrink: 0;
  font-size: 0.82em;
  opacity: 0.85;
  line-height: 1;
}

.admin-table--credit-purchase-history .cph-th-sort--end {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  text-align: right;
}

.admin-table--credit-purchase-history .cph-th-sort--center {
  display: flex;
  justify-content: center;
  width: 100%;
}

.admin-table--credit-purchase-history th.cph-th-date,
.admin-table--credit-purchase-history td.cph-td-date {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.admin-table--credit-purchase-history th.cph-th-purchased,
.admin-table--credit-purchase-history td.cph-td-purchased,
.admin-table--credit-purchase-history th.cph-th-method,
.admin-table--credit-purchase-history td.cph-td-method {
  text-align: left;
}

.admin-table--credit-purchase-history th.cph-th-credits,
.admin-table--credit-purchase-history td.cph-td-credits,
.admin-table--credit-purchase-history th.cph-th-invoice,
.admin-table--credit-purchase-history td.cph-td-invoice {
  text-align: center;
}

.admin-table--credit-purchase-history th.cph-th-amount,
.admin-table--credit-purchase-history td.cph-td-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table--credit-purchase-history td.cph-td-purchased {
  overflow: hidden;
  max-width: 0;
}

.admin-table--credit-purchase-history td.cph-td-purchased .cph-cell-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.admin-table--credit-purchase-history td.cph-td-date,
.admin-table--credit-purchase-history td.cph-td-credits,
.admin-table--credit-purchase-history td.cph-td-amount,
.admin-table--credit-purchase-history td.cph-td-invoice {
  white-space: nowrap;
}

.admin-table--credit-purchase-history td.cph-td-method {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .admin-table--credit-purchase-history {
    min-width: 52rem;
  }
}

/* Reporting tables: .table / .table-responsive names align with common conventions; no Bootstrap JS */
.table-responsive,
.report-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table.report-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
}

.table-bordered.report-table,
.table-bordered.report-table > thead > tr > th,
.table-bordered.report-table > tbody > tr > td {
  border: 1px solid var(--border);
}

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

.report-table thead th {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: bottom;
  line-height: 1.35;
  white-space: normal;
  background: rgba(148, 163, 184, 0.1);
}

body.theme-dark .report-table thead th {
  background: rgba(148, 163, 184, 0.08);
}

.report-table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  line-height: 1.4;
}

.report-th-left { text-align: left; }
.report-th-center { text-align: center; }
.report-td-left { text-align: left; }
.report-td-center { text-align: center; }

.report-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
}

.report-th-sort:hover {
  text-decoration: underline;
  color: var(--primary);
}

.report-th-sort.justify-center {
  justify-content: center;
  width: 100%;
}

.report-th-sort__label {
  min-width: 0;
}

.report-th-sort-icon {
  flex-shrink: 0;
  font-size: 0.82em;
  opacity: 0.85;
  line-height: 1;
}

.report-td-truncate {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-td-ts {
  white-space: nowrap;
}

.report-td-empty {
  text-align: center;
  padding: 24px 14px !important;
}

.report-table--consumption-log {
  min-width: 44rem;
}

@media (max-width: 640px) {
  .report-table--consumption-log {
    min-width: 36rem;
  }
}

/* Contracts table: clearer header and icon-only actions */
.admin-table-wrap-contracts {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.admin-table-contracts thead th {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 600;
  padding: 14px 12px;
}
body.theme-dark .admin-table-contracts thead th {
  background: rgba(148, 163, 184, 0.08);
}
.admin-table-contracts tbody td {
  padding: 14px 12px;
  vertical-align: middle;
}
.table-action-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-icon-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-icon-cell:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
  color: var(--text);
}
.btn-icon-cell .action-icon {
  display: block;
}
.btn-icon-cell-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-icon-cell-primary:hover {
  background: var(--brand-hover, var(--brand));
  border-color: var(--brand-hover, var(--brand));
  color: #fff;
  opacity: 0.95;
}
.contract-tile-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.contract-tile-schedule {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.10);
  color: var(--text);
  font-weight: 400;
  font-size: 12px;
  white-space: nowrap;
}

body.theme-dark .pill {
  background: rgba(148, 163, 184, 0.12);
}

.admin-cell-primary {
  font-weight: 400;
}

.admin-cell-secondary {
  font-size: 12px;
  margin-top: 2px;
}

.admin-cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .admin-cell-actions {
    justify-content: flex-start;
  }
}

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

.admin-pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-page-numbers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-page-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  font-weight: 400;
}

.admin-page-num:hover {
  background: var(--surface-hover);
}

.admin-page-num.is-current {
  background: var(--surface-hover);
  font-weight: 500;
}

.admin-page-btn.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Admin drawer (Users details) */
.admin-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 110;
}

body.theme-dark .admin-drawer-overlay {
  background: rgba(0, 0, 0, 0.55);
}

.admin-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 38vw;
  max-width: 680px;
  min-width: 360px;
  background: var(--card);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform var(--transition);
  z-index: 120;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
}

body.theme-dark .admin-drawer {
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.45);
}

.admin-drawer.is-open {
  transform: translateX(0);
}

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

.admin-drawer-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.admin-drawer-title {
  font-weight: 600;
}

.admin-drawer-body {
  padding: 16px;
  overflow: auto;
  height: calc(100vh - var(--header-height));
}

body.drawer-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .admin-drawer {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
}

/* Tablet: hide IP column */
@media (max-width: 1024px) {
  .admin-table .col-ip {
    display: none;
  }
}

/* Mobile: stack rows (label/value), no horizontal scroll (except fixed-layout report tables: horizontal scroll) */
@media (max-width: 640px) {
  .admin-table-wrap:not(.admin-table-wrap--consumption-log):not(.admin-table-wrap--transcript-storage):not(.admin-table-wrap--credit-purchase-history) {
    overflow: visible;
  }

  .admin-table-wrap--consumption-log,
  .admin-table-wrap--transcript-storage,
  .admin-table-wrap--credit-purchase-history {
    overflow-x: auto;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) thead {
    display: none;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history),
  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tbody,
  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tr,
  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) td {
    display: block;
    width: 100%;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tbody tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    background: transparent !important;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tbody tr:last-child {
    border-bottom: 0;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tbody td {
    border: 0;
    padding: 6px 0;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
  }

  .admin-table:not(.admin-table--consumption-log):not(.admin-table--transcript-storage):not(.admin-table--credit-purchase-history) tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    padding-top: 2px;
  }

  .admin-pagination {
    align-items: flex-start;
  }
}

/* Stored transcripts folder/file tree */
.stored-transcripts-tree .stored-folder {
  margin-bottom: 1.25rem;
}
.stored-transcripts-tree .stored-folder:last-child {
  margin-bottom: 0;
}
.stored-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
}
.stored-folder-icon {
  font-size: 1.1em;
}
.stored-folder-count {
  font-weight: 400;
  font-size: 13px;
}
.stored-folder-files {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.stored-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.stored-file:last-child {
  border-bottom: 0;
}
.stored-file:hover {
  background: var(--bg);
}
.stored-file-icon {
  font-size: 1em;
  flex-shrink: 0;
}
.stored-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stored-file-name {
  font-size: 14px;
  font-weight: 500;
}
.stored-file-meta {
  font-size: 12px;
}
.stored-file-retrieved {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.stored-meta-line {
  display: block;
  font-size: 12px;
}
.stored-meta-primary {
  font-weight: 500;
}
.stored-meta-subline {
  display: block;
  font-size: 11px;
  color: var(--muted, #6b7280);
  margin-top: 1px;
}
.stored-file-actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
}
.stored-file-actions .btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--card);
}
.stored-file-actions .btn:hover {
  background: var(--bg);
}
@media (max-width: 640px) {
  .stored-file {
    flex-wrap: wrap;
  }
  .stored-file-actions {
    width: 100%;
    justify-content: flex-end;
    padding-left: 1.6em;
  }
}

/* Stored files page (dedicated) */
.stored-page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.stored-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.stored-search-input {
  flex: 1;
  min-width: 420px;
  max-width: 720px;
}

/* Stored files tree: flat, integrated section (not floating card) */
.stored-files-tree.card {
  box-shadow: none;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.stored-files-tree .card-body {
  padding: 12px 16px;
}

/* Centered folder list container – compact, Google Drive / Notion style */
.stored-folder-list-container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 12px 16px;
}
@media (max-width: 768px) {
  .stored-folder-list-container {
    max-width: none;
    padding: 8px 12px;
  }
}

.stored-tree-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.stored-tree-actions .btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
}
.stored-tree-actions .stored-create-folder {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
}

/* Folder row: compact, white, soft border, 8px gap between rows */
.stored-files-tree .stored-folder {
  margin-bottom: 8px;
}
.stored-files-tree .stored-folder-toggle:last-child {
  margin-bottom: 0;
}
.stored-files-tree .stored-folder-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
  transition: box-shadow 0.15s ease;
}
.stored-files-tree .stored-folder-toggle:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.theme-dark .stored-files-tree .stored-folder-toggle:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.stored-folder-row {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 48px;
  padding: 0 4px 0 0;
}

/* Left: arrow + icon + name + count. Right: 3-dot menu – all vertically centered */
.stored-files-tree .stored-folder-header {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: background 0.15s ease;
}
.stored-folder-collapsed .stored-folder-header {
  border-radius: 8px;
}
.stored-files-tree .stored-folder-header:hover {
  background: rgba(0, 0, 0, 0.04);
}
body.theme-dark .stored-files-tree .stored-folder-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Arrow: spacing + vertical center + smooth rotate (150ms) */
.stored-folder-chevron {
  width: 20px;
  flex-shrink: 0;
  margin-right: 8px;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.stored-folder-collapsed .stored-folder-chevron {
  transform: rotate(-90deg);
}

/* Typography: folder name semibold, file count smaller + grey */
.stored-folder-name-text {
  font-weight: 600;
  color: inherit;
}
.stored-folder-count {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-left: 2px;
}

/* Right: 3-dot menu aligned center vertically */
.stored-folder-menu-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.stored-folder-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.stored-folder-menu-btn:hover,
.stored-folder-menu-btn:focus,
.stored-folder-row:hover .stored-folder-menu-btn {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}
body.theme-dark .stored-folder-menu-btn:hover,
body.theme-dark .stored-folder-menu-btn:focus,
body.theme-dark .stored-folder-row:hover .stored-folder-menu-btn {
  background: rgba(255, 255, 255, 0.08);
}
.stored-folder-menu-btn:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}
.stored-folder-menu-btn[aria-expanded="true"] {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}
body.theme-dark .stored-folder-menu-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
}
.stored-menu-icon {
  display: block;
}

/* Expanded area: slight indent, no heavy card, subtle divider, slide 150ms */
.stored-folder-content {
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
  transition: max-height 0.15s ease;
}
body.theme-dark .stored-folder-content {
  background: rgba(255, 255, 255, 0.02);
}
.stored-folder-collapsed .stored-folder-content {
  max-height: 0;
  border-top-width: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.stored-folder.expanded .stored-folder-content {
  max-height: 2000px;
}
/* Extra space at bottom of folder so drops are easier to hit */
.stored-folder-content.stored-drop-zone {
  padding-bottom: 32px;
}

.stored-files-tree .stored-folder-files {
  border: 0;
  margin: 0;
  padding: 6px 0 6px 12px;
  list-style: none;
  border-left: 1px solid var(--border);
  margin-left: 28px;
}
.stored-files-tree .stored-folder-files .stored-file {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px 0;
}
body.theme-dark .stored-files-tree .stored-folder-files .stored-file {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
.stored-files-tree .stored-folder-files .stored-file:last-child {
  border-bottom: 0;
}

/* Mobile: full width, no extra margin, smaller row */
@media (max-width: 768px) {
  .stored-files-tree .card-body {
    padding: 8px 12px;
  }
  .stored-folder-row {
    min-height: 44px;
  }
  .stored-files-tree .stored-folder-header {
    padding: 10px 12px;
  }
  .stored-files-tree .stored-folder-files {
    margin-left: 20px;
    padding-left: 10px;
  }
}
.stored-folder-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 160px;
  margin-top: 4px;
  padding: 6px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.stored-folder-dropdown[hidden] {
  display: none !important;
}
.stored-folder-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 0.1s;
}
.stored-folder-dropdown-item:hover,
.stored-folder-dropdown-item:focus {
  background: var(--border);
  outline: none;
}
.stored-folder-dropdown-item-danger {
  color: var(--danger, #b91c1c);
}
.stored-folder-dropdown-item-danger:hover,
.stored-folder-dropdown-item-danger:focus {
  background: rgba(185, 28, 28, 0.1);
}
.stored-action-icon {
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .stored-folder-menu-btn {
    color: var(--text);
    opacity: 0.9;
  }
}

/* Stored folder modals (rename / delete) */
.stored-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.stored-modal[hidden] {
  display: none !important;
}
.stored-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: default;
}
.stored-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow: auto;
}
.stored-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.stored-modal-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.stored-modal-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.stored-modal-input {
  width: 100%;
  margin-bottom: 20px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.stored-modal-input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.stored-modal-message {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.stored-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.stored-modal-cancel {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.stored-modal-save {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.stored-modal-delete-btn {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
  border: 0;
  background: var(--danger, #b91c1c);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}
.stored-modal-delete-btn:hover {
  background: #991b1b;
}

.stored-folder-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stored-files-tree .icon-folder,
.stored-files-tree .icon-file {
  display: block;
  flex-shrink: 0;
}
.stored-files-tree .icon-folder {
  width: 22px;
  height: 18px;
}
.stored-files-tree .icon-file {
  width: 20px;
  height: 24px;
  color: var(--muted);
}
.stored-folder-content[hidden] {
  display: none !important;
}
.nav-icon-folder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon-folder svg {
  display: block;
}
body.theme-dark .stored-files-tree .icon-folder path:first-of-type {
  fill: #d4a017;
}
body.theme-dark .stored-files-tree .icon-folder path:last-of-type {
  fill: #b8860b;
}

/* Unfiled list: flat list (not a folder) */
.stored-unfiled-zone {
  margin-bottom: 8px;
}
/* Larger drop target below file list (not the empty “unfiled” placeholder) */
.stored-unfiled-zone.stored-drop-zone:not(.stored-drop-zone-empty) {
  padding-bottom: 32px;
  margin-bottom: 12px;
}
.stored-unfiled-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.stored-drop-zone {
  min-height: 12px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.stored-drop-zone.stored-drop-over {
  background: var(--border);
  box-shadow: inset 0 0 0 2px var(--primary, #2563eb);
}
.stored-drop-zone-empty {
  padding: 28px 24px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
}
.stored-file-draggable {
  cursor: grab;
}
.stored-file-draggable:active {
  cursor: grabbing;
}
.stored-file.stored-dragging {
  opacity: 0.6;
}

/* ========== Mobile: sidebar overlay (shown only when sidebar open on small screens) ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

body.theme-dark .sidebar-overlay {
  background: rgba(0, 0, 0, 0.6);
}

/* ========== Mobile-first responsive layout ========== */
@media (max-width: 768px) {
  .sidebar-overlay {
    display: block;
  }

  body.sidebar-mobile-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-mobile-open {
    overflow: hidden;
  }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    width: min(280px, 85vw);
    max-width: 280px;
  }

  body.sidebar-mobile-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-mobile-open.sidebar-collapsed .app-sidebar {
    width: min(280px, 85vw);
  }

  .app-main {
    margin-left: 0;
    padding-left: 14px;
    padding-right: 14px;
    padding-top: calc(var(--header-height) + 14px);
  }

  .app-header-inner {
    padding: 0 12px;
  }

  .app-logo-text {
    font-size: 12px;
  }

  .app-logo-mark {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .app-header-menu-btn {
    display: inline-flex !important;
  }

  .standalone-main {
    padding: 24px 14px;
    align-items: center;
    justify-content: center;
  }

  .auth-wrap {
    max-width: 100%;
  }

  .page-title {
    font-size: 18px;
  }

  .admin-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

  .form-page-wide {
    max-width: 100%;
  }

  .form-sections-grid {
    grid-template-columns: 1fr;
  }

  .stored-search-input {
    min-width: 0;
    width: 100%;
  }

  .stored-page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stored-search-form {
    width: 100%;
  }

  /* Allow inline min-width form controls to shrink on small screens */
  select.form-control,
  input.form-control {
    max-width: 100%;
  }
}

/* Transcript Builder: mobile stack left/center/props and reduce min-widths */
@media (max-width: 900px) {
  .tb-body {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-left,
  .tb-props {
    width: 100%;
    min-width: 0;
    max-width: none;
    position: static;
    max-height: none;
  }

  .tb-left {
    order: 1;
  }

  .tb-center {
    order: 2;
    padding-left: 0;
    padding-top: 12px;
  }

  .tb-props {
    order: 3;
    margin-top: 12px;
  }

  .tb-editor {
    min-height: auto;
    height: auto;
  }

  .tb-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-toolbar-actions {
    justify-content: flex-start;
  }

  .tb-grid.two-col,
  .tb-grid.three-col {
    --tb-cols: 1;
    grid-template-columns: minmax(0, 1fr);
  }

  .tb-grid .tb-field-block[data-span="2"],
  .tb-grid .tb-field-block[data-span="3"] {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .tb-page {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
  }

  .tb-pages {
    width: 100%;
    padding: 0 8px;
  }

  .tb-topbar {
    flex-wrap: wrap;
  }

  .tb-validation-modal {
    width: min(94vw, 420px);
    left: 50%;
    right: auto;
    margin-left: 0;
    transform: translate(-50%, -50%);
  }

  .tb-preview-modal {
    inset: 12px;
  }
}

@media (max-width: 480px) {
  .app-main {
    padding-left: 10px;
    padding-right: 10px;
  }

  .card-body {
    padding: 14px;
  }

  .icon-btn,
  .avatar-btn {
    width: 32px;
    height: 32px;
  }

  .menu-dropdown {
    min-width: 160px;
  }
}

/* Transcript upload dropzone */
.transcript-upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 28px 24px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.transcript-upload-dropzone:hover,
.transcript-upload-dropzone:focus {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.04);
  outline: none;
}
.transcript-upload-dropzone--dragover {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.08);
}
.transcript-upload-dropzone__prompt {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted, #6b7280);
  text-align: center;
  pointer-events: none;
  max-width: 28em;
}
.transcript-upload-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
}
.transcript-upload-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 13px;
  min-height: 40px;
}
body.theme-dark .transcript-upload-file-item {
  background: rgba(30, 41, 59, 0.5);
  border-color: var(--border);
}
.transcript-upload-file-item__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.transcript-upload-file-item__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text, #1e293b);
}
.transcript-upload-file-item__size {
  flex-shrink: 0;
  font-size: 11px;
}
.transcript-upload-file-item__remove {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.transcript-upload-file-item__remove:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}
.transcript-upload-file-item__remove:focus {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

/* Transcript upload processing overlay */
.transcript-upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.transcript-upload-overlay[hidden] {
  display: none !important;
}
.transcript-upload-overlay__content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.transcript-upload-overlay__spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 4px solid var(--border);
  border-top-color: var(--primary, #2563eb);
  border-radius: 50%;
  animation: transcript-upload-spin 0.8s linear infinite;
}
.transcript-upload-overlay__text {
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 8px;
}
.transcript-upload-overlay__progress-wrap {
  margin: 12px 0 0 0;
  width: 100%;
}
.transcript-upload-overlay__progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}
.transcript-upload-overlay__progress-fill {
  height: 100%;
  background: var(--primary, #2563eb);
  border-radius: 5px;
  transition: width 0.25s ease;
}
.transcript-upload-overlay__progress-bar--indeterminate .transcript-upload-overlay__progress-fill {
  width: 30% !important;
  animation: transcript-upload-progress-indeterminate 1.2s ease-in-out infinite;
}
.transcript-upload-overlay__progress-pct {
  font-size: 13px;
  margin: 0;
}
.transcript-upload-overlay__hint {
  margin-top: 12px;
}
@keyframes transcript-upload-spin {
  to { transform: rotate(360deg); }
}
@keyframes transcript-upload-progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* Transcript Designer – action-driven SaaS UI (3 cards, responsive grid) */
.td-page {
  padding: 0 8px 32px;
  max-width: 1200px;
  margin: 0 auto;
}
.td-hero {
  margin-bottom: 28px;
}
.td-hero-back {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 12px;
}
.td-hero-back:hover {
  color: var(--text);
}
.td-hero-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.td-hero-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}
.td-alert {
  margin-bottom: 20px;
}
/* Empty state: no programs */
.td-empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.td-empty-icon {
  color: var(--muted);
  margin-bottom: 20px;
}
.td-empty-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
}
.td-empty-desc {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}
.td-empty-cta {
  margin-bottom: 12px;
}
.td-empty-link {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.td-empty-link:hover {
  color: var(--text);
}
/* 3-column grid: desktop 3, tablet 2, mobile 1 */
.td-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 900px) {
  .td-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .td-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
/* Action cards */
.td-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.td-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border-color: var(--border);
}
.td-card-primary {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.08);
}
.td-card-primary:hover {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 8px 28px rgba(59, 130, 246, 0.12);
}
.td-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.td-card-primary .td-card-icon {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary, #2563eb);
}
.td-card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
}
.td-card-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.45;
}
.td-card-muted {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.td-card-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}
.td-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.td-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.td-input {
  width: 100%;
  min-width: 0;
}
.td-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.td-searchable-wrap {
  position: relative;
}
.td-search-input {
  margin-bottom: 6px;
}
.td-select-native {
  width: 100%;
}
.td-btn {
  margin-top: 4px;
  align-self: flex-start;
}
.td-btn-primary {
  font-weight: 600;
}
.td-btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.td-btn-secondary:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}
.td-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}
/* Recent drafts list */
.td-recent {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.td-recent-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}
.td-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.td-recent-list li {
  margin: 0 0 6px;
}
.td-recent-list li:last-child {
  margin-bottom: 0;
}
.td-recent-link {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}
.td-recent-link:hover {
  text-decoration: underline;
  color: var(--primary, #2563eb);
}

/* Email settings — wide layout for all tabs (Templates, Distribution lists, Test) */
.email-settings-wide,
.email-settings-templates-list-page {
  width: 100%;
  max-width: 1200px;
  margin: 0;
}
.email-settings-page .email-settings-templates-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.admin-table-wrap--email-templates {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}
.email-templates-th-actions,
.email-templates-actions {
  min-width: 100px;
  width: 100px;
  text-align: right;
  white-space: nowrap;
}
.email-templates-actions .btn {
  flex-shrink: 0;
}
body.theme-dark .email-settings-page .email-settings-templates-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.email-settings-templates-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.email-settings-templates-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px 0;
}
.email-settings-templates-desc {
  margin: 0;
  font-size: 13px;
  max-width: 56ch;
}
.email-settings-templates-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.email-settings-per-page-form {
  display: inline-flex;
  align-items: center;
}
.email-settings-per-page-select {
  width: auto;
  min-width: 60px;
  padding: 6px 10px;
  font-size: 13px;
}
.admin-table--email-templates thead th {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 600;
  padding: 14px 12px;
  font-size: 12px;
  text-transform: none;
}
body.theme-dark .admin-table--email-templates thead th {
  background: rgba(148, 163, 184, 0.1);
}
.admin-table--email-templates tbody td {
  padding: 14px 12px;
  vertical-align: middle;
}
.email-templates-event-key {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  border-radius: 6px;
  font-weight: 500;
}
body.theme-dark .email-templates-event-key {
  background: rgba(255, 255, 255, 0.08);
}
.email-templates-channels {
  font-size: 12px;
  color: var(--muted);
}
.email-templates-actions {
  white-space: nowrap;
  text-align: right;
}
.email-settings-pagination {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Email settings — Edit template page */
.email-template-edit-page {
  max-width: 1200px;
}
.email-template-edit-breadcrumb {
  margin-bottom: 8px;
}
.email-template-edit-breadcrumb a {
  font-size: 14px;
  text-decoration: none;
}
.email-template-edit-breadcrumb a:hover {
  text-decoration: underline;
}
.email-template-edit-header {
  margin-bottom: 20px;
}
.email-template-edit-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 6px 0;
}
.email-template-edit-desc {
  margin: 0;
  font-size: 14px;
}
.email-template-editor-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .email-template-editor-layout {
    grid-template-columns: 1fr;
  }
}
.email-template-editor-main .card-body {
  padding: 24px;
}
.email-template-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.email-template-field .form-label {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}
.email-template-body {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 320px;
  resize: vertical;
}
.form-hint {
  margin-top: 8px;
  font-size: 12px;
}
.email-template-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.email-template-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.email-template-sidebar .card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.theme-dark .email-template-sidebar .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.email-template-sidebar .card-body {
  padding: 18px;
}
.email-template-sidebar-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px 0;
}
.email-template-sidebar-hint {
  font-size: 12px;
  margin: 0 0 14px 0;
  line-height: 1.45;
}
.email-template-no-placeholders,
.email-template-no-lists {
  font-size: 12px;
  margin: 0;
}
.email-template-distribution-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.email-template-list-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
  font-size: 13px;
}
.email-template-list-check input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}
.email-template-body-preview {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: var(--surface-hover, #f5f5f5);
  padding: 16px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
body.theme-dark .email-template-body-preview {
  background: rgba(255, 255, 255, 0.06);
}

.email-template-image-card .email-template-image-upload {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.email-template-image-label {
  font-size: 12px;
  margin-bottom: 0;
}
.email-template-image-input {
  font-size: 13px;
}
.email-template-image-btn {
  align-self: flex-start;
}
.email-template-image-msg {
  margin: 0;
  min-height: 1.25em;
}

/* Email settings — Distribution lists */
.email-settings-lists-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.theme-dark .email-settings-lists-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.email-settings-lists-header {
  margin-bottom: 20px;
}
.email-settings-lists-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px 0;
}
.email-settings-lists-desc {
  margin: 0;
  font-size: 13px;
  max-width: 56ch;
}
.admin-table-wrap--email-lists {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table--email-lists thead th {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 600;
  padding: 14px 12px;
  font-size: 12px;
}
body.theme-dark .admin-table--email-lists thead th {
  background: rgba(148, 163, 184, 0.1);
}
.admin-table--email-lists tbody td {
  padding: 14px 12px;
  vertical-align: middle;
}
.email-lists-slug {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  border-radius: 6px;
  font-weight: 500;
}
body.theme-dark .email-lists-slug {
  background: rgba(255, 255, 255, 0.08);
}
.email-lists-th-actions,
.email-lists-actions {
  min-width: 100px;
  width: 100px;
  text-align: right;
  white-space: nowrap;
}

/* Email settings — Test tab (compact send button) */
.email-settings-test-card .card-body {
  padding: 24px;
}
.email-settings-test-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px 0;
}
.email-settings-test-desc {
  margin: 0 0 16px 0;
  font-size: 13px;
}
.email-settings-test-form-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.email-settings-test-form-field {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.email-settings-test-form-field .form-control {
  padding: 8px 12px;
  font-size: 14px;
}
.email-settings-test-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
}

/* ============================================================
   TRANSCRIPT BUILDER — COMPACT HEADER & TOOLBAR
   Add these rules to the END of your app.css
   ============================================================ */
 
/* === COMPACT ACTION BAR (44px single row) === */
.tb-sticky-action-bar.admin-page-header {
    padding: 0 16px;
    height: 44px;
    min-height: 44px;
    align-items: center;
}
 
/* Title + state on the same row */
.tb-sticky-action-bar > div:first-of-type {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
 
/* Smaller compact title */
.tb-sticky-action-bar .page-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}
 
/* State badge — inline and subdued */
.tb-sticky-action-bar .muted {
    font-size: 11px;
    white-space: nowrap;
    opacity: 0.6;
}
 
/* Compact action buttons */
.admin-page-actions {
    gap: 6px;
}
.admin-page-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
}
 
/* === REMOVE GAP BETWEEN HEADER AND TOOLBAR === */
.tb-builder-page-shell.stack {
    gap: 0;
}
 
/* === COMPACT TOOLBAR (tabs + zoom on one slim bar) === */
.tb-toolbar {
    padding: 5px 12px;
    margin-bottom: 0;
    height: auto;
    min-height: 40px;
    border-bottom: 1px solid #e5e7eb;
}
 
/* Smaller tabs */
.tb-tab {
    padding: 5px 10px;
    font-size: 13px;
}
 
/* Compact zoom controls */
.tb-zoom-inline {
    font-size: 12px;
    gap: 4px;
}
.tb-zoom-inline .muted {
    font-size: 12px;
}
.tb-zoom-btn {
    padding: 2px 6px;
    font-size: 12px;
}
