/*
 * Surf Suite — Premium Refinements
 * ===================================
 * Final operational UX & premium perception pass.
 * Load after shell-v2.css + shell-mobile.css.
 *
 * This file does NOT redesign the system.
 * It applies surgical precision improvements across:
 *
 *   1.  Scanning & operational clarity
 *   2.  Table world-class refinements
 *   3.  KPI / dashboard system
 *   4.  Forms & data entry
 *   5.  AI-native patterns
 *   6.  Surface & elevation hierarchy
 *   7.  Interaction polish & motion
 *   8.  Empty states & microcopy
 *   9.  Operational status system
 *  10.  Typography precision
 */


/* ═══════════════════════════════════════════════════════════════════════════
   1. SCANNING & OPERATIONAL CLARITY
   Making critical information identifiable in milliseconds.
═══════════════════════════════════════════════════════════════════════════ */

/* Tabular numbers — essential for financial/metric data alignment */
.surf-num,
.surf-stat-value,
.ats-widget-card > strong,
.global-sales-kpi-value,
th[data-type="number"],
td[data-type="number"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Priority dot — 6px signal for urgency level */
.surf-priority {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.surf-priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.surf-priority-dot.high   { background: var(--status-error-text); }
.surf-priority-dot.medium { background: var(--app-primary); }
.surf-priority-dot.low    { background: var(--c-border-strong); }
.surf-priority-dot.none   { background: var(--c-border); }

/* Overdue / urgency timestamp */
.surf-ts-overdue {
  color: var(--status-error-text);
  font-weight: 600;
}

.surf-ts-warning {
  color: var(--status-warning-text);
  font-weight: 600;
}

.surf-ts-fresh {
  color: var(--status-success-text);
  font-weight: 500;
}

/* Change indicator — row-level signal for new/updated/urgent items */
.surf-change-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.surf-change-dot.new     { background: var(--app-primary); }
.surf-change-dot.updated { background: var(--status-info-text); }
.surf-change-dot.urgent  { background: var(--status-error-text); }

/* Count / meta display */
.surf-meta-count {
  font-size: var(--fs-sm);
  color: var(--c-text-4);
  font-variant-numeric: tabular-nums;
}

.surf-meta-divider {
  display: inline-block;
  width: 1px;
  height: 10px;
  background: var(--c-border);
  margin: 0 8px;
  vertical-align: middle;
}

/* "N resultados" page subtitle pattern */
.surf-results-line {
  font-size: var(--fs-sm);
  color: var(--c-text-4);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.surf-results-line strong {
  color: var(--c-text-2);
  font-weight: 600;
}


/* ═══════════════════════════════════════════════════════════════════════════
   2. TABLE — WORLD-CLASS ENTERPRISE REFINEMENTS
═══════════════════════════════════════════════════════════════════════════ */

/* Wrap with sticky-header support */
.surf-table-wrap.sticky-header {
  max-height: 520px;
  overflow-y: auto;
}

.surf-table-wrap.sticky-header .surf-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  /* Re-declare background to ensure it stacks over rows */
  background: var(--c-bg);
  box-shadow: 0 1px 0 var(--c-border);
}

/* Column header polish */
.surf-table th {
  padding: 8px 13px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .65px;
  text-transform: uppercase;
  color: var(--c-text-4);
  white-space: nowrap;
  user-select: none;
  cursor: default;
}

/* Sortable column */
.surf-th-sort {
  cursor: pointer;
}

.surf-th-sort:hover {
  color: var(--c-text-2);
  background: var(--c-hover);
}

.surf-th-sort .surf-sort-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--c-border-strong);
  transition: color var(--t-fast), transform var(--t-base);
  vertical-align: middle;
}

.surf-th-sort.is-active {
  color: var(--c-text-2);
}

.surf-th-sort.is-active .surf-sort-icon {
  color: var(--app-primary);
}

.surf-th-sort.sort-asc  .surf-sort-icon { transform: rotate(0deg); color: var(--app-primary); }
.surf-th-sort.sort-desc .surf-sort-icon { transform: rotate(180deg); color: var(--app-primary); }

/* Row refinements */
.surf-table tbody tr {
  transition: background var(--t-fast);
  position: relative;
  border-left: 2.5px solid transparent;
}

/* Row signal bars — left border identity system */
.surf-table tbody tr.row-new     { border-left-color: var(--app-primary); }
.surf-table tbody tr.row-updated { border-left-color: var(--status-info-text); }
.surf-table tbody tr.row-urgent  { border-left-color: var(--status-error-text); }
.surf-table tbody tr.row-warning { border-left-color: var(--status-warning-text); }
.surf-table tbody tr.row-success { border-left-color: var(--status-success-text); }

/* Inline actions — reveal on row hover */
.surf-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.surf-row-action-btn {
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--t-fast), transform var(--t-fast), background var(--t-fast);
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--c-text-3);
  font-family: var(--font);
}

