/* =========================================================================
   COMPONENTS - buttons, cards, tables, badges, modals, toasts, states
   ========================================================================= */

/* --------------------------------------------------------------- BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 38px;
  padding: 0 var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: 1;
  color: var(--text-body);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  text-decoration: none;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  color: var(--primary-fg);
  background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
  border-color: var(--blue-600);
  box-shadow: 0 1px 2px rgba(28, 68, 163, 0.24);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--blue-600), var(--blue-700)); border-color: var(--blue-700); color: #fff; }

.btn-secondary {
  color: var(--blue-700);
  background: var(--blue-50);
  border-color: var(--blue-200);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--blue-100); border-color: var(--blue-300); color: var(--blue-800); }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }

.btn-danger { color: #fff; background: linear-gradient(180deg, #e0473f, var(--danger-fg)); border-color: var(--danger-fg); }
.btn-danger:hover { background: linear-gradient(180deg, var(--danger-fg), #8f1c19); border-color: #8f1c19; color: #fff; }

.btn-success { color: #fff; background: linear-gradient(180deg, #1ba85c, var(--success-fg)); border-color: var(--success-fg); }
.btn-success:hover { color: #fff; background: linear-gradient(180deg, var(--success-fg), #0b6337); }

.btn-sm { min-height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { min-height: 44px; padding: 0 var(--sp-5); font-size: var(--fs-lg); }
.btn-icon { padding: 0; width: 34px; min-height: 34px; }
.btn-icon.btn-sm { width: 28px; min-height: 28px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; box-shadow: none; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn.is-active { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-300); z-index: 1; }

.btn .spinner { width: 14px; height: 14px; }

/* ----------------------------------------------------------------- CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-muted), var(--surface));
}
.card-header h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.card-header .card-subtitle { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }
.card-body.tight { padding: var(--sp-4); }
.card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

/* Hero Card Extensions */
.card-hero {
  border-width: 1px;
  border-color: var(--border-strong);
  box-shadow: var(--sh-md);
}
.card-hero .card-header {
  background: linear-gradient(180deg, var(--surface-tint), var(--surface));
  border-bottom-color: var(--border);
}
.budget-hero-grid { display: grid; gap: var(--sp-6); }
.budget-main { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-6); }
.budget-stats { display: grid; gap: var(--sp-4); }
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3);
  background: var(--surface-muted);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.stat-mini .stat-label {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.stat-mini .amount { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }

.icon-box {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.icon-box.primary { background: var(--blue-600); color: #fff; }
.icon-box svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------- STAT CARD */
.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--blue-500);
  opacity: 0.9;
}
.stat-card.tone-success::before { background: var(--success-fg); }
.stat-card.tone-warning::before { background: var(--warning-fg); }
.stat-card.tone-danger::before  { background: var(--danger-fg); }
.stat-card.tone-neutral::before { background: var(--gray-300); }
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

.stat-head { display: flex; align-items: center; gap: var(--sp-2); }
.stat-icon {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--blue-50);
  color: var(--blue-600);
  flex-shrink: 0;
}
.stat-icon svg { width: 16px; height: 16px; }
.tone-success .stat-icon { background: var(--success-bg); color: var(--success-fg); }
.tone-warning .stat-icon { background: var(--warning-bg); color: var(--warning-fg); }
.tone-danger  .stat-icon { background: var(--danger-bg);  color: var(--danger-fg); }
.tone-neutral .stat-icon { background: var(--neutral-bg); color: var(--neutral-fg); }

.stat-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  line-height: 1.3;
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-value.sm { font-size: var(--fs-xl); }
.stat-meta { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-muted); }
.stat-meta .delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); }
.stat-meta .delta.up { color: var(--danger-fg); }
.stat-meta .delta.down { color: var(--success-fg); }

