/* ═══════════════════════════════════════════════════════════════════════════════
   Terceros CSS — Premium Design System (iEnTop ERP)
   Theme-aware via CSS variables, compatible with theme-switcher.js
   Reutiliza patrones de ConfigEmpresa con prefijo ter-
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Scope all resets to .ter-layout to avoid conflicts with iEnTop.css */
.ter-layout,
.ter-layout *,
.ter-layout *::before,
.ter-layout *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ── Map ter-* to ERP --color-* variables (auto theme-aware) ── */
  --ter-primary:        var(--color-accent, #6366f1);
  --ter-primary-hover:  var(--color-accent-hover, #4f46e5);
  --ter-primary-light:  var(--color-accent-subtle, rgba(99,102,241,.15));
  --ter-bg-main:        var(--color-bg-primary, #0f172a);
  --ter-bg-surface:     var(--color-bg-secondary, #1e293b);
  --ter-bg-card:        var(--color-bg-card, #1e293b);
  --ter-bg-input:       var(--color-bg-input, #334155);
  --ter-bg-sidebar:     var(--color-bg-sidebar, #0c1222);
  --ter-border:         var(--color-border, #334155);
  --ter-border-subtle:  var(--color-border, #334155);
  --ter-text-primary:   var(--color-text-primary, #f1f5f9);
  --ter-text-secondary: var(--color-text-secondary, #94a3b8);
  --ter-text-muted:     var(--color-text-muted, #64748b);
  --ter-text-on-primary:#ffffff;
  --ter-shadow:         var(--shadow-card, 0 1px 3px rgba(0,0,0,.4));
  --ter-success:        var(--color-success, #22c55e);
  --ter-warning:        var(--color-warning, #f59e0b);
  --ter-danger:         var(--color-danger, #ef4444);
  --ter-radius:         var(--radius, 0.5rem);
  --ter-radius-sm:      8px;
  --ter-radius-lg:      12px;
  --ter-transition:     var(--transition, 0.2s ease);
}

/* ─── TYPOGRAPHY ─── */
.ter-layout {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--ter-bg-main);
  color: var(--ter-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--ter-transition), color var(--ter-transition);
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT — SIDEBAR + MAIN
   ═══════════════════════════════════════════════════════════════ */
.ter-layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.ter-sidebar {
  width: 260px;
  background: var(--ter-bg-sidebar);
  color: #e0e7ff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: background var(--ter-transition);
}

.ter-sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ter-sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ter-sidebar-brand h1 i {
  color: var(--ter-primary);
  font-size: 22px;
}

.ter-sidebar-brand .ter-brand-sub {
  font-size: 11px;
  color: rgba(224, 231, 255, 0.5);
  margin-top: 4px;
  font-weight: 400;
}

/* ─── Sidebar Nav ─── */
.ter-sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.ter-nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(224, 231, 255, 0.35);
  margin-top: 8px;
}

.ter-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: rgba(224, 231, 255, 0.7);
  transition: all var(--ter-transition);
  border-left: 3px solid transparent;
  position: relative;
}

.ter-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.ter-nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #fff;
  border-left-color: var(--ter-primary);
  font-weight: 600;
}

.ter-nav-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.ter-nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.ter-nav-item .ter-nav-badge {
  margin-left: auto;
  background: var(--ter-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.ter-sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: rgba(224, 231, 255, 0.4);
}

/* ─── MAIN CONTENT ─── */
.ter-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

.ter-header {
  background: var(--ter-bg-surface);
  border-bottom: 1px solid var(--ter-border-subtle);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  transition: background var(--ter-transition), border var(--ter-transition);
}

.ter-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ter-header-left h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ter-header-left .ter-breadcrumb {
  font-size: 12px;
  color: var(--ter-text-muted);
}

.ter-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ter-content {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS (reutilizado de CE)
   ═══════════════════════════════════════════════════════════════ */
.ter-card {
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  box-shadow: 0 1px 3px var(--ter-shadow);
  transition: all var(--ter-transition);
}

.ter-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ter-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.ter-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ter-card-header h3 i {
  color: var(--ter-primary);
  font-size: 16px;
}

.ter-card-body {
  padding: 24px;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   FORM ELEMENTS (reutilizado de CE)
   ═══════════════════════════════════════════════════════════════ */
.ter-form-group {
  margin-bottom: 20px;
}

.ter-form-check {
  margin-bottom: 12px;
}

.ter-checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--ter-text-primary) !important;
}

.ter-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ter-primary);
  cursor: pointer;
}

.ter-input select,
.ter-form-group select.ter-input {
  appearance: auto;
  cursor: pointer;
}

.ter-form-group textarea.ter-input {
  min-height: 60px;
}

.ter-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ter-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ter-form-group label .required {
  color: var(--ter-danger);
  margin-left: 2px;
}

/* ── CIF/NIF Field Feedback ── */
.ter-field-feedback {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  min-height: 16px;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.ter-feedback-pending {
  color: #f59e0b;
  animation: terFeedbackPulse 1s ease infinite;
}

.ter-feedback-error {
  color: var(--ter-danger, #ef4444);
}

.ter-feedback-ok {
  color: var(--ter-success, #22c55e);
}

@keyframes terFeedbackPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ter-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--ter-bg-input);
  border: 1px solid var(--ter-border);
  border-radius: var(--ter-radius-sm);
  color: var(--ter-text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--ter-transition);
  outline: none;
}

.ter-input:focus {
  border-color: var(--ter-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ter-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

textarea.ter-input {
  min-height: 80px;
  resize: vertical;
}

select.ter-input {
  appearance: none;
  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='%236366f1' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.ter-form-row-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.ter-form-row-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.ter-form-row-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.ter-form-row-5 .ter-form-group {
  min-width: 0;
  overflow: hidden;
}

.ter-form-row-5 .ter-form-group label {
  font-size: 11px;
  margin-bottom: 4px;
}

.ter-form-row-5 .ter-input {
  padding: 6px 8px;
  font-size: 13px;
  min-height: auto;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ─── SECTION LABEL (drawer headers) ─── */
.ter-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ter-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ter-border-subtle);
}

.ter-section-label i {
  font-size: 14px;
}

/* ─── TOGGLE SWITCH (iOS-style, exact CE pattern) ─── */
.ter-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.ter-toggle-row + .ter-toggle-row {
  border-top: 1px solid var(--ter-border-subtle);
}

.ter-toggle-info {
  flex: 1;
}

.ter-toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ter-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ter-toggle-label input[type="checkbox"] {
  accent-color: var(--ter-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ─── AUTOCOMPLETE DROPDOWN (CNAE search) ─── */
.ter-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}

.ter-autocomplete-item:hover {
  background: rgba(99, 102, 241, .15);
}

/* ─── DOC TABLE (Socios) ─── */
.ter-doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ter-doc-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ter-text-muted, #64748b);
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
}

.ter-doc-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.06));
  color: var(--ter-text-primary, #e2e8f0);
}

.ter-doc-table tbody tr:hover {
  background: rgba(99, 102, 241, .06);
}

.ter-doc-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.ter-toggle-hint {
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-top: 2px;
}

.ter-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.ter-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ter-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--ter-border-subtle);
  border-radius: 24px;
  transition: background 0.25s ease;
}

.ter-toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ter-toggle input:checked + .ter-toggle-slider {
  background: var(--ter-primary);
}

.ter-toggle input:checked + .ter-toggle-slider::before {
  transform: translateX(20px);
}

/* ─── WIDE DRAWER ─── */
.ter-drawer.ter-drawer-wide {
  width: min(580px, 90vw);
}

/* ─── GHOST BUTTON (for list actions) ─── */
.ter-btn-ghost {
  background: transparent;
  color: var(--ter-text-muted);
  border: none;
  padding: 8px;
}

.ter-btn-ghost:hover {
  color: var(--ter-primary);
  background: rgba(99, 102, 241, 0.08);
}

.ter-divider {
  height: 1px;
  background: var(--ter-border-subtle);
  margin: 20px 0;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS (reutilizado de CE)
   ═══════════════════════════════════════════════════════════════ */
.ter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--ter-radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--ter-transition);
  outline: none;
  white-space: nowrap;
}

.ter-btn-primary {
  background: var(--ter-primary);
  color: var(--ter-text-on-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.ter-btn-primary:hover {
  background: var(--ter-primary-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

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

.ter-btn-secondary:hover {
  background: var(--ter-primary-light);
  border-color: var(--ter-primary);
  color: var(--ter-primary);
}

.ter-btn-danger {
  background: var(--ter-danger);
  color: #fff;
}

.ter-btn-ghost {
  background: transparent;
  color: var(--ter-text-muted);
  padding: 8px 12px;
}

.ter-btn-ghost:hover {
  color: var(--ter-primary);
  background: var(--ter-primary-light);
}

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

.ter-btn-icon {
  background: transparent;
  border: none;
  color: var(--ter-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--ter-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ter-btn-icon:hover {
  background: var(--ter-primary-light);
  color: var(--ter-primary);
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD — KPI STATS GRID
   ═══════════════════════════════════════════════════════════════ */
.ter-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ter-stat-card {
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--ter-transition);
  cursor: default;
}

.ter-stat-card:hover {
  border-color: var(--ter-primary);
  box-shadow: 0 4px 16px var(--ter-shadow);
  transform: translateY(-2px);
}

.ter-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ter-stat-icon.blue { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.ter-stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.ter-stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.ter-stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.ter-stat-icon.rose { background: rgba(244, 63, 94, 0.15); color: #fb7185; }

.ter-stat-info {
  flex: 1;
  min-width: 0;
}

.ter-stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.ter-stat-label {
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Dashboard layout */
.ter-dashboard-row {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
}

/* Chart bars */
.ter-chart-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ter-chart-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ter-chart-bar-label {
  min-width: 120px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ter-chart-bar-track {
  flex: 1;
  height: 28px;
  background: var(--ter-bg-secondary);
  border-radius: 6px;
  overflow: hidden;
}

.ter-chart-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
  min-width: 4px;
}

.ter-chart-bar-val {
  min-width: 80px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

/* Quick actions */
.ter-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ter-btn-block {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

/* ═══════════════════════════════════════════════════════════════
   TOOLBAR — Search + View Toggle + Filters
   ═══════════════════════════════════════════════════════════════ */
.ter-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ter-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.ter-search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border);
  border-radius: var(--ter-radius-sm);
  color: var(--ter-text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all var(--ter-transition);
}

.ter-search-wrap input:focus {
  border-color: var(--ter-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ter-search-wrap input::placeholder {
  color: var(--ter-text-muted);
}

.ter-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ter-text-muted);
  font-size: 13px;
  pointer-events: none;
}

.ter-view-toggle {
  display: flex;
  border: 1px solid var(--ter-border);
  border-radius: var(--ter-radius-sm);
  overflow: hidden;
}

.ter-view-toggle button {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--ter-text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--ter-transition);
}

.ter-view-toggle button:not(:last-child) {
  border-right: 1px solid var(--ter-border);
}

.ter-view-toggle button.active {
  background: var(--ter-primary);
  color: #fff;
}

.ter-view-toggle button:hover:not(.active) {
  background: var(--ter-primary-light);
  color: var(--ter-primary);
}

/* ═══════════════════════════════════════════════════════════════
   KANBAN BOARD
   ═══════════════════════════════════════════════════════════════ */
.ter-kanban {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  min-height: 0;
  flex: 1;
}

.ter-kanban::-webkit-scrollbar {
  height: 6px;
}

.ter-kanban::-webkit-scrollbar-thumb {
  background: var(--ter-border);
  border-radius: 3px;
}

.ter-column {
  flex: 1;
  min-width: 280px;
  max-width: 380px;
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  display: flex;
  flex-direction: column;
  transition: all var(--ter-transition);
}

.ter-column.drag-over {
  border-color: var(--ter-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2), 0 8px 24px var(--ter-shadow);
  background: color-mix(in srgb, var(--ter-primary) 4%, var(--ter-bg-surface));
}

.ter-column-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ter-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ter-column-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ter-column-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ter-column-name {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ter-column-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--ter-primary-light);
  color: var(--ter-primary);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

.ter-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}

.ter-column-body::-webkit-scrollbar {
  width: 4px;
}

.ter-column-body::-webkit-scrollbar-thumb {
  background: var(--ter-border);
  border-radius: 2px;
}

/* Empty column state */
.ter-column-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--ter-text-muted);
  font-size: 12px;
  opacity: 0.5;
  border: 2px dashed var(--ter-border-subtle);
  border-radius: var(--ter-radius-sm);
  margin: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   KANBAN CARDS
   ═══════════════════════════════════════════════════════════════ */
.ter-card-item {
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all var(--ter-transition);
  user-select: none;
  animation: ter-cardIn 0.3s ease-out;
}

.ter-card-item:hover {
  border-color: var(--ter-primary);
  box-shadow: 0 4px 12px var(--ter-shadow);
  transform: translateY(-1px);
}

.ter-card-item.selected {
  border-color: var(--ter-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.ter-card-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg) scale(0.98);
  box-shadow: 0 8px 24px var(--ter-shadow);
}

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

.ter-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.ter-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ter-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ter-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ter-card-sub {
  font-size: 11px;
  color: var(--ter-text-muted);
  margin-top: 1px;
}

.ter-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ter-card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ter-text-secondary);
}

.ter-card-meta-item i {
  font-size: 10px;
  color: var(--ter-text-muted);
}

.ter-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ter-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ter-tag-cliente { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.ter-tag-proveedor { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.ter-tag-colaborador { background: rgba(16, 185, 129, 0.15); color: #34d399; }

/* ═══════════════════════════════════════════════════════════════
   TABLE / LIST VIEW
   ═══════════════════════════════════════════════════════════════ */
.ter-table-wrap {
  overflow-x: auto;
}

.ter-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.ter-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ter-text-muted);
  border-bottom: 2px solid var(--ter-border-subtle);
  background: var(--ter-bg-surface);
  position: sticky;
  top: 0;
  z-index: 5;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ter-table thead th:hover {
  color: var(--ter-primary);
}

.ter-table tbody tr {
  transition: background var(--ter-transition);
  cursor: pointer;
}

.ter-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.ter-table tbody tr.selected {
  background: rgba(99, 102, 241, 0.08);
}

.ter-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ter-border-subtle);
  white-space: nowrap;
}

.ter-table .ter-table-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ter-table .ter-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   DRAWER / MODAL SYSTEM (reutilizado de CE)
   ═══════════════════════════════════════════════════════════════ */
.ter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.ter-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.ter-overlay.ter-overlay-center {
  justify-content: center;
  align-items: center;
}

.ter-drawer {
  width: 520px;
  max-width: 90vw;
  height: 100%;
  background: var(--ter-bg-surface);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.ter-overlay.open .ter-drawer {
  transform: translateX(0);
}

.ter-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ter-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ter-drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ter-text-primary);
}

.ter-drawer-header h3 i {
  color: var(--ter-primary);
}

.ter-drawer-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--ter-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all var(--ter-transition);
  line-height: 1;
}

.ter-drawer-close:hover {
  background: var(--ter-primary-light);
  color: var(--ter-primary);
}

.ter-drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 32px 24px 24px;
  scrollbar-gutter: stable;
}

.ter-drawer-body input,
.ter-drawer-body select,
.ter-drawer-body textarea {
  box-sizing: border-box;
  max-width: 100%;
}

.ter-drawer-body select,
select.ter-input {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 12px !important;
  padding-right: 28px;
}

.ter-drawer-body select::-ms-expand,
select.ter-input::-ms-expand {
  display: none !important;
}

.ter-drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ter-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Modal variation */
.ter-modal {
  background: var(--ter-bg-surface);
  border-radius: var(--ter-radius);
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.ter-overlay.open .ter-modal {
  transform: scale(1);
}

.ter-modal-header { padding: 20px 24px; border-bottom: 1px solid var(--ter-border-subtle); display: flex; align-items: center; justify-content: space-between; }
.ter-modal-body { flex: 1; overflow-y: auto; padding: 24px; }
.ter-modal-footer { padding: 16px 24px; border-top: 1px solid var(--ter-border-subtle); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══════════════════════════════════════════════════════════════
   DATA LIST (Direcciones, Bancario, Documentos)
   ═══════════════════════════════════════════════════════════════ */
.ter-data-list {
  display: flex;
  flex-direction: column;
}

.ter-data-list-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
}

.ter-data-list-item:last-child { border-bottom: none; }

.ter-data-list-item:hover {
  background: rgba(99, 102, 241, 0.04);
}

.ter-data-list-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ter-primary-light);
  color: var(--ter-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ter-data-list-content {
  flex: 1;
  min-width: 0;
}

.ter-data-list-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.ter-data-list-sub {
  font-size: 12px;
  color: var(--ter-text-muted);
}

.ter-data-list-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.ter-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ter-badge-primary { background: var(--ter-primary-light); color: var(--ter-primary); }
.ter-badge-success { background: rgba(16, 185, 129, 0.15); color: var(--ter-success); }
.ter-badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--ter-warning); }
.ter-badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--ter-danger); }

/* ═══════════════════════════════════════════════════════════════
   SMART SEARCH (reutilizado de CE)
   ═══════════════════════════════════════════════════════════════ */
.ter-smart-search {
  position: relative;
}

.ter-smart-search .ter-input {
  padding-right: 36px;
}

.ter-smart-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ter-text-muted);
  font-size: 12px;
  pointer-events: none;
}

.ter-smart-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border);
  border-radius: var(--ter-radius-sm);
  box-shadow: 0 8px 32px var(--ter-shadow);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
}

.ter-smart-dropdown.open { display: block; }

.ter-smart-dropdown-item {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--ter-transition);
  color: var(--ter-text-primary);
}

.ter-smart-dropdown-item:hover {
  background: var(--ter-primary-light);
}

.ter-smart-dropdown-crud {
  padding: 10px 14px;
  border-top: 1px solid var(--ter-border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ter-primary);
  cursor: pointer;
  transition: background var(--ter-transition);
}

.ter-smart-dropdown-crud:hover {
  background: var(--ter-primary-light);
}

/* ═══════════════════════════════════════════════════════════════
   UPLOAD ZONE
   ═══════════════════════════════════════════════════════════════ */
.ter-upload-zone {
  border: 2px dashed var(--ter-border);
  border-radius: var(--ter-radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--ter-transition);
  position: relative;
}

.ter-upload-zone:hover,
.ter-upload-zone.ter-drag-over {
  border-color: var(--ter-primary);
  background: rgba(99, 102, 241, 0.04);
}

.ter-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ter-upload-zone i {
  font-size: 32px;
  color: var(--ter-text-muted);
  margin-bottom: 8px;
}

.ter-upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ter-text-primary);
}