.surf-row-action-btn:hover {
  background: var(--c-border);
  color: var(--c-text);
}

.surf-table tbody tr:hover .surf-row-action-btn {
  opacity: 1;
  transform: translateX(0);
}

/* Primary row action (always visible, but subtler) */
.surf-row-action-primary {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--app-primary);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity var(--t-fast);
}

.surf-table tbody tr:hover .surf-row-action-primary { opacity: 1; }

/* Cell type variants */
.surf-td-name {
  font-weight: 600;
  color: var(--c-text);
}

.surf-td-meta {
  font-size: var(--fs-xs);
  color: var(--c-text-4);
  line-height: 1.4;
  margin-top: 1px;
}

.surf-td-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 600;
  color: var(--c-text);
}

.surf-td-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 700;
  font-size: var(--fs-base);
  color: var(--c-text);
}

/* Avatar stack in cells */
.surf-avatar-stack {
  display: flex;
  align-items: center;
}

.surf-avatar-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--c-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.surf-avatar-sm + .surf-avatar-sm { margin-left: -8px; }

/* Bulk selection checkbox */
.surf-table-checkbox {
  width: 36px;
  padding-right: 0;
}

.surf-table-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.surf-table tbody tr:hover .surf-table-checkbox input[type="checkbox"],
.surf-table tbody tr.is-selected .surf-table-checkbox input[type="checkbox"] {
  opacity: 1;
}

.surf-table tbody tr.is-selected { background: var(--app-primary-soft); }

/* Table toolbar (sits above table, inside panel) */
.surf-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--c-border-2);
  gap: 10px;
}

.surf-table-toolbar-left { display: flex; align-items: center; gap: 10px; }
.surf-table-toolbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.surf-table-count {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text);
}

.surf-table-count-sub {
  font-size: var(--fs-sm);
  color: var(--c-text-4);
}

/* Bulk action bar (replaces toolbar on selection) */
.surf-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--app-primary-soft);
  border-bottom: 1px solid var(--app-primary-border);
}

.surf-bulk-count {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--app-primary-text);
  flex-shrink: 0;
}

/* Table empty state — inline */
.surf-table-empty-row td {
  padding: 56px 24px;
  text-align: center;
  border-bottom: none;
  background: var(--c-surface);
}

.surf-table-empty-row:hover td { background: var(--c-surface); cursor: default; }


/* ═══════════════════════════════════════════════════════════════════════════
   3. KPI WIDGETS — OPERATIONAL & INTELLIGENT
═══════════════════════════════════════════════════════════════════════════ */

