/* ==========================================================================
   Obol — Swiss Mineral Design System
   A warm monochromatic aesthetic. Quiet luxury. Everything earns its place.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom Properties
   -------------------------------------------------------------------------- */

:root {
  /* Surfaces */
  --color-bg: #FAFAF8;
  --color-bg-warm: #FAF8F3;
  --color-surface: #FFFFFF;
  --color-surface-sunk: #F4F1EA;
  --color-muted: #F8F7F5;

  /* Ink */
  --color-text: #1A1A18;
  --color-text-ink-2: #3A362E;
  --color-text-secondary: #78756F;
  --color-text-tertiary: #A8A5A0;

  /* Rules & edges */
  --color-border: #E8E6E3;
  --color-border-warm: #E6E1D6;
  --color-border-hover: #D0CEC9;
  --color-border-strong: #D4CEBE;

  /* Accent */
  --color-accent: #1A1A18;
  --color-accent-hover: #44423E;
  --color-focus: rgba(26, 26, 24, 0.08);

  /* Semantic — held / warning */
  --color-warning: #8A734E;
  --color-warning-bg: #FBF7F0;
  --color-hold: #B8861B;
  --color-hold-bg: #FBF2DC;

  /* Semantic — approved / billable */
  --color-success: #4A6E5A;
  --color-success-bg: #F0F5F2;
  --color-approve: #3C7A4A;
  --color-approve-bg: #E5EFDF;

  /* Semantic — rejected / danger */
  --color-danger: #7D4545;
  --color-danger-bg: #FBF0F0;
  --color-reject: #9B3A2E;
  --color-reject-bg: #F3DFD8;

  /* Semantic — open / processing */
  --color-processing: #5B8CF7;
  --color-processing-ink: #3A5A8A;
  --color-processing-bg: #DDE5F1;

  /* Semantic — invoiced / settled */
  --color-invoiced: #2B4A38;
  --color-invoiced-bg: #D9E4D7;

  /* Semantic — stopped */
  --color-stopped: #6B6458;

  /* Typography */
  --font-display: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Type scale */
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-2xl: 2rem;
  --text-3xl: 2.125rem;

  /* Weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semi: 600;
  --weight-bold: 700;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.04), 0 1px 2px rgba(28, 25, 23, 0.02);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.06), 0 1px 3px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 8px 24px rgba(28, 25, 23, 0.08);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-tight: 3px;
  --radius-tight-lg: 6px;

  /* Motion */
  --motion-fast: 120ms ease;
  --motion-med: 200ms ease;
  --motion-slow: 400ms ease;
}


/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

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


/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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


/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 2rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.nav-brand a {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-text);
  text-decoration: none;
}

.nav-context {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-project-name {
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
}

.nav-project-name:hover {
  color: var(--color-accent-hover);
}

.nav-separator {
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
}

.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user-name {
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
}

.nav-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 200ms ease;
}

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


/* --------------------------------------------------------------------------
   Page Structure
   -------------------------------------------------------------------------- */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  animation: fadeIn 0.4s ease;
}

.page-header {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: 0.01em;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header-action {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.page-header-action:hover {
  color: var(--color-text-primary);
}

.page-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-top: 0.25rem;
  margin-bottom: var(--space-lg);
}


/* --------------------------------------------------------------------------
   Flash Messages
   -------------------------------------------------------------------------- */

.flash {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-size: 0.875rem;
  border-left: 3px solid;
  line-height: 1.5;
}

.flash-notice {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-left-color: var(--color-success);
}

.flash-alert {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-left-color: var(--color-danger);
}


/* --------------------------------------------------------------------------
   Project Cards
   -------------------------------------------------------------------------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: var(--space-xl);
}

.project-card {
  display: block;
  padding: 1.75rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 200ms ease;
  border: none;
}

.project-card:hover {
  box-shadow: var(--shadow-md);
}

.project-card-title {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.0625rem;
  margin-bottom: 0.375rem;
  line-height: 1.4;
}

.project-card-slug {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
}


/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-container {
  max-width: 420px;
  margin: 6rem auto;
  padding: 2.5rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-xl);
}

.login-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.75rem;
  text-align: center;
  margin-bottom: 2rem;
  letter-spacing: 0.01em;
  color: var(--color-text);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid transparent;
  background: #F8F7F5;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--color-text);
  transition: all 200ms ease;
  line-height: 1.5;
}

.form-input:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-border-hover);
  box-shadow: 0 0 0 3px var(--color-focus);
}

.form-input::placeholder {
  color: var(--color-text-tertiary);
}

.form-textarea-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  resize: vertical;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-top: 0.25rem;
}

.form-section {
  margin-bottom: var(--space-xl);
}

.form-section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}


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

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background: var(--color-accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 200ms ease;
  margin-top: var(--space-sm);
  line-height: 1.5;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

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

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus), 0 0 0 1px var(--color-accent);
}


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

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-lg);
}

.data-table + h2,
.data-table + section,
.execution-timeline + h2,
section + h2,
section + section { margin-top: var(--space-2xl); }

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid #F0EEEB;
}

.data-table tbody tr {
  transition: background 150ms ease;
}

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

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

.ticket-thumbnail {
  width: 1%;
  white-space: nowrap;
}

.ticket-thumbnail img {
  display: block;
  max-height: 48px;
  max-width: 96px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
}

/* Lightbox dialog for ANPR images */
.ticket-thumbnail dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
}

.ticket-thumbnail dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
}

.ticket-thumbnail dialog img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}


/* --------------------------------------------------------------------------
   Status Indicators
   -------------------------------------------------------------------------- */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.status-indicator::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pending_identification::before {
  background: var(--color-warning);
}

.status-pending::before {
  background: var(--color-warning);
}

.status-open::before {
  background: #5B8CF7;
}

.status-closed::before {
  background: var(--color-success);
}

.status-held::before {
  background: #D4883C;
}

.status-discarded::before {
  background: var(--color-text-tertiary);
}

.status-synced::before {
  background: var(--color-success);
}

.status-failed::before {
  background: var(--color-danger);
}

.status-sent::before,
.status-delivered::before {
  background: var(--color-success);
}

.status-paid::before {
  background: var(--color-success);
}

.status-partially_paid::before {
  background: var(--color-warning);
}

.status-overdue::before {
  background: var(--color-warning);
}

.status-processing::before {
  background: #5B8CF7;
}

.status-billable::before {
  background: #4CAF50;
}

.status-invoiced::before {
  background: var(--color-success);
}

.status-stopped::before {
  background: var(--color-text-tertiary);
}

.status-rejected::before {
  background: var(--color-danger);
}

.status-incomplete::before {
  background: var(--color-warning);
}


/* --------------------------------------------------------------------------
   Credit Note Banner
   -------------------------------------------------------------------------- */

.credit-note-banner,
.credited-banner {
  padding: 0.75rem 1.25rem;
  border-left: 3px solid;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.credit-note-banner {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-left-color: var(--color-danger);
}

.credited-banner {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-left-color: var(--color-warning);
}

.credited-banner a {
  color: var(--color-warning);
  font-weight: 600;
}

.overpayment-banner,
.partial-payment-banner {
  padding: 0.75rem 1.25rem;
  border-left: 3px solid;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-left-color: var(--color-warning);
}


/* --------------------------------------------------------------------------
   Stat Bar
   -------------------------------------------------------------------------- */

.stat-bar {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.stat::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-pending::before {
  background: var(--color-warning);
}

.stat-open::before {
  background: #5B8CF7;
}

.stat-processing::before {
  background: #5B8CF7;
}

.stat-billable::before {
  background: #4CAF50;
}

.stat-invoiced::before {
  background: var(--color-success);
}

.stat-closed::before {
  background: var(--color-success);
}

.stat-held::before {
  background: #D4883C;
}

.stat-stopped::before {
  background: var(--color-text-tertiary);
}

.stat-rejected::before {
  background: var(--color-danger);
}

a.stat {
  text-decoration: none;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

a.stat:hover {
  color: var(--color-text);
  border-color: var(--color-border);
}

.stat-active {
  color: var(--color-text);
  font-weight: 600;
  background: var(--color-surface);
  border-color: var(--color-border) !important;
}


/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */

.dashboard-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0.875rem 1.5rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--color-text);
  text-decoration: none;
  transition: box-shadow 200ms ease;
}

.action-link:hover {
  box-shadow: var(--shadow-md);
}


/* --------------------------------------------------------------------------
   Section Divider
   -------------------------------------------------------------------------- */

.section-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}