.ter-upload-hint {
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   LOGO/AVATAR AREA
   ═══════════════════════════════════════════════════════════════ */
.ter-logo-area {
  width: 100px;
  height: 100px;
  border-radius: 16px;
  border: 2px dashed var(--ter-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all var(--ter-transition);
  background: var(--ter-bg-input);
  overflow: hidden;
  flex-shrink: 0;
}

.ter-logo-area:hover {
  border-color: var(--ter-primary);
  background: var(--ter-primary-light);
}

.ter-logo-area i { font-size: 24px; color: var(--ter-text-muted); }
.ter-logo-area span { font-size: 10px; color: var(--ter-text-muted); }
.ter-logo-area img { width: 100%; height: 100%; object-fit: cover; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.ter-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ter-text-muted);
}

.ter-empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.ter-empty-state p {
  font-size: 14px;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   SPINNER
   ═══════════════════════════════════════════════════════════════ */
.ter-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ter-border-subtle);
  border-top-color: var(--ter-primary);
  border-radius: 50%;
  animation: ter-spin 0.7s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════
   DETAIL PANEL TABS (Ficha 360°)
   ═══════════════════════════════════════════════════════════════ */
.ter-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 8px 0;
}

.ter-detail-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ter-text-muted);
  cursor: pointer;
  transition: all var(--ter-transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid var(--ter-border-subtle);
  border-radius: 8px;
  font-family: inherit;
}