/* KPI delta — pill format (replaces plain colored text) */
.surf-kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.surf-kpi-delta.up {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

.surf-kpi-delta.down {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

.surf-kpi-delta.neutral {
  background: var(--c-bg);
  color: var(--c-text-3);
  border: 1px solid var(--c-border);
}

.surf-kpi-delta-arrow { font-size: 10px; }

/* Override the flat .surf-stat-delta with pill variant */
.surf-stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  width: fit-content;
}

.surf-stat-delta.up {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

.surf-stat-delta.down {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

/* KPI alert state */
.surf-stat-card.is-alert {
  border-color: var(--status-error-border);
  background: linear-gradient(135deg, var(--status-error-bg) 0%, var(--c-surface) 100%);
}

.surf-stat-card.is-alert .surf-stat-value { color: var(--status-error-text); }

.surf-stat-card.is-warning {
  border-color: var(--status-warning-border);
}

/* KPI comparison text */
.surf-kpi-vs {
  font-size: 11px;
  color: var(--c-text-4);
  margin-top: 3px;
}

/* KPI trend area — mini sparkline slot */
.surf-kpi-trend {
  height: 28px;
  margin-top: 8px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  opacity: 0.5;
}

.surf-kpi-bar {
  flex: 1;
  border-radius: 1px 1px 0 0;
  background: var(--app-primary);
  min-width: 3px;
  transition: opacity var(--t-fast);
}

.surf-kpi-bar:hover { opacity: .8; cursor: pointer; }

/* KPI grid layout */
.surf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

/* Clickable KPI card */
.surf-stat-card[href],
.surf-stat-card.is-clickable {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: block;
}

.surf-stat-card[href]:hover,
.surf-stat-card.is-clickable:hover {
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
}


/* ═══════════════════════════════════════════════════════════════════════════
   4. FORMS & DATA ENTRY — OPERATIONAL SPEED
═══════════════════════════════════════════════════════════════════════════ */

/* Form section grouping */
.surf-form-section {
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--c-surface);
}

.surf-form-section-header {
  padding: 10px 16px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.surf-form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .65px;
  color: var(--c-text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.surf-form-section-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

/* Field wrapper */
.surf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.surf-field-full { grid-column: 1 / -1; }

/* Validation states */
.surf-input.is-valid {
  border-color: var(--status-success-text);
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M2 7l4 4L12 3' stroke='%2316A34A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.surf-input.is-error {
  border-color: var(--status-error-text);
  box-shadow: 0 0 0 3px var(--status-error-bg);
}

.surf-input.is-warning {
  border-color: var(--status-warning-text);
  box-shadow: 0 0 0 3px var(--status-warning-bg);
}

/* Helper / validation text */
.surf-field-helper {
  font-size: 11px;
  color: var(--c-text-4);
  line-height: 1.4;
}

.surf-field-error {
  font-size: 11px;
  color: var(--status-error-text);
  display: flex;
  align-items: flex-start;
  gap: 4px;
  line-height: 1.4;
}

.surf-field-success {
  font-size: 11px;
  color: var(--status-success-text);
  line-height: 1.4;
}

/* Required field indicator */
.surf-label.required::after {
  content: ' *';
  color: var(--status-error-text);
  font-weight: 700;
}

/* Char count */
.surf-char-count {
  font-size: 11px;
  color: var(--c-text-4);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.surf-char-count.is-over { color: var(--status-error-text); font-weight: 600; }

/* Input with prefix/suffix */
.surf-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.surf-input-group:focus-within {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}

.surf-input-group input,
.surf-input-group select {
  flex: 1;
  border: none;
  outline: none;
  box-shadow: none;
  border-radius: 0;
}

.surf-input-group:focus-within input,
.surf-input-group:focus-within select {
  box-shadow: none;
}

.surf-input-prefix,
.surf-input-suffix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--c-bg);
  color: var(--c-text-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  border-right: 1px solid var(--c-border);
}

.surf-input-suffix {
  border-right: none;
  border-left: 1px solid var(--c-border);
}

/* Inline form (compact filter bar) */
.form-inline.compact {
  gap: 8px;
  align-items: center;
}

.form-inline.compact > div { gap: 3px; }

.form-inline.compact label,
.form-inline.compact .muted {
  margin-bottom: 0;
  font-size: 10px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   5. AI-NATIVE PATTERNS — EMBEDDED, INVISIBLE, OPERATIONAL
═══════════════════════════════════════════════════════════════════════════ */

/* Inline AI hint — appears under a field or section */
.surf-ai-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 12px;
  background: var(--app-primary-soft);
  border: 1px solid var(--app-primary-border);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--app-primary-text);
  line-height: 1.5;
}

.surf-ai-hint-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  color: var(--app-primary);
}

.surf-ai-hint-text { flex: 1; }

.surf-ai-hint-action {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--app-primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  font-family: var(--font);
  padding: 0;
}

/* Inline AI action button — appears in toolbars, near fields */
.surf-ai-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--app-primary-soft);
  color: var(--app-primary-text);
  border: 1px solid var(--app-primary-border);
  cursor: pointer;
  transition: background var(--t-fast), opacity var(--t-fast);
  font-family: var(--font);
  white-space: nowrap;
}

.surf-ai-action:hover { background: color-mix(in srgb, var(--app-primary-soft) 80%, var(--app-primary) 10%); }

.surf-ai-action svg { width: 12px; height: 12px; color: var(--app-primary); }

/* AI workflow bar — sits below filters, above content */
.surf-ai-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--app-primary-soft);
  border: 1px solid var(--app-primary-border);
  border-radius: var(--r-lg);
  margin-bottom: 10px;
}

.surf-ai-bar-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--app-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
}

.surf-ai-bar-text {
  flex: 1;
  font-size: var(--fs-base);
  color: var(--app-primary-text);
  line-height: 1.4;
}

.surf-ai-bar-text strong { font-weight: 700; }

.surf-ai-bar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.surf-ai-bar-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--app-primary-border);
  background: var(--c-surface);
  color: var(--app-primary-text);
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--t-fast);
}

.surf-ai-bar-btn:hover { background: var(--c-hover); }

.surf-ai-bar-dismiss {
  color: var(--app-primary-text);
  opacity: .5;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  font-family: var(--font);
}

.surf-ai-bar-dismiss:hover { opacity: 1; }

/* AI suggestion chips row */
.surf-ai-suggestions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.surf-ai-suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-2);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  font-family: var(--font);
  white-space: nowrap;
}

.surf-ai-suggestion-chip:hover {
  border-color: var(--app-primary-border);
  background: var(--app-primary-soft);
  color: var(--app-primary-text);
}

