/* ==========================================================================
   Reusable components
   ========================================================================== */

/* ---------- Page scaffolding ---------- */
.page { display: flex; flex-direction: column; gap: 20px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h2 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-2); margin-top: 4px; font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-sm { display: flex; flex-direction: column; gap: 4px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary-600); } .text-info { color: var(--info); }
.divider { height: 1px; background: var(--divider); margin: 4px 0; }
.icon-sm svg, svg.icon-sm { width: 14px; height: 14px; }

kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface);
  font: 600 10.5px var(--font-sans); color: var(--text-3); box-shadow: 0 1px 0 var(--border-strong);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); min-width: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 0;
}
.card-header.bordered { padding-bottom: 14px; border-bottom: 1px solid var(--divider); }
.card-title { font-family: var(--font-display); font-size: 14.5px; font-weight: 750; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 16px; height: 16px; color: var(--text-3); }
.card-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--divider); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card.hoverable { transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition); cursor: pointer; }
.card.hoverable:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.card.accent-top { border-top: 3px solid var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  border: 1px solid transparent; transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  user-select: none; text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(204, 100, 32, .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-dark { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .btn-dark { background: #2A3A57; }
.btn-dark:hover:not(:disabled) { background: var(--navy-700); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(.94); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-50); }
.btn-soft { background: var(--primary-50); color: var(--primary-700); }
.btn-soft:hover:not(:disabled) { background: var(--primary-100); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; border-radius: 6px; }
.btn-xs svg { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-xl { height: 54px; padding: 0 24px; font-size: 16px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 26px; }
.btn:disabled { opacity: .5; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.loading::after, .btn-ghost.loading::after { border-color: var(--text-2) var(--text-2) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.btn-group button { height: 34px; padding: 0 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.btn-group button + button { border-left: 1px solid var(--border); }
.btn-group button.active { background: var(--primary-50); color: var(--primary-700); }
.btn-group button svg { width: 15px; height: 15px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-section-title { grid-column: 1 / -1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 14px; }
.form-section-title:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2, .field.full { grid-column: 1 / -1; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); margin-left: 2px; }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-error { font-size: 11.5px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13.5px; transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { height: auto; min-height: 80px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A93A5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input.invalid:focus { box-shadow: 0 0 0 3px rgba(210, 70, 63, .18); }
.input-sm, .select-sm { height: 32px; font-size: 12.5px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-group .input-suffix { position: absolute; right: 10px; color: var(--text-3); font-size: 12.5px; }
.input-group .input-action { position: absolute; right: 6px; }
.input-addon { display: flex; }
.input-addon > span { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.input-addon > .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; transition: background var(--transition); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--transition); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge svg { width: 12px; height: 12px; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-50); color: var(--success); }
.badge-warning { background: var(--warning-50); color: var(--warning); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-info { background: var(--info-50); color: var(--info); }
.badge-primary { background: var(--primary-50); color: var(--primary-700); }
.badge-purple { background: var(--purple-50); color: var(--purple); }
.badge-teal { background: var(--teal-50); color: var(--teal); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }
.badge-lg { height: 26px; padding: 0 11px; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: all var(--transition);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .chip.active { background: var(--primary); border-color: var(--primary); }
.chip .count { font-size: 11px; opacity: .7; }
.chip svg { width: 14px; height: 14px; }

/* ---------- Filter bar / toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input-group { min-width: 240px; flex: 1; max-width: 360px; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { display: inline-block; margin-left: 4px; opacity: .5; }
.table th.sorted .sort-ind { opacity: 1; color: var(--primary); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; color: var(--text); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .text-right, .table th.text-right { text-align: right; }
.table .cell-title { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 12px; color: var(--text-3); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); padding: 11px 14px; }
.table-compact td { padding: 8px 12px; }
.table-compact th { padding: 8px 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--divider); font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination button { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.pagination button:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: .45; }
.pagination button svg { width: 14px; height: 14px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-xs); min-width: 0;
  position: relative; overflow: hidden;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary-600); flex-shrink: 0; }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.success { background: var(--success-50); color: var(--success); }
.kpi-icon.info { background: var(--info-50); color: var(--info); }
.kpi-icon.danger { background: var(--danger-50); color: var(--danger); }
.kpi-icon.warning { background: var(--warning-50); color: var(--warning); }
.kpi-icon.purple { background: var(--purple-50); color: var(--purple); }
.kpi-icon.navy { background: var(--surface-3); color: var(--navy); }
.kpi-icon.teal { background: var(--teal-50); color: var(--teal); }
.kpi-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 12px; }
.delta svg { width: 13px; height: 13px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-3); }
.kpi .spark { position: absolute; right: 14px; bottom: 14px; width: 84px; height: 28px; opacity: .9; }

.mini-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--divider); min-width: 0; }
.mini-stat .ms-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.mini-stat .ms-value { font-family: var(--font-display); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; font-weight: 600; font-size: 13px;
  color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-700); border-bottom-color: var(--primary); }
:root[data-theme="dark"] .tab.active { color: var(--primary-600); }
.tab svg { width: 15px; height: 15px; }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 1px 7px; border-radius: 10px; }
.tab.active .count { background: var(--primary-50); color: var(--primary-700); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: var(--radius-sm); gap: 2px; }
.segmented button { height: 28px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button svg { width: 14px; height: 14px; }

/* ---------- Modal / drawer ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--overlay); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in 150ms ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  animation: pop-in 180ms ease-out; border: 1px solid var(--border);
}
.modal.modal-sm { max-width: 420px; }
.modal.modal-lg { max-width: 820px; }
.modal.modal-xl { max-width: 1080px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--divider); }
.modal-header h3 { font-size: 16.5px; font-weight: 750; }
.modal-header .modal-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); flex-shrink: 0; }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--divider); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-footer .left { margin-right: auto; }
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--warning-50); color: var(--warning); margin-bottom: 12px; }
.confirm-icon.danger { background: var(--danger-50); color: var(--danger); }
.confirm-icon svg { width: 22px; height: 22px; }

.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 1000; animation: fade-in 150ms ease-out; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: 1001; display: flex; flex-direction: column;
  animation: drawer-in 220ms cubic-bezier(.2,.8,.3,1); border-left: 1px solid var(--border);
}
.drawer.drawer-lg { width: min(760px, 100vw); }
.drawer .modal-body { padding: 20px 22px; }
.drawer .modal-footer { border-radius: 0; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 280px; max-width: 400px; display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow-lg); animation: toast-in 220ms ease-out; border-left: 4px solid var(--info);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .t-icon svg { width: 18px; height: 18px; }
.toast.success .t-icon { color: var(--success); } .toast.error .t-icon { color: var(--danger); } .toast.warning .t-icon { color: var(--warning); } .toast.info .t-icon { color: var(--info); }
.toast .t-title { font-weight: 650; font-size: 13px; }
.toast .t-msg { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.toast.leaving { animation: toast-out 200ms ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---------- Empty / skeleton ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; gap: 8px; color: var(--text-3); }
.empty-state .es-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-3); margin-bottom: 6px; }
.empty-state .es-icon svg { width: 24px; height: 24px; }
.empty-state h4 { font-size: 14.5px; color: var(--text); }
.empty-state p { font-size: 13px; max-width: 360px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-hover) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-page { display: grid; gap: 16px; }
.skeleton-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ---------- Lists / timeline ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--divider); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-hover); }
.li-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.li-icon svg { width: 17px; height: 17px; }
.li-icon.primary { background: var(--primary-50); color: var(--primary-600); }
.li-icon.success { background: var(--success-50); color: var(--success); }
.li-icon.danger { background: var(--danger-50); color: var(--danger); }
.li-icon.warning { background: var(--warning-50); color: var(--warning); }
.li-icon.info { background: var(--info-50); color: var(--info); }
.li-icon.purple { background: var(--purple-50); color: var(--purple); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-end { text-align: right; flex-shrink: 0; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--divider); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline-item.success::before { border-color: var(--success); }
.timeline-item.danger::before { border-color: var(--danger); }
.timeline-item.info::before { border-color: var(--info); }
.timeline-item.muted::before { border-color: var(--border-strong); }
.timeline-item .tl-title { font-weight: 600; font-size: 13px; }
.timeline-item .tl-meta { font-size: 12px; color: var(--text-3); }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width 400ms ease; }
.progress.success > span { background: var(--success); }
.progress.danger > span { background: var(--danger); }
.progress.warning > span { background: var(--warning); }
.progress.info > span { background: var(--info); }
.progress.sm { height: 5px; }

/* ---------- Avatar ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--primary); flex-shrink: 0; letter-spacing: .02em; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.xl { width: 64px; height: 64px; font-size: 21px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-50); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); font-size: 13px; }
.callout svg { width: 18px; height: 18px; color: var(--info); flex-shrink: 0; margin-top: 1px; }
.callout.warning { background: var(--warning-50); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.callout.warning svg { color: var(--warning); }
.callout.danger { background: var(--danger-50); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.callout.danger svg { color: var(--danger); }
.callout.success { background: var(--success-50); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.callout.success svg { color: var(--success); }
.callout.demo { background: var(--primary-50); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.callout.demo svg { color: var(--primary-600); }
.callout .c-title { font-weight: 650; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kanban-col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; border: 1px solid var(--border); transition: background var(--transition), border-color var(--transition); }
.kanban-col.drag-over { background: var(--primary-50); border-color: var(--primary); border-style: dashed; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; font-weight: 700; font-size: 12.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.kanban-col-header .count { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.kanban-col-header .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow-xs); cursor: grab; display: flex; flex-direction: column; gap: 8px; transition: box-shadow var(--transition), transform var(--transition); }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .5; transform: rotate(1.5deg); }
.kanban-card .kc-title { font-weight: 650; font-size: 13px; }
.kanban-card .kc-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--text-3); }
.kanban-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 18px 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

/* ---------- Calendar ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.calendar .cal-dow { padding: 8px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: center; }
.calendar .cal-day { min-height: 104px; padding: 6px; border-right: 1px solid var(--divider); border-bottom: 1px solid var(--divider); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.calendar .cal-day:nth-child(7n) { border-right: 0; }
.calendar .cal-day.other { background: var(--surface-2); }
.calendar .cal-day.other .cal-num { color: var(--text-3); opacity: .6; }
.calendar .cal-day.today { background: var(--primary-50); }
.calendar .cal-num { font-size: 12px; font-weight: 700; color: var(--text-2); }
.calendar .cal-day.today .cal-num { color: var(--primary-700); }
.cal-event { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--info-50); color: var(--info); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-event.success { background: var(--success-50); color: var(--success); }
.cal-event.warning { background: var(--warning-50); color: var(--warning); }
.cal-event.primary { background: var(--primary-50); color: var(--primary-700); }
.cal-event.danger { background: var(--danger-50); color: var(--danger); }
.cal-event.neutral { background: var(--surface-3); color: var(--text-2); }
.cal-more { font-size: 11px; color: var(--text-3); padding-left: 4px; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { overflow: visible; width: 100%; height: auto; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font-sans); }
.chart .grid-line { stroke: var(--divider); stroke-width: 1; }
.chart .axis-line { stroke: var(--border); }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--navy-700); color: #fff;
  font-size: 12px; padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 120ms ease;
}
:root[data-theme="dark"] .chart-tooltip { background: #2A3A57; }
.chart-tooltip.show { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-tooltip .tt-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-wrap .chart { width: 160px; flex-shrink: 0; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-center .dc-value { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.donut-center .dc-label { font-size: 11px; color: var(--text-3); }
.legend-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; font-size: 12.5px; }
.legend-list .ll-row { display: flex; align-items: center; gap: 8px; }
.legend-list .ll-row i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-list .ll-row .ll-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.legend-list .ll-row .ll-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-list { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar-row .hb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-weight: 500; }
.hbar-row .hb-track { height: 10px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.hbar-row .hb-track span { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.hbar-row .hb-val { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }

/* ---------- Description list ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 13px; }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.dl.cols-2 { grid-template-columns: max-content 1fr max-content 1fr; }

/* ---------- Status steps ---------- */
.steps { display: flex; align-items: center; gap: 0; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.step .s-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 11px; background: var(--surface); flex-shrink: 0; }
.step .s-dot svg { width: 13px; height: 13px; }
.step.done { color: var(--success); }
.step.done .s-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.current { color: var(--primary-700); }
.step.current .s-dot { border-color: var(--primary); color: var(--primary-700); box-shadow: var(--ring); }
.step.rejected { color: var(--danger); }
.step.rejected .s-dot { border-color: var(--danger); background: var(--danger); color: #fff; }
.step-line { flex: 1; min-width: 20px; height: 2px; background: var(--border); margin: 0 8px; }
.step-line.done { background: var(--success); }

/* ---------- Product thumbnails ---------- */
.thumb { width: 40px; height: 40px; border-radius: 9px; overflow: hidden; flex-shrink: 0; background: var(--surface-3); display: flex; align-items: center; justify-content: center; }
.thumb img, .thumb svg { width: 100%; height: 100%; object-fit: cover; }
.thumb.lg { width: 64px; height: 64px; border-radius: 12px; }
.thumb.sm { width: 32px; height: 32px; border-radius: 7px; }

/* ---------- Misc ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.section-title { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.stat-inline { display: flex; align-items: baseline; gap: 6px; }
.stat-inline b { font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-3); background: var(--surface-2); cursor: pointer; transition: all var(--transition); }
.dropzone:hover { border-color: var(--primary); color: var(--primary-700); background: var(--primary-50); }
.dropzone svg { width: 26px; height: 26px; margin: 0 auto 8px; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.qty-stepper button { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.qty-stepper button:hover { background: var(--surface-3); color: var(--text); }
.qty-stepper button svg { width: 14px; height: 14px; }
.qty-stepper input { width: 42px; height: 30px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-weight: 700; font-size: 13px; background: transparent; -moz-appearance: textfield; }
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { outline: none; background: var(--primary-50); }
.sample-tag { display: inline-flex; align-items: center; font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--warning); background: var(--warning-50); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: left; }
.barcode-svg { background: #fff; padding: 8px; border-radius: 6px; border: 1px solid var(--border); display: inline-block; }