.ter-detail-tab:hover {
  color: var(--ter-primary);
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
}

.ter-detail-tab.active {
  color: #fff;
  background: var(--ter-primary);
  border-color: var(--ter-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.ter-tab-content {
  animation: ter-fadeIn 0.2s ease-out;
}

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

/* ═══════════════════════════════════════════════════════════════
   CONFIRM DIALOG (within drawer system)
   ═══════════════════════════════════════════════════════════════ */
.ter-confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 16px;
}

.ter-confirm-danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.ter-confirm-warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.ter-confirm-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.ter-confirm-msg { font-size: 14px; color: var(--ter-text-secondary); text-align: center; line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════════
   TIMELINE
   ═══════════════════════════════════════════════════════════════ */
.ter-timeline {
  position: relative;
  padding-left: 28px;
}

.ter-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ter-border-subtle);
}

.ter-timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.ter-timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ter-primary);
  border: 2px solid var(--ter-bg-card);
  z-index: 1;
}

.ter-timeline-date {
  font-size: 11px;
  color: var(--ter-text-muted);
  margin-bottom: 4px;
}

.ter-timeline-text {
  font-size: 13px;
  color: var(--ter-text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   NAV SECTION DIVIDER
   ═══════════════════════════════════════════════════════════════ */
.ter-nav-divider {
  height: 1px;
  background: var(--ter-border-subtle);
  margin: 12px 16px;
}

/* ═══════════════════════════════════════════════════════════════
   FILTER BAR (used in Docs, Comms, Audit)
   ═══════════════════════════════════════════════════════════════ */
.ter-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ter-filter-chip {
  padding: 6px 14px;
  border: 1px solid var(--ter-border);
  border-radius: 20px;
  background: transparent;
  color: var(--ter-text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--ter-transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ter-filter-chip:hover {
  border-color: var(--ter-primary);
  color: var(--ter-primary);
  background: var(--ter-primary-light);
}

.ter-filter-chip.active {
  background: var(--ter-primary);
  color: #fff;
  border-color: var(--ter-primary);
}

/* ═══════════════════════════════════════════════════════════════
   KPI STRIP (compact horizontal KPI bar)
   ═══════════════════════════════════════════════════════════════ */
.ter-kpi-strip {
  display: flex;
  gap: 0;
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.ter-kpi-mini {
  flex: 1;
  padding: 16px 20px;
  text-align: center;
  border-right: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
}

.ter-kpi-mini:last-child { border-right: none; }

.ter-kpi-mini:hover {
  background: rgba(99, 102, 241, 0.03);
}

.ter-kpi-mini-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ter-text-primary);
}

.ter-kpi-mini-label {
  font-size: 11px;
  color: var(--ter-text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   AGENDA — Event Timeline
   ═══════════════════════════════════════════════════════════════ */
.ter-event-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ter-event-card {
  display: flex;
  gap: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
}

.ter-event-card:last-child { border-bottom: none; }

.ter-event-card:hover {
  background: rgba(99, 102, 241, 0.03);
}

.ter-event-card.ter-event-past {
  opacity: 0.55;
}

.ter-event-date-col {
  width: 56px;
  text-align: center;
  flex-shrink: 0;
  padding: 4px 8px;
}

.ter-event-day {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--ter-text-primary);
}

.ter-event-month {
  font-size: 11px;
  font-weight: 600;
  color: var(--ter-text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.ter-event-line {
  width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding-top: 8px;
  position: relative;
}

.ter-event-line::after {
  content: '';
  position: absolute;
  top: 22px;
  bottom: -16px;
  width: 2px;
  background: var(--ter-border-subtle);
}

.ter-event-card:last-child .ter-event-line::after { display: none; }

.ter-event-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  z-index: 1;
  box-shadow: 0 0 0 3px var(--ter-bg-card);
}

.ter-event-body {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
}

.ter-event-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ter-text-primary);
  margin-bottom: 4px;
}

.ter-event-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-bottom: 6px;
}

.ter-event-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ter-event-meta i { font-size: 10px; }

.ter-event-cal-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ter-event-desc {
  font-size: 12px;
  color: var(--ter-text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.ter-prio-alta { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.ter-prio-media { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.ter-prio-baja { background: rgba(16, 185, 129, 0.12); color: #10b981; }

/* ═══════════════════════════════════════════════════════════════
   CRM — Deal Cards + Activity Feed
   ═══════════════════════════════════════════════════════════════ */
.ter-deals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.ter-deal-card {
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  padding: 18px;
  transition: all var(--ter-transition);
}

.ter-deal-card:hover {
  border-color: var(--ter-primary);
  box-shadow: 0 4px 16px var(--ter-shadow);
  transform: translateY(-1px);
}

.ter-deal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.ter-deal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ter-text-primary);
}

.ter-deal-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--ter-primary);
  white-space: nowrap;
}

.ter-deal-stage {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ter-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ter-stage-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-secondary);
}

.ter-deal-prob {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.ter-prob-high { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.ter-prob-med { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.ter-prob-low { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.ter-deal-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-bottom: 10px;
}

.ter-deal-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ter-deal-meta i { font-size: 10px; }

.ter-deal-actions {
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--ter-border-subtle);
  padding-top: 10px;
}

.ter-card-subheader {
  padding: 16px 0 8px;
  border-top: 1px solid var(--ter-border-subtle);
}

.ter-card-subheader h4 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ter-text-primary);
}

.ter-card-subheader h4 i { color: var(--ter-primary); font-size: 13px; }

.ter-activity-feed {
  display: flex;
  flex-direction: column;
}

.ter-feed-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
}

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

.ter-feed-item:hover { background: rgba(99, 102, 241, 0.03); }

.ter-feed-dot {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.ter-feed-body { flex: 1; min-width: 0; }

.ter-feed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-primary);
}

.ter-feed-user {
  font-weight: 400;
  color: var(--ter-text-muted);
  font-size: 12px;
}

.ter-feed-detail {
  font-size: 12px;
  color: var(--ter-text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.ter-feed-date {
  font-size: 11px;
  color: var(--ter-text-muted);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   COMUNICACIONES — Message Cards
   ═══════════════════════════════════════════════════════════════ */
.ter-comm-list {
  display: flex;
  flex-direction: column;
}

.ter-comm-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
  cursor: pointer;
}

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

.ter-comm-item:hover { background: rgba(99, 102, 241, 0.03); }

.ter-comm-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ter-comm-body { flex: 1; min-width: 0; }

.ter-comm-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ter-comm-participants {
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-top: 2px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.ter-comm-duration {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  background: var(--ter-bg-surface);
  border-radius: 4px;
  font-size: 11px;
}

.ter-comm-preview {
  font-size: 12px;
  color: var(--ter-text-secondary);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ter-comm-date {
  font-size: 11px;
  color: var(--ter-text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   AUDIT TRAIL — System Activity
   ═══════════════════════════════════════════════════════════════ */
.ter-audit-timeline {
  display: flex;
  flex-direction: column;
}

.ter-audit-entry {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: background var(--ter-transition);
}

.ter-audit-entry:last-child { border-bottom: none; }

.ter-audit-entry:hover { background: rgba(99, 102, 241, 0.03); }

.ter-audit-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.ter-audit-body { flex: 1; min-width: 0; }

.ter-audit-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--ter-text-primary);
  line-height: 1.4;
}

.ter-audit-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  align-items: center;
}

.ter-audit-module {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.ter-audit-user, .ter-audit-date {
  font-size: 11px;
  color: var(--ter-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ter-audit-user i, .ter-audit-date i { font-size: 10px; }

/* ═══════════════════════════════════════════════════════════════
   DOCUMENTS — Enhanced Grid
   ═══════════════════════════════════════════════════════════════ */
.ter-doc-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 16px;
}

.ter-doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ter-border-subtle);
  transition: all var(--ter-transition);
  cursor: pointer;
}

.ter-doc-card:last-child { border-bottom: none; }

.ter-doc-card:hover {
  background: rgba(99, 102, 241, 0.04);
}

.ter-doc-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ter-bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ter-doc-info { flex: 1; min-width: 0; }

.ter-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ter-doc-meta {
  font-size: 11px;
  color: var(--ter-text-muted);
  margin-top: 2px;
}

.ter-doc-card .ter-doc-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--ter-transition);
}

.ter-doc-card:hover .ter-doc-actions { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   FINANCIERO — KPI Grid + Risk Bar + Invoices
   ═══════════════════════════════════════════════════════════════ */
.ter-fin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ter-fin-kpi {
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  padding: 16px;
  text-align: center;
  transition: all var(--ter-transition);
}

.ter-fin-kpi:hover {
  border-color: var(--ter-primary);
  box-shadow: 0 4px 12px var(--ter-shadow);
  transform: translateY(-1px);
}

.ter-fin-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin: 0 auto 10px;
}

.ter-fin-kpi-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ter-text-primary);
}