/* Entity-level AI insight (collapsed card with expand) */
.surf-ai-insight {
  background: var(--app-primary-soft);
  border: 1px solid var(--app-primary-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.surf-ai-insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.surf-ai-insight-title {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--app-primary-text);
}

.surf-ai-insight-caret {
  width: 14px;
  height: 14px;
  color: var(--app-primary);
  transition: transform .18s ease;
  flex-shrink: 0;
}

.surf-ai-insight.is-open .surf-ai-insight-caret { transform: rotate(180deg); }

.surf-ai-insight-body {
  padding: 0 14px 14px;
  font-size: var(--fs-base);
  color: var(--app-primary-text);
  line-height: 1.6;
  display: none;
}

.surf-ai-insight.is-open .surf-ai-insight-body { display: block; }


/* ═══════════════════════════════════════════════════════════════════════════
   6. SURFACE & ELEVATION HIERARCHY
═══════════════════════════════════════════════════════════════════════════ */

/* Extended surface tokens */
:root {
  /* Elevation scale */
  --surf-el-0: var(--c-bg);          /* Page — lowest */
  --surf-el-1: var(--c-surface);     /* Cards, panels */
  --surf-el-2: #FEFEFE;              /* Nested panels, raised cards */
  --surf-el-3: var(--c-bg);          /* Table headers, section backgrounds */
  --surf-el-top: var(--c-surface);   /* Topbar, dropdowns */
}

body.surf-shell[data-theme="dark"] {
  --surf-el-0: #0D1117;
  --surf-el-1: #161B22;
  --surf-el-2: #1C2330;
  --surf-el-3: #21262D;
  --surf-el-top: #161B22;
}

/* Context header — sits between topbar and page content */
.surf-context-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 13px 26px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.surf-context-header-back {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text-3);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  transition: color var(--t-fast);
  padding: 0;
}

.surf-context-header-back:hover { color: var(--c-text); }
.surf-context-header-back svg { width: 14px; height: 14px; }

.surf-context-header-sep {
  width: 1px;
  height: 16px;
  background: var(--c-border);
  flex-shrink: 0;
}

/* Panel refinements — subtle differentiation */
.panel,
.surf-card {
  background: var(--surf-el-1);
  box-shadow: var(--sh-xs);
}

/* Elevated card variant */
.surf-card-raised,
.panel.raised {
  box-shadow: var(--sh-md);
}

/* Flat variant — no elevation, just border */
.surf-card-flat,
.panel.flat {
  box-shadow: none;
  border-color: var(--c-border-2);
}

/* Inset / nested surface */
.surf-inset {
  background: var(--c-bg);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-md);
  padding: 12px 14px;
}

/* Section divider */
.surf-section-divider {
  height: 1px;
  background: var(--c-border-2);
  margin: 16px 0;
}

.surf-section-divider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.surf-section-divider-label::before,
.surf-section-divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border-2);
}

.surf-section-divider-label span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--c-text-4);
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════════════
   7. INTERACTION POLISH & MOTION
═══════════════════════════════════════════════════════════════════════════ */

/* Refined focus rings */
:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
  transition: outline-offset 80ms ease;
}

/* Consistent transition on all interactive elements */
.nav-link,
.surf-btn,
.inline-chip,
.surf-tab,
.surf-dropdown-item,
.surf-tb-icon-btn,
.surf-bottom-nav-item {
  transition-property: background, color, border-color, box-shadow, opacity;
  transition-duration: 120ms;
  transition-timing-function: ease;
}

/* Button scale on active */
.surf-btn:active,
button.surf-btn:active {
  transform: scale(0.97);
  transition: transform 60ms ease;
}

/* Link hover refinement */
.surf-page-title a,
.surf-td-name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast);
}

.surf-page-title a:hover,
.surf-td-name a:hover {
  border-bottom-color: var(--c-border-strong);
}

/* Skeleton loading animation — smoother */
@keyframes surf-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

.surf-skeleton {
  background: var(--c-bg);
  border-radius: var(--r-md);
  animation: surf-skeleton-pulse 1.6s ease infinite;
}

/* Smooth appear for dynamic content */
@keyframes surf-appear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.surf-appear { animation: surf-appear 200ms ease; }

/* Dropdown refinement */
.surf-dropdown { animation-duration: 110ms; }

/* Sidebar nav item — tighter active state indicator */
.nav-link.active {
  position: relative;
}

/* Table hover row — slightly stronger */
.surf-table tbody tr:hover {
  background: var(--c-hover);
}

/* Card interactive hover */
a.surf-entity-card:hover,
.surf-entity-card.is-clickable:hover,
.list-card:hover {
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
  transform: none; /* No lift — enterprise precision */
}


/* ═══════════════════════════════════════════════════════════════════════════
   8. EMPTY STATES & MICROCOPY
═══════════════════════════════════════════════════════════════════════════ */

/* Standardized empty state */
.surf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
}

.surf-empty.compact { padding: 32px 24px; }

.surf-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-xl);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--c-text-4);
}

.surf-empty-icon svg { width: 22px; height: 22px; }

.surf-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 6px;
  letter-spacing: -.2px;
}

.surf-empty-desc {
  font-size: var(--fs-base);
  color: var(--c-text-3);
  max-width: 320px;
  margin: 0 0 18px;
  line-height: 1.6;
}

.surf-empty-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Contextual empty states */
.surf-empty-filter .surf-empty-icon { background: var(--app-primary-soft); border-color: var(--app-primary-border); color: var(--app-primary); }
.surf-empty-error  .surf-empty-icon { background: var(--status-error-bg);   border-color: var(--status-error-border); color: var(--status-error-text); }
.surf-empty-search .surf-empty-icon { background: var(--c-bg); }

/* Status banner */
.surf-status-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r-lg);
  font-size: var(--fs-base);
  line-height: 1.5;
  margin-bottom: 10px;
  border: 1px solid transparent;
}

.surf-status-banner-icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; }
.surf-status-banner-body { flex: 1; }
.surf-status-banner-title { font-weight: 600; display: block; margin-bottom: 2px; }
.surf-status-banner-text  { color: inherit; opacity: .85; font-size: var(--fs-sm); }

.surf-status-banner.info    { background: var(--status-info-bg);    color: var(--status-info-text);    border-color: var(--status-info-border); }
.surf-status-banner.success { background: var(--status-success-bg); color: var(--status-success-text); border-color: var(--status-success-border); }
.surf-status-banner.warning { background: var(--status-warning-bg); color: var(--status-warning-text); border-color: var(--status-warning-border); }
.surf-status-banner.error   { background: var(--status-error-bg);   color: var(--status-error-text);   border-color: var(--status-error-border); }

/* Inline status message (for form feedback) */
.surf-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--r-md);
  margin-top: 8px;
}

.surf-feedback.success { background: var(--status-success-bg); color: var(--status-success-text); }
.surf-feedback.error   { background: var(--status-error-bg);   color: var(--status-error-text); }
.surf-feedback.info    { background: var(--status-info-bg);    color: var(--status-info-text); }


/* ═══════════════════════════════════════════════════════════════════════════
   9. OPERATIONAL STATUS SYSTEM
   Urgency, change, alert — consistent visual language across all entities.
═══════════════════════════════════════════════════════════════════════════ */

/* Urgency level label */
.surf-urgency {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.surf-urgency.critical { color: var(--status-error-text); }
.surf-urgency.high     { color: var(--status-warning-text); }
.surf-urgency.medium   { color: var(--app-primary); }
.surf-urgency.low      { color: var(--c-text-4); }

/* Operational alert bar — top of a section/page */
.surf-alert-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 500;
  margin-bottom: 10px;
}

.surf-alert-bar.critical {
  background: var(--status-error-bg);
  color: var(--status-error-text);
  border: 1px solid var(--status-error-border);
}

.surf-alert-bar.warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.surf-alert-bar-count {
  font-size: var(--fs-sm);
  font-weight: 800;
  background: currentColor;
  color: var(--c-surface);
  border-radius: var(--r-full);
  padding: 1px 7px;
  flex-shrink: 0;
}

.surf-alert-bar-count.critical {
  background: var(--status-error-text);
  color: white;
}

/* Activity timeline dot */
.surf-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.surf-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: var(--c-border);
}

.surf-timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
  position: relative;
}

.surf-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-border-strong);
  border: 2px solid var(--c-surface);
  flex-shrink: 0;
  margin-top: 3px;
  z-index: 1;
  box-sizing: content-box;
  margin-left: 10px;
}

.surf-timeline-dot.accent  { background: var(--app-primary); }
.surf-timeline-dot.success { background: var(--status-success-text); }
.surf-timeline-dot.error   { background: var(--status-error-text); }
.surf-timeline-dot.info    { background: var(--status-info-text); }

.surf-timeline-body { flex: 1; min-width: 0; }

.surf-timeline-title {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--c-text-2);
  line-height: 1.4;
}

.surf-timeline-time {
  font-size: var(--fs-xs);
  color: var(--c-text-4);
  margin-top: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   10. TYPOGRAPHY PRECISION
═══════════════════════════════════════════════════════════════════════════ */

/* Page title refinements */
.page-title,
.surf-page-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.45px;
  line-height: 1.2;
}

/* Section label — uppercase utility */
.surf-label-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--c-text-4);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Value display — for detail views */
.surf-value-lg {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.surf-value-md {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* Truncate with tooltip pattern */
.surf-truncate-smart {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  display: inline-block;
  vertical-align: bottom;
}

/* Monospace for IDs, codes, CIFs */
.surf-code {
  font-family: var(--surf-font-mono, ui-monospace, 'Fira Code', monospace);
  font-size: var(--fs-xs);
  background: var(--c-bg);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  color: var(--c-text-2);
  letter-spacing: .3px;
}

/* Entity name link */
.surf-entity-link {
  color: var(--c-text);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast), color var(--t-fast);
}

.surf-entity-link:hover {
  color: var(--app-primary);
  border-bottom-color: var(--app-primary-border);
}

/* Responsive text */
@media (max-width: 768px) {
  .page-title, .surf-page-title { font-size: var(--fs-xl); }
}


/* ═══════════════════════════════════════════════════════════════════════════
   11. LAYOUT PRECISION — PAGE STRUCTURE POLISH
═══════════════════════════════════════════════════════════════════════════ */

/* Page header with actions aligned */
.surf-page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.surf-page-header-left { min-width: 0; }
.surf-page-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Filter bar — improved layout */
.surf-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.surf-filter-row-left  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.surf-filter-row-right { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }

/* Panel with internal padding — standard content card */
.surf-content-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}

