/* ==========================================================================
   Tabularium Design Tokens & Component Classes
   ========================================================================== */

:root {
  /* Brand */
  --tb-gold: #c2873a;
  --tb-gold-dark: #a16b2a;
  --tb-gold-gradient: linear-gradient(135deg, #c2873a, #a16b2a);
  --tb-gold-shadow: 0 2px 8px rgba(194, 135, 58, 0.25);
  --tb-gold-shadow-lg: 0 2px 8px rgba(194, 135, 58, 0.3);
  --tb-gold-ring: rgba(194, 135, 58, 0.3);
  --tb-gold-hover-bg: rgba(194, 135, 58, 0.06);
  --tb-gold-active-bg: rgba(194, 135, 58, 0.08);
  --tb-gold-subtle-bg: rgba(194, 135, 58, 0.1);
  --tb-gold-border: rgba(194, 135, 58, 0.15);

  /* Text */
  --tb-text-primary: #0c1222;
  --tb-text-secondary: #5a6478;
  --tb-text-tertiary: #8893a7;
  --tb-text-light: #f0ece6;
  --tb-text-muted: #6b7a92;
  --tb-text-faint: #b0b8c8;

  /* Surfaces */
  --tb-surface-page: #f4f2ee;
  --tb-surface-card: #fff;
  --tb-surface-input: #faf8f5;
  --tb-surface-input-alt: #f4f2ee;

  /* Borders */
  --tb-border: #e8e4de;
  --tb-border-light: #f4f2ee;
  --tb-border-lighter: #f0ece6;
  --tb-border-gold: rgba(194, 135, 58, 0.1);

  /* Status: success */
  --tb-success-bg: rgba(34, 139, 34, 0.06);
  --tb-success-border: rgba(34, 139, 34, 0.15);
  --tb-success-text: #1a6b1a;
  --tb-success-badge-bg: rgba(34, 139, 34, 0.08);

  /* Status: danger */
  --tb-danger-bg: rgba(194, 50, 50, 0.06);
  --tb-danger-border: rgba(194, 50, 50, 0.15);
  --tb-danger-text: #9a2020;
  --tb-danger-icon: #dc2626;
  --tb-danger-icon-bg: rgba(220, 38, 38, 0.1);

  /* Status: warning */
  --tb-warning-bg: rgba(217, 119, 6, 0.1);
  --tb-warning-text: #d97706;
  --tb-warning-icon: #d97706;
  --tb-warning-border: rgba(217, 119, 6, 0.25);

  /* Status: success icon (green for checkmarks/status indicators) */
  --tb-success-icon: #228b22;
  --tb-success-icon-bg: rgba(34, 139, 34, 0.08);

  /* Logout */
  --tb-logout-text: #c25050;

  /* Letter editor */
  --tb-letter-text: #1a1a2e;

  /* Status: inactive */
  --tb-inactive-bg: rgba(107, 114, 128, 0.08);
  --tb-inactive-text: #6b7280;

  /* Status: info (blue) */
  --tb-info-bg: rgba(59, 130, 246, 0.08);
  --tb-info-text: #1d4ed8;

  /* Dark chrome (navbar, dropdowns) */
  --tb-sidebar-bg: #0c1222;
  --tb-sidebar-divider: linear-gradient(90deg, transparent, rgba(194, 135, 58, 0.15), transparent);
  --tb-sidebar-nav-color: #8893a7;
  --tb-sidebar-section-label: #5a6478;
  --tb-sidebar-badge-color: #6b7a92;
  --tb-sidebar-badge-bg: rgba(107, 122, 146, 0.1);
  --tb-sidebar-badge-border: rgba(107, 122, 146, 0.12);

  /* Fonts */
  --tb-font-serif: 'Instrument Serif', Georgia, serif;
  --tb-font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --tb-font-mono: 'SF Mono', ui-monospace, monospace;
}

/* ==========================================================================
   Dark Theme Token Overrides
   ========================================================================== */

[data-theme="dark"] {
  --tb-surface-page:      #0c1222;
  --tb-surface-card:      #141e33;
  --tb-surface-input:     rgba(255, 255, 255, 0.05);
  --tb-surface-input-alt: #0f1628;
  --tb-text-primary:      #f0ece6;
  --tb-text-secondary:    #8893a7;
  --tb-text-tertiary:     #5a6478;
  --tb-text-muted:        #5a6478;
  --tb-text-faint:        #3a4458;
  --tb-border:            rgba(194, 135, 58, 0.12);
  --tb-border-light:      rgba(255, 255, 255, 0.05);
  --tb-border-lighter:    rgba(255, 255, 255, 0.04);
  --tb-border-gold:       rgba(194, 135, 58, 0.12);
  --tb-success-bg:        rgba(34, 139, 34, 0.12);
  --tb-success-border:    rgba(34, 139, 34, 0.2);
  --tb-success-text:      #6fcf6f;
  --tb-success-badge-bg:  rgba(34, 139, 34, 0.12);
  --tb-danger-bg:         rgba(220, 60, 60, 0.12);
  --tb-danger-border:     rgba(220, 60, 60, 0.2);
  --tb-danger-text:       #f07070;
  --tb-danger-icon:       #f07070;
  --tb-danger-icon-bg:    rgba(220, 60, 60, 0.15);
  --tb-warning-bg:        rgba(217, 119, 6, 0.15);
  --tb-warning-text:      #f0a030;
  --tb-warning-icon:      #f0a030;
  --tb-warning-border:    rgba(217, 119, 6, 0.3);
  --tb-success-icon:      #6fcf6f;
  --tb-success-icon-bg:   rgba(34, 139, 34, 0.15);
  --tb-inactive-bg:       rgba(107, 114, 128, 0.12);
  --tb-inactive-text:     #8893a7;
  --tb-info-bg:           rgba(59, 130, 246, 0.12);
  --tb-info-text:         #7db8f7;
  --tb-logout-text:       #f07070;
  --tb-letter-text:       #f0ece6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tb-surface-page:      #0c1222;
    --tb-surface-card:      #141e33;
    --tb-surface-input:     rgba(255, 255, 255, 0.05);
    --tb-surface-input-alt: #0f1628;
    --tb-text-primary:      #f0ece6;
    --tb-text-secondary:    #8893a7;
    --tb-text-tertiary:     #5a6478;
    --tb-text-muted:        #5a6478;
    --tb-text-faint:        #3a4458;
    --tb-border:            rgba(194, 135, 58, 0.12);
    --tb-border-light:      rgba(255, 255, 255, 0.05);
    --tb-border-lighter:    rgba(255, 255, 255, 0.04);
    --tb-border-gold:       rgba(194, 135, 58, 0.12);
    --tb-success-bg:        rgba(34, 139, 34, 0.12);
    --tb-success-border:    rgba(34, 139, 34, 0.2);
    --tb-success-text:      #6fcf6f;
    --tb-success-badge-bg:  rgba(34, 139, 34, 0.12);
    --tb-danger-bg:         rgba(220, 60, 60, 0.12);
    --tb-danger-border:     rgba(220, 60, 60, 0.2);
    --tb-danger-text:       #f07070;
    --tb-danger-icon:       #f07070;
    --tb-danger-icon-bg:    rgba(220, 60, 60, 0.15);
    --tb-warning-bg:        rgba(217, 119, 6, 0.15);
    --tb-warning-text:      #f0a030;
    --tb-warning-icon:      #f0a030;
    --tb-warning-border:    rgba(217, 119, 6, 0.3);
    --tb-success-icon:      #6fcf6f;
    --tb-success-icon-bg:   rgba(34, 139, 34, 0.15);
    --tb-inactive-bg:       rgba(107, 114, 128, 0.12);
    --tb-inactive-text:     #8893a7;
    --tb-info-bg:           rgba(59, 130, 246, 0.12);
    --tb-info-text:         #7db8f7;
    --tb-logout-text:       #f07070;
    --tb-letter-text:       #f0ece6;
  }
}

/* Tailwind hardcoded color overrides for dark theme */
[data-theme="dark"] .bg-white { background-color: var(--tb-surface-card) !important; }
[data-theme="dark"] .bg-gray-50 { background-color: var(--tb-surface-page) !important; }
[data-theme="dark"] .text-gray-900 { color: var(--tb-text-primary) !important; }
[data-theme="dark"] .text-gray-700 { color: var(--tb-text-primary) !important; }
[data-theme="dark"] .text-gray-600 { color: var(--tb-text-secondary) !important; }
[data-theme="dark"] .text-gray-500 { color: var(--tb-text-tertiary) !important; }
[data-theme="dark"] .border-gray-100 { border-color: var(--tb-border-light) !important; }
[data-theme="dark"] .border-gray-200 { border-color: var(--tb-border) !important; }
[data-theme="dark"] .border-gray-300 { border-color: var(--tb-border) !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-white { background-color: var(--tb-surface-card) !important; }
  :root:not([data-theme="light"]) .bg-gray-50 { background-color: var(--tb-surface-page) !important; }
  :root:not([data-theme="light"]) .text-gray-900 { color: var(--tb-text-primary) !important; }
  :root:not([data-theme="light"]) .text-gray-700 { color: var(--tb-text-primary) !important; }
  :root:not([data-theme="light"]) .text-gray-600 { color: var(--tb-text-secondary) !important; }
  :root:not([data-theme="light"]) .text-gray-500 { color: var(--tb-text-tertiary) !important; }
  :root:not([data-theme="light"]) .border-gray-100 { border-color: var(--tb-border-light) !important; }
  :root:not([data-theme="light"]) .border-gray-200 { border-color: var(--tb-border) !important; }
  :root:not([data-theme="light"]) .border-gray-300 { border-color: var(--tb-border) !important; }
}

/* Smooth theme switching transition */
body, .tb-card, .tb-metric-dark, .tb-navbar, .tb-mobile-panel,
.tb-dropdown-menu, .tb-input, .tb-badge {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* ==========================================================================
   Shared Layout Classes (previously duplicated in 3 layout <style> blocks)
   ========================================================================== */

.font-serif-display { font-family: var(--tb-font-serif); }
.font-body { font-family: var(--tb-font-body); }

/* Toast animations */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(1rem); }
}
#toast-container > div { animation: toastSlideIn 0.3s ease both; }
.toast-dismiss { animation: toastSlideOut 0.3s ease both !important; }

/* Subtle grain texture (navbar, dropdowns, mobile panel) */
.sidebar-grain::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: inherit;
}


/* ==========================================================================
   Top Navbar
   ========================================================================== */

.tb-navbar {
  background: var(--tb-sidebar-bg);
  height: 3.5rem;
  position: relative;
  z-index: 30;
}
/* Gold gradient seam at bottom */
.tb-navbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(194,135,58,0.3), transparent);
  pointer-events: none;
}

/* Nav link — inactive: muted, active: gold with glow */
.tb-navbar-link {
  color: var(--tb-sidebar-nav-color);
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
}
.tb-navbar-link:hover {
  color: var(--tb-text-light);
  background: rgba(194, 135, 58, 0.06);
}
.tb-navbar-link.active {
  color: var(--tb-gold);
}

/* Dropdown trigger */
.tb-navbar-dropdown-trigger {
  color: var(--tb-sidebar-nav-color);
  position: relative;
  transition: all 0.15s ease;
}
.tb-navbar-dropdown-trigger:hover,
.tb-navbar-dropdown-trigger[aria-expanded="true"] {
  color: var(--tb-text-light);
  background: rgba(194, 135, 58, 0.08);
}
/* Chevron rotation */
.tb-navbar-dropdown-trigger svg.chevron {
  transition: transform 0.2s ease;
}
.tb-navbar-dropdown-trigger[aria-expanded="true"] svg.chevron {
  transform: rotate(180deg);
}

/* Active dropdown trigger (child page is active) */
.tb-navbar-dropdown-trigger.active {
  color: var(--tb-gold);
}

/* Dropdown section label */
.tb-dropdown-section-label {
  color: var(--tb-sidebar-section-label);
  pointer-events: none;
}

/* Dark dropdown menu */
.tb-dropdown-menu {
  background: var(--tb-sidebar-bg);
  border: 1px solid rgba(194, 135, 58, 0.12);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(194, 135, 58, 0.06);
  min-width: 220px;
  animation: dropdownReveal 0.15s ease;
}
@keyframes dropdownReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Dropdown item */
.tb-dropdown-item {
  color: var(--tb-sidebar-nav-color);
  transition: all 0.12s ease;
}
.tb-dropdown-item:hover {
  background: rgba(194, 135, 58, 0.08);
  color: var(--tb-text-light);
}
.tb-dropdown-item.active {
  color: var(--tb-gold);
  background: rgba(194, 135, 58, 0.1);
}

.tb-dropdown-divider {
  border-top: 1px solid rgba(194, 135, 58, 0.08);
}

/* Segment control — pill-style view switcher */
.tb-segment-control {
  display: inline-flex;
  align-items: center;
  background: var(--tb-surface-input-alt);
  border: 1px solid var(--tb-border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.tb-segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tb-text-tertiary);
  transition: all 0.15s ease;
  text-decoration: none;
}

.tb-segment:hover {
  color: var(--tb-text-primary);
  background: var(--tb-surface-card);
}

.tb-segment.active {
  background: var(--tb-gold-gradient);
  color: white;
  box-shadow: var(--tb-gold-shadow);
  pointer-events: none;
}

/* Org badge (navbar) */
.tb-navbar-org-badge {
  color: var(--tb-gold);
  background: rgba(194, 135, 58, 0.08);
  border: 1px solid rgba(194, 135, 58, 0.12);
}

/* User avatar in navbar */
.tb-navbar-avatar {
  background: rgba(194, 135, 58, 0.12);
  color: var(--tb-gold);
  border: 2px solid rgba(194, 135, 58, 0.25);
  transition: border-color 0.2s ease;
}
.tb-navbar-avatar:hover {
  border-color: rgba(194, 135, 58, 0.5);
}

/* Mobile overlay + panel */
.tb-mobile-overlay {
  background: rgba(12, 18, 34, 0.6);
  backdrop-filter: blur(4px);
}
.tb-mobile-panel {
  background: var(--tb-sidebar-bg);
}

/* Mobile nav link */
.tb-mobile-nav-link {
  color: var(--tb-sidebar-nav-color);
  transition: all 0.15s ease;
}
.tb-mobile-nav-link:hover {
  color: var(--tb-text-light);
  background: rgba(194, 135, 58, 0.06);
}
.tb-mobile-nav-link.active {
  color: var(--tb-gold);
  background: rgba(194, 135, 58, 0.1);
  border-left: 3px solid var(--tb-gold);
  padding-left: 9px; /* compensate for border */
}

/* Mobile section label */
.tb-mobile-section-label {
  color: var(--tb-sidebar-section-label);
}

/* Turbo progress bar */
.turbo-progress-bar {
  background: var(--tb-gold);
  height: 3px;
}

/* ==========================================================================
   Component Classes
   ========================================================================== */

/* Card — white background, border, rounded */
.tb-card {
  background: var(--tb-surface-card);
  border: 1px solid var(--tb-border);
  border-radius: 1rem; /* rounded-2xl */
}

/* Input field */
.tb-input {
  background: var(--tb-surface-input);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-primary);
  --tw-ring-color: var(--tb-gold-ring);
}

/* Monospace input (keys, slugs, regex) */
.tb-input-mono {
  background: var(--tb-surface-input);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-primary);
  font-family: var(--tb-font-mono);
  --tw-ring-color: var(--tb-gold-ring);
}

/* Form label */
.tb-label {
  color: var(--tb-text-primary);
}

/* Small form label (used in some compact forms) */
.tb-label-sm {
  color: var(--tb-text-tertiary);
}

/* Primary button — gold gradient */
.tb-btn-primary {
  background: var(--tb-gold-gradient);
  box-shadow: var(--tb-gold-shadow);
}