.ter-fin-kpi-label {
  font-size: 11px;
  color: var(--ter-text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.ter-risk-section {
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  padding: 20px;
}

.ter-risk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ter-risk-label {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ter-risk-values {
  font-size: 13px;
  color: var(--ter-text-muted);
  font-weight: 500;
}

.ter-risk-bar {
  height: 10px;
  background: var(--ter-border-subtle);
  border-radius: 5px;
  overflow: hidden;
}

.ter-risk-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.ter-risk-pct {
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  text-align: right;
}

.ter-invoice-list {
  display: flex;
  flex-direction: column;
}

.ter-invoice-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ter-border-subtle);
  font-size: 13px;
}

.ter-invoice-row:last-child { border-bottom: none; }

.ter-invoice-num {
  font-weight: 600;
  color: var(--ter-primary);
  min-width: 100px;
}

.ter-invoice-date {
  color: var(--ter-text-muted);
  min-width: 90px;
}

.ter-invoice-type {
  font-size: 12px;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ter-invoice-amount {
  font-weight: 700;
  flex: 1;
  text-align: right;
  padding-right: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   PROYECTOS — Project Cards + Task Checklists
   ═══════════════════════════════════════════════════════════════ */
.ter-projects-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ter-project-card {
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  padding: 20px;
  transition: all var(--ter-transition);
}

.ter-project-card:hover {
  border-color: var(--ter-primary);
  box-shadow: 0 4px 16px var(--ter-shadow);
}

.ter-project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}

.ter-project-title-area { flex: 1; min-width: 0; }

.ter-project-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ter-text-primary);
  margin-bottom: 2px;
}

