/* ============================================================
   MIND — Design System aligned with ARX Sense AI
   Classic theme · Standard density (default)
   ============================================================ */

/* ── 1. CSS VARIABLES ──────────────────────────────────────── */

[data-density="compact"] {
  --density-sidebar-width: 14rem;
  --density-header-height: 3rem;
  --density-content-padding: 1rem;
  --density-text-xs: 0.75rem;
  --density-text-sm: 0.8125rem;
  --density-text-base: 0.875rem;
  --density-text-lg: 1rem;
  --density-text-xl: 1.25rem;
  --density-text-2xl: 1.5rem;
  --density-icon-xs: 1rem;
  --density-icon-sm: 1.125rem;
  --density-gap: 0.75rem;
  --density-gap-sm: 0.5rem;
  --density-card-padding: 1rem;
  --density-py: 0.5rem;
  --density-px: 0.75rem;
  --density-logo-height: 2rem;
  --density-avatar: 2rem;
}

:root,
[data-density="standard"] {
  --density-sidebar-width: 15rem;
  --density-header-height: 3.5rem;
  --density-content-padding: 1.25rem;
  --density-text-xs: 0.75rem;
  --density-text-sm: 0.875rem;
  --density-text-base: 0.9375rem;
  --density-text-lg: 1.125rem;
  --density-text-xl: 1.375rem;
  --density-text-2xl: 1.75rem;
  --density-icon-xs: 1rem;
  --density-icon-sm: 1.25rem;
  --density-gap: 1rem;
  --density-gap-sm: 0.625rem;
  --density-card-padding: 1.25rem;
  --density-py: 0.625rem;
  --density-px: 1rem;
  --density-logo-height: 2.25rem;
  --density-avatar: 2.125rem;
}

[data-density="comfortable"] {
  --density-sidebar-width: 18rem;
  --density-header-height: 4rem;
  --density-content-padding: 1.5rem;
  --density-text-xs: 0.8125rem;
  --density-text-sm: 0.9375rem;
  --density-text-base: 1rem;
  --density-text-lg: 1.25rem;
  --density-text-xl: 1.5rem;
  --density-text-2xl: 2rem;
  --density-icon-xs: 1.125rem;
  --density-icon-sm: 1.375rem;
  --density-gap: 1.25rem;
  --density-gap-sm: 0.75rem;
  --density-card-padding: 1.5rem;
  --density-py: 0.75rem;
  --density-px: 1.25rem;
  --density-logo-height: 2.5rem;
  --density-avatar: 2.25rem;
}

:root,
[data-theme="classic"] {
  /* Sidebar */
  --theme-sidebar-bg: var(--arx-charcoal);
  --theme-sidebar-text: var(--arx-gray-decorative);
  --theme-sidebar-text-active: var(--arx-white);
  --theme-sidebar-active-bg: var(--arx-blue-tint);
  --theme-sidebar-active-bar: var(--arx-blue);
  --theme-sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --theme-sidebar-border: #334155;
  --theme-sidebar-section: rgba(203, 213, 225, 0.5);
  /* Header */
  --theme-header-bg: var(--arx-white);
  --theme-header-border: var(--arx-border);
  /* Content */
  --theme-content-bg: var(--arx-gray-light);
  /* Cards */
  --theme-card-bg: var(--arx-white);
  --theme-card-border: var(--arx-border);
  --theme-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  /* Tables */
  --theme-table-header-bg: var(--arx-gray-light);
  --theme-table-header-text: var(--arx-text-secondary);
  --theme-table-row-alt: var(--arx-gray-light);
  --theme-table-border: var(--arx-border);
  --theme-table-hover: var(--arx-blue-soft);
  /* Brand */
  --color-primary: var(--arx-blue-ink);
  --color-primary-subtle: var(--arx-blue-tint);
  /* Text */
  --color-text: var(--arx-charcoal);
  --color-text-muted: var(--arx-text-muted);
  --color-text-faint: var(--arx-text-muted);
  /* Surfaces */
  --color-border: var(--arx-border);
  --color-bg: var(--arx-gray-light);
  --color-surface: var(--arx-white);
  /* Status */
  --color-success: var(--arx-success);
  --color-success-bg: var(--arx-success-soft);
  --color-warning: var(--arx-warning);
  --color-warning-bg: var(--arx-warning-soft);
  --color-danger: var(--arx-danger);
  --color-danger-bg: var(--arx-danger-soft);
  --color-info: var(--arx-blue-ink);
  --color-info-bg: var(--arx-blue-soft);

  /* ── Design System tokens ── */

  /* Typography aliases */
  --text-xs:   var(--density-text-xs);
  --text-sm:   var(--density-text-sm);
  --text-base: var(--density-text-base);
  --text-lg:   var(--density-text-lg);
  --text-xl:   var(--density-text-xl);

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  /* Border radius */
  --radius-sm:   0.375rem;
  --radius-base: 0.5rem;
  --radius-full: 9999px;

  /* Semantic color aliases */
  --color-text-primary: var(--arx-charcoal);
  --color-text-secondary: var(--arx-text-muted);
  --color-border-strong: var(--arx-border-strong);
  --color-surface-raised: var(--arx-gray-light);
  --color-surface-sunken: var(--arx-gray-light);

  /* Status extended tokens */
  --color-success-border: var(--arx-success-border);
  --color-warning-border: var(--arx-warning-border);
  --color-danger-border: var(--arx-danger-border);
  --color-info-border: var(--arx-blue-border);

  /* MIND autofill/manual states */
  --color-autofill-bg: var(--arx-blue-soft);
  --color-autofill-border: var(--arx-blue-border);
  --color-manual-bg: var(--arx-white);
  --color-manual-border: var(--arx-border-strong);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;

  /* Monospace font */
  --font-mono: 'IBM Plex Mono', 'Menlo', ui-monospace, monospace;
}

/* ── 2. BASE ────────────────────────────────────────────────── */

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: var(--density-text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

.hidden { display: none !important; }

/* ── 3. LAYOUT ──────────────────────────────────────────────── */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--theme-content-bg);
  min-width: 0;
}

/* ── 4. SIDEBAR ─────────────────────────────────────────────── */

.sidebar {
  width: var(--density-sidebar-width);
  background: var(--theme-sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  border-right: 1px solid var(--theme-sidebar-border);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  height: var(--density-header-height);
  padding: 0 var(--density-px);
  border-bottom: 1px solid var(--theme-sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo img {
  height: var(--density-logo-height);
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem 0.125rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--theme-sidebar-section);
  margin-top: 0.25rem;
  user-select: none;
}

.nav-divider {
  height: 1px;
  background: var(--theme-sidebar-border);
  margin: 0.375rem 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-base);
  color: var(--theme-sidebar-text);
  text-decoration: none;
  font-size: var(--density-text-sm);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--theme-sidebar-hover-bg);
  color: var(--theme-sidebar-text-active);
}

.nav-item.active {
  background: var(--theme-sidebar-active-bg);
  color: var(--theme-sidebar-text-active);
  border-left-color: var(--theme-sidebar-active-bar);
}

.nav-item svg {
  flex-shrink: 0;
  width: var(--density-icon-sm);
  height: var(--density-icon-sm);
}

.sidebar-footer {
  padding: var(--density-px);
  border-top: 1px solid var(--theme-sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: var(--density-avatar);
  height: var(--density-avatar);
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--density-text-sm);
  flex-shrink: 0;
}

.user-details { min-width: 0; flex: 1; }

.user-name {
  font-size: var(--density-text-sm);
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: var(--density-text-xs);
  color: var(--theme-sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 5. TOPBAR ──────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  height: var(--density-header-height);
  padding: 0 var(--density-content-padding);
  background: var(--theme-header-bg);
  border-bottom: 1px solid var(--theme-header-border);
  gap: var(--density-gap-sm);
  flex-shrink: 0;
}

.topbar-title {
  font-size: var(--density-text-lg);
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--density-gap-sm);
}

.sidebar-toggle { display: none; }

/* ── 6. VIEWS ───────────────────────────────────────────────── */

.view {
  flex: 1;
  padding: var(--density-content-padding);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--density-gap);
}
#view-graph {
  padding: 0;
  overflow: hidden;
  gap: 0;
}
#view-graph iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  min-height: 0;
}

/* ── 7. LOGIN ───────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 1.5rem;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-logo { margin-bottom: 0.5rem; }

.login-card h2 {
  font-size: var(--density-text-xl);
  font-weight: 700;
  color: var(--color-text);
}

.login-subtitle {
  font-size: var(--density-text-sm);
  color: var(--color-text-muted);
  margin-top: -0.5rem;
}

.login-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-faint);
  font-size: var(--density-text-xs);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.btn-microsoft {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font-size: var(--density-text-sm);
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-microsoft:hover { background: #F8FAFC; border-color: #CBD5E1; }

.btn-demo {
  width: 100%;
  padding: 0.625rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: var(--density-text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-demo:hover { opacity: 0.9; }

/* ── 8. BUTTONS ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-base);
  font-size: var(--density-text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background var(--transition-fast), opacity var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--arx-blue-hover); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: #F8FAFC; border-color: #CBD5E1; }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-sm {
  padding: 0.3125rem 0.625rem;
  font-size: var(--density-text-xs);
  border-radius: var(--radius-sm);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-base);
  background: transparent;
  border: none;
  color: var(--color-text-faint);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: inherit;
}

.btn-icon:hover { background: #F1F5F9; color: var(--color-text-muted); }

.sidebar-footer .btn-icon { color: var(--theme-sidebar-text); }
.sidebar-footer .btn-icon:hover {
  background: var(--theme-sidebar-hover-bg);
  color: var(--theme-sidebar-text-active);
}

/* ── 9. CARDS / FORM SECTIONS ───────────────────────────────── */

.form-section {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 0.75rem;
  box-shadow: var(--theme-card-shadow);
  padding: var(--density-card-padding);
  display: flex;
  flex-direction: column;
  gap: var(--density-gap-sm);
}

.section-title {
  font-size: var(--density-text-base);
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}

/* ── 10. FORMS ──────────────────────────────────────────────── */

.form-grid { display: grid; gap: var(--density-gap); }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 0.3125rem; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group label {
  font-size: var(--density-text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--density-py) var(--density-px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--density-text-base);
  font-family: inherit;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-group textarea { resize: vertical; min-height: 4.5rem; }

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--color-text-faint); }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--density-gap-sm);
  padding-top: 0.25rem;
}

/* ── 11. FILTERS BAR ────────────────────────────────────────── */

.dashboard-filters {
  display: flex;
  align-items: center;
  gap: var(--density-gap-sm);
  flex-wrap: wrap;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 0.75rem;
  padding: 0.625rem var(--density-px);
  box-shadow: var(--theme-card-shadow);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 12rem;
  padding: 0.375rem 0.625rem;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}

.search-box svg { color: var(--color-text-faint); flex-shrink: 0; }

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--density-text-sm);
  font-family: inherit;
  color: var(--color-text);
  width: 100%;
}

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

.dashboard-filters > select {
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font-size: var(--density-text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}

.dashboard-filters > select:focus { border-color: var(--color-primary); }

/* ── 12. TABLES ─────────────────────────────────────────────── */

.table-container {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 0.75rem;
  box-shadow: var(--theme-card-shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--density-text-sm);
}

.data-table thead tr { background: var(--theme-table-header-bg); }

.data-table thead th {
  padding: 0.375rem 0.75rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--theme-table-header-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--theme-table-border);
  white-space: nowrap;
}

.data-table thead th.text-right { text-align: right; }

.data-table tbody tr {
  border-bottom: 1px solid var(--theme-table-border);
  transition: background 0.1s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: var(--theme-table-row-alt); }
.data-table tbody tr:nth-child(odd)  { background: var(--color-surface); }
.data-table tbody tr:hover            { background: var(--theme-table-hover) !important; }

.data-table tbody td {
  padding: 0.35rem 0.75rem;
  color: var(--color-text);
  vertical-align: middle;
  font-size: var(--density-text-sm);
}

.data-table tbody td.text-right { text-align: right; }

.data-table tfoot td {
  padding: 0.375rem 0.75rem;
  border-top: 2px solid var(--theme-table-border);
  font-weight: 600;
  background: var(--theme-table-header-bg);
}

/* Inline tables inside form sections */
.form-section .table-container {
  border-radius: 0.5rem;
  box-shadow: none;
}

