.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 860px; font-size: 12px; }
.data-table th, .data-table td { padding: 11px 10px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; background: rgba(255,255,255,.025); }
.data-table td { color: var(--soft); }
.data-table tbody tr { transition: .14s ease; }
.data-table tbody tr:hover { background: rgba(255,255,255,.035); }
.data-table tfoot td { font-weight: 800; color: var(--text); background: rgba(255,255,255,.025); }
.table-actions { display: inline-flex; gap: 6px; }
.table-actions button { border: 0; background: rgba(255,255,255,.06); color: var(--soft); border-radius: 9px; width: 30px; height: 30px; }
.table-actions button:hover { color: var(--text); background: rgba(245,185,66,.12); }
.attachments-cell { display: inline-flex; gap: 4px; }
.attachment-link { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.06); text-decoration: none; color: inherit; }
.attachment-link:hover { background: rgba(245,185,66,.12); }
.attachment-link--pending { cursor: help; opacity: .7; }
.table-meta { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--muted); padding: 12px 18px 18px; font-size: 12px; }
.table-link { border: 0; background: transparent; color: var(--yellow); font-weight: 800; }
.stat-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.stat-tab { border: 1px solid var(--line); background: rgba(255,255,255,.035); color: var(--soft); border-radius: 999px; padding: 8px 11px; font-size: 12px; }
.stat-tab.is-active { color: #111; background: var(--yellow); font-weight: 900; }
.amount-positive { color: #86efac !important; }
.amount-negative { color: #fca5a5 !important; }

.data-table tbody tr[hidden] { display: none; }
.type-tabs { margin-bottom: 4px; }
.status-tabs { margin-top: 4px; }
.transaction-page .table-meta { border-top: 1px solid var(--line); margin-top: 10px; padding-left: 0; padding-right: 0; padding-bottom: 0; }

/* V9 — tabla única de movimientos */
.movements-table { min-width: 1120px; font-size: 13px; }
.movements-table th, .movements-table td { padding: 13px 12px; }
.movements-table thead th { position: sticky; top: 0; z-index: 1; background: #17263a; }
.transaction-row { position: relative; }
.transaction-row td:first-child { border-left: 3px solid transparent; }
.transaction-row--income td:first-child { border-left-color: var(--green); }
.transaction-row--expense td:first-child { border-left-color: var(--red); }
.transaction-row--income:hover { background: rgba(34,197,94,.045); }
.transaction-row--expense:hover { background: rgba(239,68,68,.045); }
.type-cell { width: 92px; }
.invoice-cell { color: #bfdbfe !important; min-width: 165px; }
.name-cell { min-width: 260px; color: var(--text) !important; }
.amount-cell { text-align: right !important; font-weight: 800; white-space: nowrap; }
.amount-income { color: #86efac !important; }
.amount-expense { color: #fca5a5 !important; }
.amount-negative { color: #fdba74 !important; }
.movements-table th:nth-last-child(-n+2), .movements-table td:nth-last-child(-n+2) { text-align: center; }
.movements-page .stat-tabs { margin: 10px 0 12px; }
.movements-page .stat-tab span { opacity: .9; font-weight: 900; }
@media (max-width: 900px) {
  .movement-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .movements-card__head { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}

/* V10 — cabeceras ordenables */
.sortable-th { padding: 0 !important; }
.sortable-th button {
  width: 100%;
  min-height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.numeric-th button { justify-content: flex-end; }
.sortable-th button:hover,
.sortable-th button.is-active {
  color: var(--yellow);
  background: rgba(245,185,66,.08);
}
.sort-indicator {
  color: var(--muted);
  font-size: 12px;
  opacity: .8;
}
.sortable-th button.is-active .sort-indicator { color: var(--yellow); opacity: 1; }

/* V11 — edición rápida en tabla de movimientos */
.editable-cell {
  cursor: pointer;
  position: relative;
}
.editable-cell:hover {
  background: rgba(245,185,66,.055);
  box-shadow: inset 0 0 0 1px rgba(245,185,66,.12);
}
.editable-cell:hover::after {
  content: "Editar";
  position: absolute;
  right: 8px;
  top: 6px;
  font-size: 9px;
  font-weight: 900;
  color: var(--yellow);
  opacity: .72;
  text-transform: uppercase;
  letter-spacing: .04em;
  pointer-events: none;
}
.editable-cell.is-editing-inline:hover::after { content: none; }
.inline-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 32px 32px;
  align-items: center;
  gap: 6px;
  min-width: 190px;
}
.inline-edit__input {
  min-height: 34px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(245,185,66,.46);
  background: #101c2b;
  color: var(--text);
  padding: 7px 9px;
  outline: none;
  font: inherit;
  font-size: 13px;
  color-scheme: dark;
}
.inline-edit__input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(245,185,66,.13);
}
.inline-edit__input option {
  background: #101c2b;
  color: #eef5ff;
}
.inline-edit__btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255,255,255,.06);
  font-weight: 900;
  cursor: pointer;
}
.inline-edit__btn--save {
  border-color: rgba(34,197,94,.42);
  background: rgba(34,197,94,.18);
  color: #86efac;
}
.inline-edit__btn--cancel {
  border-color: rgba(239,68,68,.38);
  background: rgba(239,68,68,.14);
  color: #fca5a5;
}
.inline-edit__btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.movements-table td[title*="IVA calculado"] {
  cursor: not-allowed;
  opacity: .9;
}
@media (max-width: 900px) {
  .inline-edit { min-width: 160px; grid-template-columns: minmax(100px, 1fr) 30px 30px; }
}

/* V12 — categorías en movimientos */
.category-cell { min-width: 150px; }
.category-pill {
  --category-color: #94a3b8;
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  padding: 6px 10px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--category-color) 80%, white 20%);
  background: color-mix(in srgb, var(--category-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--category-color) 55%, transparent);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.movements-filter-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.category-filter { min-width: 240px; }
.inline-edit--wide { min-width: 260px; }
.movements-table { min-width: 1280px; }
@supports not (color: color-mix(in srgb, red, blue)) {
  .category-pill { color: #e5e7eb; background: rgba(148,163,184,.13); border-color: rgba(148,163,184,.45); }
}


/* V17 — análisis por categoría en Movimientos */
.category-analysis-card {
  border-color: rgba(245,185,66,.20);
}
.category-analysis-head {
  align-items: flex-start;
}
.category-analysis-head .muted {
  margin: 6px 0 0;
  max-width: 760px;
  line-height: 1.45;
}
.category-analysis-controls {
  min-width: min(560px, 100%);
  justify-content: flex-end;
}
.category-analysis-controls .select {
  min-width: 170px;
}
.category-analysis-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.category-analysis-kpi {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
  display: grid;
  gap: 6px;
}
.category-analysis-kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.category-analysis-kpi strong {
  color: var(--text);
  font-size: 22px;
  letter-spacing: -.03em;
}
.category-analysis-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 16px;
}
.category-analysis-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}
.category-analysis-table th,
.category-analysis-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-align: left;
  vertical-align: middle;
}
.category-analysis-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: rgba(255,255,255,.025);
}
.category-analysis-table tbody tr:hover {
  background: rgba(255,255,255,.035);
}
.category-analysis-table .numeric-cell {
  text-align: right;
  white-space: nowrap;
  font-weight: 900;
}
.category-analysis-empty {
  margin-top: 0;
}

@media (max-width: 1100px) {
  .category-analysis-head {
    flex-direction: column;
    align-items: stretch;
  }
  .category-analysis-controls {
    justify-content: flex-start;
  }
  .category-analysis-kpis {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}
@media (max-width: 700px) {
  .category-analysis-kpis {
    grid-template-columns: 1fr;
  }
}