.ter-project-code {
  font-size: 12px;
  color: var(--ter-text-muted);
  font-weight: 500;
}

.ter-project-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ter-project-progress {
  margin-bottom: 12px;
}

.ter-project-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-bottom: 6px;
}

.ter-project-progress-pct {
  font-weight: 700;
  color: var(--ter-text-primary);
}

.ter-project-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ter-text-muted);
  margin-bottom: 12px;
}

.ter-project-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ter-project-meta i { font-size: 10px; }

.ter-project-budget {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--ter-border-subtle);
  border-bottom: 1px solid var(--ter-border-subtle);
  font-size: 12px;
  margin-bottom: 12px;
}

.ter-project-budget-label {
  color: var(--ter-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.ter-project-budget-vals {
  color: var(--ter-text-secondary);
  font-weight: 500;
}

.ter-project-tasks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ter-project-task {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ter-text-secondary);
  padding: 4px 0;
}

.ter-project-task i { font-size: 14px; flex-shrink: 0; }

.ter-project-task span:first-of-type {
  flex: 1;
  min-width: 0;
}

.ter-project-task-date {
  font-size: 11px;
  color: var(--ter-text-muted);
  flex-shrink: 0;
}

.ter-project-task-more {
  font-size: 12px;
  color: var(--ter-primary);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.ter-project-task-more:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════
   EDITOR DE TIPOS — 3-Column Split Layout
   ═══════════════════════════════════════════════════════════════ */
.ter-tipos-editor {
  display: grid;
  grid-template-columns: 260px 1fr 200px;
  gap: 16px;
  min-height: 0;
  height: calc(100vh - 140px);
}

.ter-tipos-left {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ter-tipos-center {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.ter-tipos-bigcard {
  background: var(--ter-bg-card);
  border: 2px dashed var(--ter-border);
  border-radius: var(--ter-radius);
  padding: 24px;
  transition: all 0.3s ease;
  min-height: 200px;
}

.ter-tipos-bigcard.ter-tipos-dropzone-active {
  border-color: var(--ter-primary);
  border-style: solid;
  background: rgba(99, 102, 241, 0.04);
}

.ter-tipos-bigcard.ter-tipos-dropzone-hover {
  border-color: var(--ter-primary);
  border-style: solid;
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 8px 32px var(--ter-shadow);
  transform: scale(1.01);
}

.ter-tipos-empty-card {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ter-tipos-bigcard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.ter-tipos-bigcard-info { flex: 1; min-width: 0; }

.ter-tipos-bigcard-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--ter-text-primary);
  letter-spacing: -0.01em;
}

.ter-tipos-bigcard-sub {
  font-size: 13px;
  color: var(--ter-text-muted);
  margin-top: 2px;
}

.ter-tipos-bigcard-meta {
  font-size: 12px;
  color: var(--ter-text-secondary);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ter-tipos-assigned-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.ter-tipos-assigned-label i { color: var(--ter-success); }

.ter-tipos-assigned {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ter-tipos-assigned-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--ter-bg-surface);
  border: 1px solid var(--ter-border);
  cursor: grab;
  transition: all var(--ter-transition);
  user-select: none;
}

.ter-tipos-assigned-chip:hover:not(.ter-tipos-locked) {
  border-color: var(--ter-primary);
  box-shadow: 0 2px 8px var(--ter-shadow);
}

.ter-tipos-assigned-chip.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.ter-tipos-locked {
  opacity: 0.7;
  cursor: default;
  border-style: dashed;
}

.ter-tipos-locked i.fa-lock {
  font-size: 10px;
  color: var(--ter-text-muted);
  margin-left: 4px;
}

.ter-tipos-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ter-tipos-grip {
  color: var(--ter-text-muted);
  font-size: 11px;
  cursor: grab;
  margin-left: 4px;
}

.ter-tipos-remove-zone {
  padding: 14px;
  border: 2px dashed transparent;
  border-radius: var(--ter-radius-sm);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: transparent;
  transition: all 0.3s ease;
  margin-bottom: 8px;
}

.ter-tipos-removezone-active {
  border-color: var(--ter-danger) !important;
  color: var(--ter-danger) !important;
  background: rgba(239, 68, 68, 0.04);
}

.ter-tipos-removezone-hover {
  border-color: var(--ter-danger) !important;
  color: #fff !important;
  background: var(--ter-danger) !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
  transform: scale(1.02);
}

.ter-tipos-hint {
  font-size: 12px;
  color: var(--ter-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--ter-bg-surface);
  border-radius: var(--ter-radius-sm);
}

.ter-tipos-hint i { color: var(--ter-primary); }

/* Terceros list — full height left panel */
.ter-tipos-terceros-list {
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ter-tipos-list-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ter-border-subtle);
  flex-shrink: 0;
}

.ter-tipos-list-header h4 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ter-tipos-list-header h4 i { color: var(--ter-primary); }

.ter-tipos-list-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--ter-border-subtle);
  flex-shrink: 0;
}