/* ------------------------------------------------------------ PROGRESS */
.progress {
  position: relative;
  height: 8px;
  background: var(--gray-150);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--blue-400), var(--blue-600));
  transition: width var(--dur-slow) var(--ease-out);
  min-width: 2px;
}
.progress.lg { height: 12px; }
.progress.sm { height: 5px; }
.progress-bar.tone-normal   { background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); }
.progress-bar.tone-warn     { background: linear-gradient(90deg, #f7c14b, var(--warning-fg)); }
.progress-bar.tone-alert    { background: linear-gradient(90deg, #f9a13c, #ea7317); }
.progress-bar.tone-critical { background: linear-gradient(90deg, #ef7a6b, var(--danger-fg)); }
.progress-bar.tone-exceeded { background: linear-gradient(90deg, #b4231f, #7f1d1d); }
.progress-bar.tone-success  { background: linear-gradient(90deg, #34c47b, var(--success-fg)); }
.progress-marks { position: absolute; inset: 0; pointer-events: none; }
.progress-mark {
  position: absolute; top: -2px; bottom: -2px;
  width: 2px;
  background: rgba(15, 23, 42, 0.18);
  border-radius: 1px;
}

/* -------------------------------------------------------------- BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 1.5;
  letter-spacing: 0.02em;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge.no-dot::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: var(--danger-bd); }
.badge-info    { background: var(--info-bg);    color: var(--info-fg);    border-color: var(--info-bd); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }
.badge-primary { background: var(--blue-600);   color: #fff;             border-color: var(--blue-700); }
.badge-lg { padding: 4px var(--sp-3); font-size: var(--fs-xs); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--gray-700);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--blue-300); background: var(--blue-50); color: var(--blue-800); }
.chip.is-active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.chip.is-active:hover { background: var(--blue-700); color: #fff; }

/* -------------------------------------------------------------- TABLES */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  text-align: left;
  white-space: nowrap;
  background: var(--gray-100);
  border-bottom: 1px solid var(--border);
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { background: var(--gray-150); color: var(--text); }
.table thead th .sort-ind { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--blue-600); }
.table thead th.text-right .sort-ind { margin-left: 0; margin-right: 4px; }
.table thead th[aria-sort] { color: var(--blue-700); }

.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-body);
  border-bottom: 1px solid var(--gray-150);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--blue-50); }
.table tbody tr.is-selected { background: var(--blue-100); }
.table tbody tr.row-danger  { background: rgba(253, 236, 236, 0.5); }
.table tbody tr.row-warning { background: rgba(255, 246, 227, 0.55); }
.table tbody tr.row-danger:hover, .table tbody tr.row-warning:hover { background: var(--gray-100); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.is-loading td { opacity: 0.45; }

.table .cell-strong { font-weight: var(--fw-semibold); color: var(--text); }
.table .cell-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td {
  padding: var(--sp-3) var(--sp-4);
  font-weight: var(--fw-semibold);
  color: var(--text);
  background: var(--gray-100);
  border-top: 1px solid var(--border);
}
.table.compact tbody td, .table.compact thead th { padding: var(--sp-2) var(--sp-3); }

.cell-person { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--blue-700);
  background: var(--blue-100);
  letter-spacing: 0.02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: var(--fs-2xs); }
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-lg); }
.avatar.tone-gray { background: var(--gray-150); color: var(--gray-600); }
.avatar.tone-green { background: var(--success-bg); color: var(--success-fg); }
.avatar.tone-amber { background: var(--warning-bg); color: var(--warning-fg); }

.cell-person .person-meta { min-width: 0; }
.cell-person .person-name { font-weight: var(--fw-semibold); color: var(--text); }
.cell-person .person-sub { font-size: var(--fs-2xs); color: var(--text-muted); }

.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: var(--fw-semibold); color: var(--text); }
.amount.sm { font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.amount.negative { color: var(--danger-fg); }
.amount.positive { color: var(--success-fg); }
.amount.muted { color: var(--text-muted); font-weight: var(--fw-regular); }
.limit-tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  color: var(--blue-700);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--r-xs);
  text-transform: uppercase;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--gray-700);
  white-space: nowrap;
}
.type-pill svg { width: 14px; height: 14px; }
.type-pill.CASHLESS { color: var(--c-cashless); }
.type-pill.DENTAL { color: #1e87c8; }
.type-pill.OPTICAL { color: var(--c-optical); }

/* ------------------------------------------------------------- TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.toolbar .grow { flex: 1 1 220px; min-width: 0; }
.filter-group { display: flex; align-items: center; gap: var(--sp-2); }
.filter-group .select, .filter-group .input { min-height: 34px; font-size: var(--fs-sm); }
.filter-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

.search-box { position: relative; flex: 1 1 240px; min-width: 180px; }
.search-box .input { padding-left: 34px; min-height: 34px; font-size: var(--fs-sm); }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
}
.search-box .clear-btn {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  display: none;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
  border: none; border-radius: var(--r-xs);
  background: var(--gray-200); color: var(--gray-600);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.search-box.has-value .clear-btn { display: flex; }

/* ---------------------------------------------------------- PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--gray-25);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}
.pagination .pages { display: flex; align-items: center; gap: 2px; }
.page-btn {
  min-width: 28px; height: 28px;
  padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.page-btn:hover:not(:disabled) { background: var(--gray-150); color: var(--text); }
.page-btn.is-active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { padding: 0 4px; color: var(--text-subtle); }

/* -------------------------------------------------------------- MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(15, 32, 66, 0.42);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--dur) var(--ease);
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - var(--sp-8));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  animation: modalIn var(--dur-slow) var(--ease-out);
  overflow: hidden;
}
.modal.sm { max-width: 420px; }
.modal.md { max-width: 640px; }
.modal.lg { max-width: 880px; }
.modal.xl { max-width: 1140px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: var(--fs-xl); }
.modal-header .modal-sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-1); }
.modal-close {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1 1 auto; }
.modal-body.flush { padding: 0; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--gray-25);
  flex-wrap: wrap;
}
.modal-footer .left { margin-right: auto; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------- TOASTS */
.toast-host {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: min(400px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-500);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: toastIn var(--dur-slow) var(--ease-out);
}
.toast.is-leaving { animation: toastOut var(--dur) var(--ease) forwards; }
.toast.success { border-left-color: var(--success-fg); }
.toast.error   { border-left-color: var(--danger-fg); }
.toast.warning { border-left-color: var(--warning-fg); }
.toast.info    { border-left-color: var(--blue-500); }
.toast-icon { flex-shrink: 0; display: flex; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success-fg); }
.toast.error .toast-icon   { color: var(--danger-fg); }
.toast.warning .toast-icon { color: var(--warning-fg); }
.toast.info .toast-icon    { color: var(--blue-600); }
.toast-icon svg { width: 18px; height: 18px; }
.toast-content { flex: 1 1 auto; min-width: 0; }
.toast-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.toast-message { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; word-break: break-word; }
.toast-close {
  flex-shrink: 0;
  border: none; background: transparent;
  color: var(--text-subtle);
  cursor: pointer; padding: 2px;
  border-radius: var(--r-xs);
  line-height: 0;
}
.toast-close:hover { color: var(--text); background: var(--gray-100); }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ------------------------------------------------------ EMPTY/LOADING */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
}
.state-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: var(--r-xl);
  background: var(--blue-50);
  color: var(--blue-400);
}
.state-icon svg { width: 26px; height: 26px; }
.state-icon.error { background: var(--danger-bg); color: var(--danger-fg); }
.state-icon.warning { background: var(--warning-bg); color: var(--warning-fg); }
.state-icon.neutral { background: var(--gray-100); color: var(--gray-400); }
.state-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text); }
.state-message { font-size: var(--fs-md); color: var(--text-muted); max-width: 46ch; }
.state-actions { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); }