/* Cancel / muted text button */
.tb-btn-cancel {
  color: var(--tb-text-tertiary);
}

/* Danger text button */
.tb-btn-danger {
  color: var(--tb-danger-text);
}

/* Outlined danger button (deactivate) */
.tb-btn-danger-outline {
  color: var(--tb-danger-text);
  border: 1px solid var(--tb-danger-border);
}
/* Outlined restore/reactivate button (green) */
.tb-btn-restore {
  color: var(--tb-success-text);
  border: 1px solid var(--tb-success-border);
}

/* Active badge */
.tb-badge-active {
  background: var(--tb-success-badge-bg);
  color: var(--tb-success-text);
}

/* Inactive badge */
.tb-badge-inactive {
  background: var(--tb-inactive-bg);
  color: var(--tb-inactive-text);
}

/* Info badge (blue) */
.tb-badge-info {
  background: var(--tb-info-bg);
  color: var(--tb-info-text);
}

/* Gold badge */
.tb-badge-gold {
  background: var(--tb-gold-subtle-bg);
  color: var(--tb-gold);
}

/* Danger badge (red — deactivated, error) */
.tb-badge-danger {
  background: var(--tb-danger-bg);
  color: var(--tb-danger-text);
}
/* Warning badge (amber — draft, pending) */
.tb-badge-warning {
  background: var(--tb-warning-bg);
  color: var(--tb-warning-text);
}

/* Table header cell */
.tb-table-header {
  color: var(--tb-text-tertiary);
}

/* Gold link (edit, details, etc.) */
.tb-link-gold {
  color: var(--tb-gold);
}

/* Back/cancel link */
.tb-link-back {
  color: var(--tb-text-tertiary);
}

/* Sidebar gradient divider */
.tb-divider {
  background: var(--tb-sidebar-divider);
}

/* Error box for form validation */
.tb-error-box {
  background: var(--tb-danger-bg);
  border: 1px solid var(--tb-danger-border);
  color: var(--tb-danger-text);
}

/* Toast notification — base */
.tb-toast {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Toast success — solid card for overlay visibility */
.tb-toast-success {
  background: var(--tb-surface-card);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-primary);
}

/* Pill tab navigation */
.tb-tab-active {
  background: var(--tb-gold);
  color: #fff;
}
.tb-tab-inactive {
  color: var(--tb-text-muted);
}
.tb-tab-inactive:hover {
  background: var(--tb-gold-hover-bg);
}

/* Toast error */
.tb-toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
[data-theme="dark"] .tb-toast-error {
  background: #3b1111;
  border: 1px solid #5c2020;
  color: #f07070;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-toast-error {
    background: #3b1111;
    border: 1px solid #5c2020;
    color: #f07070;
  }
}

/* Checkbox matching brand */
.tb-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  border-radius: 0.25rem;
  border: 1.5px solid var(--tb-border);
  background-color: var(--tb-surface-card);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
  vertical-align: middle;
}
.tb-checkbox:hover {
  border-color: var(--tb-gold);
  background-color: var(--tb-gold-hover-bg);
}
.tb-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--tb-gold-ring);
  border-color: var(--tb-gold);
}
.tb-checkbox:checked {
  background-color: var(--tb-gold);
  border-color: var(--tb-gold);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 8l3.5 3.5L13 5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}
.tb-checkbox:checked:hover {
  background-color: var(--tb-gold-dark);
  border-color: var(--tb-gold-dark);
}
.tb-checkbox:checked:focus {
  box-shadow: 0 0 0 3px var(--tb-gold-ring);
}
.tb-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
[data-theme="dark"] .tb-checkbox {
  border-color: rgba(194, 135, 58, 0.35);
  background-color: rgba(255, 255, 255, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-checkbox {
    border-color: rgba(194, 135, 58, 0.35);
    background-color: rgba(255, 255, 255, 0.06);
  }
}

/* Table border-bottom for thead rows */
.tb-border-b {
  border-bottom: 1px solid var(--tb-border);
}

/* Table tbody divider color */
.tb-divide-light {
  border-color: var(--tb-border-light);
}

/* Code/tag inline style */
.tb-code {
  background: var(--tb-surface-input-alt);
  color: var(--tb-text-secondary);
  font-family: var(--tb-font-mono);
}

/* Body defaults */
.tb-body {
  background: var(--tb-surface-page);
  color: #1a1a2e;
}

/* Icon container (small) */
.tb-icon-container {
  background: var(--tb-gold-active-bg);
}

/* Icon container (on dark) */
.tb-icon-container-dark {
  background: rgba(194, 135, 58, 0.12);
}

/* Sidebar badge (org name / sysadmin) */
.tb-sidebar-badge {
  color: var(--tb-sidebar-badge-color);
  background: var(--tb-sidebar-badge-bg);
  border: 1px solid var(--tb-sidebar-badge-border);
}

/* Sidebar sysadmin badge */
.tb-sidebar-badge-sysadmin {
  color: var(--tb-gold);
  background: var(--tb-gold-subtle-bg);
  border: 1px solid var(--tb-gold-border);
}

/* User avatar */
.tb-avatar {
  background: rgba(194, 135, 58, 0.12);
  color: var(--tb-gold);
}

/* User name in sidebar */
.tb-user-name {
  color: var(--tb-text-light);
}

/* User email in sidebar */
.tb-user-email {
  color: var(--tb-sidebar-section-label);
}


/* Description list item border */
.tb-dl-border {
  border-bottom: 1px solid var(--tb-border-light);
}

/* Page heading */
.tb-heading {
  color: var(--tb-text-primary);
}

/* Subheading / description */
.tb-subtext {
  color: var(--tb-text-tertiary);
}

/* Secondary text */
.tb-text-secondary {
  color: var(--tb-text-secondary);
}

/* Metric card (dark) */
.tb-metric-dark {
  background: var(--tb-sidebar-bg);
  border: 1px solid var(--tb-border-gold);
}

/* Metric card label */
.tb-metric-label {
  color: var(--tb-text-muted);
}

/* Metric card value on dark bg */
.tb-metric-value-light {
  color: var(--tb-text-light);
}

/* Impersonation banner */
.tb-impersonation-banner {
  background: var(--tb-gold);
  color: white;
}

.tb-impersonation-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.tb-impersonation-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Badge System
   ========================================================================== */

/* Base badge */
.tb-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
}

/* Larger badge variant for headers */
.tb-badge-lg {
  padding: 4px 10px;
  font-size: 11px;
}

/* Subscription: trial (blue) */
.tb-badge-trial {
  background: var(--tb-info-bg);
  color: var(--tb-info-text);
}

/* Subscription: suspended (amber) */
.tb-badge-suspended {
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
}

/* Role: sysadmin (gold) */
.tb-badge-sysadmin {
  background: var(--tb-gold-subtle-bg);
  color: var(--tb-gold);
}

/* Role: admin (blue) — alias of info */
.tb-badge-admin {
  background: var(--tb-info-bg);
  color: var(--tb-info-text);
}

/* Question type: purple */
.tb-badge-purple {
  background: rgba(147, 51, 234, 0.08);
  color: #7c3aed;
}

/* ==========================================================================
   FOI Status & Priority Badges
   ========================================================================== */

/* FOI status: in_progress (teal) */
.tb-badge-foi-in-progress {
  background: rgba(20, 184, 166, 0.08);
  color: #0d9488;
}

/* FOI status: extended (amber) */
.tb-badge-foi-extended {
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
}

/* FOI priority: high (orange) */
.tb-badge-foi-high {
  background: rgba(249, 115, 22, 0.08);
  color: #c2410c;
}

/* FOI priority: urgent (red) */
.tb-badge-foi-urgent {
  background: var(--tb-danger-bg);
  color: var(--tb-danger-text);
}

/* FOI deadline: overdue */
.tb-badge-foi-overdue {
  background: var(--tb-danger-bg);
  color: var(--tb-danger-text);
}

/* FOI deadline: approaching */
.tb-badge-foi-deadline-warning {
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
}