/* Sortable column headers */
.data-table thead th[data-sort] { cursor: pointer; user-select: none; }
.data-table thead th[data-sort]:hover { background: #E8EDF5; }

.sort-icon { display: inline-block; margin-left: 0.25rem; opacity: 0.45; font-size: 0.65rem; }

/* ── 13. BADGES ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: var(--density-text-xs);
  font-weight: 500;
  white-space: nowrap;
}

.badge-draft      { background: #F1F5F9; color: #475569; }
.badge-final      { background: var(--color-success-bg); color: var(--color-success); }
.badge-calculated { background: var(--color-primary-subtle); color: #1D5FA3; }
.badge-approved   { background: var(--color-success-bg); color: var(--color-success); }
.badge-invoiced   { background: var(--color-info-bg); color: var(--color-info); }
.badge-rejected   { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-pending    { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-success    { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger     { background: var(--color-danger-bg); color: var(--color-danger); }

.axdb-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7C3AED;
  background: #F3EEFF;
  border: 1px solid #DDD6FE;
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

.mind-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-info);
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

/* Supply Map table */
.sm-item-id {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--color-primary);
  font-family: var(--font-mono, monospace);
}
.sm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
}
.sm-toggle:hover { background: var(--color-surface-sunken); color: #334155; }
.sm-secondary-row td {
  color: var(--color-text-secondary);
  font-size: var(--density-text-sm);
}
.sm-vendor-name { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-product-name { font-size: var(--density-text-sm); color: var(--color-text-secondary); font-weight: 400; font-family: inherit; }
.sm-part-alias { font-weight: 600; color: #334155; }
.td-truncate { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.result-positive  { color: var(--color-success); font-weight: 600; }
.result-negative  { color: var(--color-danger);  font-weight: 600; }
.mind-positive, .data-table td.mind-positive, .data-table td.mind-positive strong { color: #065F46 !important; font-weight: 700; }
.mind-negative, .data-table td.mind-negative, .data-table td.mind-negative strong { color: #991B1B !important; font-weight: 700; }

/* ── 14. SETTINGS TABS ──────────────────────────────────────── */

.settings-tabs {
  display: flex;
  gap: 0;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 0.625rem;
  padding: 0.1875rem;
  flex-wrap: wrap;
  box-shadow: var(--theme-card-shadow);
}

.settings-tab {
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: var(--density-text-xs);
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.settings-tab:hover  { background: #F1F5F9; color: var(--color-text); }
.settings-tab.active { background: var(--color-primary); color: #fff; }

#settings-content {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 0.75rem;
  box-shadow: var(--theme-card-shadow);
  padding: 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

#settings-content .table-container {
  border-radius: 0.5rem;
  box-shadow: none;
}

.st-filter-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}

.st-filter-row input,
.st-filter-row select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--density-text-xs);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.st-filter-row input:focus,
.st-filter-row select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-subtle);
}

.settings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}

.settings-search-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
  min-width: 0;
}

.settings-search-group .search-box {
  padding: 0.25rem 0.5rem;
  min-width: 10rem;
  max-width: 18rem;
  flex: 1;
}

.settings-search-group .search-box input {
  font-size: var(--density-text-xs);
}

.settings-count {
  font-size: var(--density-text-xs);
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* ── Products category filter tabs ─────────────────────────── */
.prod-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.prod-cat-tab {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--density-text-xs);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.prod-cat-tab:hover { background: #F1F5F9; color: var(--color-text); }
.prod-cat-tab.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Products badges ────────────────────────────────────────── */
.prod-cat-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #EFF6FF;
  color: #3B82F6;
  font-size: var(--density-text-xs);
  font-weight: 500;
}
.prod-sku-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: #F3E8FF;
  color: #7C3AED;
  font-size: var(--density-text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 1.8rem;
  text-align: center;
}

.sku-hover-trigger {
  position: relative;
}
.sku-popover {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 200;
  background: var(--theme-card-bg, #1e2433);
  border: 1px solid var(--color-border, #2d3548);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  white-space: nowrap;
}
.sku-hover-trigger:hover .sku-popover {
  display: block;
}
.sku-popover-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 3px 0;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--color-border, #2d3548);
}
.sku-popover-row:last-child {
  border-bottom: none;
}
.sku-code {
  text-align: right;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: var(--color-text, #e2e8f0);
}
.sku-kg {
  text-align: right;
  color: var(--color-text-secondary, #94a3b8);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
}
.sku-primary {
  color: #f59e0b;
  font-size: 0.65rem;
}

.actions-cell {
  white-space: nowrap;
  text-align: right;
}

.actions-cell .btn-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.25rem;
}

.actions-cell .btn-icon svg {
  width: 13px;
  height: 13px;
}

.settings-form-card {
  max-width: 52rem;
}

.settings-form-card h3 {
  font-size: var(--density-text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}

.settings-form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--theme-card-border);
}

.settings-loading,
.settings-error {
  padding: 1rem;
  text-align: center;
  font-size: var(--density-text-sm);
  color: var(--color-text-muted);
}

.settings-error { color: var(--color-danger); }

.empty-row td,
td.empty-row {
  padding: 1rem 0.75rem !important;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--density-text-sm);
}

/* ── 15. SEARCHABLE SELECT ──────────────────────────────────── */

.searchable-select { position: relative; }

.ss-display {
  width: 100%;
  padding: var(--density-py) var(--density-px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--density-text-base);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.ss-display:hover      { border-color: #CBD5E1; }
.ss-display.open       { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-subtle); }
.ss-display .ss-placeholder { color: var(--color-text-faint); }
.ss-display .ss-arrow  { color: var(--color-text-faint); flex-shrink: 0; }

.ss-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 14rem;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.ss-dropdown.open { display: flex; }

.ss-search {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--color-border);
}

.ss-search input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.3125rem 0.5rem;
  font-size: var(--density-text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface-raised);
  outline: none;
}

.ss-search input:focus { border-color: var(--color-primary); }

.ss-options { overflow-y: auto; flex: 1; }

.ss-option {
  padding: 0.4375rem 0.75rem;
  font-size: var(--density-text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.1s;
}

.ss-option:hover                 { background: var(--theme-table-hover); }
.ss-option.selected              { background: var(--color-primary-subtle); color: #1D5FA3; font-weight: 500; }
.ss-option.ss-no-match           { color: var(--color-text-faint); cursor: default; }
.ss-option.ss-no-match:hover     { background: transparent; }

/* ── 16. PAGINATION ─────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.625rem var(--density-px);
  background: var(--theme-card-bg);
  border-top: 1px solid var(--color-border);
}

.pagination button {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--density-text-xs);
  font-family: inherit;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.pagination button:hover:not(:disabled) { background: #F1F5F9; border-color: var(--color-border); }
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination span { color: var(--color-text-faint); padding: 0 0.25rem; font-size: var(--density-text-xs); }

/* ── 17. MODAL ──────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  margin: auto;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-card h3 {
  font-size: var(--density-text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.625rem;
}

.modal-card p {
  font-size: var(--density-text-sm);
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--density-gap-sm);
}

/* ── 18. TOAST ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  background: #1E293B;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: var(--density-text-sm);
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  max-width: 24rem;
  animation: toastIn 0.2s ease;
}

.toast.toast-success { background: var(--color-success); }
.toast.toast-error   { background: var(--color-danger); }
.toast.toast-warning { background: var(--color-warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 19. EMPTY STATE ────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--color-text-faint);
}

.empty-state svg { opacity: 0.35; }
.empty-state p   { font-size: var(--density-text-sm); margin: 0; }

/* ── 20. PREVIEW ────────────────────────────────────────────── */

.preview-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: var(--theme-card-shadow);
  padding: 2rem;
  overflow: auto;
}

/* ── 21. MIND FORM SECTIONS ─────────────────────────────────── */

.mind-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--density-text-sm);
  font-family: inherit;
  border: none;
  width: 100%;
  text-align: left;
  user-select: none;
  transition: opacity 0.15s;
}

.mind-section-header { background: var(--arx-blue-soft); color: var(--arx-blue-ink); }

.mind-section-header:hover { opacity: 0.85; }
.mind-section-header.green { background: var(--arx-blue-soft); color: var(--arx-blue-ink); }
.mind-section-header.orange { background: var(--arx-blue-soft); color: var(--arx-blue-ink); }
.mind-section-header.purple { background: var(--arx-blue-soft); color: var(--arx-blue-ink); }
.mind-section-header.gray   { background: #F1F5F9; color: #334155; }
.mind-section-header.blue { background: var(--arx-blue-soft); color: var(--arx-blue-ink); }

.mind-section-body {
  padding: var(--density-card-padding);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
  background: var(--color-surface);
}

.exporter-preview {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: 0.875rem 1rem;
}

.exporter-preview-title {
  font-weight: 600;
  font-size: var(--density-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.exporter-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.1875rem 0;
  font-size: var(--density-text-xs);
  color: var(--color-text-muted);
}

.exporter-preview-row strong { color: var(--color-text); font-weight: 600; }

/* ── mind-exporter preview panel ────────────────────────────── */
.mind-exporter-preview {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border, #E2E8F0);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
.mind-exporter-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted, #64748B);
  margin-bottom: 6px;
}
.mind-exporter-grid { display: flex; flex-direction: column; gap: 0; }
.mind-exporter-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 4px 8px;
  padding: 3px 0;
  font-size: var(--text-xs);
  align-items: baseline;
}
.mind-exporter-calc {
  color: #94A3B8;
  font-size: var(--text-xs);
  font-family: var(--font-mono, monospace);
  word-break: break-all;
}
.mind-exporter-val { font-weight: 500; white-space: nowrap; }
/* Context rows (Total Purchase / Total Sales) — slightly muted */
.mind-exporter-context .mind-exporter-val { color: #475569; }
.mind-exporter-context > span:first-child { color: #64748B; }
/* Thin divider row between context and markup rows */
.mind-exporter-divider {
  border-top: 1px solid var(--color-border);
  margin: 4px 0 2px;
  padding: 0;
  height: 0;
}
/* Total row */
.mind-exporter-total > span:first-child { font-weight: 600; color: var(--color-text, #1E293B); }
.mind-exporter-total .mind-exporter-val  { font-weight: 700; font-size: var(--text-xs); }
/* Pct row */
.mind-exporter-pct { opacity: .8; }
/* CIF price summary rows */
.mind-exporter-cif > span:first-child { color: #334155; font-weight: 500; }
.mind-exporter-cif .mind-exporter-val  { color: #1E293B; font-weight: 600; }

/* ── Sales Allocation table ──────────────────────────────────── */

/* Container panel — same visual language as .mind-exporter-preview */
.mind-section-body > .table-container {
  border: 1px solid var(--color-border, #E2E8F0);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface, #fff);
}

.mind-clients-table {
  font-size: var(--text-xs);
  min-width: 780px;
}

.mind-section-body > .mind-allocation-table-scroll {
  overflow-x: auto;
}

/* Header — compact uppercase, matches exporter title style */
.mind-clients-table thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted, #64748B);
  padding: 6px 8px;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border, #E2E8F0);
  white-space: nowrap;
}

/* Body rows — no alternating stripes, clean separation */
.mind-clients-table tbody tr {
  border-bottom: 1px solid #F1F5F9;
  background: var(--color-surface, #fff);
  transition: background 0.1s;
}
.mind-clients-table tbody tr:last-child { border-bottom: none; }
.mind-clients-table tbody tr:hover { background: var(--color-surface-raised) !important; }

.mind-clients-table tbody td {
  padding: 3px 4px;
  vertical-align: middle;
}
.mind-clients-table tbody td:first-child { padding-left: 8px; min-width: 180px; }
.mc-relevance {
  margin: 4px 6px 0;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  line-height: 1.4;
  white-space: normal;
}
.mind-clients-table tbody td:last-child  { padding-right: 6px; }

/* Semantic controls keep numeric alignment stable when columns are inserted. */
.mind-clients-table :is(.mc-qty,.mc-price,.mc-payment,.mc-freight) { text-align: right; }

/* Inputs and selects inside allocation rows */
.mind-clients-table input,
.mind-clients-table select {
  width: 100%;
  min-width: 0;
  font-size: var(--text-xs);
  padding: 3px 5px;
  height: 26px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface, #fff);
  color: var(--color-text, #1E293B);
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mind-clients-table input:focus,
.mind-clients-table select:focus {
  outline: none;
  border-color: var(--color-primary, #2563EB);
  box-shadow: 0 0 0 2px var(--color-primary-subtle, #DBEAFE);
}

/* Actions cell (evidence + remove) */
.mc-actions-cell {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.mc-ev-btn {
  font-size: 10px;
  padding: 1px 4px;
  line-height: 1.4;
}
.mc-remove-btn {
  color: var(--color-danger, #DC2626) !important;
  padding: 2px;
}

/* Per-Client Breakdown — editable qty/price inputs */
.pcb-input {
  width: 92px;
  min-width: 0;
  font-size: var(--text-xs);
  padding: 3px 5px;
  height: 26px;
  text-align: right;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface, #fff);
  color: var(--color-text, #1E293B);
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pcb-input:focus {
  outline: none;
  border-color: var(--color-primary, #2563EB);
  box-shadow: 0 0 0 2px var(--color-primary-subtle, #DBEAFE);
}
.pcb-recalc-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2, 8px);
  margin-top: var(--space-2, 8px);
}
.pcb-recalc-hint {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
/* Row tone by displayed Result %: <4% loss-risk red, 4–6% warning amber, ≥6% unmarked.
   Applied on the cells so the whole row keeps its tone over striping and hover.
   :where() keeps these below arx-selection.css, so a selected toned row shows
   the shared blue selection tint and edge (the tone returns on deselect). */
.data-table tbody tr:where(.pcb-tone-low) > td { background: var(--arx-danger-soft, #fdecec); box-shadow: inset 0 -1px 0 var(--arx-danger-border, #fecaca); }
.data-table tbody tr:where(.pcb-tone-mid) > td { background: var(--arx-warning-soft, #fef3c7); box-shadow: inset 0 -1px 0 var(--arx-warning-border, #fde68a); }
.data-table tbody tr:where(.pcb-tone-low) > td:first-child { box-shadow: inset 3px 0 0 var(--arx-danger, #c92a2a), inset 0 -1px 0 var(--arx-danger-border, #fecaca); }
.data-table tbody tr:where(.pcb-tone-mid) > td:first-child { box-shadow: inset 3px 0 0 var(--arx-warning, #a85700), inset 0 -1px 0 var(--arx-warning-border, #fde68a); }
.pcb-suggest-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pcb-suggest-cell .ev-badge { margin-left: 4px; }
.pcb-suggested { display: inline-block; min-width: 68px; text-align: right; }
.pcb-no-suggestion .pcb-suggested { color: var(--color-text-muted); }
/* Suggested-NET apply control, shared by Sales Allocation and Per-Client Breakdown
   (MIND_USE_SUGGESTION_BTN): arrow + the Focus Desk spec's "Use" label, one compact button. */
.mc-use-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  height: 24px;
  padding: 0 6px 0 5px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .2px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface, #fff);
  color: var(--color-primary, #2563EB);
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
}
.mc-use-suggestion .mc-use-arrow { font-size: 13px; line-height: 1; }
.mc-use-suggestion:hover:not(:disabled) { background: var(--color-primary-subtle, #DBEAFE); border-color: var(--color-primary, #2563EB); }
.mc-use-suggestion:focus-visible { outline: 2px solid var(--color-primary, #2563EB); outline-offset: 1px; }
.mc-use-suggestion:disabled { color: var(--color-text-muted); cursor: not-allowed; opacity: .6; }
.pcb-legend { font-size: var(--text-xs); color: var(--color-text-secondary); margin: var(--space-1, 4px) 0 0; }
.pcb-actions-cell { text-align: center; white-space: nowrap; }
.pcb-actions-cell .mc-remove-btn { display: inline-flex; align-items: center; justify-content: center; }
#mind-form.the-mind .pcb-input { width: 76px; height: 22px; font-size: 10px; }
#mind-form.the-mind .mc-use-suggestion { height: 20px; padding: 0 4px 0 3px; font-size: 10px; gap: 2px; }
#mind-form.the-mind .mc-use-suggestion .mc-use-arrow { font-size: 11px; }
#mind-form.the-mind .pcb-suggested { min-width: 56px; }

/* ── 22. UTILITIES ──────────────────────────────────────────── */

.text-right   { text-align: right !important; }
.text-center  { text-align: center !important; }
.text-muted   { color: var(--color-text-muted); }
.text-faint   { color: var(--color-text-faint); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.font-mono    { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }

/* ── 23. RESPONSIVE ─────────────────────────────────────────── */

@media (max-width: 1024px) {
  .form-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 40;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .form-grid.cols-2,
  .form-grid.cols-3,
  .form-grid.cols-4 { grid-template-columns: 1fr; }
  .dashboard-filters { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; }
}

/* ── MIND Calculator Form — Compact Override ──────────────── */
/* Scoped to the calculator form container so settings tables  */
/* and other sections keep their normal density.               */
#mind-form-container {
  --density-card-padding: 0.625rem;
  --density-gap: 0.5rem;
  --density-py: 0.3125rem;
  --density-px: 0.625rem;
  --density-text-xs: 0.6875rem;
  --density-text-sm: 0.75rem;
}

#mind-form-container .form-group { gap: 0.1875rem; }

#mind-form-container .mind-section-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

#mind-form-container .mind-section-body {
  padding: 0.625rem;
  gap: 0.375rem;
  display: flex;
  flex-direction: column;
}

#mind-form-container .form-grid { gap: 0.5rem; margin-bottom: 0; }

#mind-form-container .form-section { margin-bottom: 0.5rem; }

/* Auto-fill hint label */
.form-group label:has(.mind-autofill-hint) {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
}
.mind-autofill-hint {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--arx-blue-ink);
  margin-left: 0.25rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  order: 2;
}
.form-group label .ev-badge { flex-shrink: 0; order: 1; }

/* Persistent auto-fill highlight — stays until user manually edits */
.mind-autofilled {
  background: var(--color-autofill-bg) !important;
  border-color: var(--color-autofill-border) !important;
  box-shadow: inset 0 0 0 1px var(--arx-blue-border);
}

/* Searchable select auto-fill */
.mind-autofilled-ss .ss-input {
  background: var(--color-autofill-bg) !important;
  border-color: var(--color-autofill-border) !important;
  box-shadow: inset 0 0 0 1px var(--arx-blue-border);
}

/* Transit time readonly — gray by default, blue when auto-filled */
.m-transit-readonly {
  background: #f0f1f3;
}
.m-transit-readonly.mind-autofilled {
  background: var(--color-autofill-bg) !important;
  border-color: var(--color-autofill-border) !important;
}

/* Manual input field — neutral (legacy class name) (regular inputs) */
.mind-input-green {
  background: var(--color-manual-bg) !important;
  border-color: var(--color-manual-border) !important;
  box-shadow: none;
}

/* Manual input field — neutral (legacy class name) (only for PRODUCT searchable select) */
.mind-manual-input-ss .ss-input {
  background: var(--color-manual-bg) !important;
  border-color: var(--color-manual-border) !important;
  box-shadow: none;
}
.mind-manual-input-hint {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--arx-text-secondary);
  margin-left: 0.25rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ── Activity Timeline ───────────────────────────────────── */
.act-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.act-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: var(--density-text-xs);
  font-weight: 500;
}
.act-timeline {
  position: relative;
  padding-left: 1.5rem;
}
.act-timeline::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--color-border, #e2e8f0);
}
.act-item {
  position: relative;
  padding-bottom: 1.25rem;
}
.act-item-last { padding-bottom: 0; }
.act-dot {
  position: absolute;
  left: -1.15rem;
  top: 0.35rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  border: 2px solid var(--color-surface, #fff);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.act-body {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.act-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.act-badge {
  display: inline-block;
  border-radius: 0.25rem;
  padding: 0.1rem 0.45rem;
  font-size: var(--density-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.act-entity {
  font-size: var(--density-text-sm);
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  color: var(--color-primary, var(--arx-blue));
}
.act-time {
  margin-left: auto;
  font-size: var(--density-text-xs);
  color: var(--color-text-muted, #64748b);
  font-family: var(--font-mono, monospace);
}
.act-desc {
  font-size: var(--density-text-sm);
  color: var(--color-text-muted, #64748b);
}

/* ── Evidence Badges ───────────────────────────────────────── */
.ev-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  border-radius: 10px;
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  cursor: pointer;
  vertical-align: middle;
  user-select: none;
  white-space: nowrap;
  transition: background .15s;
}
.ev-badge:hover { background: #DBEAFE; }

/* Evidence popover */
.ev-popover {
  position: absolute;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--color-border, #E2E8F0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  min-width: 360px;
  max-width: 560px;
  font-size: 12px;
}
.ev-popover-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--color-border, #F1F5F9);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: 11px;
  color: #334155;
}
.ev-popover-avg {
  margin-left: 4px;
  color: #1D4ED8;
  font-weight: 500;
}
.ev-popover-body {
  padding: 8px;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
}
.ev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.ev-table th {
  background: var(--color-surface-sunken);
  color: var(--color-text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 4px 8px;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}
.ev-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-surface-sunken);
  white-space: nowrap;
  color: #1E293B;
}
.ev-table tr:last-child td { border-bottom: none; }
.ev-table tr:nth-child(even) td { background: #FAFAFA; }

/* ── Formula Trace ────────────────────────────────────────── */
.formula-trace-section {
  margin-top: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.formula-trace-section > summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 600;
  color: #334155;
  background: var(--color-surface-raised);
  list-style: none;
  user-select: none;
}
.formula-trace-section > summary::-webkit-details-marker { display: none; }
.formula-trace-section[open] > summary { border-bottom: 1px solid var(--color-border); }
.formula-group {
  border-bottom: 1px solid var(--color-surface-sunken);
}
.formula-group:last-child { border-bottom: none; }
.formula-group-header {
  padding: 6px 14px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #94A3B8;
  background: #FAFAFA;
}
.formula-row {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 0 8px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--color-surface-raised);
  align-items: start;
  font-size: var(--text-xs);
}
.formula-row:last-child { border-bottom: none; }
.formula-label {
  font-weight: 600;
  color: #334155;
  word-break: break-word;
}
.formula-expr {
  color: var(--color-text-secondary);
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  word-break: break-word;
}
.formula-result {
  font-weight: 700;
  color: #1D4ED8;
  text-align: right;
  white-space: nowrap;
}
.formula-note {
  grid-column: 2 / 4;
  font-size: var(--text-xs);
  color: #94A3B8;
  margin-top: 1px;
}

/* ── P&L Summary ─────────────────────────────────────────────── */
.pnl-panel {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: var(--space-4, 16px);
}
.pnl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
}
.pnl-header-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #334155;
}
.pnl-header-id {
  font-size: var(--text-xs);
  font-weight: 600;
  color: #94A3B8;
  letter-spacing: .04em;
}
.pnl-header-mind-no {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary, #2563EB);
  background: var(--color-primary-subtle, #DBEAFE);
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.pnl-group-header {
  padding: 5px 14px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #94A3B8;
  background: #FAFAFA;
  border-bottom: 1px solid var(--color-surface-sunken);
}
.pnl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 12px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--color-surface-raised);
  align-items: baseline;
  font-size: var(--text-xs);
}
.pnl-row:last-child { border-bottom: none; }
.pnl-row-label {
  color: #475569;
  font-size: var(--text-xs);
}
.pnl-row-sub .pnl-row-label {
  color: #94A3B8;
  padding-left: 14px;
  font-size: var(--text-xs);
}
.pnl-row-sub .pnl-row-label::before {
  content: "▸ ";
  color: #CBD5E1;
}
.pnl-row-val {
  font-weight: 600;
  font-size: var(--text-xs);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pnl-row-total .pnl-row-label {
  font-weight: 700;
  color: #1E293B;
  font-size: var(--text-xs);
}
.pnl-row-total .pnl-row-val {
  font-weight: 700;
  font-size: var(--text-xs);
}
.pnl-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}
/* Result row — colored background */
.pnl-result-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0 16px;
  padding: 9px 14px;
  align-items: baseline;
  border-top: 2px solid transparent;
}
.pnl-result-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.pnl-result-val {
  font-size: var(--text-sm);
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pnl-result-pct {
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  opacity: .85;
}
/* Profit split — two summary lines directly under the result row */
.pnl-split {
  border-top: 1px solid var(--color-border);
  background: #FAFAFA;
}
.pnl-split-row { grid-template-columns: 1fr auto; }
.pnl-split-row .pnl-row-label { font-weight: 600; color: #1E293B; }
.pnl-split-row .pnl-row-val { font-weight: 700; }
.pnl-split-sep { color: #CBD5E1; margin: 0 6px; font-weight: 400; }
.pnl-split-note {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  line-height: 1.3;
}
.pnl-split-info {
  cursor: pointer;
  margin-left: 5px;
  color: var(--color-border-strong);
  font-weight: 400;
  user-select: none;
}
.pnl-split-info:hover { color: #475569; }
.pnl-split-evidence {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border-left: 2px solid var(--color-border);
  margin: 2px 14px 6px 28px;
  padding: 3px 8px;
  line-height: 1.6;
}
/* "Divert X p.p." — the exporter % becomes a button; the diverted note sits under the line */
.pnl-split-divert-btn {
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px dashed currentColor;
  padding: 0 1px;
  margin: 0;
  cursor: pointer;
  line-height: inherit;
  font-variant-numeric: tabular-nums;
}
.pnl-split-divert-btn:hover,
.pnl-split-divert-btn[aria-expanded="true"] { background: var(--arx-blue-soft); border-bottom-style: solid; }
.pnl-split-divert-btn:focus-visible { outline: 2px solid var(--arx-blue); outline-offset: 2px; border-radius: 2px; }
.pnl-split-diverted { color: var(--color-text-secondary); }
.pnl-split-undo {
  font: inherit;
  color: var(--arx-blue-ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pnl-split-undo:hover { color: var(--arx-blue-hover); }
.pnl-split-undo:focus-visible { outline: 2px solid var(--arx-blue); outline-offset: 1px; border-radius: 2px; }
.mind-divert-popover { min-width: 0; width: 620px; max-width: calc(100vw - 32px); }
.mind-divert-popover .ev-popover-body { max-height: min(70vh, 520px); overflow-x: auto; }
.mind-divert-close {
  margin-left: auto;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--color-text-secondary);
  padding: 0 2px;
}
.mind-divert-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: var(--text-xs);
  font-weight: 600;
  color: #334155;
  padding: 2px 4px 0;
}
.mind-divert-field input { width: 84px; padding: 3px 6px; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.mind-divert-unit { font-weight: 400; color: var(--color-text-secondary); }
.mind-divert-hint { margin: 6px 4px 8px; font-size: var(--text-xs); color: var(--color-text-secondary); line-height: 1.4; }
.mind-divert-preview { min-height: 40px; }
.mind-divert-table { table-layout: fixed; }
.mind-divert-table th[scope="row"] { text-align: left; font-weight: 500; color: var(--color-text-secondary); width: 32%; }
.mind-divert-table td { text-align: right; white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; padding: 3px 4px; vertical-align: top; }
.mind-divert-table thead th { text-align: right; }
.mind-divert-table thead th:first-child { text-align: left; }
.mind-divert-arrow { color: var(--color-border-strong); padding: 3px 2px !important; width: 14px; text-align: center !important; }
.mind-divert-gain td { border-top: 1px solid var(--color-border); padding-top: 5px !important; }
.mind-divert-muted { font-weight: 400; color: var(--color-text-secondary); font-size: var(--text-xs); }
.mind-divert-note { margin: 6px 4px 0; font-size: var(--text-xs); color: var(--color-text-secondary); }
.mind-divert-actions { display: flex; align-items: center; gap: 8px; margin: 10px 4px 2px; }
.mind-divert-status { margin-right: auto; font-size: var(--text-xs); color: var(--color-text-secondary); }
/* Exporter panel uses same pnl-panel but with a tinted header */
.pnl-panel-exporter .pnl-header { background: var(--arx-blue-soft); border-bottom-color: var(--arx-blue-border); }
.pnl-panel-exporter .pnl-header-title { color: var(--arx-blue-ink); }

/* ══════════════════════════════════════════════════════════════
   Offers Module
   ══════════════════════════════════════════════════════════════ */

/* ── Nav badge (pending count) ── */
.nav-badge {
  background: #DC2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: auto;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

/* ── Offer Letter status badges ── */
.ol-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ol-badge-pending     { background: #FEF3C7; color: #92400E; }
.ol-badge-pdf         { background: #EFF6FF; color: #1D4ED8; }
.ol-badge-sent        { background: #F0F9FF; color: #0369A1; }
.ol-badge-confirmed   { background: #ECFDF5; color: #065F46; }
.ol-badge-adjustment  { background: #FFF7ED; color: #C2410C; }
.ol-badge-updated     { background: #F5F3FF; color: #6D28D9; }
.ol-badge-rejected    { background: var(--color-danger-bg); color: var(--color-danger); }
.ol-badge-rev         { background: #F1F5F9; color: #334155; border: 1px solid #CBD5E1; padding: 1px 6px; }

/* ── Offer Letter revise modal + history timeline (Phase 2) ── */
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.rv-hint { font-size: 11px; color: var(--color-text-muted); margin-top: 3px; font-weight: 400; }
.rv-sched-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 6px; }
.rv-sched-table th { text-align: left; padding: 3px 8px; background: #F1F5F9; border: 1px solid #E2E8F0; font-size: 11px; font-weight: 600; }
.rv-sched-table td { padding: 2px 6px; border: 1px solid #E2E8F0; }
.rv-sched-table td input { border: none; background: transparent; font-size: 13px; width: 100%; }
.rv-sched-table td:last-child { width: 36px; text-align: center; }
.rv-options { display: flex; gap: 20px; margin: 4px 0 10px; }
.rv-check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.rv-check input { width: auto; margin: 0; }
.ol-history { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.ol-history-empty, .ol-history-nochange, .ol-history-nopdf { font-size: 12px; color: var(--color-text-muted); }
.ol-history-item { border: 1px solid #E2E8F0; border-left: 3px solid var(--arx-blue); border-radius: 6px; padding: 8px 12px; background: var(--color-surface, #fff); }
.ol-history-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ol-history-ol { font-size: 12px; font-weight: 600; color: var(--arx-blue-ink); font-variant-numeric: tabular-nums; }
.ol-history-meta { font-size: 11px; color: var(--color-text-muted); margin-left: auto; white-space: nowrap; }
.ol-history-reason { font-size: 13px; margin: 6px 0 2px; }
.ol-history-changes { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.ol-history-field { color: var(--color-text-secondary); }
.ol-history-old { color: #9CA3AF; text-decoration: line-through; }
.ol-history-arrow { color: #9CA3AF; margin: 0 4px; }
.ol-history-new { font-weight: 600; color: #065F46; }
.ol-history-links { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 12px; }
.ol-history-sent { color: #0369A1; }

/* ── Offer detail header ── */
.offer-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}
.offer-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}
.offer-detail-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.offer-detail-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

/* ── Offer letters table ── */
.offer-letters-table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  overflow-x: auto;
}
/* 9 cols: OL# | Customer | Qty | Price | Packaging | Payment | Expires | Status | Actions */
.ol-table-header,
.ol-row-main {
  display: grid;
  grid-template-columns: 110px minmax(160px,220px) 60px 90px 90px 80px 90px 110px 1fr;
  gap: 0;
  min-width: 820px;
  align-items: center;
}
.ol-table-header {
  padding: 8px 16px;
  background: var(--color-surface-sunken);
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ol-row {
  border-bottom: 1px dotted #94a3b8;
  transition: background .15s;
}
.ol-row:last-child { border-bottom: none; }
.ol-row:hover { background: var(--color-surface-sunken); }
.ol-row-rejected { opacity: .65; }
.ol-row-main {
  padding: var(--density-py) 16px;
}
.ol-col-number { font-size: 11px; font-weight: 600; color: var(--arx-blue-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ol-col-client strong { font-size: 13px; }
.ol-client-email { font-size: 11px; color: var(--color-text-muted); display: flex; flex-direction: column; gap: 1px; }
.ol-col-qty, .ol-col-price { font-variant-numeric: tabular-nums; font-size: 13px; }
.ol-col-product { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ol-col-pkg, .ol-col-pt, .ol-col-expiry { font-size: 12px; color: var(--color-text-secondary); }
.ol-contact-link { color: inherit; text-decoration: none; }
.ol-contact-link:hover { text-decoration: underline; }
.ol-col-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Response timeline ── */
.ol-response-timeline {
  padding: 8px 16px 8px 136px;
  background: #FAFBFC;
  border-top: 1px dashed var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ol-response-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  flex-wrap: wrap;
}
.ol-response-type {
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 11px;
}
.ol-response-type.accepted, .ol-response-type.purchase_order { background:#ECFDF5; color:#065F46; }
.ol-response-type.rejected   { background:#FEF2F2; color:#991B1B; }
.ol-response-type.adjustment_request { background:#FFF7ED; color:#C2410C; }
.ol-response-date  { color: var(--color-text-muted); font-size: 11px; }
.ol-response-msg   { color: var(--color-text-secondary); }
.ol-response-proposed { font-style: italic; color: #7C3AED; }
.ol-response-decision { font-weight: 700; }
.ol-response-decision.approved { color: #065F46; }
.ol-response-decision.rejected  { color: #991B1B; }

/* ── Rejection reason bar ── */
.ol-rejection-reason {
  padding: 6px 16px 6px 136px;
  font-size: 12px;
  color: #991B1B;
  background: #FEF2F2;
  border-top: 1px solid #FCA5A5;
}

/* ── Adjustment summary ── */
.ol-adj-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  background: var(--color-surface-sunken);
  padding: 12px;
  border-radius: var(--radius-base);
  margin-bottom: 12px;
}
.ol-adj-summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Offers management info: goal bar, expiry chip, detail strip ── */
.ol-goal { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
.ol-goal-track { display: flex; height: 8px; background: var(--color-surface-sunken); border-radius: var(--radius-full); overflow: hidden; }
.ol-goal-fill { height: 100%; }
.ol-goal-accepted { background: var(--color-primary); }
.ol-goal-pending  { background: var(--color-primary); opacity: .3; }
.ol-goal-amber .ol-goal-accepted { background: var(--color-warning); }
.ol-goal-green .ol-goal-accepted { background: var(--color-success); }
.ol-goal-label { font-size: 11px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ol-goal-amber .ol-goal-label { color: var(--color-warning); }
.ol-goal-green .ol-goal-label { color: var(--color-success); font-weight: 600; }
.ol-goal-lg .ol-goal-track { height: 14px; }
.ol-goal-lg .ol-goal-label { font-size: 13px; }
.ol-goal-nogoal { font-size: 11px; color: var(--color-text-muted); }
.ol-exp-chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; background: var(--color-surface-sunken); color: var(--color-text-secondary); white-space: nowrap; }
.ol-exp-soon    { background: var(--color-warning-bg); color: #92400E; }
.ol-exp-expired { background: var(--color-danger-bg); color: #991B1B; }
.ol-dates { font-size: 11px; line-height: 1.6; white-space: nowrap; }
.ol-dates span:first-child { color: var(--color-text-muted); }
.ol-adj-mark { font-size: 9px; font-weight: 700; color: #C2410C; background: #FFF7ED; padding: 0 4px; border-radius: 6px; vertical-align: middle; }
.offer-mgmt-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}
.offer-mgmt-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.offer-mgmt-progress { grid-column: 1 / -1; }
.offer-mgmt-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
.offer-mgmt-value { font-size: 18px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.offer-mgmt-sub { font-size: 11px; color: var(--color-text-secondary); }
.offer-mgmt-accepted { color: var(--color-success); }
.offer-mgmt-rejected { color: var(--color-danger); }
.offer-mgmt-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.ol-history-effective { font-size: 12px; color: var(--color-text-secondary); margin-top: 4px; }
.ol-adj-summary span { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ol-adj-summary strong { font-size: 14px; font-variant-numeric: tabular-nums; }

/* ── Modal large ── */
.modal-card-lg {
  max-width: 600px;
  width: 90vw;
}

/* ── Modal extra-large (FinOps detail, any wide two-panel layout) ── */
.modal-card-xl {
  max-width: 1200px;
  width: 95vw;
}

/* ── FinOps list table: keep long labels on one line ── */
.finops-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finops-col-product  { max-width: 180px; }
.finops-col-supplier { max-width: 180px; }
.finops-col-customer { max-width: 200px; }

/* ── FinOps typeahead (customer / vendor search dropdown) ── */
.finops-typeahead {
  position: relative;
  max-height: 240px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-top: 2px;
  font-size: 13px;
}
.finops-typeahead:empty { display: none; }
.finops-typeahead-row {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #F3F4F6;
}
.finops-typeahead-row:hover  { background: #F9FAFB; }
.finops-typeahead-row:last-child { border-bottom: none; }

/* ── Form note ── */
.form-note {
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 8px 12px;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-base);
  margin-bottom: var(--space-3);
}

/* ── Dispatch to Offers button ── */
.btn-dispatch {
  background: #1E40AF;
  color: white;
  border-color: #1E40AF;
}
.btn-dispatch:hover { background: #1D3A9E; border-color: #1D3A9E; }

/* ── AGX summary panel ── */
.agx-summary-panel {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-base);
  padding: 16px 20px;
  margin-top: var(--space-4);
}
.agx-summary-panel h4 { color: #065F46; font-size: 14px; margin-bottom: 8px; }
.agx-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.agx-summary-item { display: flex; flex-direction: column; gap: 2px; }
.agx-summary-label { font-size: 10px; color: #6B7280; text-transform: uppercase; letter-spacing: .05em; }
.agx-summary-val   { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════
   PDF Preview Viewer (ported from ARX Sense AI)
   ══════════════════════════════════════════════════════════════ */

.pdf-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.pdf-preview-modal {
  display: flex;
  flex-direction: column;
  width: 88vw;
  height: 90vh;
  background: var(--color-surface);
  border-radius: var(--radius-base, 10px);
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
  overflow: hidden;
}

.pdf-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.pdf-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

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

.pdf-preview-body {
  flex: 1;
  overflow: hidden;
  background: #E5E7EB;
  display: flex;
  align-items: stretch;
}

.pdf-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Eye icon button styling */
.ol-preview-btn {
  color: var(--arx-blue-ink);
  border-color: #BFDBFE;
  background: #EFF6FF;
}
.ol-preview-btn:hover {
  background: #DBEAFE;
  border-color: #93C5FD;
}

/* ── Document Layouts configurator ─────────────────────────── */

.dl-wrap {
  display: flex;
  gap: 0;
  height: calc(100vh - 160px);
  min-height: 500px;
}

.dl-controls {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px 18px;
  border-right: 1px solid var(--color-border, #E5E7EB);
  background: #FAFAFA;
}

.dl-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #E5E7EB;
}

.dl-group {
  margin-bottom: 20px;
}

.dl-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6B7280;
  margin-bottom: 8px;
}

.dl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.dl-row label:first-child {
  width: 110px;
  flex-shrink: 0;
  color: #374151;
}

.dl-row input[type="range"] {
  flex: 1;
  accent-color: var(--arx-blue-ink);
  height: 4px;
  cursor: pointer;
}

.dl-row span {
  width: 42px;
  text-align: right;
  font-size: 11px;
  color: #6B7280;
  font-variant-numeric: tabular-nums;
}

.dl-color-row input[type="color"] {
  width: 32px;
  height: 24px;
  border: 1px solid #D1D5DB;
  border-radius: 4px;
  cursor: pointer;
  padding: 1px;
  background: none;
}

.dl-color-row span {
  font-size: 11px;
  color: #6B7280;
  font-family: monospace;
  width: auto;
}

.dl-toggle-row {
  justify-content: space-between;
}

.dl-toggle-row label:first-child {
  width: auto;
  flex: 1;
}

/* Toggle switch */
.dl-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.dl-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.dl-switch-track {
  display: block;
  width: 34px;
  height: 18px;
  background: #D1D5DB;
  border-radius: 9px;
  transition: background 0.2s;
  position: relative;
}

.dl-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.dl-switch input:checked + .dl-switch-track {
  background: var(--arx-blue-ink);
}

.dl-switch input:checked + .dl-switch-track::after {
  transform: translateX(16px);
}

.dl-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #E5E7EB;
  flex-wrap: wrap;
}

/* Preview pane */
.dl-preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #E5E7EB;
}

.dl-preview-header {
  padding: 10px 16px;
  font-size: 11px;
  color: #6B7280;
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
  flex-shrink: 0;
}

.dl-preview-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

.dl-no-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9CA3AF;
  font-size: 13px;
  padding: 40px;
  text-align: center;
}


/* ════════════════════════════════════════════════════════════
   AUDIT — Data Quality Dashboard
   ════════════════════════════════════════════════════════════ */

/* ── Tab bar ──────────────────────────────────────────────── */
.audit-main-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.audit-main-tabs::-webkit-scrollbar { display: none; }
.audit-main-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.audit-main-tab:hover { color: var(--color-text); }
.audit-main-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ── Overall page header ──────────────────────────────────── */
.audit-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.audit-page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.audit-page-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 3px;
}
.audit-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Source section header ────────────────────────────────── */
.audit-source-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.audit-source-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.audit-source-line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.audit-source-ts {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Source provenance strip (per-tab) ────────────────────── */
.audit-source-strip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  margin-bottom: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.audit-source-strip > svg {
  align-self: center;
  flex-shrink: 0;
  opacity: 0.55;
}
.audit-source-strip-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.audit-source-path {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-secondary);
  word-break: break-word;
}
.audit-source-checks {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.audit-check-chip {
  font-size: 10px;
  line-height: 1.5;
  padding: 0 6px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.audit-source-strip-ts {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Data Provenance card (Overall tab) ───────────────────── */
.audit-provenance {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}
.audit-provenance .audit-source-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.audit-provenance .audit-source-label svg { opacity: 0.55; }
.audit-prov-row {
  display: grid;
  grid-template-columns: minmax(96px, 130px) minmax(80px, 150px) 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--color-border);
  font-size: 11.5px;
}
.audit-source-header + .audit-prov-row { border-top: none; }
.audit-prov-domain {
  font-weight: 600;
  color: var(--color-text-primary);
}
.audit-prov-db {
  font-size: 10.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.audit-prov-path {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-secondary);
  word-break: break-word;
}
.audit-prov-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-align: right;
}
@media (max-width: 720px) {
  .audit-prov-row { grid-template-columns: 1fr auto; }
  .audit-prov-db, .audit-prov-path { grid-column: 1 / -1; }
}

/* ── Stat cards ───────────────────────────────────────────── */
.audit-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.audit-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + 5px);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.audit-stat-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-subtle);
}
.audit-stat-card.s-ok,
.audit-stat-card.s-warn,
.audit-stat-card.s-bad,
.audit-stat-card.s-load { border-left-width: 1px; }
/* Bottom progress bar */
.audit-stat-bar {
  position: absolute;
  bottom: 0; left: 0;
  height: 4px;
  min-width: 0;
  max-width: 100%;
  border-radius: 0;
  transition: width 0.5s ease;
}
.audit-stat-card.s-ok .audit-stat-bar   { background: var(--color-success); }
.audit-stat-card.s-warn .audit-stat-bar { background: var(--color-warning); }
.audit-stat-card.s-bad .audit-stat-bar  { background: var(--color-danger); }
.audit-stat-card.s-load .audit-stat-bar { background: var(--color-border); width: 100% !important; }
.audit-stat-entity {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.audit-stat-num {
  font-family: var(--font-mono);
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}
.audit-stat-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.audit-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}
.audit-pill-ok   { background: #dcfce7; color: #15803d; }
.audit-pill-bad  { background: #fee2e2; color: #b91c1c; }
.audit-pill-muted{ background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.audit-stat-source {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 4px;
}
.audit-stat-arrow {
  position: absolute;
  top: 14px; right: 12px;
  color: var(--color-text-muted);
  opacity: 0.35;
}

/* ── Meta / staleness bar ─────────────────────────────────── */
.audit-meta-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.audit-meta-bar.stale {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.audit-meta-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}
.audit-meta-bar.stale .audit-meta-dot { background: #d97706; }

/* ── Entity tab toolbar ───────────────────────────────────── */
.audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 14px;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.audit-toolbar-left { display: flex; align-items: center; gap: 10px; }
.audit-toolbar-right { display: flex; align-items: center; gap: 8px; }
.audit-entity-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}
.audit-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
}
.audit-count-ok  { background: #dcfce7; color: #15803d; }
.audit-count-bad { background: #fee2e2; color: #b91c1c; }
.audit-count-warn{ background: #fef3c7; color: #b45309; }  /* stale mirror (audit freshness strip) */

/* ── Filter segmented control ─────────────────────────────── */
.audit-filter-tabs {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}
.audit-filter-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-surface);
  border: none;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.12s, color 0.12s;
}
.audit-filter-btn:last-child { border-right: none; }
.audit-filter-btn.active { background: var(--color-primary); color: #fff; font-weight: 600; }
.audit-filter-btn:hover:not(.active) { background: var(--color-bg); color: var(--color-text); }

/* ── Table behaviour ──────────────────────────────────────── */
.audit-data-row { cursor: pointer; }
.audit-data-row:hover { background: #f5f8ff !important; }
.audit-row-incomplete td:first-child { border-left: 3px solid #fca5a5; }
.audit-row-expanded { background: #eff6ff !important; }
.audit-row-expanded .dd-chevron { transform: rotate(180deg); }
.audit-expand-chevron {
  width: 26px; text-align: center;
  padding: 0 !important;
  color: var(--color-text-muted);
}
.dd-chevron { transition: transform 0.18s; vertical-align: middle; }
.audit-cell-empty { background: #fffbf0; }

/* ── Drill-down panel ─────────────────────────────────────── */
.audit-drilldown-row td { padding: 0 !important; background: #f8fafc; }
.audit-drilldown {
  padding: 16px 20px 14px;
  border-left: 3px solid var(--color-primary);
  border-bottom: 1px solid var(--color-border);
}
.dd-missing-banner {
  display: flex; align-items: center; gap: 7px;
  background: var(--color-danger-bg); border: 1px solid var(--color-danger-border); color: var(--color-danger);
  border-radius: 5px; padding: 6px 12px; font-size: var(--text-xs); margin-bottom: 12px;
}
.dd-ok-banner {
  display: flex; align-items: center; gap: 7px;
  background: var(--color-success-bg); border: 1px solid var(--color-success-border); color: var(--color-success);
  border-radius: 5px; padding: 6px 12px; font-size: var(--text-xs); margin-bottom: 12px;
}
.dd-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.dd-field {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 7px 10px;
}
.dd-field-missing { border-color: var(--color-danger-border); background: var(--color-danger-bg); }
.dd-field-empty   { border-color: var(--color-border); background: var(--color-surface-raised); }
.dd-field-ok      { border-color: var(--color-success-border); background: var(--color-success-bg); }
.dd-field-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 3px;
}
.dd-field-missing .dd-field-label { color: var(--color-danger); }
.dd-field-ok .dd-field-label      { color: var(--color-success); }
.dd-field-value {
  font-size: 12px; color: var(--color-text);
  display: flex; align-items: center; gap: 5px; word-break: break-word;
}
.dd-actions { display: flex; gap: 8px; }

/* ── Utility ──────────────────────────────────────────────── */
.audit-all-ok {
  background: var(--color-success-bg); border: 1px solid var(--color-success-border); color: var(--color-success);
  border-radius: 6px; padding: 10px 14px; font-size: var(--text-sm); margin-top: 8px;
}
.audit-subsection {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--color-border);
}
.audit-subsection-title {
  font-size: 13px; font-weight: 600; color: var(--color-text); margin-bottom: 3px;
}
.audit-subsection-note {
  font-size: 11px; color: var(--color-text-muted); margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════════
   SYSTEM AREA — Unified design for Settings, Audit, Changelog
   ══════════════════════════════════════════════════════════════ */

/* ── Page header (used in Changelog) ────────────────────────── */
.sys-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
}
.sys-eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}
.sys-page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.sys-page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  line-height: 1.55;
}

/* ── Settings: dark section header (full-bleed inside #settings-content) ─ */
.settings-section {
  margin-bottom: var(--space-5);
}
.settings-section-header {
  background: var(--theme-sidebar-bg);
  margin: -0.75rem -0.75rem var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: 0.625rem 0.625rem 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.settings-section-header h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: #F1F5F9;
  margin: 0;
  letter-spacing: 0.01em;
}
.settings-section-header p {
  font-size: var(--text-xs);
  color: #94A3B8;
  margin: 3px 0 0;
  line-height: 1.5;
}

/* ── Changelog timeline ──────────────────────────────────────── */
.cl-timeline {
  max-width: 820px;
  position: relative;
  padding-left: 2.75rem;
}
.cl-timeline::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 0.4rem;
  bottom: 2.5rem;
  width: 1px;
  background: linear-gradient(to bottom, var(--color-primary) 0%, var(--color-border) 100%);
}
.cl-release {
  position: relative;
  margin-bottom: 2.5rem;
}
.cl-release::before {
  content: "";
  position: absolute;
  left: -2.3rem;
  top: 0.375rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-primary);
  z-index: 1;
}
.cl-release-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.cl-version {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}
.cl-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.cl-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}
.cl-entries {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cl-entry {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}
.cl-entry.open {
  border-color: var(--color-border-strong);
}
.cl-entry-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}
.cl-entry-header:hover { background: var(--color-surface-raised); }
.cl-type-badge {
  flex-shrink: 0;
  margin-top: 1px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid;
  white-space: nowrap;
}
.cl-entry-request {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin: 0;
}
.cl-entry-request strong {
  color: var(--color-text-primary);
  font-weight: 600;
}
.cl-chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
  margin-top: 2px;
}
.cl-entry.open .cl-chevron { transform: rotate(180deg); }
.cl-entry-built {
  display: none;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4) var(--space-4) 5.5rem;
  background: var(--color-surface-raised);
}
.cl-entry.open .cl-entry-built { display: block; }
.cl-built-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.cl-entry-built ul {
  margin: 0;
  padding-left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cl-entry-built li {
  font-size: var(--text-xs);
  color: var(--color-text-primary);
  line-height: 1.65;
}


/* ── Files View ──────────────────────────────────────────────────── */

#view-files {
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 0;
}

.files-layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Drop Zone */
.file-dropzone {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  margin: var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}
.file-dropzone:hover,
.file-dropzone.drag-over {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface));
}
.file-dropzone.drag-over .dropzone-icon svg {
  stroke: var(--color-primary);
}
.dropzone-icon svg {
  stroke: var(--color-text-muted);
  transition: stroke var(--transition-fast);
}
.dropzone-text {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0;
}
.dropzone-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.dropzone-btn {
  margin-top: var(--space-1);
}

/* Analysis Panel */
.analysis-panel {
  margin: 0 var(--space-4) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-surface-raised);
  overflow: hidden;
}
.analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.analysis-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
}
.analysis-result {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.ar-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.ar-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 80px;
  flex-shrink: 0;
}
.ar-val { font-size: var(--text-sm); color: var(--color-text-primary); }
.ar-val.mono { font-family: var(--font-mono, monospace); font-size: var(--text-xs); }
.ar-reasoning {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
}

/* Type selector + confidence badge */
.ar-type-select {
  font-size: var(--text-sm);
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
}
.ar-conf {
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
}
.conf-high   { background: #F0FDF4; color: #166534; }
.conf-medium { background: #FFF7ED; color: #C2410C; }
.conf-low    { background: #FFF1F2; color: #BE123C; }

/* Formula trace */
.formula-trace {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ft-summary {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ft-summary:hover { background: var(--theme-table-hover, rgba(0,0,0,.03)); }
.ft-custom-badge {
  font-size: 10px;
  background: #EFF6FF;
  color: #1D4ED8;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.ft-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-top: 1px solid var(--color-border);
}
.ft-pattern-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.ft-pattern-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ft-pattern-input {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.5;
}
.ft-pattern-input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.ft-pattern-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.btn-xs {
  font-size: var(--text-xs);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.ft-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-xs);
}
.ft-table tr { border-bottom: 1px solid var(--color-border); }
.ft-table tr:last-child { border-bottom: none; }
.ft-placeholder {
  font-family: var(--font-mono, monospace);
  padding: 3px 8px 3px 0;
  white-space: nowrap;
}
.ft-arrow { color: var(--color-text-muted); padding: 3px 6px; }
.ft-value { padding: 3px 0; }
.ft-found .ft-placeholder { color: var(--color-primary, #2563EB); }
.ft-found .ft-value { color: var(--color-text-primary); font-weight: 500; }
.ft-missing .ft-placeholder { color: var(--color-text-muted); }
.ft-nil { color: var(--color-text-muted); font-style: italic; }

/* + New type button */
.btn-new-type {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-new-type:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* New Document Type Modal */
.ntm-card {
  width: min(680px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.ntm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.ntm-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}
.ntm-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.ntm-footer {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.ntm-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.ntm-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}
.ntm-input, .ntm-pattern {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  width: 100%;
  box-sizing: border-box;
}
.ntm-pattern {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  resize: vertical;
  line-height: 1.6;
}
.ntm-input:focus, .ntm-pattern:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}
.ntm-pattern-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.ntm-pattern-hint code {
  background: var(--theme-table-hover, rgba(0,0,0,.06));
  padding: 0 3px;
  border-radius: 3px;
  font-family: var(--font-mono, monospace);
}
.ntm-vars {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ntm-vars-summary {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}
.ntm-vars-summary:hover { background: var(--theme-table-hover, rgba(0,0,0,.03)); }
.ntm-vars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--color-border);
  border-top: 1px solid var(--color-border);
}
.ntm-var-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}
.ntm-var-chip:hover { background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface)); }
.ntm-var-key {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  color: var(--color-primary, #2563EB);
  font-weight: 600;
}
.ntm-var-label {
  font-size: 11px;
  color: var(--color-text-muted);
}
.ar-fields table { border-collapse: collapse; width: 100%; }
.af-key {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: capitalize;
  padding: 2px 12px 2px 0;
  white-space: nowrap;
}
.ar-fields td { font-size: var(--text-xs); padding: 2px 0; color: var(--color-text-primary); }
.ar-rename {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.ar-name-input {
  font-size: var(--text-sm);
  font-family: var(--font-mono, monospace);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  width: 100%;
  box-sizing: border-box;
}
.ar-name-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}
.ar-actions {
  display: flex;
  gap: var(--space-2);
}
.analysis-error {
  padding: var(--space-3) var(--space-4);
  color: var(--color-danger, #dc2626);
  font-size: var(--text-sm);
}

/* Doc type badge */
.doc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
}

/* Work area — analysis + preview side by side */
.files-work-area {
  display: flex;
  flex-direction: row;
}
/* When split (preview open), work area becomes fixed-height so preview can scroll */
.files-work-area.split {
  height: calc(100vh - 160px);
  min-height: 400px;
}
.files-work-area.split .analysis-panel {
  width: 380px;
  flex-shrink: 0;
  margin-bottom: 0;
  border-radius: var(--radius-base) 0 0 var(--radius-base);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

/* All-fields table */
.af-table { border-collapse: collapse; width: 100%; }
.af-row { border-bottom: 1px solid var(--color-border); }
.af-row:last-child { border-bottom: none; }
.af-found .af-var { color: var(--color-primary, #2563EB); }
.af-missing .af-label { color: var(--color-text-muted); }
.af-missing .af-var  { color: var(--color-text-muted); opacity: .6; }
.af-key {
  padding: 4px 8px 4px 0;
  white-space: nowrap;
  vertical-align: middle;
  width: 1%;
}
.af-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-primary);
}
.af-var {
  display: block;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  color: var(--color-text-muted);
}
.af-val-cell { padding: 3px 6px 3px 0; }
.af-val-input {
  width: 100%;
  font-size: var(--text-xs);
  font-family: var(--font-mono, monospace);
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--color-text-primary);
  box-sizing: border-box;
}
.af-val-input:hover { border-color: var(--color-border); background: var(--color-surface); }
.af-val-input:focus { outline: none; border-color: var(--color-primary); background: var(--color-surface); }
.af-val-found { color: var(--color-text-primary); }
.af-val-empty { color: var(--color-text-muted); font-style: italic; }
.af-extra { display: none; }
.af-table.af-expanded .af-extra { display: table-row; }

.af-show-all-row { border-bottom: none !important; }
.af-show-all-row td { padding: 4px 0; }
.af-show-all-btn {
  background: none;
  border: none;
  font-size: var(--text-xs);
  color: var(--color-primary);
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.af-show-all-btn:hover { opacity: .75; }

.af-na .af-label { text-decoration: line-through; color: var(--color-text-muted); opacity: .5; }
.af-na .af-var   { opacity: .35; }
.af-val-na { font-size: var(--text-xs); color: var(--color-text-muted); font-style: italic; opacity: .6; }

.af-locate-cell { padding: 3px 0; white-space: nowrap; }
.af-missing-btns { display: inline-flex; gap: 3px; }
.af-locate-btn, .af-na-btn {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.af-locate-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.af-na-btn:hover { border-color: #D97706; color: #D97706; }
.af-locate-found { border-color: transparent; color: var(--color-success, #16a34a); font-weight: 600; }
.af-locate-found:hover { border-color: var(--color-success, #16a34a); }
.af-na-active { border-color: #D97706; color: #D97706; background: #FFFBEB; font-weight: 600; }
.af-na-active:hover { background: #FEF3C7; }

/* Type definition section */
.type-def {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.td-summary {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.td-summary:hover { background: var(--theme-table-hover, rgba(0,0,0,.03)); }
.td-saved-badge {
  font-size: 10px;
  background: #F0FDF4; color: #166534;
  padding: 1px 6px; border-radius: 999px;
  font-weight: 500; text-transform: none; letter-spacing: 0;
}
.td-unsaved-badge {
  font-size: 10px;
  background: #FFF7ED; color: #C2410C;
  padding: 1px 6px; border-radius: 999px;
  font-weight: 500; text-transform: none; letter-spacing: 0;
}
.td-body {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.td-intro {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}
.td-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
}
.td-label-hint {
  font-weight: 400;
  color: var(--color-text-muted);
}
.td-hint {
  font-size: var(--text-xs);
  font-family: inherit;
  line-height: 1.6;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}
.td-hint:focus { outline: none; border-color: var(--color-primary); }
.td-na-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
}
.td-na-label { color: var(--color-text-muted); flex-shrink: 0; }
.td-na-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #FFF7ED;
  color: #C2410C;
  border: 1px solid #FED7AA;
  border-radius: 999px;
  padding: 1px 6px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}
.td-na-chip button {
  background: none; border: none; cursor: pointer;
  color: #C2410C; padding: 0; font-size: 13px; line-height: 1;
}
.td-na-chip button:hover { color: #7C2D12; }
.td-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Document Preview Panel */
.doc-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--color-bg);
  position: relative;
}
.dp-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
}
.dp-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  flex-shrink: 0;
}
.dp-page-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}
.dp-page-info { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.dp-nav-btn:disabled { opacity: .35; }
.dp-instruction {
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  background: #EFF6FF;
  color: #1D4ED8;
  border-bottom: 1px solid #BFDBFE;
  flex-shrink: 0;
}
.dp-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-3);
  background: #e5e7eb;
}
.dp-img-wrap {
  position: relative;
  display: inline-block;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.dp-img {
  display: block;
  max-width: 100%;
  height: auto;
  transition: opacity .2s;
}
.dp-regions-svg {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  overflow: visible;
}
.dp-draw-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}
.dp-error {
  padding: var(--space-4);
  color: var(--color-danger, #dc2626);
  font-size: var(--text-sm);
}

/* Region define mode */
#dp-region-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Region label popup */
.dp-region-popup {
  position: absolute;
  bottom: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-3);
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  z-index: 20;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.dp-rp-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dp-rp-select {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
}
.dp-rp-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* analysis-panel header with actions */
.analysis-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* File Explorer */
.files-explorer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 var(--space-4) var(--space-4);
}
.files-explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0 var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}
.files-explorer-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}
.files-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.files-list {
  flex: 1;
  overflow-y: auto;
}
.files-empty {
  text-align: center;
  padding: var(--space-6) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.file-item:hover { background: var(--color-surface-raised); }
.file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: .02em;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}
.file-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}
.btn-danger-icon:hover svg { stroke: var(--color-danger, #dc2626); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════
   OFFERS WORKSPACE (offers.js) — KPI strip, toolbar, board / rounds /
   customers views, master-detail shell. Uses the app's tokens; density
   scales with --density-*.
   ═══════════════════════════════════════════════════════════════ */
/* overflow: clip (not hidden) — a focus()/scrollIntoView() inside the panel
   can never scroll the whole view sideways and clip the KPI strip / toolbar. */
#view-offers { overflow: hidden; overflow: clip; gap: 0; min-height: 0; flex-direction: column; }
.offers-ws { flex: 1; min-height: 0; min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: var(--space-3); }
.offers-ws-top { flex-shrink: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }

/* ── Two-pane shell: list | divider | detail ── */
.offers-shell {
  --offers-detail-w: 760px;
  flex: 1; min-height: 0; min-width: 0; max-width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
/* Detail rail: never wider than the shell minus a usable list (mirrors
   _owClampRailWidth: [420px, 100% − 426px]). */
.offers-shell.has-detail { grid-template-columns: minmax(0, 1fr) 6px clamp(420px, var(--offers-detail-w), calc(100% - 426px)); }
.offers-main { min-width: 0; min-height: 0; overflow: auto; }
.offers-divider, .offers-detail { display: none; }
.offers-shell.has-detail .offers-divider,
.offers-shell.has-detail .offers-detail { display: block; }
.offers-divider { cursor: col-resize; background: transparent; border-left: 1px solid var(--color-border); transition: background var(--transition-fast); }
.offers-divider:hover, .offers-divider:focus-visible { background: var(--color-primary-subtle); outline: none; }
.offers-detail { min-width: 0; min-height: 0; overflow: auto; padding-left: var(--space-3); }
.ow-detail-loading { padding: var(--space-6); color: var(--color-text-muted); font-size: var(--density-text-sm); }

/* ── KPI strip ── */
.ow-kpis { display: grid; grid-template-columns: repeat(5, minmax(96px, 1fr)) minmax(200px, 2fr); gap: var(--space-2); min-width: 0; }
.ow-kpi {
  background: var(--theme-card-bg); border: 1px solid var(--theme-card-border); border-radius: var(--radius-base);
  padding: var(--space-2) var(--space-3); min-width: 0; display: flex; flex-direction: column; gap: 1px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.ow-kpi-click { cursor: pointer; }
.ow-kpi-click:hover { border-color: var(--color-border-strong); background: var(--color-surface-raised); }
.ow-kpi.is-active { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); background: var(--color-primary-subtle); }
.ow-kpi-value { font-size: var(--density-text-xl); font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; line-height: 1.15; }
.ow-kpi-label { font-size: var(--density-text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-kpi-sub { font-size: var(--density-text-xs); color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-kpi-warn .ow-kpi-value { color: var(--color-warning); }
.ow-kpi-ok { color: var(--color-success); font-weight: 600; }
.ow-kpi-danger { color: var(--color-danger); font-weight: 600; }
.ow-kpi-goal { justify-content: center; gap: 4px; }
.ow-kpi-goal .ol-goal { min-width: 0; }

/* ── Toolbar: view switch, lifecycle tabs, filters ── */
.ow-toolbar { display: flex; flex-direction: column; gap: var(--space-2); }
.ow-toolbar-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.ow-toolbar-spacer { flex: 1; }
.ow-switch { display: inline-flex; background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-base); padding: 2px; }
.ow-switch-btn {
  border: none; background: transparent; padding: 0.3rem 0.85rem; border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-size: var(--density-text-sm); font-weight: 500; color: var(--color-text-muted);
}
.ow-switch-btn.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--theme-card-shadow); font-weight: 600; }
.ow-tabs { display: inline-flex; gap: 2px; border-bottom: 1px solid transparent; }
.ow-tab {
  border: none; background: transparent; padding: 0.35rem 0.6rem; cursor: pointer; font-family: inherit;
  font-size: var(--density-text-sm); color: var(--color-text-muted); border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center;
}
.ow-tab:hover { color: var(--color-text); }
.ow-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.ow-tab-count { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 9px; background: var(--color-surface-sunken); color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.ow-tab.is-active .ow-tab-count { background: var(--color-primary-subtle); color: var(--color-primary); }
.ow-filters .ow-search { flex: 1 1 260px; min-width: 200px; max-width: 420px; }
.ow-select {
  padding: 0.35rem 1.8rem 0.35rem 0.6rem; border: 1px solid var(--color-border); border-radius: var(--radius-base);
  font-size: var(--density-text-xs); font-family: inherit; color: var(--color-text); background: var(--color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.45rem center; appearance: none; -webkit-appearance: none; outline: none; cursor: pointer; max-width: 200px;
}
.ow-select:focus { border-color: var(--color-primary); }
.ow-quick { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.ow-quick-btn {
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-secondary);
  border-radius: var(--radius-full); padding: 0.2rem 0.65rem; font-size: var(--density-text-xs); font-family: inherit; cursor: pointer; font-weight: 500;
}
.ow-quick-btn:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.ow-quick-btn.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ── Empty states ── */
.ow-empty { background: var(--theme-card-bg); border: 1px dashed var(--color-border); border-radius: var(--radius-base); }
.ow-empty-title { font-size: var(--density-text-base); font-weight: 600; color: var(--color-text); }
.ow-empty p { max-width: 460px; text-align: center; color: var(--color-text-muted); }

/* ── Chips shared by cards / rows ── */
.ow-chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; white-space: nowrap; background: var(--color-surface-sunken); color: var(--color-text-secondary); }
.ow-chip-warn   { background: var(--color-warning-bg); color: #92400E; }
.ow-chip-danger { background: var(--color-danger-bg); color: #991B1B; }
.ow-chip-stale  { background: #F1F5F9; color: #475569; border: 1px dashed #CBD5E1; }
.ow-done { font-size: var(--density-text-xs); color: var(--color-text-faint); font-weight: 600; }
.ow-btn-warn { background: var(--color-warning) !important; border-color: var(--color-warning) !important; color: #fff !important; }
.ow-btn-ok   { background: #065F46 !important; border-color: #065F46 !important; color: #fff !important; }
.ow-round-closed { color: var(--color-text-faint); font-weight: 500; font-style: italic; cursor: help; }
.date-approx { color: var(--color-text-muted); cursor: help; }
.ow-round-sub { font-size: var(--density-text-xs); color: var(--color-text-muted); line-height: 1.4; }
.ow-round-number { font-weight: 700; color: var(--color-text); font-size: var(--density-text-sm); white-space: nowrap; }
.ow-resp { color: var(--color-text-faint); }

/* ── Board ── */
/* Columns are minmax(240px, 1fr) (template set inline per render so an
   empty Rejected column collapses to 44px); the board scrolls sideways
   only when the columns really cannot fit. */
.ow-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: var(--space-2); height: 100%; min-height: 0; align-items: stretch; overflow-x: auto; padding-bottom: 2px; }
.ow-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-base); }
.ow-col-muted { opacity: .8; }
.ow-col-collapsed { opacity: .6; }
.ow-col-collapsed .ow-col-head { flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-bottom: none; }
.ow-col-collapsed .ow-col-title { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.ow-col-head { display: flex; align-items: baseline; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-surface-sunken); border-radius: var(--radius-base) var(--radius-base) 0 0; z-index: 1; }
.ow-col-title { font-size: var(--density-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-secondary); }
.ow-col-count { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 9px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-secondary); }
.ow-col-tons { margin-left: auto; font-size: var(--density-text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ow-col-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.ow-col-empty { font-size: var(--density-text-xs); color: var(--color-text-faint); padding: 12px 6px; text-align: center; }
.ow-card {
  background: var(--theme-card-bg); border: 1px solid var(--theme-card-border); border-radius: var(--radius-base); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; border-left-width: 3px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.ow-card:hover { border-color: var(--color-border-strong); box-shadow: var(--theme-card-shadow); }
.ow-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.ow-card-expiring { border-left-color: var(--color-warning); }
.ow-card-expired  { border-left-color: var(--color-danger); }
.ow-card-closed   { opacity: .7; border-left-color: var(--color-border); }
.ow-card-top { display: flex; align-items: center; gap: 6px; }
.ow-card-customer { font-weight: 600; font-size: var(--density-text-sm); color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ow-card-round { font-size: var(--density-text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-card-round .sm-item-id { font-size: var(--density-text-xs); }
.ow-card-dot { color: var(--color-text-faint); }
.ow-card-terms { font-size: var(--density-text-sm); color: var(--color-text); font-variant-numeric: tabular-nums; }
.ow-card-pkg { font-size: var(--density-text-xs); color: var(--color-text-muted); }
.ow-card-meta { display: flex; gap: 8px; font-size: var(--density-text-xs); color: var(--color-text-muted); }
.ow-card-resp { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-card-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.ow-card-actions { display: flex; gap: 4px; margin-top: 2px; align-items: center; }
.ow-card-actions .btn { flex: 1; }
.ow-card-actions .ow-card-more { flex: 0 0 auto; }

/* ── Rounds table ── */
.ow-rounds { overflow: auto; }
.ow-rounds-table th { white-space: nowrap; }
.ow-round-row { cursor: pointer; }
.ow-round-row:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.ow-round-completed td { color: var(--color-text-muted); }
.ow-round-expired .ow-round-number { color: var(--color-text-muted); }
.ow-td-goal { min-width: 170px; }
.ow-td-letters { max-width: 260px; }
.ow-letter-mix { display: flex; gap: 4px; flex-wrap: wrap; }
.ow-letter-mix .ol-badge { font-size: 10px; padding: 1px 6px; }
.ow-td-age { white-space: nowrap; color: var(--color-text-secondary); font-size: var(--density-text-xs); }
.ow-td-expiry { white-space: nowrap; font-size: var(--density-text-xs); }
.ow-td-next { white-space: nowrap; }
.ow-td-op { white-space: nowrap; font-size: var(--density-text-xs); }
.ow-group-row td { background: var(--color-surface-sunken) !important; padding: 6px 12px !important; }
.ow-group-title { font-size: var(--density-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-secondary); margin-right: 8px; }
.ow-group-closing { color: var(--color-success); }
.ow-group-expired { color: var(--color-danger); }
.ow-group-count { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 9px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-secondary); margin-right: 10px; }
.ow-group-hint { font-size: var(--density-text-xs); color: var(--color-text-muted); }

/* ── Customers view ── */
.ow-customers { display: flex; flex-direction: column; gap: var(--space-3); }
.ow-customer { background: var(--theme-card-bg); border: 1px solid var(--theme-card-border); border-radius: var(--radius-base); overflow: hidden; }
.ow-customer-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 10px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-surface-raised); flex-wrap: wrap; }
.ow-customer-name { font-weight: 700; font-size: var(--density-text-base); color: var(--color-text); }
.ow-customer-contact { font-size: var(--density-text-xs); color: var(--color-text-muted); }
.ow-customer-stats { display: flex; gap: var(--space-4); }
.ow-cstat { display: flex; flex-direction: column; align-items: flex-end; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); line-height: 1.2; }
.ow-cstat span { font-size: var(--density-text-base); font-weight: 700; color: var(--color-text); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.ow-cstat-ok span { color: var(--color-success); }
.ow-cstat-bad span { color: var(--color-danger); }
.ow-cstat-warn span { color: var(--color-warning); }
.ow-customer-table { width: 100%; border-collapse: collapse; font-size: var(--density-text-sm); table-layout: fixed; }
.ow-customer-table th, .ow-customer-table td { min-width: 0; }
.ow-customer-table .ow-th-ol { width: 118px; }
.ow-customer-table .ow-th-status { width: 128px; }
.ow-customer-table .ow-td-age { width: 76px; }
.ow-customer-table .ow-th-next { width: 136px; }
.ow-customer-table .ow-td-rp > div, .ow-customer-table .ow-terms > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ow-customer-table .ow-td-next .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* Squeezed list (detail panel open): drop the non-essential columns; the next-step cell always stays. */
.offers-main.is-narrow .ow-customer-table .ow-td-age { display: none; }
.offers-main.is-tight .ow-rounds-table .ow-td-op,
.offers-main.is-tight .ow-rounds-table .ow-td-age { display: none; }
.ow-customer-table th { text-align: left; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 6px 14px; border-bottom: 1px solid var(--color-border); }
.ow-customer-table td { padding: 7px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.ow-customer-table tbody tr { cursor: pointer; }
.ow-customer-table tbody tr:hover { background: var(--theme-table-hover); }
.ow-customer-table tbody tr:last-child td { border-bottom: none; }
.ow-terms { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Detail panel ── */
.ow-detail-header { position: sticky; top: 0; z-index: 2; background: var(--color-surface); flex-wrap: wrap; box-shadow: 0 1px 0 var(--color-border); padding-right: 52px; }
.ow-detail-title-wrap { min-width: 0; }
.ow-detail-header .offer-detail-actions { flex-wrap: wrap; }
.offer-detail-title .ol-badge { vertical-align: middle; margin-left: 6px; }
/* Close stays top-right however the actions wrap (header is sticky → positioned). */
.ow-detail-close { padding-left: .5rem; padding-right: .5rem; position: absolute; top: var(--space-3); right: var(--space-3); }
.offers-detail .offer-mgmt-strip { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
/* Letters table in the panel: OL# | Customer | Terms | Status | Next step | ⋯
   Column minimums sum to ≈614px so the row fits a 640px panel without a
   horizontal scroll; secondary actions live in the "⋯" menu. */
.ow-row-main.ol-table-header, .ow-row-main { grid-template-columns: minmax(96px, auto) minmax(120px, 1.2fr) minmax(140px, 1fr) 110px 112px 36px; min-width: 620px; column-gap: 6px; }
.ow-row-main > * { min-width: 0; }                       /* no cell may overlap its neighbour */
.ow-row-main .ol-col-actions { display: flex; justify-content: flex-end; flex-wrap: nowrap; }
/* OL # cell: number + revision badge wrap onto their own lines instead of
   overflowing into the customer cell. */
.ow-row-main .ol-col-number { white-space: normal; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding-right: 6px; }
.ow-row-main .ol-col-number .ol-badge-rev { flex: 0 0 auto; }
.ow-row-main .ol-col-client { overflow: hidden; }
.ow-row-main .ol-col-client strong, .ow-row-main .ol-client-email > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ol-col-terms { font-size: var(--density-text-sm); font-variant-numeric: tabular-nums; }
/* Terms: the main line may wrap onto two lines; the sub-line ellipsizes (full text in the title). */
.ow-row-main .ol-col-terms { overflow: hidden; }
.ow-row-main .ol-col-terms > div:first-child { white-space: normal; }
.ow-row-main .ol-col-terms .ow-round-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── "⋯" row menu (secondary actions) ── */
.ow-menu-wrap { position: relative; display: flex; justify-content: flex-end; }
.ow-menu-btn { padding-left: .45rem; padding-right: .45rem; font-weight: 700; letter-spacing: .06em; line-height: 1; }
.ow-menu-wrap.is-open .ow-menu-btn { background: var(--color-primary-subtle); border-color: var(--color-primary); color: var(--color-primary); }
.ow-menu {
  position: fixed; z-index: 1200; min-width: 168px; padding: 4px;
  display: flex; flex-direction: column; cursor: default;
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-base); box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
}
.ow-menu-item {
  display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; border-radius: 4px;
  background: none; font: inherit; font-size: var(--density-text-sm); color: var(--color-text);
  cursor: pointer; white-space: nowrap;
}
.ow-menu-item:hover, .ow-menu-item:focus-visible { background: var(--color-surface-sunken); outline: none; }
.ol-col-next { padding-right: 6px; }
.ol-col-next .btn { width: 100%; }
.ol-row { cursor: pointer; }
.ow-activity { padding: 8px 16px 10px 112px; background: #FAFBFC; border-top: 1px dashed var(--color-border); cursor: default; }
.ow-timeline { position: relative; display: flex; flex-direction: column; gap: 6px; padding-left: 14px; border-left: 2px solid var(--color-border); }
.ow-tl-item { position: relative; display: flex; gap: 10px; align-items: baseline; font-size: var(--density-text-xs); flex-wrap: wrap; }
.ow-tl-dot { position: absolute; left: -20px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-faint); }
.ow-tl-sent .ow-tl-dot { background: var(--color-info); }
.ow-tl-revision .ow-tl-dot { background: #6D28D9; }
.ow-tl-response .ow-tl-dot { background: var(--color-warning); }
.ow-tl-response.accepted .ow-tl-dot, .ow-tl-response.purchase_order .ow-tl-dot, .ow-tl-decision.approved .ow-tl-dot, .ow-tl-adjusted .ow-tl-dot { background: var(--color-success); }
.ow-tl-response.rejected .ow-tl-dot, .ow-tl-decision.rejected .ow-tl-dot { background: var(--color-danger); }
.ow-tl-when { color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ow-tl-title { font-weight: 600; color: var(--color-text); }
.ow-tl-detail { color: var(--color-text-secondary); }
.ow-tl-foot { font-size: 10px; color: var(--color-text-faint); margin-top: 4px; }

/* ── Rounds table: expandable rows (letters as an indented child table) ── */
.ow-th-x, .ow-td-x { width: 26px; padding-left: 6px !important; padding-right: 0 !important; }
.ow-expander {
  width: 22px; height: 22px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--color-text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.ow-expander:hover { background: var(--color-surface-sunken); color: var(--color-text); border-color: var(--color-border); }
.ow-expander svg { transition: transform var(--transition-fast); }
.ow-expander.is-open svg { transform: rotate(90deg); }
.ow-td-letters { cursor: pointer; }
.ow-round-row.is-expanded td { border-bottom-color: transparent; }
.ow-letters-row > td { padding: 0 0 0 32px !important; background: var(--color-surface-sunken) !important; border-bottom: 1px solid var(--color-border); }
.ow-sub-table { width: 100%; border-collapse: collapse; font-size: var(--density-text-sm); background: var(--color-surface); border-left: 3px solid var(--color-border-strong); }
.ow-sub-table th { text-align: left; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 5px 12px; border-bottom: 1px solid var(--color-border); background: var(--color-surface-raised); white-space: nowrap; }
.ow-sub-table td { padding: 6px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; min-width: 0; }
.ow-sub-table tbody tr:last-child td { border-bottom: none; }
.ow-sub-table .ow-th-ol { width: 130px; }
.ow-sub-table .ow-th-status { width: 160px; }
.ow-sub-table .ow-th-next { width: 140px; }
.ow-sub-table .ow-th-more { width: 44px; }
.ow-sub-row { cursor: pointer; }
.ow-sub-row:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.ow-sub-row:hover td { background: var(--theme-table-hover); }
.ow-sub-closed .ow-sub-customer strong { color: var(--color-text-secondary); }
.ow-sub-customer strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-sub-empty { padding: 10px 12px; font-size: var(--density-text-xs); color: var(--color-text-faint); }
.ow-td-more { text-align: right; white-space: nowrap; }
.ow-customer-table .ow-th-more { width: 44px; }
/* Status chip that opens the PDF preview (any state, as long as a PDF exists) */
.ol-badge-click { cursor: pointer; border: 1px solid transparent; font-family: inherit; line-height: inherit; }
.ol-badge-click:hover, .ol-badge-click:focus-visible { text-decoration: underline; box-shadow: inset 0 0 0 1px currentColor; outline: none; }

/* ── Board: parent-first cards, single Closed column ── */
.ow-card-parent { font-size: 10.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-card-parent .ow-card-offer { font-weight: 700; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.ow-card-parent .sm-item-id, .ow-card-parent .sm-product-name { font-size: 10.5px; }
.ow-card-actions .ow-menu-wrap, .ow-card-actions .ow-menu-wrap .btn { flex: 0 0 auto; }
.ow-col-closed { opacity: 1; border-style: dashed; }
.ow-col-closed .ow-col-title { color: var(--color-text-muted); }
.ow-col-note { font-size: var(--density-text-xs); color: var(--color-text-muted); padding: 6px 10px; border-bottom: 1px dashed var(--color-border); }
.ow-col-note a { color: var(--color-primary); }
.ow-col-group { display: flex; flex-direction: column; gap: 6px; }
.ow-col-group + .ow-col-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--color-border); }
.ow-col-group-head {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  border: 0; background: transparent; padding: 2px 4px; cursor: pointer; text-align: left; font-family: inherit;
}
.ow-col-group-head:hover .ow-round-number { color: var(--color-primary); text-decoration: underline; }
.ow-col-group-meta { font-size: var(--density-text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ow-col-group .ow-card { opacity: .85; }
.ow-chip-closed { background: var(--color-surface-sunken); color: var(--color-text-muted); border: 1px dashed var(--color-border-strong); cursor: help; }

/* ── Letter detail (the child; its parent one click away) ── */
.ow-ld { display: flex; flex-direction: column; gap: var(--space-3); }
.ow-ld-crumb {
  position: sticky; top: 0; z-index: 2; background: var(--color-surface); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 52px 8px 0; box-shadow: 0 1px 0 var(--color-border); font-size: var(--density-text-sm);
}
.ow-ld-crumb-link { color: var(--color-primary); font-weight: 700; text-decoration: none; white-space: nowrap; }
.ow-ld-crumb-link:hover { text-decoration: underline; }
.ow-ld-crumb-sep { color: var(--color-text-faint); }
.ow-ld-crumb-here { font-weight: 700; color: var(--color-text); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.ow-ld-crumb-round { font-size: var(--density-text-xs); color: var(--color-text-muted); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-ld-crumb .ow-detail-close { top: 4px; right: 0; }
.ow-ld-head {
  display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-base);
}
.ow-ld-title-wrap { min-width: 0; flex: 1 1 260px; }
.ow-ld-title { font-size: 18px; font-weight: 700; color: var(--color-text); overflow-wrap: anywhere; }
.ow-ld-sub { font-size: var(--density-text-xs); color: var(--color-text-muted); margin-top: 2px; }
.ow-ld-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.ow-ld-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.ow-ld-block { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-base); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ow-ld-block-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ow-ld-block-title { font-size: var(--density-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.ow-ld-terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
.ow-ld-term { background: var(--color-surface-sunken); border-radius: var(--radius-sm); padding: 6px 10px; min-width: 0; }
.ow-ld-term-label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); font-weight: 600; }
.ow-ld-term-value { font-size: var(--density-text-sm); color: var(--color-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ow-ld-sched { width: 100%; border-collapse: collapse; font-size: var(--density-text-xs); margin-top: 4px; }
.ow-ld-sched th, .ow-ld-sched td { padding: 4px 8px; border-bottom: 1px solid var(--color-border); text-align: left; }
.ow-ld-sched th { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); background: var(--color-surface-sunken); }
.ow-ld-sched tbody tr:last-child td { border-bottom: none; }
.ow-ld-notes { font-size: var(--density-text-xs); color: var(--color-text-secondary); display: flex; flex-direction: column; gap: 2px; }
.ow-ld-pdf-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ow-ld-frame-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; background: #525659; }
.ow-ld-frame { display: block; width: 100%; height: 540px; border: 0; }
.ow-ld-revs { display: flex; flex-direction: column; gap: 6px; }
.ow-ld-rev { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: var(--density-text-xs); }
.ow-ld-rev .btn { padding-top: 2px; padding-bottom: 2px; text-decoration: none; }
.ow-ld-activity { padding-top: 4px; }
.ow-ld-reject { padding-left: 16px; border: 1px solid #FCA5A5; border-radius: var(--radius-sm); }
.ow-ld-round { background: var(--color-surface-sunken); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-base); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 8px; }
.ow-ld-round-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ow-ld-round-head a.ow-round-number { text-decoration: none; }
.ow-ld-round-head a.ow-round-number:hover { color: var(--color-primary); text-decoration: underline; }
.ow-ld-round-head .btn { margin-left: auto; }
.ow-ld-round-body { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.ow-ld-round-body .ol-goal { flex: 1 1 220px; }

/* ── Responsive: stack detail under the list on narrow screens ── */
@media (max-width: 1280px) {
  .ow-kpis { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .ow-kpi-goal { grid-column: 1 / -1; }
  .offers-shell.has-detail { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(200px, 45%) 6px minmax(0, 1fr); }
  .offers-shell.has-detail .offers-divider { cursor: default; border-left: none; border-top: 1px solid var(--color-border); }
  .offers-detail { padding-left: 0; padding-top: var(--space-2); }
  .ow-board { grid-auto-columns: minmax(230px, 1fr); }
}
@media (min-width: 2200px) {
  .ow-kpis { grid-template-columns: repeat(5, minmax(140px, 1fr)) minmax(320px, 2fr); }
  .offers-shell { --offers-detail-w: 960px; }
}


/* Standalone MIND workspace: same full-window navigation model as Offers. */
.mind-workspace-brand, .mind-workspace-nav { display: none; }
body.mind-workspace .sidebar,
body.mind-workspace .sidebar-toggle { display: none; }
body.mind-workspace .main-content { width: 100%; margin-left: 0; }
body.mind-workspace .mind-workspace-brand { display: flex; align-items: center; }
body.mind-workspace .mind-workspace-nav { display: flex; align-items: center; gap: var(--space-2); }
body.mind-workspace #mind-form-container { width: 100%; max-width: none; }
body.mind-workspace .topbar { min-height: 56px; height: auto; padding-top: 8px; padding-bottom: 8px; }
@media (max-width: 640px) {
  body.mind-workspace .topbar { flex-wrap: wrap; }
  body.mind-workspace .mind-workspace-nav { width: 100%; justify-content: flex-end; }
}