.surf-content-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--c-border-2);
}

.surf-content-card-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--c-text);
}

.surf-content-card-body { padding: 16px 18px; }

/* Sticky page header option */
.surf-page-header-sticky {
  position: sticky;
  top: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 14px 26px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ── Scrollable content wrapper ── */
.surf-scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}


/* ═══════════════════════════════════════════════════════════════════════════
   12. MOBILE OPERATIONAL REFINEMENTS
═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* Entity card actions — full-width on mobile */
  .surf-entity-card .surf-row-actions {
    opacity: 1;
    transform: none;
    width: 100%;
    justify-content: stretch;
  }

  /* KPI grid 2-col on mobile */
  .surf-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* KPI stat cards compact */
  .surf-stat-card { padding: 12px 14px; }
  .surf-stat-value { font-size: 20px; }
  .surf-stat-icon  { width: 28px; height: 28px; margin-bottom: 8px; }

  /* Remove hover-only behaviors */
  .surf-row-action-btn { opacity: 1; transform: none; }

  /* AI bar stacks on mobile */
  .surf-ai-bar { flex-direction: column; align-items: flex-start; }
  .surf-ai-bar-actions { width: 100%; }
  .surf-ai-bar-btn { flex: 1; justify-content: center; text-align: center; }

  /* Empty state compact */
  .surf-empty { padding: 40px 20px; }
  .surf-empty-icon { width: 40px; height: 40px; margin-bottom: 10px; }

  /* Form sections on mobile */
  .surf-form-grid,
  .surf-form-grid-2,
  .surf-form-grid-3 { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   13. RAW TABLE COMPATIBILITY
   Templates use plain <table> without .surf-table — apply world-class styles.
═══════════════════════════════════════════════════════════════════════════ */

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 9px 13px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-border-2);
  font-size: var(--fs-base);
  color: var(--c-text-2);
}

th {
  background: var(--c-bg);
  color: var(--c-text-4);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .65px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
  user-select: none;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--c-hover); }

/* First column in table — primary identity cell */
td:first-child { color: var(--c-text); }


/* ═══════════════════════════════════════════════════════════════════════════
   14. SIDEBAR ACTIVE INDICATOR
   Left-edge accent bar on active nav item.
═══════════════════════════════════════════════════════════════════════════ */

.nav-link.active {
  position: relative;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--app-primary);
  border-radius: 0 2px 2px 0;
}

/* Collapsed sidebar — hide the indicator */
.surf-sidebar.is-collapsed .nav-link.active::before { display: none; }


/* ═══════════════════════════════════════════════════════════════════════════
   15. FILTER PANEL DENSITY
   Compact filter panels — tighter gap, better label alignment.
═══════════════════════════════════════════════════════════════════════════ */

/* Filter section panel — tighter than standard content panels */
.panel > h3 + .form-inline,
.panel > h3 + .status-row {
  margin-top: 2px;
}

/* Panel containing only filter controls — reduce padding */
section.panel:has(.form-inline:only-child),
section.panel:has(.status-row:only-child) {
  padding: 11px 15px;
}

/* Status row chips — tighter gap */
.status-row {
  gap: 5px;
}

/* Form inline — improve vertical alignment of label + control pairs */
.form-inline > div {
  min-width: 120px;
  max-width: 260px;
}

/* Filter submit button alignment */
.form-inline > button[type="submit"] {
  align-self: flex-end;
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════════════
   16. PAGE HEADER PRECISION
   Tighter, more decisive page header rhythm.
═══════════════════════════════════════════════════════════════════════════ */

/* Section head — flex layout polish */
.section-head {
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head > h1,
.section-head > h2,
.section-head > h3 {
  margin: 0;
  line-height: 1.25;
}

/* Page meta — tighter margin */
.page-meta {
  margin-bottom: 12px;
}

/* Panel > h3 — section label style, not full heading */
.panel > h3,
section.panel > h3 {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--c-text-4);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border-2);
}


/* ═══════════════════════════════════════════════════════════════════════════
   17. CARD & LIST OPERATIONAL IMPROVEMENTS
═══════════════════════════════════════════════════════════════════════════ */

/* Entity cards — no lift transform, border emphasis only */
.entity-card:hover,
.list-card:hover,
.kpi:hover,
.metric-card:hover,
.todo-item:hover,
.kanban-card:hover {
  transform: none;
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
}

/* Todo / followup items — denser */
.todo-item {
  padding: 10px 13px;
}

/* Helper text — tighter */
.helper-text {
  font-size: var(--fs-xs);
  color: var(--c-text-4);
  line-height: 1.4;
}

/* Metric label */
.metric-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--c-text-4);
}