/* FOI deadline: safe */
.tb-badge-foi-deadline-ok {
  background: var(--tb-success-badge-bg);
  color: var(--tb-success-text);
}

/* Draft badge */
.tb-badge-draft {
  background: var(--tb-bg-subtle, #f5f2ed);
  color: var(--tb-text-secondary, #7c7c7c);
  border: 1px solid var(--tb-border, #ddd);
}

/* Drag-and-drop active state */
.tb-dropzone-active {
  border-color: var(--tb-gold, #c2873a) !important;
  background: var(--tb-gold-subtle-bg, rgba(194, 135, 58, 0.05));
}

/* ==========================================================================
   Button Variants
   ========================================================================== */

/* Secondary button — neutral */
.tb-btn-secondary {
  background: var(--tb-surface-page);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-primary);
}

/* Gold outlined button */
.tb-btn-gold-outline {
  background: var(--tb-gold-hover-bg);
  color: var(--tb-gold);
  border: 1px solid var(--tb-gold-border);
}

/* ==========================================================================
   Table & Layout Utilities
   ========================================================================== */

/* Toggle switch */
.tb-toggle-off {
  background: var(--tb-border);
}
.tb-toggle-on {
  background: var(--tb-gold);
}

/* Table row hover */
.tb-row-hover {
  transition: background-color 0.15s ease;
}
.tb-row-hover:hover {
  background: var(--tb-surface-input);
}

/* Bordered action card link */
.tb-action-card {
  border: 1px solid var(--tb-border);
}

/* ==========================================================================
   Form Utilities
   ========================================================================== */

/* Styled file input */
.tb-file-input {
  color: var(--tb-text-secondary);
  font-size: 13px;
}
.tb-file-input::file-selector-button {
  background: var(--tb-surface-page);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-right: 8px;
  transition: opacity 0.15s ease;
}
.tb-file-input::file-selector-button:hover {
  opacity: 0.8;
}

/* Read-only info box */
.tb-info-box {
  background: var(--tb-surface-input);
  border: 1px solid var(--tb-border-lighter);
}

/* Disabled/readonly input look */
.tb-input-disabled {
  background: var(--tb-surface-page);
  border: 1px solid var(--tb-border);
  color: var(--tb-text-tertiary);
}

/* Step number circle */
.tb-step-number {
  background: var(--tb-gold-hover-bg);
  color: var(--tb-gold);
}

/* Faintest text */
.tb-text-faint {
  color: var(--tb-text-faint);
}

/* Muted text */
.tb-text-muted {
  color: var(--tb-text-muted);
}

/* ==========================================================================
   Landing Page — Product Showcase
   ========================================================================== */

.showcase-section {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.showcase-step {
  display: flex;
  align-items: flex-start;
  gap: 3rem;
}
.showcase-step:nth-child(even) {
  flex-direction: row-reverse;
}

.showcase-text {
  flex: 0 0 320px;
  padding-top: 2rem;
}

.showcase-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c2873a 0%, #a16b2a 100%);
  color: #fff;
  font-family: var(--tb-font-serif);
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 1rem;
}

.showcase-heading {
  font-family: var(--tb-font-serif);
  font-size: 1.75rem;
  line-height: 1.2;
  color: #f0ece6;
  margin-bottom: 0.75rem;
}

.showcase-description {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: #8893a7;
}

.showcase-image-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
}

.showcase-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(194, 135, 58, 0.15);
  box-shadow: 0 20px 50px -12px rgba(12, 18, 34, 0.4);
}

.showcase-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  border: 1px solid rgba(194, 135, 58, 0.15);
  box-shadow: 0 20px 50px -12px rgba(12, 18, 34, 0.4);
  background: #141e33;
  color: #5a6478;
  font-size: 0.875rem;
  font-weight: 500;
}

.showcase-annotation {
  position: absolute;
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #0c1222;
  box-shadow: 0 4px 16px -2px rgba(12, 18, 34, 0.15);
  border-left: 3px solid #c2873a;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

/* Mobile annotations: inline list below image */
.showcase-annotations-mobile {
  display: none;
  margin-top: 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.showcase-annotations-mobile .showcase-annotation-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(194, 135, 58, 0.08);
  border: 1px solid rgba(194, 135, 58, 0.15);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #f0ece6;
}
.showcase-annotations-mobile .showcase-annotation-inline::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c2873a;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .showcase-step,
  .showcase-step:nth-child(even) {
    flex-direction: column;
  }
  .showcase-text {
    flex: none;
    padding-top: 0;
  }
  .showcase-annotation {
    display: none;
  }
  .showcase-annotations-mobile {
    display: flex;
  }
}

/* ==========================================================================
   Landing Page — Step Connector Line
   ========================================================================== */

.steps-connector {
  position: relative;
}

@media (min-width: 768px) {
  .steps-connector::before {
    content: '';
    position: absolute;
    top: 38px;
    left: calc(16.67% + 16px);
    right: calc(16.67% + 16px);
    height: 2px;
    background: linear-gradient(90deg, rgba(194, 135, 58, 0.15), rgba(194, 135, 58, 0.4), rgba(194, 135, 58, 0.15));
    border-radius: 1px;
    z-index: 0;
  }
}

/* ==========================================================================
   Landing Page — Contact Section
   ========================================================================== */

.contact-icon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
}

.contact-icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(194, 135, 58, 0.1);
}

/* ==========================================================================
   Landing Page — Scroll Reveal & Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .animate-fade-up,
  .animate-fade-in,
  .pulse-subtle,
  .scroll-indicator,
  .demo-prompt-pulse {
    animation: none !important;
  }
}

/* ==========================================================================
   Landing Page — Hero Showcase (screenshot tabs)
   ========================================================================== */

/* Tab buttons (inactive) */
.hero-tab {
  color: #5a6478;
  background: transparent;
  border: none;
  cursor: pointer;
}
.hero-tab:hover {
  color: #8893a7;
  background: rgba(194, 135, 58, 0.06);
}

/* Active tab: gold tint */
.hero-tab-active {
  background: rgba(194, 135, 58, 0.15) !important;
  color: #c2873a !important;
}

/* Screenshot placeholder container */
.hero-screenshot-placeholder {
  aspect-ratio: 16 / 10;
  position: relative;
  overflow: hidden;
  background: #141e33;
}

/* Actual screenshot image (when available) */
.hero-screenshot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fallback shown when image fails to load */
.hero-screenshot-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  text-align: center;
  padding: 2rem;
}

/* ==========================================================================
   Landing Page — Interactive Demo Component (deprecated, kept for _demo.html.erb)
   ========================================================================== */