/* --------------------------------------------------------------------------
   Page Header Row
   -------------------------------------------------------------------------- */

.page-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-lg);
}


/* --------------------------------------------------------------------------
   Secondary & Danger Buttons
   -------------------------------------------------------------------------- */

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.625rem 1.25rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  line-height: 1.5;
}

.btn-secondary:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-danger:hover {
  text-decoration: underline;
}


/* --------------------------------------------------------------------------
   Search Form
   -------------------------------------------------------------------------- */

.search-form {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.search-form .btn-primary {
  width: auto;
  margin-top: 0;
  padding: 0.625rem 1.25rem;
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--color-text);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-border-hover);
  box-shadow: 0 0 0 3px var(--color-focus);
}

.search-input::placeholder {
  color: var(--color-text-tertiary);
}


/* --------------------------------------------------------------------------
   Form Row (side-by-side fields)
   -------------------------------------------------------------------------- */

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-row .form-group {
  flex: 1;
}


/* --------------------------------------------------------------------------
   Detail Grid (key/value layout)
   -------------------------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-sm) var(--space-lg);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xl);
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  padding-top: 2px;
}

.detail-value {
  font-size: 0.9375rem;
  line-height: 1.6;
}


/* --------------------------------------------------------------------------
   Dropdown
   -------------------------------------------------------------------------- */

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  white-space: nowrap;
}

.dropdown-toggle::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  margin-left: 2px;
}

.dropdown-toggle:hover {
  border-color: var(--color-border-hover);
}

.dropdown-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;
  z-index: 100;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease;
}

.dropdown-item:hover {
  background: var(--color-bg);
}

.dropdown-item--danger {
  color: var(--color-danger);
}

.dropdown-item--danger:hover {
  background: var(--color-danger-bg);
}


/* --------------------------------------------------------------------------
   Icons
   -------------------------------------------------------------------------- */

.icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  vertical-align: middle;
}


/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.monospace {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.code-block {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  background: #F1EFEC;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

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


/* --------------------------------------------------------------------------
   Debug Panel
   -------------------------------------------------------------------------- */

.debug-panel {
  margin-top: var(--space-md);
}

.debug-panel-summary {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-sm) 0;
  transition: color 200ms ease;
  list-style: none;
}

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

.debug-panel-summary::before {
  content: '▸ ';
}

.debug-panel[open] > .debug-panel-summary::before {
  content: '▾ ';
}

.debug-panel-summary:hover {
  color: var(--color-text-secondary);
}

.debug-panel-content {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--color-text-secondary);
  background: #F8F7F5;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-sm);
  overflow-x: auto;
  white-space: pre;
}


/* --------------------------------------------------------------------------
   Inline Create Button
   -------------------------------------------------------------------------- */

.btn-inline-create {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.5rem 0.875rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 200ms ease, color 200ms ease;
  margin-top: calc(-1 * var(--space-sm));
}

.btn-inline-create:hover {
  border-color: var(--color-border-hover);
  color: var(--color-text);
}

.inline-create-section {
  margin-bottom: var(--space-xl);
}


/* --------------------------------------------------------------------------
   Button Row (equal-width side-by-side buttons)
   -------------------------------------------------------------------------- */

.button-row {
  display: flex;
  gap: var(--space-sm);
}

.button-row > * {
  flex: 1;
}

.button-row .btn-primary {
  width: auto;
  margin-top: 0;
}


/* --------------------------------------------------------------------------
   Mode Switch Tabs
   -------------------------------------------------------------------------- */

.mode-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.mode-tab {
  flex: 1;
  padding: 0.875rem 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
  text-align: center;
}

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

.mode-tab.active {
  color: var(--color-text);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}


/* --------------------------------------------------------------------------
   Combobox
   -------------------------------------------------------------------------- */

.combobox {
  position: relative;
}

.combobox-list {
  position: absolute;
  z-index: 100;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  margin-top: var(--space-xs);
}

.combobox-option {
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 150ms ease;
}

.combobox-option:hover {
  background: var(--color-bg);
}


/* --------------------------------------------------------------------------
   Animation
   -------------------------------------------------------------------------- */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* --------------------------------------------------------------------------
   Responsive — Tablet
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}


/* --------------------------------------------------------------------------
   Responsive — Mobile
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .nav {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }

  .nav-brand {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .nav-user {
    gap: 0.75rem;
  }

  main {
    padding: 1.5rem 1rem;
  }

  .page-header {
    font-size: 1.5rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .login-container {
    margin: 2rem auto;
    padding: 1.5rem;
  }

  .dashboard-actions {
    flex-direction: column;
  }

  .stat-bar {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .data-table {
    font-size: 0.875rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.75rem;
  }
}


/* --------------------------------------------------------------------------
   Pagination (Pagy)
   -------------------------------------------------------------------------- */

.pagy {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.pagy a {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  min-width: 2rem;
  text-align: center;
  text-decoration: none;
  color: var(--color-text-secondary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.pagy a[href]:hover {
  color: var(--color-text);
  border-color: var(--color-border-hover);
}

.pagy a[aria-current] {
  color: var(--color-surface);
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.pagy a[role="link"]:not([href]) {
  opacity: 0.4;
  cursor: default;
}

.pagy a[role="separator"] {
  border-color: transparent;
  background-color: transparent;
  cursor: default;
}


/* --------------------------------------------------------------------------
   Workflow
   -------------------------------------------------------------------------- */

.page-header--row {
  justify-content: space-between;
  gap: var(--space-md);
}

.page-header--row > .page-header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: background 150ms ease, color 150ms ease;
}

.page-header--row > .page-header-action:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.workflow-section {
  margin-bottom: var(--space-2xl);
}

.workflow-section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.workflow-section-description {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

.workflow-section--secondary .workflow-section-title {
  font-size: 1.0625rem;
  color: var(--color-text-secondary);
}

.workflow-section--tertiary {
  margin-top: var(--space-2xl);
  max-width: 520px;
}

.workflow-section--tertiary .workflow-section-title {
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-md);
}

/* --- Workflow list (index) --- */

.workflow-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.workflow-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-xl);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.workflow-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

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

.workflow-card-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.workflow-card-link {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: 0.005em;
  line-height: 1.2;
}

/* Stretched link — clickable whole card */
.workflow-card-link::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 0;
}

.workflow-card-link:hover {
  color: var(--color-accent-hover);
}

.workflow-card-key {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.workflow-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
}

.workflow-card-dot {
  color: var(--color-text-tertiary);
}

.workflow-card-conditional {
  color: var(--color-warning);
}

.workflow-card-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.workflow-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  text-decoration: none;
}

.workflow-card-action:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.workflow-card-action--danger:hover {
  color: var(--color-danger);
}

/* button_to wraps in a form — unwrap for inline placement */
.workflow-card-actions form {
  display: inline-flex;
  margin: 0;
}

.workflow-key-badge {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  margin-left: var(--space-xs);
}

/* --- Pipeline flowchart --- */

.pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: var(--space-2xl);
  padding: var(--space-lg) 0;
}

/* Start/end caps */

.pipeline-cap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
}

.pipeline-cap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  flex-shrink: 0;
}

.pipeline-cap-success {
  color: var(--color-success);
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.pipeline-cap-success .pipeline-cap-dot {
  background: var(--color-success);
}

.pipeline-cap-stop {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

.pipeline-cap-stop .pipeline-cap-dot {
  background: var(--color-danger);
}

.pipeline-cap-hold {
  color: var(--color-warning);
  border-color: var(--color-warning);
  background: var(--color-warning-bg);
}

.pipeline-cap-hold .pipeline-cap-dot {
  background: var(--color-warning);
}

/* Connectors — vertical lines between elements */

.pipeline-connector {
  width: 2px;
  height: 2rem;
  background: var(--color-border);
  position: relative;
}

.pipeline-connector::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--color-border);
}

.pipeline-connector-inner {
  height: 1.25rem;
  align-self: center;
}

.pipeline-connector-pass {
  height: 2.5rem;
}

.pipeline-connector-label {
  position: absolute;
  left: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

.pipeline-pass-label {
  position: absolute;
  right: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  background: var(--color-bg);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
}

/* Stages */

.pipeline-stage {
  width: 100%;
  max-width: 420px;
}

.pipeline-stage-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.pipeline-stage-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.pipeline-stage-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--color-text);
}

.pipeline-stage-mode-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft, rgba(255, 170, 0, 0.15));
  color: var(--color-accent, #b8790a);
  border: 1px solid var(--color-accent, #b8790a);
}

.pipeline-stage-branch {
  /* Kept for downstream hooks — switch-group chrome carries the branch semantics. */
}

/* --------------------------------------------------------------------------
   Switch group — the decision point
   --------------------------------------------------------------------------

   A <section.pipeline-switch> holds:
     - .pipeline-switch-head  (decision cap)
     - svg.pipeline-switch-fan-out
     - .pipeline-switch-lanes (flex row of lanes)
     - svg.pipeline-switch-fan-in
     - .pipeline-switch-foot  (merge cap)

   The caps + SVG fans are connected — the SVG curves attach at the top/bottom
   of the lanes container. Each lane has a lifted CASE label acting as the
   case statement label, followed by the stage card and its steps.
   -------------------------------------------------------------------------- */

:root {
  --color-switch: #8A734E;
  --color-switch-soft: rgba(138, 115, 78, 0.18);
  --color-switch-bg: #FBF7F0;
}

.pipeline-switch {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  margin-top: var(--space-sm);
  background:
    radial-gradient(ellipse at top, var(--color-switch-bg) 0%, transparent 55%),
    radial-gradient(ellipse at bottom, var(--color-switch-bg) 0%, transparent 55%);
  border-radius: var(--radius-xl);
  isolation: isolate;
}

.pipeline-switch::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed var(--color-switch);
  border-radius: inherit;
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}

/* Decision caps — the diamond glyph marks split and merge */

.pipeline-switch-head,
.pipeline-switch-foot {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.125rem 0.5rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-switch);
  border-radius: 999px;
  color: var(--color-switch);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(138, 115, 78, 0.08);
}

.pipeline-switch-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--color-switch);
  flex-shrink: 0;
}

.pipeline-switch-label {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--color-switch);
}

.pipeline-switch-sub {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text-secondary);
}

/* Fan-out / fan-in SVGs connect caps to lanes */

.pipeline-switch-fan {
  display: block;
  width: 100%;
  height: 60px;
  color: var(--color-switch);
  opacity: 0.75;
}

.pipeline-switch-fan-out {
  margin-top: 0.5rem;
}

.pipeline-switch-fan-in {
  margin-bottom: 0.5rem;
}

/* Lanes row */

.pipeline-switch-lanes {
  display: grid;
  grid-template-columns: repeat(var(--lane-count, 2), minmax(0, 1fr));
  grid-template-rows: auto auto 1fr;
  gap: var(--space-md);
  align-items: stretch;
  padding: 0 var(--space-sm);
}

.pipeline-switch-lane {
  min-width: 0;
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
  gap: var(--space-sm);
  align-items: stretch;
}

.pipeline-switch-lane > * {
  min-width: 0;
}

.pipeline-switch-lane .pipeline-stage {
  max-width: none;
  width: 100%;
}

/* Tail — bridges the gap between a lane's content and the common fan-in.
   Shorter lanes would otherwise show dead space; this dashed rule ties them
   visually to the merge point. */

.pipeline-switch-lane-tail {
  justify-self: center;
  align-self: stretch;
  width: 0;
  min-height: 0.75rem;
  border-left: 2px dotted var(--color-switch);
  opacity: 0.6;
  margin-top: var(--space-xs);
}

/* Stop/hold arms would protrude past the switch group border in a narrow
   lane — the step's colored left border already communicates the outcome. */

.pipeline-switch-lane .pipeline-branch-arm,
.pipeline-switch-lane .pipeline-branch-end {
  display: none;
}

.pipeline-switch-lane .pipeline-step {
  padding-right: 0;
}

/* Case label — lifted above each lane's stage card */

.pipeline-case-label {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding: 0.625rem 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-switch);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(138, 115, 78, 0.06);
  min-height: 2.75rem;
}

.pipeline-case-marker {
  flex-shrink: 0;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-switch);
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--color-switch-soft);
  align-self: flex-start;
  margin-top: 2px;
}

.pipeline-case-label .pipeline-condition-expressions {
  flex: 1;
  min-width: 0;
}

.pipeline-case-label .pipeline-condition-expr code {
  background: var(--color-switch-bg);
  border-color: var(--color-switch-soft);
}

/* "otherwise" lane — the else case */

.pipeline-case-label-else {
  justify-content: flex-start;
  background: transparent;
  border: 1px dashed var(--color-switch);
  box-shadow: none;
}

.pipeline-case-label-else em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1rem;
  color: var(--color-switch);
  letter-spacing: 0.01em;
}

.pipeline-switch-lane-else .pipeline-stage {
  opacity: 0.92;
}

/* Narrow screens — collapse to vertical stack but keep the switch identity */

@media (max-width: 900px) {
  .pipeline-switch-lanes {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .pipeline-switch-fan {
    height: 32px;
  }
}

/* --------------------------------------------------------------------------
   Timeline variant — retrospective execution log

   Used on ticket pages. Shares the switch-group language (dashed frame,
   diamond cap, case labels) but stacks lanes vertically and drops the fan
   SVGs — the log reads top-to-bottom, and only one branch actually ran.
   -------------------------------------------------------------------------- */

.pipeline-switch--timeline {
  padding: var(--space-md) var(--space-md) var(--space-sm);
  margin-top: 0;
}

.pipeline-switch--timeline .pipeline-switch-lanes {
  grid-template-columns: 1fr;
  grid-template-rows: none;
  gap: var(--space-md);
  padding: 0;
}

.pipeline-switch--timeline .pipeline-switch-lane {
  display: block;
  grid-row: auto;
}

.pipeline-switch--timeline .pipeline-switch-fan,
.pipeline-switch--timeline .pipeline-switch-lane-tail {
  display: none;
}

.pipeline-switch--timeline .pipeline-switch-head {
  margin-bottom: var(--space-md);
}

.pipeline-switch--timeline .pipeline-switch-foot {
  margin-top: var(--space-sm);
  padding: 0.375rem 0.875rem;
  font-size: 0.6875rem;
}

.pipeline-switch--timeline .pipeline-case-label {
  margin-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: none;
  min-height: 0;
  padding: 0.5rem 0.75rem;
}

.pipeline-switch--timeline .pipeline-switch-lane .execution-stage {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border-top: 0;
  margin: 0;
}

.pipeline-switch--timeline .pipeline-switch-lane-ran .pipeline-case-label {
  background: var(--color-switch-bg);
  box-shadow: 0 1px 3px rgba(138, 115, 78, 0.1);
}

.pipeline-switch--timeline .pipeline-switch-lane-ran .execution-stage {
  border-color: var(--color-switch);
}

.pipeline-switch--timeline .pipeline-switch-lane-skipped .pipeline-case-label {
  opacity: 0.55;
}

.pipeline-switch--timeline .pipeline-switch-lane-skipped .execution-stage {
  opacity: 0.55;
}

.execution-stage-skipped-tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-left: 0.5rem;
}

@media (max-width: 640px) {
  .pipeline-switch {
    padding: var(--space-md) var(--space-sm) var(--space-sm);
  }

  .pipeline-switch-fan {
    height: 24px;
  }

  .pipeline-switch-sub {
    display: none;
  }
}

/* Steps container */

.pipeline-steps {
  display: flex;
  flex-direction: column;
}

/* Step wrapper — allows branch elements to extend right */

.pipeline-step {
  position: relative;
}

.pipeline-step-branching {
  /* Extra right margin to prevent content overlap on narrow screens */
}

/* Node cards */

.pipeline-node {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.pipeline-node-continue {
  border-left: 3px solid var(--color-success);
}

.pipeline-node-stop {
  border-left: 3px solid var(--color-danger);
}

.pipeline-node-hold {
  border-left: 3px solid var(--color-warning);
}

/* Condition gate — IF header on conditional steps */

.pipeline-condition-gate {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #F8F7F5;
  border-bottom: 1px solid var(--color-border);
}

/* Workflow- and stage-level condition gates — standalone, not inside a node */
.pipeline-gate {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #F8F7F5;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-width: 420px;
  width: 100%;
}

.pipeline-gate-workflow {
  align-self: center;
}

.pipeline-gate-stage {
  margin-top: calc(-1 * var(--space-xs));
  margin-bottom: var(--space-md);
}

.pipeline-if-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--color-accent);
  color: var(--color-surface);
  flex-shrink: 0;
  margin-top: 1px;
}