/* Metric value */
.metric-value,
.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Score badges — cleaner */
.score-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  letter-spacing: .1px;
}

/* Status pill — unified with surf-badge system */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .15px;
  border: 1px solid transparent;
  white-space: nowrap;
}

/* Tag chip — subtle */
.tag-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  letter-spacing: .3px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   18. EMPTY STATE — EXISTING CLASS OVERRIDE
   .empty-state used in templates — upgrade from dashed box to proper state.
═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
  padding: 40px 24px;
  text-align: center;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 5px;
  letter-spacing: -.15px;
}

.empty-text {
  font-size: var(--fs-base);
  color: var(--c-text-3);
  margin: 0;
  line-height: 1.6;
}


/* ═══════════════════════════════════════════════════════════════════════════
   19. LINK BUTTONS & INLINE ACTIONS
   Better .link-button and .danger-link for operational use.
═══════════════════════════════════════════════════════════════════════════ */

.link-button {
  padding: 0;
  min-height: unset;
  border: 0;
  background: transparent;
  color: var(--app-primary-text);
  box-shadow: none;
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
  font-family: var(--font);
  transition: color var(--t-fast), opacity var(--t-fast);
}

.link-button:hover {
  color: var(--app-primary);
  background: transparent;
  transform: none;
  box-shadow: none;
  opacity: .85;
}

.danger-link {
  color: var(--status-error-text);
}

.danger-link:hover {
  color: var(--status-error-text);
  opacity: .8;
}


/* ═══════════════════════════════════════════════════════════════════════════
   20. TAB LINKS — LEGACY CLASS UPGRADE
   .tab-link / .tabs used in templates — upgrade to surf-tabs aesthetics.
═══════════════════════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding-bottom: 0;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-3);
  font-size: var(--fs-base);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.tab-link:hover {
  background: var(--c-hover);
  border-color: var(--c-border-strong);
  color: var(--c-text-2);
}

.tab-link.active {
  background: var(--app-primary-soft);
  border-color: var(--app-primary-border);
  color: var(--app-primary-text);
  font-weight: 600;
}


/* ═══════════════════════════════════════════════════════════════════════════
   21. GLOBAL SALES KPI TOPBAR — OPERATIONAL PRECISION
   Tighter, denser pill for the topbar KPI widget.
═══════════════════════════════════════════════════════════════════════════ */

.global-sales-kpi {
  gap: 3px;
  padding: 3px 9px;
  border-radius: var(--r-md);
  flex-direction: column;
  align-items: flex-start;
}

.global-sales-kpi-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.global-sales-kpi-value {
  font-size: var(--fs-base);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.global-sales-kpi-meta {
  font-size: 9px;
  line-height: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   22. NOTICE / TOAST — ENSURE BASE CLASS IS STYLED
   app-notice without type modifier should have sensible defaults.
═══════════════════════════════════════════════════════════════════════════ */

.app-notice {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}


/* ═══════════════════════════════════════════════════════════════════════════
   23. SCROLLBAR REFINEMENT — SURF MAIN AREA
   Thin, subtle scrollbar in the main content area.
═══════════════════════════════════════════════════════════════════════════ */

.surf-main {
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.surf-main::-webkit-scrollbar { width: 5px; }
.surf-main::-webkit-scrollbar-track { background: transparent; }
.surf-main::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: var(--r-full); }
.surf-main::-webkit-scrollbar-thumb:hover { background: var(--c-text-4); }


/* ═══════════════════════════════════════════════════════════════════════════
   24. KANBAN BOARD — REFINED DENSITY
═══════════════════════════════════════════════════════════════════════════ */

.kanban-column {
  background: var(--c-bg);
  border-color: var(--c-border);
  min-width: 264px;
  padding: 12px;
}

.kanban-column-head {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border-2);
}

.kanban-card {
  padding: 10px 12px;
  margin-bottom: 0;
}

.kanban-card:hover {
  transform: none;
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
}

.kanban-card-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--c-text);
}

.kanban-meta {
  font-size: var(--fs-xs);
  color: var(--c-text-4);
  margin-top: 4px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   25. TIMELINE — IMPROVED VISUAL STRUCTURE
═══════════════════════════════════════════════════════════════════════════ */

.timeline {
  gap: 0;
  position: relative;
}

.timeline-item {
  padding: 8px 12px;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--c-border-2);
  background: transparent;
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-date {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--c-text-3);
}

.timeline-text {
  font-size: var(--fs-base);
  color: var(--c-text-2);
  margin-top: 2px;
}

.timeline-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--c-text-4);
}