.demo-passage {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.demo-passage:hover {
  background-color: rgba(194, 135, 58, 0.12) !important;
}
.demo-stamp-picker {
  position: absolute;
  z-index: 50;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 32px -4px rgba(12, 18, 34, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  min-width: 240px;
}
.demo-stamp-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.demo-stamp-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  text-align: left;
  transition: background-color 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
}
.demo-stamp-option:hover { background: #f4f2ee; }
.demo-stamp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.demo-stamp-ref { display: block; font-size: 11px; font-weight: 600; color: #0c1222; }
.demo-stamp-label-text { display: block; font-size: 10px; color: #6b7a92; }
.demo-tab { color: #5a6478; background: transparent; border: none; cursor: pointer; }
.demo-tab:hover { color: #8893a7; background: rgba(194, 135, 58, 0.06); }
.demo-tab-active { background: rgba(194, 135, 58, 0.15) !important; color: #c2873a !important; }
.demo-reset-btn { color: #c2873a; }
.demo-reset-btn:hover { color: #d4a054; }
.demo-table-header { padding: 8px 6px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #5a6478; }
.demo-table-row { border-bottom: 1px solid rgba(194, 135, 58, 0.06); }
.demo-table-cell { padding: 8px 6px; font-size: 11px; color: #8893a7; }
.demo-table-cell:last-child { text-align: right; }
.demo-badge { display: inline-block; padding: 2px 10px; border-radius: 9999px; font-size: 10px; font-weight: 600; }
.demo-letter-placeholder { font-size: 11px; line-height: 1.6; color: #5a6478; font-style: italic; }
.demo-letter-intro { font-size: 11px; line-height: 1.6; color: #8893a7; margin-bottom: 12px; }
.demo-letter-item { font-size: 11px; line-height: 1.6; color: #8893a7; padding: 4px 0; border-bottom: 1px solid rgba(194, 135, 58, 0.06); }
.demo-letter-ref { font-weight: 700; font-size: 11px; }
.demo-letter-footer { font-size: 11px; line-height: 1.6; color: #5a6478; margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(194, 135, 58, 0.08); }
@keyframes demoPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.demo-prompt-pulse { animation: demoPulse 2.5s ease-in-out infinite; }

/* ==========================================================================
   Letter Paper — Decision Letter Editor
   ========================================================================== */

.letter-paper {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 4px 16px rgba(0, 0, 0, 0.06),
              0 0 0 1px rgba(0, 0, 0, 0.03);
  min-height: 1000px;
}

/* Paper stays white in dark mode — it's a real letter */
[data-theme="dark"] .letter-paper,
:root:not([data-theme="light"]) .letter-paper {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2),
              0 4px 16px rgba(0, 0, 0, 0.25),
              0 0 0 1px rgba(255, 255, 255, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .letter-paper {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2),
                0 4px 16px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

.letter-paper-body {
  padding: 3rem;
  font-family: var(--tb-font-serif);
  color: #1a1a2e;
}

/* Section container */
.letter-section {
  position: relative;
}

/* Inline section header bar */
.letter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  margin: 0 -8px 4px;
  border-radius: 6px;
  font-family: var(--tb-font-body);
  font-size: 11px;
  color: var(--tb-text-tertiary);
  opacity: 0.5;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.letter-section:hover .letter-section-header {
  opacity: 1;
  background: rgba(194, 135, 58, 0.03);
}

.letter-section-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.letter-section-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.letter-section-drag-handle {
  cursor: grab;
  opacity: 0.4;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}

.letter-section-drag-handle:active { cursor: grabbing; }
.letter-section:hover .letter-section-drag-handle { opacity: 0.7; }

.letter-section-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.letter-section-badge-override {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 9999px;
  font-size: 9px;
  font-weight: 600;
  background: rgba(217, 119, 6, 0.1);
  color: #b45309;
  white-space: nowrap;
}

.letter-section-badge-required {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 9999px;
  font-size: 9px;
  font-weight: 600;
  background: var(--tb-inactive-bg);
  color: var(--tb-inactive-text);
  white-space: nowrap;
}

.letter-section-action {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--tb-text-tertiary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.letter-section-action:hover {
  background: var(--tb-gold-hover-bg);
  color: var(--tb-gold);
}

/* Section content (display mode) */
.letter-section-content {
  position: relative;
  cursor: text;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.625;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.15s ease;
}

.letter-section-content:hover {
  background: rgba(194, 135, 58, 0.06);
}

/* Pencil edit hint — appears on hover */
.letter-section-edit-hint {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  color: var(--tb-text-tertiary);
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.letter-section-content:hover .letter-section-edit-hint {
  opacity: 0.5;
}

/* Textarea with gold focus ring */
.letter-section-textarea {
  width: 100%;
  padding: 8px;
  font-size: 14px;
  line-height: 1.625;
  background: rgba(194, 135, 58, 0.04);
  border: 1px solid rgba(194, 135, 58, 0.15);
  border-radius: 6px;
  outline: none;
  resize: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.letter-section-textarea:focus {
  border-color: var(--tb-gold);
  box-shadow: 0 0 0 3px var(--tb-gold-ring);
}

/* Ghost input — transparent, looks like text until focused */
.letter-ghost-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  color: #1a1a2e;
  outline: none;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: 100%;
  font-family: var(--tb-font-body);
}

.letter-ghost-input:hover {
  background: var(--tb-gold-hover-bg);
}

.letter-ghost-input:focus {
  background: var(--tb-gold-hover-bg);
  border-color: var(--tb-gold);
}

/* ---------- Two-column editor layout ---------- */

.letter-editor-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  max-width: 1080px;
  margin: 0 auto;
}

.letter-editor-main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
}

.letter-editor-sidebar {
  width: 280px;
  flex-shrink: 0;
}

.letter-sidebar-sticky {
  position: sticky;
  top: 2rem;
}

/* Mobile sidebar toggle (hidden on desktop) */
.letter-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  background: var(--tb-gold);
  color: #fff;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--tb-gold-shadow-lg);
  transition: transform 0.15s ease;
}

.letter-sidebar-toggle:hover {
  transform: scale(1.05);
}

@media (max-width: 1023px) {
  .letter-editor-layout {
    display: block;
    max-width: 720px;
  }

  .letter-editor-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 50;
    background: var(--tb-surface-card);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 1.5rem;
  }

  .letter-editor-sidebar.letter-sidebar-open {
    transform: translateX(0);
  }

  .letter-sidebar-sticky {
    position: static;
  }

  .letter-sidebar-toggle {
    display: flex;
  }
}

/* ---------- Metadata grid ---------- */

.letter-meta-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.letter-meta-group {
  display: flex;
  flex-direction: column;
}

.letter-meta-label {
  font-family: var(--tb-font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tb-text-tertiary);
  margin-bottom: 2px;
}

.letter-ghost-input-lg {
  font-size: 18px;
  font-weight: 600;
}

.letter-meta-static {
  font-family: var(--tb-font-body);
  font-size: 12px;
  color: var(--tb-text-muted);
  padding: 2px 6px;
}

/* ---------- Save indicator ---------- */

.letter-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-family: var(--tb-font-body);
  font-size: 11px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.letter-save-indicator[data-state="saving"] {
  background: rgba(194, 135, 58, 0.1);
  color: var(--tb-gold);
}

.letter-save-indicator[data-state="saved"] {
  background: var(--tb-success-badge-bg);
  color: var(--tb-success-text);
}

.letter-save-indicator[data-state="error"] {
  background: var(--tb-danger-bg);
  color: var(--tb-danger-text);
}

.letter-save-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: letter-spin 0.6s linear infinite;
}

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

/* Override indicator: subtle gold left border */
.letter-section-override {
  border-left: 2px solid rgba(194, 135, 58, 0.4);
  padding-left: 0.5rem;
}

/* Variable placeholder highlight */
.letter-variable-highlight {
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- Letter template preview ---------- */

.letter-preview-frame {
  background: #46464a;
  border-radius: 10px;
  overflow: hidden;
}

.letter-preview-toolbar {
  background: #333337;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.letter-preview-page-area {
  padding: 36px 48px 52px;
}

.letter-preview-paper {
  background: #fff;
  max-width: 680px;
  margin: 0 auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  border-radius: 1px;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  color: #1a1a1a;
}

.letter-preview-header {
  padding: 52px 60px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}

.letter-preview-recipient {
  padding-top: 36px;
  font-size: 11px;
  line-height: 1.6;
  color: #888;
}

.letter-preview-recipient-name {
  font-weight: 600;
  color: #1a1a1a;
}

.letter-preview-sender {
  text-align: right;
  flex-shrink: 0;
}

.letter-preview-logo {
  max-width: 130px;
  max-height: 52px;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-bottom: 14px;
}

.letter-preview-logo-placeholder {
  width: 130px;
  height: 52px;
  border-radius: 6px;
  background: #f5f2ed;
  border: 1.5px dashed #ccc8c0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-left: auto;
  margin-bottom: 14px;
}

.letter-preview-logo-text {
  font-size: 10px;
  color: #b8b0a8;
  font-family: system-ui, sans-serif;
}

.letter-preview-address {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 10px;
  color: #888;
}

.letter-preview-skeleton {
  height: 9px;
  border-radius: 3px;
  background: #efecea;
}

.letter-preview-spacer {
  height: 72px;
}

.letter-preview-body {
  padding: 0 60px 60px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.letter-preview-meta {
  width: 110px;
  flex-shrink: 0;
  font-size: 11.5px;
  line-height: 1.5;
}

.letter-preview-meta-label {
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.letter-preview-meta-value {
  color: #888;
  margin-bottom: 16px;
}

.letter-preview-meta-value-last {
  margin-bottom: 0;
}

.letter-preview-content {
  flex: 1;
  min-width: 0;
}

.letter-preview-section-text {
  font-size: 12.5px;
  line-height: 1.9;
  color: #1a1a1a;
  margin: 0 0 20px 0;
  white-space: pre-wrap;
}

.letter-preview-auto-section {
  border: 1.5px dashed #ccc8be;
  border-radius: 5px;
  padding: 12px 16px;
  background: #faf8f5;
  margin-bottom: 20px;
}

.letter-preview-auto-section-text {
  font-size: 11.5px;
  color: #a09888;
  font-style: italic;
  margin: 0;
}

/* ---------- Structured letter editor (paper metaphor) ---------- */

.letter-paper-body--structured {
  padding: 0;
  font-family: var(--tb-font-serif);
  color: #1a1a2e;
}

.letter-editor-header {
  padding: 52px 60px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}

.letter-editor-recipient {
  display: flex;
  flex-direction: column;
  padding-top: 36px;
  flex: 1;
  min-width: 0;
}

.letter-ghost-input--name {
  font-size: 11px;
  font-weight: 600;
  color: #1a1a2e;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
}

.letter-ghost-input--address {
  font-size: 11px;
  color: #888;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  margin-top: 2px;
}

.letter-ghost-input--meta {
  font-size: 11px;
  color: #888;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  width: 100%;
  margin-bottom: 16px;
}

.letter-editor-spacer {
  height: 72px;
}

.letter-editor-body-grid {
  padding: 0 60px 60px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.letter-editor-meta {
  width: 110px;
  flex-shrink: 0;
  font-size: 11.5px;
  line-height: 1.5;
}

.letter-editor-meta-label {
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 2px;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
}

.letter-editor-meta-value {
  color: #888;
  margin-bottom: 16px;
  font-size: 11.5px;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
}

.letter-editor-content {
  flex: 1;
  min-width: 0;
}

/* Print-only metadata sidebar — hidden on screen, shown on print */
.letter-editor-meta--print {
  display: none;
}

/* Hover-revealed section controls */
.letter-section-controls {
  position: absolute;
  right: 4px;
  top: 2px;
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 2px;
}

.letter-section:hover .letter-section-controls {
  opacity: 1;
}

/* Always show controls on excluded sections */
.letter-section-controls--visible {
  opacity: 1;
}

/* Section headings */
.letter-section-heading {
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  color: #1a1a2e;
  margin-bottom: 2px;
  margin-top: 4px;
}

.letter-section-heading--heading_2 {
  font-size: 13px;
  font-weight: 700;
}

.letter-section-heading--heading_3 {
  font-size: 12.5px;
  font-weight: 600;
}

/* Hide old header bar inside structured layout */
.letter-paper-body--structured .letter-section-header {
  display: none;
}

/* No override border in structured layout — already indicated by badge + reset button */
.letter-paper-body--structured .letter-section-override {
  border-left: none;
  padding-left: 0;
}

/* Structured layout: tighten section spacing */
.letter-paper-body--structured .letter-section {
  margin-bottom: 0;
}

.letter-paper-body--structured .letter-section > .h-3 {
  height: 6px;
}

/* Structured layout typography for section content */
.letter-paper-body--structured .letter-section-content {
  font-size: 12.5px;
  line-height: 1.7;
  padding: 2px 4px;
  border-radius: 2px;
}

.letter-paper-body--structured .letter-section-textarea {
  font-size: 12.5px;
  line-height: 1.7;
  padding: 4px 6px;
  min-height: 3em;
}

/* Letter preview subject line */
.letter-preview-subject {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 20px;
}

/* Responsive: structured editor */
@media (max-width: 1023px) {
  .letter-editor-header {
    flex-direction: column;
    padding: 32px 24px 0;
    gap: 24px;
  }

  .letter-editor-recipient {
    padding-top: 0;
  }

  .letter-editor-body-grid {
    flex-direction: column;
    padding: 0 24px 32px;
    gap: 24px;
  }

  .letter-editor-meta {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    align-items: baseline;
  }

  .letter-editor-meta .letter-ghost-input--meta {
    margin-bottom: 0;
  }

  .letter-editor-spacer {
    height: 36px;
  }

  .letter-section-controls {
    position: static;
    opacity: 1;
    margin-bottom: 4px;
    background: transparent;
  }
}

/* ---------- Template selection layout ---------- */

.template-selection-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.template-selection-guide {
  flex: 1;
  min-width: 0;
}

.template-selection-picker {
  width: 380px;
  flex-shrink: 0;
  position: sticky;
  top: 2rem;
}

.template-selection-picker-centered {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: static;
}

@media (max-width: 1023px) {
  .template-selection-layout {
    flex-direction: column;
  }

  .template-selection-picker {
    width: 100%;
    position: static;
  }
}

/* ---------- Template picker cards ---------- */

.template-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-picker-card {
  position: relative;
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--tb-border);
  background: var(--tb-surface-card);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.template-picker-card:hover {
  border-color: var(--tb-gold-border);
  background: var(--tb-gold-hover-bg);
}

.template-picker-card:has(input:checked) {
  border-color: var(--tb-gold);
  box-shadow: 0 0 0 3px var(--tb-gold-ring);
}

.template-picker-card.template-picker-recommended {
  border-color: var(--tb-gold-border);
}

.template-picker-card.template-picker-recommended .template-picker-badge {
  display: inline-flex;
}

.template-picker-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--tb-text-primary);
}

.template-picker-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(217, 119, 6, 0.1);
  color: #b45309;
}

/* ---------- Sidebar section list ---------- */

.letter-sidebar-panel {
  background: var(--tb-surface-card);
  border-radius: 1rem;
  border: 1px solid var(--tb-border-light);
  overflow: hidden;
}

.letter-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tb-border-light);
}

.letter-sidebar-list {
  padding: 4px 0;
}

.letter-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  transition: background 0.12s ease;
}

.letter-sidebar-item:hover {
  background: var(--tb-gold-hover-bg);
}

.letter-sidebar-item-excluded {
  opacity: 0.4;
}

.letter-sidebar-item-num {
  font-family: var(--tb-font-body);
  font-size: 11px;
  color: var(--tb-text-tertiary);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.letter-sidebar-item-link {
  flex: 1;
  min-width: 0;
  font-family: var(--tb-font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--tb-text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s ease;
}

.letter-sidebar-item-link:hover {
  color: var(--tb-gold);
}

.letter-sidebar-item-toggle {
  margin-left: auto;
}

/* Print styles for letter paper */
@media print {
  .letter-paper {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    min-height: auto !important;
  }

  .letter-paper-body {
    padding: 0 !important;
  }

  /* Hide all editor chrome */
  .letter-section-header,
  .letter-section-edit-hint,
  .letter-section-controls,
  .letter-editor-sidebar,
  .letter-sidebar-toggle,
  .letter-save-indicator,
  .no-print {
    display: none !important;
  }

  /* Show print-only metadata sidebar */
  .letter-editor-meta--print {
    display: block !important;
    width: 110px;
    flex-shrink: 0;
    font-size: 11.5px;
    line-height: 1.5;
  }

  .letter-editor-meta--print .letter-editor-meta-label {
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 2px;
    font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  }

  .letter-editor-meta--print .letter-editor-meta-value {
    color: #555;
    margin-bottom: 16px;
    font-size: 11.5px;
    font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  }

  /* Full width paper */
  .letter-editor-layout {
    display: block !important;
  }

  .letter-editor-main {
    max-width: none !important;
  }

  /* Clean up ghost inputs */
  .letter-ghost-input {
    background: transparent !important;
    border: none !important;
    padding: 0 2px !important;
    color: #1a1a2e !important;
  }

  .letter-ghost-input-lg {
    font-size: 18px !important;
  }

  /* Structured layout print adjustments */
  .letter-paper-body--structured {
    padding: 0 !important;
  }

  .letter-editor-header {
    padding: 40px 40px 0 !important;
  }

  /* Keep the body grid as flex in print (not block) */
  .letter-editor-body-grid {
    display: flex !important;
    padding: 0 40px 40px !important;
  }

  .letter-editor-spacer {
    height: 48px !important;
  }

  /* Hide entire excluded sections in print */
  .letter-section[data-included="false"] {
    display: none !important;
  }

  /* No override borders in print */
  .letter-section-override {
    border-left: none !important;
    padding-left: 0 !important;
  }

  /* No variable highlights in print */
  .letter-variable-highlight {
    background: transparent !important;
    padding: 0 !important;
  }

  /* Section spacing in print */
  .letter-paper-body--structured .letter-section > .h-3 {
    height: 4px !important;
  }

  /* Section content: keep some padding */
  .letter-paper-body--structured .letter-section-content {
    padding: 2px 0 !important;
  }

  .letter-section-content {
    padding: 2px 0 !important;
  }

  /* Letter preview frame: remove chrome for print */
  .letter-preview-frame {
    background: transparent !important;
    border-radius: 0 !important;
  }

  .letter-preview-page-area {
    padding: 0 !important;
  }

  .letter-preview-paper {
    box-shadow: none !important;
    max-width: none !important;
  }

  .letter-preview-toolbar {
    display: none !important;
  }
}

/* Demo section — mobile responsiveness */
@media (max-width: 767px) {
  .demo-titlebar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
  }
  .demo-tab svg {
    display: none;
  }
  .demo-tab {
    padding: 4px 10px;
    font-size: 10px;
  }
  .demo-content {
    min-height: 320px !important;
  }
  .demo-doc-panel {
    border-right: none !important;
    border-bottom: 1px solid rgba(194, 135, 58, 0.1);
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   VIDENSBANK — Article body typography
   ──────────────────────────────────────────────────────────────────────────── */

.tb-article-body {
  font-family: var(--tb-font-body);
  font-size: 14px;
  line-height: 1.75;
  color: var(--tb-text-primary);
}
.tb-article-body h1 { font-family: var(--tb-font-serif); font-size: 1.75rem; font-weight: 400; margin: 2rem 0 0.75rem; }
.tb-article-body h2 { font-family: var(--tb-font-serif); font-size: 1.35rem; font-weight: 400; margin: 1.75rem 0 0.5rem; }
.tb-article-body h3 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.tb-article-body h4 { font-size: 0.95rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.tb-article-body p { margin: 0 0 1rem; }
.tb-article-body ul, .tb-article-body ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.tb-article-body li { margin: 0.25rem 0; }
.tb-article-body ul { list-style: disc; }
.tb-article-body ol { list-style: decimal; }
.tb-article-body a { color: var(--tb-gold); text-decoration: underline; text-underline-offset: 2px; }
.tb-article-body a:hover { opacity: 0.7; }
.tb-article-body blockquote {
  border-left: 3px solid var(--tb-gold);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--tb-text-secondary);
  background: var(--tb-surface-input);
  border-radius: 0 8px 8px 0;
}
.tb-article-body code {
  font-family: var(--tb-font-mono);
  font-size: 0.85em;
  background: var(--tb-surface-input);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.tb-article-body pre {
  background: var(--tb-surface-input);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
}
.tb-article-body pre code {
  background: none;
  padding: 0;
}
.tb-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 13px;
}
.tb-article-body th, .tb-article-body td {
  border: 1px solid var(--tb-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.tb-article-body th { background: var(--tb-surface-input); font-weight: 600; }
.tb-article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 1rem 0;
}
.tb-article-body hr {
  border: none;
  border-top: 1px solid var(--tb-border);
  margin: 2rem 0;
}

/* Responsive video embed */
.tb-video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  margin: 1rem 0;
}
.tb-video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ────────────────────────────────────────────────────────────────────────────
   VIDENSBANK — Navbar Panel
   ──────────────────────────────────────────────────────────────────────────── */

/* Article list item */
.tb-vidensbank-item {
  border-bottom: 1px solid rgba(194, 135, 58, 0.06);
}
.tb-vidensbank-item:last-of-type {
  border-bottom: none;
}
.tb-vidensbank-item:hover {
  background: rgba(194, 135, 58, 0.06);
}

/* Category filter pills */
.tb-vidensbank-category-pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--tb-sidebar-nav-color);
  border: 1px solid transparent;
}
.tb-vidensbank-category-pill:hover {
  color: var(--tb-text-light);
  background: rgba(194, 135, 58, 0.08);
}
.tb-vidensbank-category-pill.active {
  background: var(--tb-gold-subtle-bg);
  color: var(--tb-gold);
  border-color: rgba(194, 135, 58, 0.2);
}

/* Article body inside panel — tighter spacing, dark-theme text */
.tb-article-body--panel {
  font-size: 13px;
  line-height: 1.7;
  color: var(--tb-text-light);
}
.tb-article-body--panel h1 { font-size: 1.35rem; margin: 1.5rem 0 0.5rem; }
.tb-article-body--panel h2 { font-size: 1.1rem; margin: 1.25rem 0 0.4rem; }
.tb-article-body--panel h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
.tb-article-body--panel a { color: var(--tb-gold); }
.tb-article-body--panel blockquote {
  color: var(--tb-sidebar-nav-color);
  background: rgba(255, 255, 255, 0.03);
}
.tb-article-body--panel code {
  background: rgba(255, 255, 255, 0.06);
  color: var(--tb-text-light);
}
.tb-article-body--panel pre {
  background: rgba(255, 255, 255, 0.04);
}
.tb-article-body--panel th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--tb-text-light);
}
.tb-article-body--panel td, .tb-article-body--panel th {
  border-color: rgba(194, 135, 58, 0.1);
}
.tb-article-body--panel hr {
  border-top-color: rgba(194, 135, 58, 0.1);
}

/* ==========================================================================
   Confirmation Modal
   ========================================================================== */

.tb-modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
  background: var(--tb-surface-card);
  color: var(--tb-text-primary);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--tb-border);
}

.tb-modal-dialog::backdrop {
  background: rgba(12, 18, 34, 0.5);
  backdrop-filter: blur(4px);
}

.tb-modal-content {
  padding: 1.75rem;
}

.tb-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.tb-modal-message {
  font-size: 0.875rem;
  color: var(--tb-text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.tb-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.tb-modal-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--tb-font-body);
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.tb-modal-btn:hover { opacity: 0.85; }

.tb-modal-btn-cancel {
  background: var(--tb-surface-page);
  color: var(--tb-text-secondary);
  border: 1px solid var(--tb-border);
}

.tb-modal-btn-primary {
  background: var(--tb-gold-gradient);
  color: #fff;
  box-shadow: var(--tb-gold-shadow);
}

.tb-modal-btn-danger {
  background: var(--tb-danger-text);
  color: #fff;
}

/* ==========================================================================
   Form Validation
   ========================================================================== */

.tb-field-invalid {
  border-color: var(--tb-danger-text) !important;
  box-shadow: 0 0 0 2px rgba(194, 50, 50, 0.15) !important;
}

.tb-field-error {
  color: var(--tb-danger-text);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  line-height: 1.4;
}

/* ==========================================================================
   Attachment Preview & Lightbox
   ========================================================================== */

.tb-attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--tb-border-light);
}

.tb-attachment-row:last-child {
  border-bottom: none;
}

.tb-attachment-thumb {
  width: 3rem;
  height: 3rem;
  border-radius: 8px;
  overflow: hidden;
  display: block;
  cursor: pointer;
  border: 1px solid var(--tb-border);
  transition: opacity 0.15s;
}

.tb-attachment-thumb:hover {
  opacity: 0.8;
}

.tb-attachment-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tb-attachment-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tb-gold-subtle-bg);
  color: var(--tb-gold);
}

.tb-attachment-icon-pdf {
  cursor: pointer;
  transition: opacity 0.15s;
  background: rgba(220, 38, 38, 0.06);
  color: var(--tb-danger-icon);
}

.tb-attachment-icon-pdf:hover {
  opacity: 0.8;
}

.tb-btn-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tb-text-tertiary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tb-btn-icon:hover {
  background: var(--tb-surface-input-alt);
  color: var(--tb-text-secondary);
}

.tb-btn-danger-icon {
  color: var(--tb-danger-icon);
}

.tb-btn-danger-icon:hover {
  background: var(--tb-danger-icon-bg);
  color: var(--tb-danger-text);
}

/* Lightbox overlay */
.tb-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 18, 34, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
}

.tb-lightbox-overlay.active {
  display: flex;
}

.tb-lightbox-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  flex-shrink: 0;
}

.tb-lightbox-filename {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  font-family: var(--tb-font-body);
}

.tb-lightbox-close {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tb-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.tb-lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 2rem 2rem;
  min-height: 0;
}

.tb-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.tb-lightbox-pdf {
  width: 100%;
  max-width: 900px;
  height: 100%;
  border: none;
  border-radius: 8px;
  background: #fff;
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

@keyframes tb-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.tb-skeleton {
  background: linear-gradient(90deg, var(--tb-border-light) 25%, var(--tb-surface-page) 50%, var(--tb-border-light) 75%);
  background-size: 200% 100%;
  animation: tb-shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.tb-skeleton-text {
  height: 0.875rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.tb-skeleton-heading {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 0.75rem;
  border-radius: 4px;
}

.tb-skeleton-card {
  height: 6rem;
  border-radius: 12px;
}

/* ==========================================================================
   Bulk Action Bar
   ========================================================================== */

.tb-bulk-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--tb-sidebar-bg);
  color: var(--tb-text-light);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  font-size: 0.8125rem;
  animation: tb-slide-up 0.2s ease;
}

@keyframes tb-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==========================================================================
   Audit Log Timeline
   ========================================================================== */

.tb-timeline {
  position: relative;
  padding-left: 2rem;
}
.tb-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--tb-border);
}
.tb-timeline-node {
  position: relative;
  padding-bottom: 1.5rem;
}
.tb-timeline-node::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tb-gold);
  border: 2px solid var(--tb-surface-card);
  box-shadow: 0 0 0 2px var(--tb-gold-border);
}
.tb-timeline-node.tb-timeline-danger::before {
  background: var(--tb-danger-text);
  box-shadow: 0 0 0 2px var(--tb-danger-border);
}
.tb-timeline-node.tb-timeline-success::before {
  background: var(--tb-success-text);
  box-shadow: 0 0 0 2px var(--tb-success-border);
}
.tb-timeline-date-marker {
  position: relative;
  padding: 0.25rem 0 0.75rem 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tb-text-tertiary);
}
.tb-timeline-date-marker::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tb-border);
  border: 2px solid var(--tb-surface-card);
}