.pipeline-condition-expressions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipeline-condition-expr {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  flex-wrap: wrap;
}

.pipeline-condition-expr code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--color-surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
}

.pipeline-condition-join {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
}

.pipeline-condition-group {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
}

.pipeline-group-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--color-text-tertiary);
  color: var(--color-surface);
  flex-shrink: 0;
  margin-top: 2px;
}

.pipeline-condition-nested {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-sm);
}

.pipeline-op {
  font-weight: 600;
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
}

/* Node body and header */

.pipeline-node-body {
  padding: 0.75rem 0.875rem;
}

.pipeline-node-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.pipeline-node-name {
  font-weight: 500;
  font-size: 0.9375rem;
  flex: 1;
}

.pipeline-action-type {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  background: #F8F7F5;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* --- Branch visualization — horizontal fork for stop/hold steps --- */

.pipeline-branch-arm {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 2rem;
  height: 0;
  border-top: 2px dashed var(--color-border);
  transform: translateY(-1px);
}

.pipeline-branch-arm::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -5px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.pipeline-branch-arm-stop {
  border-top-color: var(--color-danger);
}

.pipeline-branch-arm-stop::after {
  border-left: 6px solid var(--color-danger);
}

.pipeline-branch-arm-hold {
  border-top-color: var(--color-warning);
}

.pipeline-branch-arm-hold::after {
  border-left: 6px solid var(--color-warning);
}

.pipeline-branch-arm-label {
  position: absolute;
  top: -1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

.pipeline-branch-end {
  position: absolute;
  top: 50%;
  left: calc(100% + 2rem + 6px);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pipeline-branch-end .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.pipeline-branch-end-stop {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.pipeline-branch-end-hold {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

/* Active branch states (simulation) */

.pipeline-branch-arm-active {
  border-top-style: solid;
}

.pipeline-branch-end-active {
  opacity: 1;
  box-shadow: var(--shadow-sm);
}

/* Simulation states */

.pipeline-sim-miss {
  opacity: 0.45;
}

.pipeline-sim-skip {
  opacity: 0.3;
  border-left-color: var(--color-text-tertiary);
}

.pipeline-sim-match {
  box-shadow: 0 0 0 1px var(--color-success);
}

/* --- Outcome & simulation badges (shared) --- */

.workflow-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
}

.workflow-mapping {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

.workflow-mapping code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: #F8F7F5;
  padding: 2px 6px;
  border-radius: 4px;
}

.workflow-arrow-text {
  color: var(--color-text-tertiary);
}

/* --- Tariffs (compact single-row strips) --- */

.workflow-tariffs {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.workflow-tariff-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) auto 1fr auto auto auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  font-size: 0.875rem;
  border-top: 1px solid var(--color-border);
}

.workflow-tariff-row:first-child {
  border-top: 0;
}

.workflow-tariff-name {
  font-weight: 500;
  color: var(--color-text);
}

.workflow-tariff-code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.workflow-tariff-amount {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  text-align: right;
  justify-self: end;
  padding-right: var(--space-md);
}

.workflow-tariff-type,
.workflow-tariff-vat,
.workflow-tariff-valid {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.workflow-tariff-vat {
  font-variant-numeric: tabular-nums;
}

/* --- Project settings panel (tertiary) --- */

.workflow-settings-panel {
  padding: var(--space-lg) var(--space-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.workflow-settings-panel .detail-grid {
  margin: 0;
}

/* --- Simulation verdict --- */

.simulation-verdict {
  font-size: 0.8125rem;
  font-weight: 500;
  flex-shrink: 0;
}

.simulation-match {
  color: var(--color-success);
}

.simulation-miss {
  color: var(--color-text-tertiary);
}

.simulation-skip {
  color: var(--color-text-tertiary);
}

.simulation-verdict-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  border-left: 3px solid;
  font-size: 0.9375rem;
  margin-bottom: var(--space-lg);
}

.simulation-verdict-banner .btn-primary {
  width: auto;
  margin-left: auto;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.simulation-verdict-banner code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.simulation-verdict-stop {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-left-color: var(--color-danger);
}

.simulation-verdict-hold {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-left-color: var(--color-warning);
}

.simulation-verdict-continue {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-left-color: var(--color-success);
}

.simulation-verdict-reason {
  font-size: 0.8125rem;
}

/* --- Verdict actions (approve / reject with presets) --- */

.verdict-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-lg);
  align-items: start;
  margin-bottom: var(--space-lg);
}

.verdict-reject-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.verdict-reason {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  cursor: pointer;
}

.verdict-reject-form .btn-danger {
  align-self: flex-start;
  margin-top: var(--space-xs);
}

/* --- Execution timeline (ticket pipeline view) --- */

.execution-timeline {
  margin-bottom: var(--space-xl);
}

.execution-workflow {
  position: relative;
  padding-left: 2rem;
  padding-bottom: var(--space-lg);
}

.execution-workflow::before {
  content: "";
  position: absolute;
  left: 0.6875rem;
  top: 1.75rem;
  bottom: 0;
  width: 2px;
  background: var(--color-border);
}

.execution-workflow-last::before {
  display: none;
}

.execution-workflow-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  position: relative;
}

.execution-workflow-number {
  position: absolute;
  left: -2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.execution-workflow-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.0625rem;
  color: var(--color-text);
}

.execution-workflow-time {
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  margin-left: auto;
}

.execution-stages {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.execution-stage {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.execution-stage-label {
  padding: 0.5rem 0.875rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  background: #F8F7F5;
  border-bottom: 1px solid var(--color-border);
}

.execution-steps {
  display: flex;
  flex-direction: column;
}

.execution-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.625rem 0.875rem;
  border-left: 3px solid transparent;
}

.execution-step + .execution-step {
  border-top: 1px solid var(--color-border);
}

.execution-step-continue {
  border-left-color: var(--color-success);
}

.execution-step-stop {
  border-left-color: var(--color-danger);
  background: var(--color-danger-bg);
}

.execution-step-hold {
  border-left-color: var(--color-warning);
  background: var(--color-warning-bg);
}

.execution-step-yield {
  border-left-color: var(--color-text-tertiary);
}

.execution-step-skipped {
  opacity: 0.4;
}

.execution-step-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
}

.execution-step-indicator-continue {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.execution-step-indicator-continue::after {
  content: "\2713";
}

.execution-step-indicator-stop {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.execution-step-indicator-stop::after {
  content: "\2717";
}

.execution-step-indicator-hold {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.execution-step-indicator-hold::after {
  content: "!";
}

.execution-step-indicator-yield {
  background: #F0EFEC;
  color: var(--color-text-tertiary);
}

.execution-step-indicator-yield::after {
  content: "\21B3";
}

.execution-step-indicator-skipped {
  background: var(--color-border);
  color: var(--color-text-tertiary);
}

.execution-step-name {
  font-size: 0.9375rem;
  font-weight: 450;
  color: var(--color-text);
  flex: 1;
}

.execution-step-result {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.execution-step-result-continue {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.execution-step-result-stop {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.execution-step-result-hold {
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

.execution-step-result-yield {
  color: var(--color-text-tertiary);
  background: #F0EFEC;
}

/* --- Workflow builder controls --- */

.pipeline-stage-actions,
.pipeline-node-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pipeline-stage-actions a,
.pipeline-stage-actions button,
.pipeline-stage-actions form,
.pipeline-node-actions a,
.pipeline-node-actions button,
.pipeline-node-actions form {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-tertiary);
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
}

.pipeline-stage-header:hover .pipeline-stage-actions a,
.pipeline-stage-header:hover .pipeline-stage-actions button,
.pipeline-stage-header:hover .pipeline-stage-actions form,
.pipeline-node:hover .pipeline-node-actions a,
.pipeline-node:hover .pipeline-node-actions button,
.pipeline-node:hover .pipeline-node-actions form {
  opacity: 1;
}

.pipeline-stage-actions a:hover,
.pipeline-node-actions a:hover {
  color: var(--color-text);
}

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

.pipeline-add-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 1rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  transition: all 150ms ease;
  align-self: center;
  margin-top: var(--space-sm);
}

.pipeline-add-link:hover {
  color: var(--color-text);
  border-color: var(--color-border-hover);
  background: var(--color-surface);
}

.pipeline-add-link--block {
  display: flex;
  width: 100%;
  gap: 0.5rem;
  font-size: 0.8125rem;
  padding: 0.875rem 1rem;
  margin-top: 0;
  margin-bottom: var(--space-2xl);
  align-self: stretch;
  color: var(--color-text-secondary);
}

.pipeline-add-link--block:hover {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-hover);
}

/* Condition row in step form */

.condition-row .form-row {
  align-items: flex-end;
}

.condition-row .btn-danger {
  flex-shrink: 0;
  margin-bottom: var(--space-lg);
}

.condition-operator {
  max-width: 120px;
}

.conditions-group {
  border-left: 3px solid var(--border-color);
  padding-left: var(--space-md);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.conditions-group-root {
  border-left: none;
  padding-left: 0;
}

.conditions-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.conditions-group-header select {
  max-width: 180px;
}

.conditions-group-header .btn-danger {
  flex-shrink: 0;
}

.conditions-group-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
}

.form-input-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
}

.back-link {
  margin-top: var(--space-lg);
}

.back-link a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
}

.back-link a:hover {
  color: var(--color-text);
}

/* Inline form (Turbo Frame) */

.pipeline-inline-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  width: 100%;
}

.pipeline-inline-form-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.125rem;
  margin-bottom: var(--space-md);
}

.pipeline-inline-form .btn-primary {
  margin-top: var(--space-md);
}

.pipeline-inline-cancel {
  display: inline-block;
  margin-top: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  text-decoration: none;
}

.pipeline-inline-cancel:hover {
  color: var(--color-text);
}

@media (max-width: 768px) {
  .workflow-tariff-row {
    grid-template-columns: 1fr auto;
    gap: var(--space-xs) var(--space-md);
  }

  .workflow-tariff-amount {
    grid-column: 2;
    grid-row: 1;
    padding-right: 0;
  }

  .workflow-tariff-type,
  .workflow-tariff-vat,
  .workflow-tariff-valid {
    grid-column: 1 / -1;
    font-size: 0.75rem;
  }

  .pipeline-stage {
    max-width: 100%;
  }

  .pipeline-branch-arm,
  .pipeline-branch-end {
    display: none;
  }
}


/* ==========================================================================
   Tickets index — Bold variation
   Date-scoped command strip, brush chart, needs-attention / settled split,
   expanding command-palette search. Scoped under .tickets-bold to avoid
   collisions with the rest of the admin UI.
   ========================================================================== */

.tickets-bold {
  --tb-bg: #FAF8F3;
  --tb-bg-elev: #FFFFFF;
  --tb-bg-sunk: #F4F1EA;
  --tb-ink: #1C1A15;
  --tb-ink-2: #3A362E;
  --tb-ink-3: #6B6458;
  --tb-ink-4: #9A9384;
  --tb-rule: #E6E1D6;
  --tb-rule-strong: #D4CEBE;

  --tb-hold: #B8861B;
  --tb-hold-bg: #FBF2DC;
  --tb-approve: #3C7A4A;
  --tb-approve-bg: #E5EFDF;
  --tb-reject: #9B3A2E;
  --tb-reject-bg: #F3DFD8;
  --tb-processing: #3A5A8A;
  --tb-processing-bg: #DDE5F1;
  --tb-invoiced: #2B4A38;
  --tb-invoiced-bg: #D9E4D7;
  --tb-stopped: #6B6458;

  --tb-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --tb-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --tb-radius: 3px;
  --tb-radius-lg: 6px;

  color: var(--tb-ink);
  font-family: var(--tb-sans);
  font-size: 14px;
  line-height: 1.5;
}

.tickets-bold a { color: inherit; text-decoration: none; }
.tickets-bold button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
.tickets-bold kbd {
  font-family: var(--tb-mono);
  font-size: 10px;
  background: var(--tb-bg-sunk);
  border: 1px solid var(--tb-rule-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px 0;
  color: var(--tb-ink-3);
  margin-left: 6px;
}

/* --- Command strip ------------------------------------------------------- */
.tickets-bold .v2-command {
  background: var(--tb-bg-elev);
  border: 1px solid var(--tb-rule);
  border-radius: var(--tb-radius-lg);
  margin-bottom: 20px;
}
.tickets-bold .v2-command-top {
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr auto;
  gap: 24px;
  padding: 16px 20px;
  align-items: center;
  border-bottom: 1px solid var(--tb-rule);
}
.tickets-bold .v2-scope-picker {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.tickets-bold .v2-scope-label {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--tb-ink);
  display: inline-flex; align-items: center; gap: 8px;
}
.tickets-bold .v2-scope-label .cal {
  width: 18px; height: 18px;
  color: var(--tb-ink-3);
}
.tickets-bold .v2-scope-preset {
  display: flex; align-items: center;
  background: var(--tb-bg-sunk);
  border-radius: 20px;
  padding: 3px;
}
.tickets-bold .v2-scope-preset a,
.tickets-bold .v2-scope-preset button {
  padding: 5px 13px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tb-ink-3);
  display: inline-block;
}
.tickets-bold .v2-scope-preset .active {
  background: var(--tb-bg-elev);
  color: var(--tb-ink);
  box-shadow: 0 1px 2px rgba(28,26,21,.04), 0 1px 0 rgba(28,26,21,.03);
}
.tickets-bold .v2-custom {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px dashed var(--tb-rule-strong);
  border-radius: 16px;
  font-size: 12px;
  color: var(--tb-ink-3);
}
.tickets-bold .v2-custom:hover { border-color: var(--tb-ink); color: var(--tb-ink); }
.tickets-bold .v2-custom.active {
  border-style: solid;
  border-color: var(--tb-ink);
  color: var(--tb-ink);
  background: var(--tb-bg-elev);
}
.tickets-bold .v2-custom-wrap { position: relative; }
.tickets-bold .v2-custom-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  background: var(--tb-bg-elev);
  border: 1px solid var(--tb-rule);
  border-radius: var(--tb-radius-lg);
  box-shadow: 0 2px 6px rgba(28,26,21,.06), 0 0 0 1px rgba(28,26,21,.04);
  padding: 12px;
}
.tickets-bold .v2-custom-form {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end;
}
.tickets-bold .v2-custom-form label {
  font-size: 11px; color: var(--tb-ink-3); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600;
  display: flex; flex-direction: column; gap: 4px;
}
.tickets-bold .v2-custom-form input[type="date"] {
  font: inherit; font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--tb-rule-strong);
  border-radius: var(--tb-radius);
  background: var(--tb-bg-elev);
  color: var(--tb-ink);
}
.tickets-bold .v2-custom-form .btn-apply {
  font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 7px 14px;
  background: var(--tb-ink);
  color: #F4F1EA;
  border: 0;
  border-radius: var(--tb-radius);
  cursor: pointer;
}

/* --- Brush chart --------------------------------------------------------- */
.tickets-bold .v2-brush {
  height: 56px;
  background: var(--tb-bg-sunk);
  border-radius: var(--tb-radius);
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}
.tickets-bold .v2-brush-bars {
  position: absolute; inset: 6px 6px 12px 6px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 28), 1fr);
  gap: 2px;
  align-items: end;
}
.tickets-bold .v2-brush-bar {
  display: flex; flex-direction: column-reverse;
  height: 100%;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
  opacity: .45;
  transition: opacity .15s;
}
.tickets-bold .v2-brush-bar.in-range { opacity: 1; }
.tickets-bold .v2-brush-bar .seg { width: 100%; }
.tickets-bold .v2-brush-bar .seg-i { background: var(--tb-invoiced); }
.tickets-bold .v2-brush-bar .seg-h { background: var(--tb-hold); }
.tickets-bold .v2-brush-bar .seg-p { background: var(--tb-processing); }
.tickets-bold .v2-brush-bar .seg-r { background: var(--tb-reject); opacity: .7; }
.tickets-bold .v2-brush-bar .seg-s { background: var(--tb-ink-4); opacity: .5; }