.skeleton {
  background: linear-gradient(90deg, var(--gray-150) 25%, var(--gray-100) 37%, var(--gray-150) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
  height: 12px;
}
.skeleton.line { height: 13px; }
.skeleton.title { height: 20px; width: 45%; }
.skeleton.block { height: 100%; border-radius: var(--r-md); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--blue-150);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
.spinner.on-light { border-color: rgba(255,255,255,0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(1px);
  border-radius: inherit;
  z-index: 5;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--info-bd);
  border-radius: var(--r-md);
  background: var(--info-bg);
  color: var(--info-fg);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert strong { font-weight: var(--fw-semibold); }
.alert.success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success-fg); }
.alert.warning { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning-fg); }
.alert.danger  { background: var(--danger-bg);  border-color: var(--danger-bd);  color: var(--danger-fg); }
.alert.neutral { background: var(--gray-100);   border-color: var(--border);      color: var(--text-body); }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert-title { font-weight: var(--fw-semibold); margin-bottom: 2px; }

/* ------------------------------------------------------------- DETAILS */
.kv-list { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }
.kv-list dt { color: var(--text-muted); white-space: nowrap; }
.kv-list dd { margin: 0; color: var(--text); font-weight: var(--fw-medium); text-align: right; }

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--blue-700); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--sp-2); right: var(--sp-2); bottom: -1px;
  height: 2px;
  background: var(--blue-600);
  border-radius: 2px 2px 0 0;
}
.tab .count {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  background: var(--gray-150);
  color: var(--gray-600);
  border-radius: var(--r-pill);
}
.tab.is-active .count { background: var(--blue-100); color: var(--blue-700); }

.section { margin-bottom: var(--sp-6); }
.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--sp-3);
}
.section-title::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }

.grid { display: grid; gap: var(--sp-4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.auto-220 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.auto-260 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.auto-300 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.divider { height: 1px; background: var(--border); border: none; margin: var(--sp-4) 0; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }