/* ============================================
   BAOGIA.MMCORP — Component Styles
   ============================================ */

/* ─── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}

.btn:hover::before { background: rgba(255,255,255,0.05); }
.btn:active::before { background: rgba(0,0,0,0.1); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.btn-primary {
  background: var(--color-brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(245, 158, 11, 0.4); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.btn-success:hover { background: var(--color-success); color: #fff; }

.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }

.btn-info { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }
.btn-info:hover { background: var(--color-info); color: #fff; }

/* Button Sizes */
.btn-xs { padding: 5px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); gap: 4px; }
.btn-sm { padding: 7px 12px; font-size: var(--text-xs); }
.btn-lg { padding: 12px var(--space-6); font-size: var(--text-md); border-radius: var(--radius-lg); }
.btn-xl { padding: 16px var(--space-8); font-size: var(--text-lg); border-radius: var(--radius-lg); }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-md); }
.btn-icon-sm { padding: 6px; width: 28px; height: 28px; border-radius: var(--radius-sm); }

/* ─── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card:hover { border-color: var(--border-default); }

.card-hover:hover {
  border-color: var(--border-brand);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stat Card */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.accent-amber::before { background: var(--color-brand-gradient); }
.stat-card.accent-blue::before { background: var(--color-brand-gradient-blue); }
.stat-card.accent-green::before { background: var(--color-brand-gradient-green); }
.stat-card.accent-purple::before { background: linear-gradient(135deg, #8B5CF6, #EC4899); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: var(--space-4);
  flex-shrink: 0;
}

.stat-icon.amber { background: var(--color-warning-bg); }
.stat-icon.blue { background: var(--color-info-bg); }
.stat-icon.green { background: var(--color-success-bg); }
.stat-icon.purple { background: var(--color-purple-bg); }

.stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
}

.stat-change.up { background: var(--color-success-bg); color: var(--color-success); }
.stat-change.down { background: var(--color-danger-bg); color: var(--color-danger); }