.tickets-bold .v2-brush-selection {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(28,26,21,.06);
  border-left: 1px solid var(--tb-ink);
  border-right: 1px solid var(--tb-ink);
  pointer-events: none;
}
.tickets-bold .v2-brush-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  background: var(--tb-ink);
  cursor: ew-resize;
}
.tickets-bold .v2-brush-handle::after {
  content: ""; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 16px;
  background: rgba(244,241,234,.6);
  border-radius: 1px;
}
.tickets-bold .v2-brush-axis {
  position: absolute;
  left: 6px; right: 6px; bottom: 0;
  display: flex; justify-content: space-between;
  font-size: 9.5px;
  color: var(--tb-ink-4);
  font-family: var(--tb-mono);
  padding-top: 2px;
}

/* --- Summary numerals ---------------------------------------------------- */
.tickets-bold .v2-summary {
  display: flex; align-items: center; gap: 18px;
  padding-left: 10px;
  border-left: 1px solid var(--tb-rule);
  white-space: nowrap;
}
.tickets-bold .v2-summary .num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  color: var(--tb-ink);
  display: block;
}
.tickets-bold .v2-summary .num.amber { color: var(--tb-hold); }
.tickets-bold .v2-summary .lbl {
  font-size: 11px;
  color: var(--tb-ink-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

.tickets-bold .v2-command-bot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  gap: 16px;
  flex-wrap: wrap;
}

/* --- Pills --------------------------------------------------------------- */
.tickets-bold .pill-row {
  display: flex; align-items: center; gap: 2px;
  flex-wrap: wrap;
}
.tickets-bold .pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 4px;
  color: var(--tb-ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background .12s;
  position: relative;
}
.tickets-bold .pill:hover { background: var(--tb-bg-sunk); }
.tickets-bold .pill.active { background: var(--tb-ink); color: #F4F1EA; }
.tickets-bold .pill.active .dot { background: #F4F1EA !important; }
.tickets-bold .pill .count { color: var(--tb-ink-4); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.tickets-bold .pill.active .count { color: rgba(244,241,234,.65); }
.tickets-bold .pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--tb-ink-3);
  flex: 0 0 auto;
}
.tickets-bold .pill.open   .dot,
.tickets-bold .pill.proc   .dot { background: var(--tb-processing); }
.tickets-bold .pill.held   .dot { background: var(--tb-hold); }
.tickets-bold .pill.billable .dot { background: var(--tb-approve); }
.tickets-bold .pill.invoiced .dot { background: var(--tb-invoiced); }
.tickets-bold .pill.stopped  .dot { background: var(--tb-stopped); }
.tickets-bold .pill.rejected .dot { background: var(--tb-reject); }

.tickets-bold .pill-scoped::after {
  content: "";
  position: absolute;
  top: 4px; right: 3px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--tb-hold);
}
.tickets-bold .pill.active.pill-scoped::after { background: #F4F1EA; }

/* --- Section headers & CTA ---------------------------------------------- */
.tickets-bold .v2-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 0 10px;
  gap: 14px;
}
.tickets-bold .v2-section-head h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -.005em;
}
.tickets-bold .v2-section-head h2 .count {
  color: var(--tb-ink-4);
  font-size: 18px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.tickets-bold .v2-section-head .meta {
  font-size: 12px;
  color: var(--tb-ink-3);
}
.tickets-bold .v2-section-head .head-right {
  display: flex; align-items: center; gap: 14px;
}
.tickets-bold .v2-review-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--tb-ink);
  color: #F4F1EA !important;
  border-radius: var(--tb-radius);
  font-size: 13px;
  font-weight: 500;
  transition: background .12s;
}
.tickets-bold .v2-review-cta:hover { background: #000; }
.tickets-bold .v2-review-cta svg { transition: transform .12s; }
.tickets-bold .v2-review-cta:hover svg { transform: translateX(2px); }

/* --- Data table (scoped) ------------------------------------------------ */
.tickets-bold .data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--tb-bg-elev);
  border: 1px solid var(--tb-rule);
  border-radius: var(--tb-radius-lg);
  overflow: hidden;
  margin: 0;
}
.tickets-bold .data-table thead th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--tb-ink-4);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 16px;
  background: var(--tb-bg-sunk);
  border-bottom: 1px solid var(--tb-rule);
  white-space: nowrap;
}
.tickets-bold .data-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--tb-rule);
  vertical-align: middle;
  font-size: 13.5px;
  background: var(--tb-bg-elev);
}
.tickets-bold .data-table tbody tr:last-child td { border-bottom: 0; }
.tickets-bold .data-table tbody tr:hover td { background: #FCFBF7; }

.tickets-bold .t-thumb {
  width: 56px; height: 36px;
  background-size: cover; background-position: center;
  border-radius: var(--tb-radius);
  border: 1px solid var(--tb-rule);
  background-color: var(--tb-bg-sunk);
  display: block;
  overflow: hidden;
}
.tickets-bold .t-thumb > div { width: 100%; height: 100%; }
.tickets-bold .t-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  cursor: zoom-in;
}
.tickets-bold .t-thumb dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
}
.tickets-bold .t-thumb dialog::backdrop { background: rgba(0, 0, 0, 0.75); cursor: pointer; }
.tickets-bold .t-thumb dialog img {
  width: auto; height: auto;
  max-width: 90vw; max-height: 90vh;
  object-fit: contain; border-radius: 8px; cursor: auto;
}
.tickets-bold .t-id {
  font-family: var(--tb-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tb-processing);
}
.tickets-bold .t-id:hover { text-decoration: underline; }

.tickets-bold .status-ind {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tb-ink-2);
}
.tickets-bold .status-ind::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--tb-ink-3);
}
.tickets-bold .status-ind.open::before,
.tickets-bold .status-ind.processing::before { background: var(--tb-processing); }
.tickets-bold .status-ind.held::before { background: var(--tb-hold); }
.tickets-bold .status-ind.billable::before { background: var(--tb-approve); }
.tickets-bold .status-ind.invoiced::before { background: var(--tb-invoiced); }
.tickets-bold .status-ind.stopped::before,
.tickets-bold .status-ind.incomplete::before,
.tickets-bold .status-ind.pending::before { background: var(--tb-stopped); }
.tickets-bold .status-ind.rejected::before { background: var(--tb-reject); }

.tickets-bold .mono {
  font-family: var(--tb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--tb-ink-2);
}
.tickets-bold .muted { color: var(--tb-ink-4); }

/* --- Settled fold ------------------------------------------------------- */
.tickets-bold .v2-settled-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  background: var(--tb-bg-sunk);
  border: 1px solid var(--tb-rule);
  border-radius: var(--tb-radius-lg);
  font-size: 13px;
  color: var(--tb-ink-2);
  cursor: pointer;
  user-select: none;
  width: 100%;
  text-align: left;
  transition: background .12s;
}
.tickets-bold .v2-settled-toggle:hover { background: #EDE9DC; }
.tickets-bold .v2-settled-toggle .chev {
  transition: transform .15s;
  flex: 0 0 auto;
}
.tickets-bold .v2-settled-toggle.open .chev { transform: rotate(90deg); }
.tickets-bold .v2-settled-toggle .summary { flex: 1; }
.tickets-bold .v2-settled-toggle .summary strong { font-weight: 600; color: var(--tb-ink); }
.tickets-bold .v2-settled-toggle .mini-bar {
  display: inline-flex; gap: 2px; align-items: flex-end;
  margin-left: auto;
  height: 24px;
}
.tickets-bold .v2-settled-toggle .mini-bar i {
  display: inline-block; width: 3px;
  background: var(--tb-invoiced);
  opacity: .7;
  border-radius: 1px;
}
.tickets-bold .v2-settled-body {
  display: none;
  margin-top: 10px;
}
.tickets-bold .v2-settled-toggle.open + .v2-settled-body { display: block; }

/* --- Pagination --------------------------------------------------------- */
.tickets-bold .pag {
  display: flex; gap: 4px; margin-top: 20px;
  font-size: 13px;
  font-family: var(--tb-mono);
}
.tickets-bold .pag a,
.tickets-bold .pag span,
.tickets-bold .pag em {
  padding: 5px 10px;
  border: 1px solid var(--tb-rule);
  border-radius: var(--tb-radius);
  color: var(--tb-ink-3);
  background: var(--tb-bg-elev);
  font-style: normal;
}
.tickets-bold .pag em.current,
.tickets-bold .pag .current {
  background: var(--tb-ink);
  color: #F4F1EA;
  border-color: var(--tb-ink);
}
.tickets-bold .pag .gap { border: 0; background: transparent; }

/* --- Vehicle-type filter row -------------------------------------------- */
.tickets-bold .v2-types {
  display: flex; align-items: center; gap: 2px;
  margin-bottom: 14px;
}
.tickets-bold .v2-types .lbl {
  font-size: 11.5px;
  color: var(--tb-ink-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-right: 10px;
}

/* --- Topbar review-queue link (applies in nav) -------------------------- */
.nav .review-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: #F4F1EA;
  border: 1px solid #D4CEBE;
  border-radius: 3px;
  color: #3A362E;
  font-size: 12.5px;
  font-weight: 500;
  transition: all .12s;
  text-decoration: none;
}
.nav .review-link:hover {
  background: #1C1A15;
  color: #F4F1EA;
  border-color: #1C1A15;
}
.nav .review-link .count-pip {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px;
  padding: 0 6px;
  background: #B8861B;
  color: #fff;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
}
.nav .review-link:hover .count-pip { background: #F4F1EA; color: #1C1A15; }



/* ==========================================================================
   Admin shell — chrome, section rail, page scaffolding
   (New design system — overrides legacy rules above via cascade order.)
   ========================================================================== */

.chrome {
  display: flex; align-items: center;
  gap: var(--space-lg);
  padding: 0 var(--space-xl);
  height: 52px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 20;
}

.chrome-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
  color: var(--color-text);
  padding-right: var(--space-md);
  border-right: 1px solid var(--color-border);
  height: 100%;
  display: inline-flex; align-items: center;
}

.chrome-projswitch {
  position: relative;
  height: 100%;
  display: inline-flex; align-items: center;
  padding-right: var(--space-md);
  border-right: 1px solid var(--color-border);
}
.chrome-projswitch-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast);
  font-family: inherit;
}
.chrome-projswitch-btn:hover { background: var(--color-surface-sunk); }
.chrome-projswitch-btn[aria-expanded="true"] {
  background: var(--color-surface-sunk);
  border-color: var(--color-border);
}
.chrome-projswitch-btn .caret {
  color: var(--color-text-tertiary);
  margin-left: 2px;
}
.chrome-projswitch-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
}
.chrome-projswitch-menu {
  position: absolute;
  top: calc(100% - 6px);
  left: 0;
  min-width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--motion-fast), transform var(--motion-fast);
}
.chrome-projswitch-menu[data-open="true"] {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.chrome-projswitch-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
}
.chrome-projswitch-item:hover { background: var(--color-surface-sunk); }
.chrome-projswitch-item[aria-current="true"] { background: var(--color-surface-sunk); }
.chrome-projswitch-item .mk {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-surface-sunk); color: var(--color-text);
  font-family: var(--font-display); font-weight: 600; font-size: 11px;
  border: 1px solid var(--color-border);
}
.chrome-projswitch-item[aria-current="true"] .mk {
  background: var(--color-accent); color: #fff; border-color: transparent;
}
.chrome-projswitch-item .nm { flex: 1; font-weight: var(--weight-medium); }
.chrome-projswitch-item .sl { font-family: var(--font-mono); font-size: 11.5px; color: var(--color-text-tertiary); }
.chrome-projswitch-div { height: 1px; background: var(--color-border); margin: 6px 4px; }
.chrome-projswitch-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
}
.chrome-projswitch-foot:hover { background: var(--color-surface-sunk); color: var(--color-text); }

.chrome-crumb {
  display: inline-flex; align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.chrome-crumb a { color: var(--color-text-secondary); transition: color var(--motion-fast); text-decoration: none; }
.chrome-crumb a:hover { color: var(--color-text); }
.chrome-crumb .chrome-project {
  color: var(--color-text);
  font-weight: var(--weight-medium);
}
.chrome-crumb .ic { color: var(--color-text-tertiary); }

.chrome-spacer { flex: 1; }

.chrome-search {
  display: inline-flex; align-items: center; gap: var(--space-sm);
  background: var(--color-surface-sunk);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  width: 280px;
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  transition: border-color var(--motion-med), background var(--motion-med);
  cursor: text;
  font-family: inherit;
}
.chrome-search:hover { border-color: var(--color-border); }
.chrome-search .ic { flex-shrink: 0; }
.chrome-search span { flex: 1; text-align: left; }
.chrome-search kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
}

.chrome-queue {
  display: inline-flex; align-items: center; gap: var(--space-sm);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  transition: border-color var(--motion-fast), background var(--motion-fast);
  text-decoration: none;
}
.chrome-queue:hover { border-color: var(--color-border-hover); background: var(--color-surface); }
.chrome-queue .ic { color: var(--color-text-secondary); }
.chrome-queue .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--color-hold);
  color: #fff;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: var(--weight-semi);
}

.chrome-user {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--motion-fast), background var(--motion-fast);
  text-decoration: none;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.chrome-user:hover { color: var(--color-text); background: var(--color-surface-sunk); }
.chrome-user form { display: inline-flex; }
.chrome-user button {
  background: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  color: inherit; font: inherit; padding: 0;
}

/* Section rail */
.rail {
  display: flex; align-items: stretch;
  padding: 0 var(--space-xl);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  gap: 2px;
  position: sticky; top: 52px; z-index: 19;
  overflow-x: auto;
  overflow-y: hidden;
}
.rail-tab {
  display: inline-flex; align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  height: 42px;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  position: relative;
  transition: color var(--motion-fast);
  text-decoration: none;
}
.rail-tab .ic { color: currentColor; opacity: 0.7; }
.rail-tab:hover { color: var(--color-text); }
.rail-tab .rail-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--color-text-tertiary);
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--color-surface-sunk);
}
.rail-tab[aria-current="page"] { color: var(--color-text); }
.rail-tab[aria-current="page"] .ic { opacity: 1; }
.rail-tab[aria-current="page"]::after {
  content: "";
  position: absolute; left: var(--space-md); right: var(--space-md); bottom: -1px;
  height: 2px;
  background: var(--color-text);
}
.rail-tab[aria-current="page"] .rail-count {
  background: var(--color-text);
  color: var(--color-bg);
}

/* Page container (override legacy main rule) */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-xl) var(--space-3xl);
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.page-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
  color: var(--color-text);
  line-height: 1.1;
}

.page-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: 6px;
}

/* Override legacy page-header to use IBM Plex Sans, matching the new display */
.page-header {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

/* Filter pills — new look, mapped from legacy .stat / .stat-bar markup */
.stat-bar, .filter-row {
  display: flex; align-items: center;
  gap: 2px;
  margin-bottom: var(--space-md);
  border: 0;
  background: transparent;
  padding: 0;
}

.stat, .fp {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  background: transparent;
  border: 0;
  text-decoration: none;
  transition: all var(--motion-fast);
  cursor: pointer;
}
.stat:hover, .fp:hover { color: var(--color-text); background: var(--color-surface-sunk); }

/* Dot marker — legacy .stat gets one via pseudo; new .fp uses <span class=dot> */
.stat::before {
  content: ""; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-text-tertiary);
  flex-shrink: 0;
}
.stat:first-child::before { display: none; } /* "All" pill — no dot */
.fp .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-text-tertiary);
}
.fp .fp-count, .stat .stat-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* Active pill — black ink, paper text */
.stat.stat-active, .fp[aria-current="true"] {
  background: var(--color-text);
  color: #F4F1EA;
}
.stat.stat-active::before, .fp[aria-current="true"] .dot { background: #F4F1EA; }
.stat.stat-active .stat-count, .fp[aria-current="true"] .fp-count { color: rgba(244,241,234,.65); }

/* Dot colors — legacy class map */
.stat.stat-closed::before, .fp.fp-processed .dot { background: var(--color-success); }
.stat.stat-open::before,   .fp.fp-unprocessed .dot { background: var(--color-processing); }
.stat.stat-pending::before,.fp.fp-draft .dot { background: var(--color-warning); }
.stat.stat-held::before,   .fp.fp-held .dot { background: var(--color-hold); }
.fp.fp-billable .dot { background: var(--color-approve); }
.fp.fp-invoiced .dot { background: var(--color-invoiced); }
.fp.fp-finalized .dot { background: var(--color-approve); }
.fp.fp-credit .dot { background: var(--color-danger); }
.fp.fp-company .dot { background: var(--color-processing); }
.fp.fp-person .dot { background: var(--color-warning); }

/* Search input — the legacy class still used by every index view */
.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: all var(--motion-fast);
  margin-bottom: var(--space-lg);
}
.search-input:focus {
  outline: 0;
  border-color: var(--color-border-hover);
  box-shadow: 0 0 0 3px var(--color-focus);
}
.search-input::placeholder { color: var(--color-text-tertiary); }