/* ═══════════════════════════════════════════════════════════════════════════
   26. REDUCED MOTION
   Honour prefers-reduced-motion: remove all transforms and long transitions.
   Required for WCAG 2.1 SC 2.3.3.
═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

  /* Kill all CSS animations */
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Sidebar collapse — instant */
  .sidebar-section-panel { transition: none !important; }
  .surf-sidebar { transition: none !important; }

  /* Dropdown — instant appear */
  .surf-dropdown { animation: none !important; }
  .surf-cmd-panel { animation: none !important; }
  .surf-cmd-backdrop { animation: none !important; }

  /* Mobile drawer — instant slide */
  .surf-mobile-drawer { transition: none !important; }

  /* Skeleton — no pulse */
  .surf-skeleton { animation: none !important; }
  .animate-shimmer { animation: none !important; }

  /* Plan bar — no width transition */
  .surf-plan-bar-fill { transition: none !important; }
  .onboarding-progress-bar span { transition: none !important; }

  /* Notices — instant appear */
  .app-notice { animation: none !important; transition: none !important; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   27. PRINT STYLES
   Minimal, readable print output — hides chrome, expands content.
═══════════════════════════════════════════════════════════════════════════ */

@media print {

  /* Hide navigation chrome */
  .surf-topbar,
  .surf-sidebar,
  .surf-mobile-drawer,
  .surf-mobile-menu-trigger,
  .surf-bottom-nav,
  .surf-fab,
  .surf-cmd-backdrop,
  .surf-cmd-panel,
  .app-notice-stack,
  .surf-dropdown,
  .onboarding-panel,
  .surf-ai-bar,
  .surf-alert-bar { display: none !important; }

  /* Full-width main content */
  .surf-body { display: block; height: auto; overflow: visible; }
  .surf-main { overflow: visible; }
  .surf-content, .content { padding: 0; }
  .page-container, .max-w-screen-2xl { max-width: 100%; }

  /* Panels — no shadow, just border */
  .panel, .surf-card, .surf-stat-card, .list-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }

  /* Tables — full width, no scroll */
  .surf-table-wrap, .table-wrap, .scroll-table {
    overflow: visible;
    max-height: none;
    border: 1px solid #ccc;
  }

  .surf-table, table {
    font-size: 11px;
  }

  /* Typography */
  body { font-size: 12px; color: #000; background: #fff; }
  .page-title, .surf-page-title { font-size: 18px; }

  /* Links — show href for print */
  a[href]::after { content: " (" attr(href) ")"; font-size: 10px; color: #555; }
  a[href^="#"]::after,
  a[href^="javascript:"]::after { content: ""; }

  /* Page breaks */
  .panel, section { break-before: auto; }
  h1, h2, h3 { break-after: avoid; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   28. FORCED COLORS (Windows High Contrast)
   Ensure interactive elements remain distinguishable in HC mode.
═══════════════════════════════════════════════════════════════════════════ */

@media (forced-colors: active) {

  /* Restore border visibility on interactive elements */
  .surf-btn, .btn, button,
  input, select, textarea,
  .surf-input, .inline-chip, .tab-link, .surf-tab,
  .surf-dropdown, .surf-card, .panel {
    border: 1px solid ButtonText !important;
  }

  /* Active nav link — use system highlight */
  .nav-link.active, .surf-nav-item.active {
    background: Highlight !important;
    color: HighlightText !important;
  }

  /* Focus rings — defer to system */
  :focus-visible { outline: 3px solid Highlight !important; }

  /* Hide cosmetic backgrounds */
  .surf-topbar, .surf-sidebar { background: Canvas !important; }

  /* Badges and status pills — text only with border */
  .surf-badge, .status-pill, .badge, .inline-chip, .tag-chip {
    background: Canvas !important;
    color: CanvasText !important;
    border: 1px solid ButtonText !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   29. KEYBOARD NAVIGATION VISIBILITY
   Ensure all interactive elements have clearly visible focus when tabbing.
   Extends the shell-v2 :focus-visible rule with higher specificity.
═══════════════════════════════════════════════════════════════════════════ */

/* Nav links — focus ring inside sidebar */
.nav-link:focus-visible,
.surf-nav-item:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 1px;
  border-radius: var(--r-md);
}

/* Table rows — keyboard row focus */
.surf-table tbody tr:focus-visible td:first-child,
table tbody tr:focus-visible td:first-child {
  outline: 2px solid var(--app-primary);
  outline-offset: -2px;
}

/* Buttons — slightly larger ring */
button:focus-visible,
.btn:focus-visible,
.surf-btn:focus-visible,
a.btn-secondary:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 3px;
  border-radius: var(--r-md);
}

/* Inputs — keep ring, ensure enough offset */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 0;
}

/* Command palette items — keyboard navigation */
.surf-cmd-item:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: -2px;
}

/* Skip to main content link (visually hidden until focused) */
.surf-skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--app-primary);
  color: white;
  font-weight: 700;
  border-radius: var(--r-md);
  text-decoration: none;
  font-size: var(--fs-base);
  transition: top 0s;
}

.surf-skip-link:focus {
  top: 8px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   30. SAFE AREA INSETS (iPhone notch / home indicator)
   Extends shell-mobile.css with additional coverage for content areas.
═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .surf-content, .content {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .surf-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
    }

    .app-notice-stack {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}