/* ─── Badges / Tags ──────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-sm { padding: 2px 8px; font-size: 10px; }

/* Status Badges */
.badge-draft { background: rgba(100,116,139,0.15); color: #94A3B8; border-color: rgba(100,116,139,0.3); }
.badge-review { background: var(--color-info-bg); color: #60A5FA; border-color: var(--color-info-border); }
.badge-approved { background: var(--color-success-bg); color: #34D399; border-color: var(--color-success-border); }
.badge-sent { background: var(--color-purple-bg); color: #A78BFA; border-color: var(--color-purple-border); }
.badge-discussing { background: var(--color-warning-bg); color: #FCD34D; border-color: var(--color-warning-border); }
.badge-revised { background: rgba(249,115,22,0.12); color: #FB923C; border-color: rgba(249,115,22,0.3); }
.badge-won { background: var(--color-success-bg); color: #34D399; border-color: var(--color-success-border); }
.badge-lost { background: var(--color-danger-bg); color: #F87171; border-color: var(--color-danger-border); }
.badge-archived { background: rgba(71,85,105,0.15); color: #64748B; border-color: rgba(71,85,105,0.3); }

/* BU Badges */
.badge-bu { background: rgba(59,130,246,0.12); color: #60A5FA; border-color: rgba(59,130,246,0.3); }

/* Margin Badges */
.badge-margin-high { background: var(--color-success-bg); color: #34D399; border-color: var(--color-success-border); }
.badge-margin-ok { background: var(--color-warning-bg); color: #FCD34D; border-color: var(--color-warning-border); }
.badge-margin-low { background: var(--color-danger-bg); color: #F87171; border-color: var(--color-danger-border); }

/* ─── Forms ──────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 3px;
}

.form-control {
  width: 100%;
  padding: 10px var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  transition: all var(--transition-fast);
  appearance: none;
}

.form-control::placeholder { color: var(--text-disabled); }

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
  background: var(--bg-card);
}

.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-control-sm { padding: 7px var(--space-3); font-size: var(--text-sm); }
.form-control-lg { padding: 14px var(--space-4); font-size: var(--text-md); }

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

/* Input Groups */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; border-left: none; }
.input-group .input-addon {
  padding: 0 var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  display: flex; align-items: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  cursor: pointer;
  accent-color: var(--color-brand-primary);
  flex-shrink: 0;
}

/* Search Input */
.search-input-wrap {
  position: relative;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px; height: 16px;
}

.search-input-wrap .form-control {
  padding-left: 34px;
}

/* ─── Tables ─────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

table, .table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead {
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table th {
  padding: 14px var(--space-5);
  text-align: left;
  font-size: 11px; /* Smaller, cleaner */
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em; /* Slightly wider */
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table td {
  padding: 16px var(--space-5); /* More spacious */
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover { background: var(--bg-card-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table .col-actions { text-align: right; width: 120px; }

/* ─── Library Grid & Cards ───────────────────── */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.lib-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

.lib-card:hover {
  border-color: var(--border-brand);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lib-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-brand-gradient-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--border-subtle);
}

.lib-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  justify-content: space-between;
}

/* ─── Modals ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 28, 0.8);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: fadeInScale 0.2s ease;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ─── Tabs ───────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-6);
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -1px;
  font-family: var(--font-body);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--color-brand-primary);
  border-bottom-color: var(--color-brand-primary);
}

/* ─── Dropdown ───────────────────────────────── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}

.dropdown-menu.left { right: auto; left: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.dropdown-item:hover { background: var(--bg-card); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* ─── Toast Notifications ────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}

.toast-success { border-left: 3px solid var(--color-success); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-error { border-left: 3px solid var(--color-danger); }
.toast-info { border-left: 3px solid var(--color-info); }

/* ─── AI Panel ───────────────────────────────── */
.ai-panel {
  background: linear-gradient(160deg, #10192E 0%, #0F1729 100%);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: sticky;
  top: var(--space-6);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid rgba(245, 158, 11, 0.15);
  background: rgba(245, 158, 11, 0.06);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-brand-primary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ai-section {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.ai-section:last-child { border-bottom: none; }

.ai-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ai-recommendation-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-recommendation-card:hover {
  border-color: var(--border-brand);
  background: rgba(245, 158, 11, 0.04);
}

.ai-recommendation-card.selected {
  border-color: var(--border-brand);
  background: rgba(245, 158, 11, 0.08);
}

.ai-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: #F87171;
  margin-bottom: var(--space-2);
}

.ai-tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: #60A5FA;
  margin-bottom: var(--space-2);
}

/* ─── Progress / Steps ───────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  flex: 1;
}

.step-circle {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 2px solid var(--border-default);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition-base);
  z-index: 1;
}

.step.active .step-circle {
  background: var(--color-brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.step.done .step-circle {
  background: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-subtle);
  transition: background var(--transition-slow);
}

.step.done + .step .step-line,
.step.done .step-line { background: var(--color-success); }

.step-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}

.step.active .step-label { color: var(--color-brand-primary); }
.step.done .step-label { color: var(--color-success); }

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Line Item Row ──────────────────────────── */
.line-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 80px 110px 80px 110px 36px;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: all var(--transition-fast);
}

.line-item-row:hover { border-color: var(--border-default); background: var(--bg-card); }
.line-item-row.group-header {
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-3) var(--space-1);
}

/* ─── Margin Bar ─────────────────────────────── */
.margin-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.margin-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.margin-bar-fill.healthy { background: linear-gradient(90deg, var(--color-success), #34D399); }
.margin-bar-fill.ok { background: linear-gradient(90deg, #F59E0B, #FCD34D); }
.margin-bar-fill.low { background: linear-gradient(90deg, var(--color-danger), #F87171); }

/* ─── Empty State ────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 320px;
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

/* ─── Filter Bar ─────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.filter-chip.active { background: rgba(245,158,11,0.12); border-color: var(--border-brand); color: var(--color-brand-primary); }

/* ─── Page Header ────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ─── Tooltip ────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--text-xs);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
  border: 1px solid var(--border-default);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ─── Kanban ─────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-4);
}

.kanban-col {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.kanban-col-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.kanban-count {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.kanban-card:hover { border-color: var(--border-brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ─── Package Card ───────────────────────────── */
.package-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

.package-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-default); }

.package-card-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.package-card-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}

.package-card.basic .package-card-header::before { background: linear-gradient(90deg, #64748B, #94A3B8); }
.package-card.pro .package-card-header::before { background: var(--color-brand-gradient-blue); }
.package-card.premium .package-card-header::before { background: var(--color-brand-gradient); }

.package-tier {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-2);
}

.package-card.basic .package-tier { color: var(--text-muted); }
.package-card.pro .package-tier { color: var(--color-info); }
.package-card.premium .package-tier { color: var(--color-brand-primary); }

.package-price {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.package-price-unit {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

.package-card-body {
  padding: var(--space-5);
  flex: 1;
}

.package-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.package-feature .icon-check { color: var(--color-success); flex-shrink: 0; }
.package-feature .icon-x { color: var(--text-disabled); flex-shrink: 0; }

/* ─── Quotation Preview Card ─────────────────── */
.quote-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.quote-card:hover { border-color: var(--border-default); border-left-color: inherit; background: var(--bg-card-hover); }

.quote-card.status-draft { border-left-color: var(--status-draft); }
.quote-card.status-review { border-left-color: var(--status-review); }
.quote-card.status-approved { border-left-color: var(--status-approved); }
.quote-card.status-sent { border-left-color: var(--status-sent); }
.quote-card.status-discussing { border-left-color: var(--status-discussing); }
.quote-card.status-won { border-left-color: var(--status-won); }
.quote-card.status-lost { border-left-color: var(--status-lost); }

/* ═══════════════════════════════════════════════
   BUILDER — Quote Workspace Specific Styles
   ═══════════════════════════════════════════════ */

/* ─── Builder Header ─────────────────────────── */
.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: rgba(15, 23, 41, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 200;
  height: 60px;
  flex-shrink: 0;
}

.builder-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.builder-back-btn:hover { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg-card-hover); }

.builder-project-name {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  width: 280px;
  transition: all var(--transition-fast);
}
.builder-project-name:hover { background: var(--bg-elevated); }
.builder-project-name:focus { outline: none; background: var(--bg-elevated); box-shadow: 0 0 0 2px rgba(245,158,11,0.25); }
.builder-project-name::placeholder { color: var(--text-disabled); font-weight: 400; }

.builder-sep { width: 1px; height: 24px; background: var(--border-subtle); }

/* ─── Library Panel ──────────────────────────── */
.lib-search-wrap { position: relative; }
.lib-search-wrap .lib-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; pointer-events: none; color: var(--text-muted);
}
.lib-search-wrap input { padding-left: 30px; }

.lib-tab-toggle {
  display: flex;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.lib-tab-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
}
.lib-tab-btn.active { background: var(--color-brand-primary); color: #fff; box-shadow: 0 2px 8px rgba(245,158,11,0.3); }

.lib-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 2px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lib-group-label::before {
  content: '';
  width: 3px; height: 10px;
  background: var(--color-brand-primary);
  border-radius: 2px;
  opacity: 0.6;
}

.lib-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  margin-bottom: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 10px;
}
.lib-item-card:hover {
  border-color: var(--border-brand);
  background: rgba(245,158,11,0.04);
}
.lib-item-card:hover .lib-add-btn { opacity: 1; transform: scale(1); }

.lib-item-name { font-size: 12px; font-weight: 500; color: var(--text-primary); line-height: 1.3; }
.lib-item-price { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.lib-add-btn {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-brand-primary);
  border: none; cursor: pointer;
  color: #fff; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.8);
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(245,158,11,0.4);
  line-height: 1;
}

/* ─── Cost Group Headers ─────────────────────── */
.cost-group-block {
  margin-bottom: 28px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.cost-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border-left: 3px solid var(--color-brand-primary);
  position: relative;
}
.cost-group-header::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(245,158,11,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.cost-group-num {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--color-brand-primary);
  margin-right: 8px;
}
.cost-group-name {
  font-size: 12px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.04em;
}
.cost-group-total {
  font-size: 13px; font-weight: 700;
  font-family: var(--font-heading);
  color: var(--color-brand-primary);
  background: rgba(245,158,11,0.1);
  padding: 3px 10px; border-radius: var(--radius-full);
}

/* ─── Cost Table Rows ────────────────────────── */
.cost-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cost-table thead { background: var(--bg-base); }
.cost-table th {
  padding: 8px 10px; text-align: left;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}
.cost-table td { padding: 12px 11px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: middle; }
.cost-table tbody tr { transition: background var(--transition-fast); cursor: pointer; }
.cost-table tbody tr:hover { background: var(--bg-card-hover); }
.cost-table tbody tr:last-child td { border-bottom: none; }
.cost-table tbody tr:hover .cost-row-del { opacity: 1; }

.cost-item-name { font-weight: 600; color: var(--text-primary); font-size: 12px; }
.cost-item-badge { font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--bg-elevated); color: var(--text-muted); margin-left: 4px; vertical-align: middle; }
.cost-price { font-family: var(--font-heading); font-weight: 700; color: var(--text-primary); font-size: 12px; }
.cost-price-muted { color: var(--text-muted); font-size: 12px; }
.cost-row-del {
  opacity: 0; transition: opacity var(--transition-fast);
  background: transparent; border: none; cursor: pointer;
  color: var(--color-danger); font-size: 13px; padding: 2px 4px; border-radius: 4px;
}
.cost-row-del:hover { background: var(--color-danger-bg); }

/* ─── Right Panel: Financial Summary ────────── */
.fin-section { padding: 20px 20px; border-bottom: 1px solid var(--border-subtle); }
.fin-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 14px; }

.fin-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.fin-row-label { font-size: 12px; color: var(--text-secondary); }
.fin-row-val { font-size: 13px; font-weight: 600; font-family: var(--font-heading); color: var(--text-primary); }
.fin-row-val.brand { color: var(--color-brand-primary); }

.fin-total-card {
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(59,130,246,0.08));
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 16px;
}
.fin-total-label { font-size: 10px; font-weight: 700; color: var(--color-success); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.fin-total-num { font-family: var(--font-heading); font-size: 22px; font-weight: 800; color: var(--text-primary); }

.margin-bar-lg { height: 8px; background: var(--bg-elevated); border-radius: var(--radius-full); overflow: hidden; margin: 10px 0; }
.margin-bar-lg-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.5s ease; }
.margin-bar-lg-fill.healthy { background: linear-gradient(90deg, var(--color-success), #34D399); }
.margin-bar-lg-fill.ok { background: linear-gradient(90deg, #F59E0B, #FCD34D); }
.margin-bar-lg-fill.low { background: linear-gradient(90deg, var(--color-danger), #F87171); }

/* ─── Builder AI Tips ────────────────────────── */
.builder-ai-tip {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 8px;
  border-radius: var(--radius-md);
  font-size: 11px; line-height: 1.5;
}
.builder-ai-tip.warn { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); color: #F87171; border-left: 3px solid var(--color-danger); }
.builder-ai-tip.info { background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.2); color: #60A5FA; border-left: 3px solid var(--color-info); }
.builder-ai-tip .tip-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* ─── Cover Section ──────────────────────────── */
.builder-cover {
  padding: 32px 36px;
  border-bottom: 1px dashed var(--border-subtle);
}
.builder-cover-title {
  text-align: center;
  font-size: 26px; font-weight: 800;
  font-family: var(--font-heading);
  background: var(--color-brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.builder-cover-subtitle {
  text-align: center; font-size: 16px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 24px;
}
.builder-cover-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  background: var(--bg-base); padding: 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}




/* ═══════════════════════════════════════════════
   BUILDER v4 — Single-Page Spreadsheet
   ═══════════════════════════════════════════════ */

/* ─── Page Container ─────────────────────────── */
.bld { max-width: 1060px; margin: 0 auto; padding: 20px 24px 80px; }

/* ─── Project Bar ────────────────────────────── */
.bld-project-bar {
  display: grid; grid-template-columns: 1.5fr 1fr 0.7fr; gap: 1px;
  background: var(--border-subtle); border-radius: var(--radius-md);
  overflow: hidden; margin-bottom: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.bld-pf { background: var(--bg-card); padding: 10px 16px; display: flex; flex-direction: column; gap: 3px; }
.bld-pf-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.bld-pf-input { background: transparent; border: none; padding: 0; font-size: 13px; font-weight: 600; color: var(--text-primary); font-family: var(--font-body); outline: none; width: 100%; }
.bld-pf-input::placeholder { color: var(--text-disabled); font-weight: 400; }
.bld-pf-input:focus { color: var(--color-brand-primary); }
.bld-pf select.bld-pf-input { -webkit-appearance: none; appearance: none; cursor: pointer; }

/* ─── Spreadsheet Table ──────────────────────── */
.bld-sheet {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
}
.bld-sheet thead th:first-child { border-top-left-radius: var(--radius-md); }
.bld-sheet thead th:last-child { border-top-right-radius: var(--radius-md); }
.bld-sheet thead th {
  padding: 8px 8px; text-align: left; background: var(--bg-base);
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 2px solid var(--border-default); white-space: nowrap;
  position: sticky; top: 0; z-index: 5;
}
.bld-sheet thead th.r { text-align: right; }
.bld-sheet thead th.c { text-align: center; }

/* ─── Group Header Row ───────────────────────── */
.bld-group-row {
  cursor: pointer; user-select: none;
}
.bld-group-row td {
  padding: 0; border-bottom: 1px solid var(--border-default);
}
.bld-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
  border-left: 3px solid var(--color-brand-primary);
}
.bld-gh-left { display: flex; align-items: center; gap: 10px; }
.bld-gh-icon { font-size: 16px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: rgba(245,158,11,0.1); border-radius: var(--radius-sm); flex-shrink: 0; }
.bld-gh-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.bld-gh-count { font-size: 11px; color: var(--text-muted); margin-left: 4px; font-weight: 400; }
.bld-gh-hint { font-size: 11px; color: var(--color-warning); display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.bld-gh-right { display: flex; align-items: center; gap: 14px; }
.bld-gh-sub { font-family: var(--font-heading); font-size: 14px; font-weight: 700; color: var(--text-primary); }
.bld-gh-sub.zero { color: var(--text-disabled); font-weight: 400; }
.bld-gh-toggle { font-size: 12px; color: var(--text-disabled); transition: transform 0.2s ease; }
.bld-gh-toggle.collapsed { transform: rotate(-90deg); }

/* ─── Item Row ───────────────────────────────── */
.bld-sheet tbody td { padding: 0; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.bld-sheet tbody tr.bld-item:hover { background: var(--bg-card-hover); }
.bld-sheet tbody tr.bld-item:hover .bld-act { opacity: 1; }
.bld-sheet tbody tr.bld-item.is-optional { opacity: 0.55; }

.bld-c { width: 100%; padding: 8px 8px; background: none; border: none; outline: none; color: var(--text-primary); font-size: 12px; font-family: var(--font-body); line-height: 1.4; box-sizing: border-box; }
.bld-c:focus { background: rgba(245,158,11,0.06); }
.bld-c::placeholder { color: var(--text-disabled); font-size: 10px; }
.bld-c.c-name { font-weight: 600; font-size: 13px; }
.bld-c.c-desc { color: var(--text-secondary); font-size: 11px; }
.bld-c.c-num { text-align: center; font-family: var(--font-heading); -moz-appearance: textfield; }
.bld-c.c-num::-webkit-inner-spin-button { display: none; }
.bld-c.c-price { text-align: right; font-family: var(--font-heading); font-weight: 600; }

.bld-td-num { padding: 8px 4px; text-align: center; font-size: 10px; color: var(--text-disabled); font-family: var(--font-heading); }
.bld-td-total { padding: 8px 8px; text-align: right; font-family: var(--font-heading); font-weight: 700; font-size: 12px; color: var(--text-primary); white-space: nowrap; }
.bld-td-act { padding: 4px 6px; text-align: center; white-space: nowrap; }

.bld-act { opacity: 0; background: none; border: none; cursor: pointer; font-size: 12px; padding: 3px 5px; border-radius: var(--radius-sm); transition: all 0.1s ease; color: var(--text-muted); }
.bld-act:hover { background: var(--bg-elevated); }
.bld-act.del:hover { color: var(--color-danger); background: var(--color-danger-bg); }
.bld-act.dup:hover { color: var(--color-info); background: var(--color-info-bg); }

.bld-badge { font-size: 8px; padding: 1px 5px; border-radius: 3px; background: var(--bg-elevated); color: var(--text-muted); margin-left: 4px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.bld-badge.gift { background: var(--color-success-bg); color: var(--color-success); }

/* ─── Add Row ────────────────────────────────── */
.bld-add-row td { padding: 6px 8px; border-bottom: 2px solid var(--border-default); }
.bld-add-row-inner { display: flex; align-items: center; gap: 6px; }
.bld-add-btn {
  padding: 4px 12px; font-size: 11px; font-weight: 500; cursor: pointer;
  background: transparent; border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-family: var(--font-body); transition: all 0.12s ease;
}
.bld-add-btn:hover { border-color: var(--border-brand); color: var(--color-brand-primary); }

/* ─── Library Search Dropdown (inline) ───────── */
.bld-lib-wrap { position: relative; flex: 1; }
.bld-lib-input {
  width: 100%; padding: 4px 10px; font-size: 11px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: var(--font-body); outline: none;
}
.bld-lib-input:focus { border-color: var(--border-brand); }
.bld-lib-input::placeholder { color: var(--text-disabled); }
.bld-lib-dd {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  z-index: 30; max-height: 220px; overflow-y: auto; display: none;
}
.bld-lib-dd.show { display: block; }
.bld-lib-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; font-size: 12px; cursor: pointer;
  border-bottom: 1px solid var(--border-subtle); transition: background 0.08s ease;
}
.bld-lib-item:last-child { border-bottom: none; }
.bld-lib-item:hover { background: var(--bg-card-hover); }
.bld-lib-item-name { font-weight: 500; color: var(--text-primary); }
.bld-lib-item-unit { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.bld-lib-item-price { font-family: var(--font-heading); font-size: 11px; font-weight: 600; color: var(--color-brand-primary); }
.bld-lib-empty { padding: 12px; font-size: 11px; color: var(--text-muted); text-align: center; }

/* ─── Custom Multi-Select Dropdown ────────────── */
.ms-dropdown { position: relative; width: 100%; font-family: var(--font-body); }
.ms-toggle { width: 100%; padding: 6px 10px; font-size: 11px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer; display: flex; justify-content: space-between; align-items: center; min-height: 28px; text-align: left; }
.ms-toggle:hover { border-color: var(--border-brand); }
.ms-toggle.active { border-color: var(--color-brand-primary); box-shadow: 0 0 0 2px rgba(245,158,11,0.1); }
.ms-toggle-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 999; display: none; max-height: 260px; overflow-y: auto; overflow-x: hidden; }
.ms-menu.open { display: block; animation: fadeIn 0.15s ease; }
.ms-search { padding: 8px; border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-elevated); z-index: 2; }
.ms-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--border-default); border-radius: 4px; outline: none; background: var(--bg-card); color: var(--text-primary); font-size: 11px; }
.ms-search input:focus { border-color: var(--border-focus); }
.ms-group-label { padding: 6px 12px; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; background: var(--bg-card); letter-spacing: 0.05em; margin-top: 4px; }
.ms-group:first-child .ms-group-label { margin-top: 0; }
.ms-option { padding: 8px 12px; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; transition: background 0.1s; font-size: 12px; margin: 0; }
.ms-option:hover { background: var(--bg-card-hover); }
.ms-option input[type="checkbox"] { flex-shrink: 0; cursor: pointer; margin-top: 2px; }
.ms-option-name { color: var(--text-primary); font-weight: 500; }
.ms-option-niches { font-size: 10px; color: var(--text-muted); display: block; margin-top: 2px; }

/* ─── Financial Bar ──────────────────────────── */
.bld-fin {
  position: fixed; bottom: 0;
  left: var(--sidebar-width, 210px); right: 0; height: 52px;
  background: var(--bg-card); border-top: 1px solid var(--border-default);
  display: flex; align-items: center; padding: 0 24px; gap: 0; z-index: 150;
}
.bld-fin-block { display: flex; align-items: center; gap: 6px; padding: 0 18px; }
.bld-fin-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.bld-fin-val { font-family: var(--font-heading); font-size: 13px; font-weight: 700; color: var(--text-primary); }
.bld-fin-val.sell { color: var(--color-brand-primary); }
.bld-fin-val.margin-ok { color: var(--color-success); }
.bld-fin-val.margin-warn { color: var(--color-warning); }
.bld-fin-val.margin-low { color: var(--color-danger); }
.bld-fin-sep { width: 1px; height: 28px; background: var(--border-subtle); flex-shrink: 0; }
.bld-fin-vat { display: flex; align-items: center; gap: 5px; padding: 0 14px; font-size: 11px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.bld-fin-total { margin-left: auto; display: flex; align-items: center; gap: 12px; padding-left: 18px; border-left: 1px solid var(--border-subtle); }
.bld-fin-total-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.bld-fin-total-val { font-family: var(--font-heading); font-size: 20px; font-weight: 800; color: var(--text-primary); }
.bld-fin-margin-track { width: 48px; height: 4px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.bld-fin-margin-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.bld-fin-margin-fill.ok { background: var(--color-success); }
.bld-fin-margin-fill.warn { background: var(--color-warning); }
.bld-fin-margin-fill.low { background: var(--color-danger); }