/* ==========================================================================
   Command Palette
   ========================================================================== */

.tb-palette-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 560px;
  width: calc(100% - 2rem);
  background: var(--tb-surface-card);
  color: var(--tb-text-primary);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--tb-border);
  margin: 15vh auto 0;
}

.tb-palette-dialog::backdrop {
  background: rgba(12, 18, 34, 0.5);
  backdrop-filter: blur(4px);
}

.tb-palette-container {
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.tb-palette-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--tb-border-light);
}

.tb-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  font-family: var(--tb-font-body);
  color: var(--tb-text-primary);
  outline: none;
}

.tb-palette-input::placeholder { color: var(--tb-text-faint); }

.tb-palette-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.125rem 0.375rem;
  background: var(--tb-surface-input-alt);
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-family: var(--tb-font-mono);
  color: var(--tb-text-tertiary);
  line-height: 1.4;
}

.tb-palette-results {
  overflow-y: auto;
  flex: 1;
}

.tb-palette-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  text-decoration: none;
  color: var(--tb-text-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--tb-font-body);
  font-size: 0.8125rem;
  transition: background 0.1s;
}

.tb-palette-result:hover,
.tb-palette-result-active {
  background: var(--tb-gold-hover-bg);
}

.tb-palette-ref {
  font-family: var(--tb-font-mono);
  font-size: 0.75rem;
  color: var(--tb-gold);
  font-weight: 600;
  white-space: nowrap;
}

.tb-palette-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-palette-meta {
  font-size: 0.6875rem;
  color: var(--tb-text-tertiary);
  white-space: nowrap;
}

/* ==========================================================================
   Slide-over Panel
   ========================================================================== */

.tb-slideover-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: hidden;
}

.tb-slideover-dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

.tb-slideover-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--tb-surface-card);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.tb-slideover-enter {
  transform: translateX(0);
}

.tb-slideover-exit {
  transform: translateX(100%);
  transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1);
}

/* Size variants */
.tb-slideover-sm { width: 380px; }
.tb-slideover-md { width: 480px; }
.tb-slideover-lg { width: 640px; }
.tb-slideover-xl { width: 800px; }

@media (max-width: 640px) {
  .tb-slideover-sm,
  .tb-slideover-md,
  .tb-slideover-lg,
  .tb-slideover-xl { width: 100%; }
}

.tb-slideover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--tb-border);
  flex-shrink: 0;
}

.tb-slideover-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tb-text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-slideover-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--tb-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.tb-slideover-close:hover {
  background: var(--tb-gold-hover-bg);
  color: var(--tb-text-primary);
}

.tb-slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Loading skeleton inside panels */
.tb-slideover-loading,
.tb-modal-loading {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.tb-skeleton {
  border-radius: 0.375rem;
  background: linear-gradient(90deg, var(--tb-border-light) 25%, var(--tb-border-lighter) 50%, var(--tb-border-light) 75%);
  background-size: 200% 100%;
  animation: tb-skeleton-pulse 1.5s ease-in-out infinite;
}

.tb-skeleton-line {
  height: 1rem;
  width: 100%;
}

.tb-skeleton-short {
  width: 60%;
}

@keyframes tb-skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Modal Panel (centered dialog)
   ========================================================================== */

.tb-modal-dialog-panel {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.tb-modal-dialog-panel::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

.tb-modal-dialog-panel[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tb-modal-panel {
  background: var(--tb-surface-card);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
  overflow: hidden;
}

/* Size variants */
.tb-modal-sm { width: 400px; }
.tb-modal-md { width: 560px; }
.tb-modal-lg { width: 720px; }

@media (max-width: 640px) {
  .tb-modal-sm,
  .tb-modal-md,
  .tb-modal-lg {
    width: calc(100vw - 2rem);
  }
}

.tb-modal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--tb-border);
  flex-shrink: 0;
}

.tb-modal-panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tb-text-primary);
  margin: 0;
}

.tb-modal-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ==========================================================================
   Sortable / Drag-and-Drop
   ========================================================================== */

.tb-sortable-handle {
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--tb-text-tertiary);
  border-radius: 0.25rem;
  transition: color 0.15s, background 0.15s;
}

.tb-sortable-handle:hover {
  color: var(--tb-text-secondary);
  background: var(--tb-gold-hover-bg);
}

.tb-sortable-handle:active {
  cursor: grabbing;
}

.sortable-ghost {
  opacity: 0.4;
  background: var(--tb-gold-hover-bg) !important;
}

.sortable-chosen {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sortable-drag {
  opacity: 1 !important;
  background: var(--tb-surface-card) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
}

/* ==========================================================================
   Inline Field Editing
   ========================================================================== */

.tb-inline-field {
  position: relative;
}

.tb-inline-field-display {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  min-height: 2rem;
  display: flex;
  align-items: center;
}

.tb-inline-field-display:hover {
  border-color: var(--tb-border);
  background: var(--tb-surface-input);
}

.tb-inline-field-input {
  width: 100%;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid var(--tb-gold);
  background: var(--tb-surface-input);
  font-family: var(--tb-font-body);
  font-size: inherit;
  color: var(--tb-text-primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--tb-gold-ring);
}

.tb-inline-field-saving {
  opacity: 0.6;
  pointer-events: none;
}