.ter-tipos-list-search .ter-search-wrap {
  max-width: none;
}

.ter-tipos-terceros-grid {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ter-tipos-tercero-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--ter-transition);
  border-bottom: 1px solid var(--ter-border-subtle);
}

.ter-tipos-tercero-mini:last-child { border-bottom: none; }

.ter-tipos-tercero-mini:hover {
  background: rgba(99, 102, 241, 0.04);
}

.ter-tipos-tercero-mini.selected {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--ter-primary);
}

.ter-tipos-section-divider {
  height: 1px;
  background: var(--ter-border-subtle);
  margin: 12px 0;
}

/* Right panel: tipo palette */
.ter-tipos-right {
  background: var(--ter-bg-card);
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ter-tipos-right-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ter-border-subtle);
}

.ter-tipos-right-header h4 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ter-tipos-right-header h4 i { color: var(--ter-primary); }

.ter-tipos-palette {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ter-tipos-palette-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ter-border-subtle);
  border-radius: var(--ter-radius-sm);
  cursor: grab;
  transition: all var(--ter-transition);
  user-select: none;
}

.ter-tipos-palette-card:hover:not(.ter-tipos-palette-disabled) {
  border-color: var(--ter-primary);
  box-shadow: 0 2px 12px var(--ter-shadow);
  transform: translateY(-1px);
}

.ter-tipos-palette-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.ter-tipos-palette-disabled {
  opacity: 0.5;
  cursor: default;
  background: var(--ter-bg-surface);
}

.ter-tipos-palette-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ter-tipos-palette-info { flex: 1; min-width: 0; }

.ter-tipos-palette-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ter-text-primary);
}

.ter-tipos-palette-code {
  font-size: 11px;
  color: var(--ter-text-muted);
}

.ter-tipos-palette-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
  border-radius: var(--ter-radius-sm);
  padding: 2px;
}

.ter-tipos-palette-drop-hover {
  background: rgba(239, 68, 68, 0.06);
  box-shadow: inset 0 0 0 2px var(--ter-danger);
  border-radius: var(--ter-radius-sm);
}

/* ─── ICON BUTTONS (used in doc table, tree actions, etc.) ─── */
.ter-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,.06);
  color: var(--ter-text-secondary, #94a3b8);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, color .15s;
}

.ter-btn-icon:hover {
  background: rgba(99, 102, 241, .15);
  color: var(--ter-text-primary, #e2e8f0);
}

/* ═══════════════════════════════════════════════════════════════
   BASE DOCUMENTAL (CE doc-manager pattern)
   ═══════════════════════════════════════════════════════════════ */
.ter-doc-manager {
  display: flex;
  border: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
  border-radius: var(--ter-radius-lg, 12px);
  overflow: hidden;
  min-height: 500px;
  background: var(--ter-bg-card);
}

.ter-doc-tree {
  width: 280px;
  min-width: 220px;
  border-right: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
  overflow-y: auto;
  background: rgba(0,0,0,.1);
}

.ter-doc-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.ter-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
  color: var(--ter-text-primary, #e2e8f0);
}

.ter-tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ter-text-secondary, #94a3b8);
  transition: background .15s;
  border-left: 3px solid transparent;
}

.ter-tree-node:hover {
  background: rgba(99, 102, 241, .08);
}

.ter-tree-active {
  background: rgba(99, 102, 241, .12) !important;
  border-left-color: var(--ter-primary, #6366f1);
  color: var(--ter-text-primary, #e2e8f0);
  font-weight: 600;
}

.ter-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  font-size: 10px;
  flex-shrink: 0;
  color: var(--ter-text-muted, #64748b);
}

.ter-tree-icon {
  font-size: 13px;
  flex-shrink: 0;
  color: var(--ter-primary, #6366f1);
  opacity: .8;
}

.ter-tree-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ter-tree-count {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,.06);
  color: var(--ter-text-muted, #64748b);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.ter-tree-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.ter-tree-node:hover .ter-tree-actions {
  display: flex;
}

.ter-tree-node:hover .ter-tree-count {
  display: none;
}

.ter-docpanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
}

.ter-doc-file-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ter-doc-file-icon {
  font-size: 20px;
  color: var(--ter-primary, #6366f1);
  flex-shrink: 0;
  opacity: .7;
}

.ter-doc-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ter-text-primary, #e2e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.ter-doc-file-meta {
  font-size: 11px;
  color: var(--ter-text-muted, #64748b);
  margin-top: 2px;
}

.ter-doc-desc {
  font-size: 12px;
  color: var(--ter-text-secondary, #94a3b8);
}

.ter-doc-row:hover {
  background: rgba(99, 102, 241, .06);
}

/* Document table */
.ter-doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ter-doc-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ter-text-muted, #64748b);
  padding: 10px 14px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.08));
}

.ter-doc-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,.04));
  vertical-align: middle;
}

/* Override: doc actions in table are ALWAYS visible, not hidden like tree actions */
.ter-doc-table .ter-doc-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .ter-kanban {
    flex-direction: column;
  }
  .ter-column {
    max-width: none;
    min-width: 0;
  }
  .ter-tipos-editor {
    grid-template-columns: 1fr;
    height: auto;
  }
  .ter-tipos-left {
    max-height: 300px;
  }
  .ter-tipos-right {
    position: static;
  }
  .ter-dashboard-row {
    flex-direction: column;
  }
  .ter-dashboard-row .ter-card {
    flex: 1 1 auto !important;
  }
}

@media (max-width: 768px) {
  .ter-sidebar {
    display: none;
  }
  .ter-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .ter-content {
    padding: 16px;
  }
  .ter-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ter-card-header {
    padding: 14px 16px;
  }
  .ter-card-body {
    padding: 16px;
  }
  .ter-kpi-strip {
    flex-wrap: wrap;
  }
  .ter-kpi-mini {
    min-width: 45%;
    flex: 1;
  }
  .ter-fin-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ter-invoice-row {
    font-size: 12px;
    gap: 8px;
  }
  .ter-chart-bar-label {
    min-width: 90px;
    font-size: 11px;
  }
  .ter-chart-bar-val {
    min-width: 60px;
    font-size: 12px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   OVERLAY / DRAWER / MODAL SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* Overlay backdrop */
.ter-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ter-overlay.open {
  opacity: 1;
}

.ter-overlay.ter-overlay-center {
  justify-content: center;
  align-items: center;
}

/* Right-side drawer */
.ter-drawer {
  width: 480px;
  max-width: 90vw;
  height: 100%;
  background: var(--ter-bg-card, #1e1b4b);
  border-left: 1px solid var(--ter-border, rgba(255,255,255,0.1));
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
}

.ter-overlay.open .ter-drawer {
  transform: translateX(0);
}

.ter-drawer-wide {
  width: 640px;
}

.ter-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.ter-drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ter-text-primary, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.ter-drawer-header h3 i {
  color: var(--ter-primary, #6366f1);
}

.ter-drawer-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ter-border-subtle, rgba(255,255,255,0.08));
  color: var(--ter-text-secondary, #94a3b8);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ter-drawer-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--ter-danger, #ef4444);
  border-color: var(--ter-danger, #ef4444);
}

.ter-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.ter-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--ter-border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

/* Centered modal variant */
.ter-modal {
  width: 560px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--ter-bg-card, #1e1b4b);
  border: 1px solid var(--ter-border, rgba(255,255,255,0.1));
  border-radius: var(--ter-radius-lg, 12px);
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.ter-overlay.open .ter-modal {
  transform: scale(1) translateY(0);
}

.ter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--ter-border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.ter-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ter-text-primary, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.ter-modal-header h3 i {
  color: var(--ter-primary, #6366f1);
}

.ter-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.ter-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--ter-border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

/* Form helpers inside drawers/modals */
.ter-form-group {
  margin-bottom: 16px;
}

.ter-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ter-text-secondary, #94a3b8);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ter-form-group label .required {
  color: var(--ter-danger, #ef4444);
}

.ter-form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ter-form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .ter-drawer {
    width: 100%;
    max-width: 100%;
  }
  .ter-form-row-2,
  .ter-form-row-3 {
    grid-template-columns: 1fr;
  }
}