.search-wrap {
  position: relative;
  margin-bottom: var(--space-lg);
}
.search-wrap .search-input { margin-bottom: 0; }
.search-wrap > .ic,
.search-wrap > svg.ic {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
  pointer-events: none;
}

/* Data table — refined look */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 0;
}
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  background: var(--color-surface-sunk);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table th.num { text-align: right; }
.data-table td {
  padding: 12px 16px;
  font-size: var(--text-sm);
  border-bottom: 1px solid #F2F0EC;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--motion-fast); }
.data-table tbody tr:hover td { background: #FCFBF7; }
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.data-table td.monospace,
.data-table td .monospace,
.monospace {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.t-id {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: var(--weight-medium);
  color: var(--color-processing-ink);
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  text-decoration: none;
  transition: color var(--motion-fast);
}
.t-id:hover { color: var(--color-text); }

.t-thumb {
  display: block;
  width: 56px; height: 36px;
  background: var(--color-surface-sunk);
  border-radius: var(--radius-tight);
  background-size: cover;
  background-position: center;
}
.t-thumb-empty {
  display: inline-block;
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
}

.cell-sec { color: var(--color-text-secondary); font-size: var(--text-sm); }
.cell-main { color: var(--color-text); font-weight: var(--weight-medium); }

/* Status indicator — dot + label. Maps legacy status-* to new si-* semantics. */
.status-indicator {
  display: inline-flex; align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  color: var(--color-text);
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.status-indicator::before {
  content: ""; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-text-tertiary);
  flex-shrink: 0;
}
.si-processed::before, .status-closed::before, .status-finalized::before { background: var(--color-success); }
.si-unprocessed::before, .status-open::before { background: var(--color-processing); }
.si-held::before, .status-held::before { background: var(--color-hold); }
.si-billable::before, .status-approved::before { background: var(--color-approve); }
.si-finalized::before { background: var(--color-approve); }
.si-draft::before, .status-pending::before, .status-draft::before { background: var(--color-warning); }
.si-invoiced::before { background: var(--color-invoiced); }

/* Pagination — pagy series_nav outputs <nav class="pagy">…<a>…</a>… */
.pagy, nav.pagy {
  display: flex; align-items: center;
  gap: 4px;
  margin-top: var(--space-lg);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.pagy a, .pagy span, nav.pagy a, nav.pagy span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 30px;
  padding: 0 8px;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  transition: all var(--motion-fast);
  text-decoration: none;
}
.pagy a:hover, nav.pagy a:hover { border-color: var(--color-border-hover); color: var(--color-text); }
.pagy .current, nav.pagy .current, nav.pagy a.current,
nav.pagy a[aria-current="page"] {
  background: var(--color-text);
  border-color: var(--color-text);
  color: #F4F1EA;
}
.pagy .gap, nav.pagy .gap,
nav.pagy a[role="separator"] { border-color: transparent; background: transparent; }
.pagy .disabled, nav.pagy .disabled,
nav.pagy a[aria-disabled="true"]:not([aria-current="page"]) { opacity: 0.45; pointer-events: none; }

/* Icon helper */
.ic {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.ic-14 { width: 14px; height: 14px; }
.ic-18 { width: 18px; height: 18px; }
.ic-20 { width: 20px; height: 20px; }

/* Page title subtitle */
.page-title-group .page-count { margin-top: 4px; }


/* ==========================================================================
   Dashboard (Overview) — hero, stat strip, section grid
   ========================================================================== */

.hero {
  padding: var(--space-2xl) 0 var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-2xl);
}
.hero-eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-sm);
}
.hero-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: 2.5rem;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--color-text);
  display: flex; align-items: center; gap: var(--space-md);
}
.hero-title .page-header-action { color: var(--color-text-tertiary); }
.hero-title .page-header-action:hover { color: var(--color-text); }
.hero-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--text-md);
  margin-top: 8px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2xl);
}
.stat-cell {
  padding: var(--space-lg);
  border-right: 1px solid var(--color-border);
}
.stat-cell:last-child { border-right: 0; }
.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: 10px;
}
.stat-value {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: 1.75rem;
  letter-spacing: -0.015em;
  color: var(--color-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value .unit {
  font-family: var(--font-mono);
  font-weight: var(--weight-normal);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-left: 4px;
}
.stat-delta {
  margin-top: 8px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: inline-flex; align-items: center; gap: 6px;
}
.stat-delta .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-hold);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}
@media (max-width: 800px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-cell:nth-child(2) { border-right: 0; }
  .section-grid { grid-template-columns: 1fr; }
}

.section-card {
  display: block;
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--motion-fast);
  text-decoration: none;
  color: var(--color-text);
}
.section-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}
.section-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md);
}
.section-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
  color: var(--color-text);
}
.section-card-arrow {
  color: var(--color-text-tertiary);
  transition: transform var(--motion-fast), color var(--motion-fast);
}
.section-card:hover .section-card-arrow {
  color: var(--color-text);
  transform: translateX(2px);
}
.section-card-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.section-card-meta {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.section-card-meta .pip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 10px;
  color: var(--color-hold);
}
.section-card-meta .pip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-hold);
}

/* Actions-cell — used in vehicles/customers tables */
.actions-cell {
  display: inline-flex;
  gap: var(--space-md);
  align-items: center;
}

.btn-ghost-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: color var(--motion-fast);
}
.btn-ghost-link:hover { color: var(--color-text); }
.btn-ghost-link.danger:hover { color: var(--color-danger); }
.btn-ghost-link form { display: inline; }
.btn-ghost-link[type="submit"] { line-height: inherit; }

/* Review queue is a full-bleed workspace — strip main padding when present. */
main:has(.review-queue) {
  max-width: none;
  padding: 0;
  margin: 0;
}


/* ==========================================================================
   Projects selector — root /
   ========================================================================== */

.projects-head {
  padding: var(--space-2xl) 0 var(--space-xl);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}
.projects-eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-sm);
}
.projects-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: 2.5rem;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--color-text);
}
.projects-sub {
  color: var(--color-text-secondary);
  font-size: var(--text-md);
  margin-top: 8px;
}

.proj-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
@media (max-width: 800px) {
  .proj-grid { grid-template-columns: 1fr; }
}

.proj-card {
  display: block;
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--motion-fast);
  color: var(--color-text);
  text-decoration: none;
}
.proj-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}
.proj-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.proj-card-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-surface-sunk);
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: 17px;
  letter-spacing: -0.02em;
}
.proj-card-arrow {
  color: var(--color-text-tertiary);
  transition: transform var(--motion-fast), color var(--motion-fast);
}
.proj-card:hover .proj-card-arrow {
  color: var(--color-text);
  transform: translateX(2px);
}
.proj-card-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.proj-card-slug {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-md);
}
.proj-card-stats {
  display: flex; gap: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid #F2F0EC;
}
.proj-card-stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}
.proj-card-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}
.proj-card-stat-value .held {
  color: var(--color-hold);
  font-weight: var(--weight-semi);
}


/* ==========================================================================
   Data-table image thumbnails (events, attention tickets)
   The lightbox wrapper renders an <img> directly — constrain it to thumb size.
   ========================================================================== */

.data-table td [data-controller="lightbox"] {
  display: inline-block;
  line-height: 0;
}
.data-table td [data-controller="lightbox"] > img {
  display: block;
  width: 56px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-tight);
  cursor: zoom-in;
  background: var(--color-surface-sunk);
}

/* Lightbox dialog — full-bleed modal */
.data-table td [data-controller="lightbox"] dialog {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
}
.data-table td [data-controller="lightbox"] dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
}
.data-table td [data-controller="lightbox"] dialog img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
