:root {
  --bg: #f3efe4;
  --surface: #fffdf7;
  --surface-soft: #ebe4d6;
  --ink: #221d16;
  --muted: #6f675b;
  --line: #d8cfbd;
  --primary: #1d7c45;
  --primary-strong: #14583c;
  --accent: #d39b2d;
  --danger: #c33b32;
  --ok: #1d8e55;
  --warning: #c47b21;
  --sidebar: #143f3d;
  --sidebar-soft: #1f5a4b;
  --assistant: #16474b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, .72);
  color: var(--primary-strong);
  font-size: .78rem;
}

.shell-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 264px;
  background: var(--sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(236, 228, 204, .14);
  color: #d6b25e;
  font-weight: 800;
}

.brand-mark svg {
  width: 29px;
  height: 29px;
}

.brand-mark.mini {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-mark.mini svg {
  width: 23px;
  height: 23px;
}

.brand strong,
.brand small { display: block; }

.brand small {
  color: #b9cbc2;
  margin-top: 3px;
  font-size: .78rem;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #d9e7dd;
  font-weight: 600;
  font-size: .92rem;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(236, 228, 204, .13);
  color: #fff;
  box-shadow: inset 3px 0 0 #d6b25e;
}

.nav-item.is-disabled {
  opacity: .45;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  flex-shrink: 0;
}

.nav-icon svg {
  color: rgba(217,231,221,.60);
  transition: color .15s;
}

.nav-item:hover .nav-icon svg,
.nav-item.is-active .nav-icon svg {
  color: #fff;
}

.nav-item.is-active .nav-icon {
  background: rgba(214,178,94,.18);
}

.breadcrumb-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.breadcrumb-row a {
  color: var(--primary);
}

.shell-main {
  margin-left: 264px;
  min-height: 100vh;
  padding: 0 0 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .92);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.15;
}

.topbar-title {
  min-width: 220px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-field {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 800;
}

.topbar-field select,
.topbar-field input {
  min-height: 30px;
  max-width: 260px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.user-menu {
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  gap: 0 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: .86rem;
  font-weight: 800;
}

.user-menu small {
  grid-column: 2;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.user-avatar {
  grid-row: span 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #d7b774;
  color: #203c35;
}

.context-chip,
.icon-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

.context-chip.is-enabled {
  color: var(--ok);
  border-color: rgba(20, 122, 69, .32);
  background: #edf8ef;
}

.context-chip.is-blocked {
  color: var(--danger);
  border-color: rgba(180, 35, 24, .28);
  background: #fff0ec;
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--ink);
}

.assistant-toggle.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  padding: 0 20px;
}

.workspace-main {
  min-width: 0;
}

.assistant-panel {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid rgba(20, 63, 61, .22);
  border-radius: 10px;
  background: var(--assistant);
  color: #f6f2e7;
}

.assistant-panel.is-collapsed {
  display: none;
}

.assistant-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.assistant-header strong,
.assistant-header small {
  display: block;
}

.assistant-header small {
  color: #c8d8d0;
  margin-top: 2px;
}

.assistant-thread {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.assistant-message {
  display: grid;
  gap: 6px;
  padding: 11px;
  border-radius: 10px;
  background: rgba(255,255,255,.10);
  line-height: 1.35;
}

.assistant-message.is-user {
  background: #f4eadb;
  color: var(--ink);
}

.assistant-message p {
  margin: 0;
}

.assistant-message.user-message {
  background: rgba(244,234,219,.18);
  border-left: 2px solid #f4eadb;
}

.experto-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 12px 12px 12px;
  align-items: end;
}

.experto-chat-form textarea {
  resize: vertical;
  min-height: 38px;
  max-height: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.35;
}

.experto-chat-form textarea:focus {
  outline: 2px solid rgba(244,234,219,.45);
  outline-offset: 1px;
}

.experto-chat-form button[type="submit"] {
  align-self: stretch;
}

.cfdi-cols-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,30,25,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 24px;
}

.cfdi-cols-overlay[hidden] {
  display: none;
}

.cfdi-cols-dialog {
  background: var(--surface, #fff);
  color: var(--ink, #1a2422);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  overflow: hidden;
}

.cfdi-cols-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.cfdi-cols-header h3 {
  margin: 0;
  font-size: 16px;
}

.cfdi-cols-help {
  margin: 12px 20px 4px 20px;
}

.cfdi-cols-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 20px 0 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.cfdi-cols-tab {
  padding: 6px 12px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  background: rgba(0,0,0,.04);
  cursor: pointer;
  font-size: 13px;
  color: inherit;
}

.cfdi-cols-tab.is-active {
  background: var(--surface, #fff);
  border-color: rgba(0,0,0,.12);
  border-bottom-color: var(--surface, #fff);
  font-weight: 600;
}

.cfdi-cols-panes {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}

.cfdi-cols-pane-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.cfdi-cols-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.08);
  cursor: pointer;
  font-size: 13px;
}

.cfdi-cols-check input {
  margin: 0;
}

.cfdi-cols-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid rgba(0,0,0,.08);
  gap: 12px;
}

.cfdi-cols-actions {
  display: flex;
  gap: 8px;
}

.cfdi-cols-section {
  margin-bottom: 18px;
}

.cfdi-cols-h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 8px 0;
  color: var(--text-muted, #6c7872);
}

.cfdi-cols-h5 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin: 12px 0 6px 0;
  color: var(--text-muted, #6c7872);
  font-weight: 600;
}

.cfdi-cols-category {
  margin-bottom: 12px;
}

.cfdi-cols-selected {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.cfdi-cols-selected-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 6px;
  background: rgba(0,0,0,.02);
  cursor: grab;
}

.cfdi-cols-selected-item:active,
.cfdi-cols-selected-item.is-dragging {
  cursor: grabbing;
  opacity: .55;
}

.cfdi-cols-drag-handle {
  font-family: monospace;
  color: var(--text-muted, #999);
  user-select: none;
}

.cfdi-cols-selected-label {
  font-size: 13px;
}

.cfdi-cols-selected-key {
  font-family: monospace;
  font-size: 11px;
  opacity: .65;
}

.cfdi-cols-remove {
  border: none;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 4px;
}

.cfdi-cols-remove:hover {
  background: rgba(220,53,69,.15);
  color: #b02a37;
}

.cfdi-cols-deep-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: #d97706;
  color: #fff;
  margin-left: 4px;
  letter-spacing: .04em;
  vertical-align: middle;
}

.upgrade-strip,
.role-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.upgrade-strip {
  border-color: rgba(178, 93, 27, .35);
  background: #fff7ed;
}

.upgrade-strip span,
.role-hero p {
  color: var(--muted);
}

.role-hero h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.role-hero p {
  margin: 0;
}

.focus-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel,
.plan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  position: relative;
  padding: 16px;
  min-height: 124px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.metric-card:first-child {
  background: linear-gradient(135deg, #188448, #0f5b42);
  color: #fff;
}

.metric-card:first-child span,
.metric-card:first-child small {
  color: rgba(255,255,255,.82);
}

.metric-card:first-child::before {
  background: #d7b774;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 1.9rem;
  line-height: 1.1;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.panel {
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(31, 38, 29, .06);
}

.panel-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.toolbar,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 0;
}

.toolbar input,
.toolbar select,
.form-panel input,
.form-panel select,
.document-filters input,
.document-filters select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.button,
.tabs a,
.tabs button {
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: linear-gradient(180deg, #208b4b, var(--primary));
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.button.ghost,
.tabs a,
.tabs button {
  background: var(--surface);
  color: var(--primary);
}

.tabs .is-active,
.tabs button.is-active {
  background: var(--primary);
  color: #fff;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.billing-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px 16px;
}

.billing-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.billing-actions select {
  min-height: 40px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.watch-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.watch-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.watch-filters select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.table-wrap { overflow-x: auto; }

.table-wrap table {
  background: var(--surface);
}

.document-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.document-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.document-filter-actions,
.document-toolbar,
.document-pager {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.document-toolbar {
  align-items: center;
  justify-content: flex-end;
}

.document-pager {
  justify-content: flex-end;
  padding: 12px 16px;
  color: var(--muted);
  font-weight: 700;
}

.document-table { min-width: 1180px; }

.numeric,
td[data-key*="total"],
td[data-key*="importe"],
td[data-key*="monto"],
td[data-key*="saldo"],
td[data-key*="amount"],
td[data-key*="cargo"],
td[data-key*="abono"],
td[data-key*="iva"],
td[data-key*="base"],
td[data-key*="score"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.select-col {
  width: 42px;
  text-align: center;
}

.select-col input {
  width: 16px;
  height: 16px;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
}

.table-action {
  min-height: 32px;
  padding: 0 10px;
}

.button.is-busy {
  position: relative;
}

.loading-row td,
.loading-state {
  color: var(--muted);
}

.mini-spinner {
  width: 13px;
  height: 13px;
  display: inline-block;
  margin-right: 8px;
  border: 2px solid rgba(100, 116, 139, .28);
  border-top-color: var(--primary);
  border-radius: 50%;
  vertical-align: -2px;
  animation: mini-spin .8s linear infinite;
}

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

.table-chip {
  min-height: 28px;
  padding: 0 8px;
  font-size: .74rem;
}

.button-row.compact {
  gap: 6px;
  margin-top: 8px;
}

.impact-summary {
  display: grid;
  gap: 6px;
  min-width: 280px;
}

.impact-summary + .impact-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.impact-summary-row,
.impact-actions li {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.impact-actions {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tax-normative-panel {
  border-left: 4px solid var(--line);
}

.inline-note {
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

.tax-normative-panel.has-warning {
  border-left-color: #f59e0b;
}

.tax-normative-panel.has-critical {
  border-left-color: var(--danger);
}

.tax-normative-body {
  padding: 14px 16px 16px;
}

.tax-normative-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.demo-flow-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #efe7d7;
  color: var(--muted);
  font-size: .86rem;
}

.demo-flow-links span {
  color: var(--ink);
  font-weight: 800;
}

.demo-flow-links a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 800;
}

.demo-flow-links code {
  background: rgba(255,255,255,.58);
}

.demo-flow-links a:hover {
  border-color: var(--primary);
}

.compact-feed {
  gap: 8px;
}

.feed-item-main {
  display: grid;
  gap: 4px;
}

.budget-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  min-height: 420px;
}

.budget-scenarios {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.budget-scenario-card {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  cursor: pointer;
}

.budget-scenario-card:hover {
  border-color: var(--primary);
}

.compact-table-wrap {
  overflow: auto;
}

.budget-scenario-table,
.portfolio-summary-table {
  min-width: 0;
}

.budget-scenario-table tr[data-budget-scenario] {
  cursor: pointer;
}

.budget-scenario-table tr[data-budget-scenario]:hover,
.budget-scenario-table tr.is-selected {
  background: rgba(15, 107, 109, .07);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-align: left;
}

.subtotal-row {
  background: rgba(15, 107, 109, .05);
  font-weight: 800;
}

.budget-detail {
  min-width: 0;
}

.compact-header {
  border-bottom: 1px solid var(--line);
}

.budget-line-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.budget-line-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.budget-line-editor input,
.modal-form input,
.modal-form select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.budget-table .variance-strong {
  background: rgba(220, 38, 38, .06);
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.task-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.quick-filter-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.task-filters select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.portfolio-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.portfolio-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portfolio-filters input,
.portfolio-filters select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
}

.portfolio-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.portfolio-table td:nth-child(6),
.portfolio-table td:nth-child(7),
.portfolio-table td:nth-child(8),
.portfolio-summary-table td:nth-child(3),
.portfolio-summary-table td:nth-child(4),
.portfolio-summary-table td:nth-child(5),
.budget-table td:nth-child(3),
.budget-table td:nth-child(4),
.budget-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.portfolio-totals {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-row div {
  display: grid;
  gap: 4px;
}

.metric-row span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-row strong {
  font-size: .98rem;
}

.button.is-active {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 109, .10);
}

.tasks-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  min-height: 420px;
}

.tasks-table tr[data-task-id] {
  cursor: pointer;
}

.tasks-table tr[data-task-id]:hover {
  background: rgba(37, 99, 235, .05);
}

.task-detail {
  border-left: 1px solid var(--line);
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.task-detail-header {
  display: grid;
  gap: 8px;
}

.task-origin-link {
  justify-self: start;
}

.converter-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.converter-upload,
.converter-result {
  min-width: 0;
}

.nested-panel {
  margin-bottom: 0;
}

.compact-form {
  max-width: none;
  padding: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
}

.compact-form label {
  padding-top: 14px;
}

.adapter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.adapter-chip {
  display: grid;
  gap: 2px;
  min-width: 130px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f2e7;
}

.adapter-chip strong {
  font-size: .84rem;
}

.adapter-chip small {
  color: var(--muted);
}

.adapter-chip.is-ready {
  border-color: rgba(29, 142, 85, .36);
  background: #edf8ef;
}

.adapter-chip.is-warning {
  border-color: rgba(196, 123, 33, .36);
  background: #fff6e6;
}

.adapter-chip.is-muted {
  opacity: .74;
}

.converter-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.converter-progress {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #ded5c2;
}

.progress-track span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.converter-table th:nth-child(4),
.converter-table th:nth-child(5),
.converter-table th:nth-child(6) {
  text-align: right;
}

.alerta,
.errorbox {
  margin: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid var(--warning);
  background: #fff6e6;
  color: var(--ink);
}

.errorbox {
  border-left-color: var(--danger);
  background: #fff0ec;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: .9rem;
}

th {
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  background: #f8fafc;
}

.muted,
.empty-state {
  color: var(--muted);
}

.empty-state {
  padding: 24px 16px;
}

.list-feed {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.feed-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.feed-item strong {
  display: block;
  margin-bottom: 4px;
}

.detail-grid,
.aging-grid,
.module-matrix,
.definition-list {
  padding: 16px;
}

.definition-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 14px;
}

.definition-list dt {
  color: var(--muted);
  font-weight: 800;
}

.definition-list dd {
  margin: 0;
}

.json-panel {
  margin: 0;
  padding: 16px;
  max-height: 520px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  font-size: .86rem;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.plan-card {
  padding: 18px;
}

.plan-card h2 {
  margin: 0 0 8px;
}

.plan-card p {
  min-height: 48px;
  color: var(--muted);
}

.plan-card span {
  color: var(--primary);
  font-weight: 800;
}

.plan-card.is-current {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 109, .12);
}

.feature-list {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: .9rem;
}

.plan-suggestion {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px;
}

.form-panel {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.form-panel label {
  display: grid;
  gap: 6px;
  padding: 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.form-panel .button {
  margin: 2px 16px 16px;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.modal::backdrop {
  background: rgba(15, 23, 42, .52);
}

.modal-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

#web-modal-body {
  padding: 22px;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .82rem;
}

.modal-form select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
}

.mapping-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.mapping-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mapping-form input,
.mapping-form select,
.mapping-form textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
}

.mapping-form textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.mapping-json {
  grid-column: span 3;
}

.mapping-active {
  align-content: end;
  grid-template-columns: 18px 1fr;
  display: grid;
}

.mapping-active input {
  min-height: 18px;
}

.preview-result {
  padding: 14px 16px 16px;
}

.preview-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

@media (max-width: 980px) {
  .shell-sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shell-main {
    margin-left: 0;
    padding: 0 0 16px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .assistant-panel {
    position: static;
    max-height: none;
  }

  .dashboard-grid,
  .split-grid,
  .plans-grid,
  .budget-layout,
  .budget-line-editor,
  .tasks-layout,
  .task-filters,
  .portfolio-filters,
  .portfolio-summary,
  .converter-layout,
  .document-filters,
  .watch-filters,
  .mapping-form {
    grid-template-columns: 1fr;
  }

  .budget-scenarios {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .task-detail {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .mapping-json {
    grid-column: auto;
  }

  .role-hero,
  .upgrade-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-field {
    width: 100%;
  }
}

/* ── CFDI Dashboard ───────────────────────────────────────────────────────── */
.cfdi-twin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 860px) {
  .cfdi-twin-grid { grid-template-columns: 1fr; }
}

.cfdi-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 24px 16px;
  margin: 14px 16px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}

.cfdi-dropzone:focus,
.cfdi-dropzone:hover,
.cfdi-dropzone.is-dragover {
  border-color: var(--primary);
  background: #edf8ef;
}

.cfdi-dropzone-icon {
  font-size: 2rem;
  color: var(--primary);
  line-height: 1;
}

.cfdi-file-label {
  cursor: pointer;
}

.cfdi-upload-results {
  padding: 0 16px 14px;
}

.cfdi-upload-row {
  margin: 4px 0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .85rem;
}

.cfdi-upload-row.is-ok    { background: #edf8ef; color: #1d7a3e; }
.cfdi-upload-row.is-error { background: #fef2f2; color: #b91c1c; }
.cfdi-upload-row.is-loading { color: var(--muted); }

.cfdi-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}

.cfdi-badge--ok      { background: #d1fae5; color: #065f46; }
.cfdi-badge--err     { background: #fee2e2; color: #991b1b; }
.cfdi-badge--warn    { background: #fef3c7; color: #92400e; }
.cfdi-badge--partial { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.cfdi-badge--muted   { background: #f1f5f9; color: #64748b; }
.cfdi-badge--tipo    { background: #ede9fe; color: #4c1d95; }

.jobs-partial-detail { font-size: 11px; color: #9a3412; margin-top: 3px; line-height: 1.4; max-width: 260px; }
.calc-compare { margin-top: 16px; }
.calc-compare__title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.calc-compare__row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.calc-compare__row:last-child { border-bottom: none; }
.calc-patron { margin-top: 16px; border-top: 2px solid var(--line); padding-top: 12px; }
.calc-patron__title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.flow-step { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: var(--surface-alt, #f8fafc); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.flow-step__num { width: 22px; height: 22px; border-radius: 50%; background: var(--brand, #3b82f6); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.flow-step__done { background: #059669; }
.flow-step__label { font-size: 13px; font-weight: 500; flex: 1; }
.flow-step__action a, .flow-step__action button { font-size: 12px; }

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* dialog reset */
dialog#cfdi-job-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 460px;
  width: 90vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}

dialog#cfdi-job-dialog::backdrop {
  background: rgba(0, 0, 0, .45);
}

dialog#cfdi-job-dialog .modal-form {
  padding: 24px;
}

/* =============================================================
   NAVEGACION — grupos de sección
   ============================================================= */

.nav-group-label {
  padding: 16px 14px 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(185,203,194,.45);
  user-select: none;
}

/* Separa visualmente el primer grupo del ítem "Inicio" */
.nav-group-label:not(:first-child) {
  margin-top: 4px;
}

/* =============================================================
   BOTONES DE TOPBAR (asistente, logout)
   ============================================================= */

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}

.icon-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--primary);
}

.icon-button svg {
  display: block;
}

/* Botón de logout — tono de danger suave en hover */
a.icon-button[href="/logout"]:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff0ef;
}

/* =============================================================
   MODAL CLOSE BUTTON — SVG icon
   ============================================================= */

.modal-close {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.modal-close:hover {
  background: var(--surface-soft);
  color: var(--danger);
}

/* =============================================================
   AUTH SHELL — base_auth.html
   ============================================================= */

.auth-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 60px;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.auth-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
}

.auth-brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--sidebar);
  color: #d6b25e;
  flex-shrink: 0;
}

.auth-brand-mark svg {
  width: 32px;
  height: 32px;
}

.auth-brand-name strong {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.01em;
}

.auth-brand-name small {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-top: 2px;
}

.auth-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(34,29,22,.10), 0 2px 8px rgba(34,29,22,.04);
  padding: 32px 32px 28px;
}

.auth-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.01em;
}

.auth-subtitle {
  margin: 0 0 24px;
  font-size: .88rem;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
}

.auth-input {
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,124,69,.12);
}

.auth-input.has-error {
  border-color: var(--danger);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap .auth-input {
  padding-right: 44px;
}

.auth-input-toggle {
  position: absolute;
  right: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.auth-input-toggle:hover { color: var(--ink); }

.auth-submit {
  height: 46px;
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-submit:hover { background: var(--primary-strong); }
.auth-submit:disabled { opacity: .6; cursor: not-allowed; }

.auth-alert {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: .86rem;
  border: 1px solid transparent;
}

.auth-alert.error {
  background: #fff0ef;
  border-color: #f4b8b5;
  color: var(--danger);
}

.auth-alert.ok {
  background: #e6f6ec;
  border-color: #9fdbb8;
  color: #14583c;
}

.auth-divider {
  text-align: center;
  font-size: .84rem;
  color: var(--muted);
  margin: 4px 0;
}

.auth-divider a {
  color: var(--primary);
  font-weight: 600;
}

.auth-divider a:hover { text-decoration: underline; }

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .84rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 4px;
}

.auth-back:hover { color: var(--ink); }

.auth-footer {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

.auth-footer a {
  color: var(--muted);
  text-decoration: underline;
}

/* Verificación de código */
.auth-verify {
  display: none;
  text-align: center;
}

.auth-verify.active { display: block; }

.auth-code-input {
  height: 56px;
  width: 100%;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: .5em;
  padding: 0 8px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  margin: 16px 0;
  font-family: inherit;
}

.auth-code-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,124,69,.12);
}

/* OTP icon circle */
.auth-otp-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b8841e);
  color: #fff;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

/* Password strength bars */
.pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.pw-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background .2s;
}

.pw-strength-bar.active-1 { background: var(--danger); }
.pw-strength-bar.active-2 { background: var(--warning); }
.pw-strength-bar.active-3 { background: var(--accent); }
.pw-strength-bar.active-4 { background: var(--ok); }

/* =============================================================
   DASHBOARD — flujo onboarding + tarjetas de módulos
   ============================================================= */

.dashboard-flow {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.flow-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow .15s, border-color .15s, transform .1s;
  position: relative;
  overflow: hidden;
}

.flow-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--line);
  border-radius: 2px 0 0 2px;
  transition: background .15s;
}

.flow-card:hover {
  box-shadow: 0 6px 20px rgba(34,29,22,.08);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.flow-card:hover::before { background: var(--primary); }

.flow-card-step {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-soft);
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  font-size: .7rem;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}

.flow-card-icon {
  color: var(--primary);
}

.flow-card-icon svg {
  width: 22px;
  height: 22px;
}

.flow-card strong {
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.3;
}

.flow-card small {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Tarjetas de módulos rápidos */
.module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow .15s, border-color .15s;
}

.module-card:hover {
  box-shadow: 0 6px 22px rgba(34,29,22,.09);
  border-color: var(--primary);
}

.module-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  color: var(--primary);
  margin-bottom: 4px;
}

.module-card-icon svg {
  width: 20px;
  height: 20px;
}

.module-card strong {
  font-size: .9rem;
  font-weight: 700;
}

.module-card span {
  font-size: .78rem;
  color: var(--muted);
}

/* Banner hero del dashboard */
.dash-hero {
  background: linear-gradient(135deg, #143f3d 0%, #1f5a4b 100%);
  border-radius: 14px;
  padding: 24px 28px;
  color: #f6f2e7;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.dash-hero h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 800;
}

.dash-hero p {
  margin: 0;
  opacity: .8;
  font-size: .9rem;
}

.dash-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dash-hero-chip {
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .78rem;
  font-weight: 600;
  color: #f0ead8;
}

.dash-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 10px;
}

/* =============================================================
   RESPONSIVE — sidebar collapsa en pantallas pequeñas
   ============================================================= */

@media (max-width: 900px) {
  .shell-sidebar {
    width: 220px;
  }
  .shell-main {
    margin-left: 220px;
  }
}

@media (max-width: 680px) {
  .shell-sidebar {
    display: none;
  }
  .shell-main {
    margin-left: 0;
  }
  .auth-card {
    padding: 24px 18px;
  }
  .dashboard-flow {
    grid-template-columns: 1fr 1fr;
  }
}

/* =============================================================
   ONBOARDING — flow-card completado
   ============================================================= */

.flow-card.is-done {
  border-color: var(--ok);
  background: #f0faf4;
}

.flow-card.is-done::before {
  background: var(--ok);
}

.flow-card-check {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ok);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
}

.flow-card.is-done .flow-card-check {
  display: flex;
}

.flow-card.is-done .flow-card-step {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.flow-card.is-done strong {
  color: var(--primary-strong);
}

/* Badge "Nuevo" para primeras entradas */
.badge-new {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--accent);
  color: #3b2800;
  vertical-align: middle;
  margin-left: 6px;
}

/* =============================================================
   EMPTY STATES — patrón rico: ícono + título + texto + CTA
   ============================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  margin-bottom: 4px;
}

.empty-state-icon svg {
  width: 26px;
  height: 26px;
  opacity: .7;
}

.empty-state-title {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
}

.empty-state-body {
  margin: 0;
  font-size: .84rem;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.5;
}

.empty-state .button {
  margin-top: 4px;
}

/* Empty state dentro de tabla */
.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

.table-empty-state .empty-state-icon {
  width: 44px;
  height: 44px;
}

.table-empty-state .empty-state-title {
  font-size: .88rem;
}

.table-empty-state .empty-state-body {
  font-size: .8rem;
}

/* =============================================================
   APP ALERTS — sistema unificado: error / warning / ok / info
   ============================================================= */

.app-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .88rem;
  border: 1px solid transparent;
  line-height: 1.5;
}

.app-alert svg {
  flex-shrink: 0;
  margin-top: 1px;
  width: 16px;
  height: 16px;
}

.app-alert.error {
  background: #fff3f2;
  border-color: #f9c8c5;
  color: #8b1e1a;
}

.app-alert.warning {
  background: #fffbf0;
  border-color: #f7e08a;
  color: #7a4e00;
}

.app-alert.ok {
  background: #edfaf3;
  border-color: #99d9b6;
  color: #145c38;
}

.app-alert.info {
  background: #f0f6ff;
  border-color: #b3d0ff;
  color: #1a3f80;
}

/* =============================================================
   TOOLTIPS LIGEROS — data-hint + data-coach
   ============================================================= */

[data-hint] {
  position: relative;
  cursor: help;
}

[data-hint]::after {
  content: attr(data-hint);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: .75rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 100;
  max-width: 220px;
  white-space: normal;
  text-align: center;
}

[data-hint]:hover::after,
[data-hint]:focus-within::after {
  opacity: 1;
}

/* Coach marks (first-time hints) */
.coach-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  animation: coach-pulse 2s ease-in-out infinite;
  border: none;
}

@keyframes coach-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29,124,69,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(29,124,69,.0); }
}

@media (prefers-reduced-motion: reduce) {
  .coach-mark { animation: none; }
}

/* =============================================================
   DETAIL PANELS — detail-section / detail-list / detail-row
   ============================================================= */

.detail-section {
  margin-bottom: 24px;
}

.detail-section + .detail-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.section-label {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.detail-list {
  display: grid;
  gap: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 4px 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

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

.detail-row dt {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  margin: 0;
}

.detail-row dd {
  margin: 0;
  font-size: .88rem;
  word-break: break-word;
}

/* =============================================================
   EVENT LIST — audit trail & timeline
   ============================================================= */

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: .83rem;
}

.event-tag {
  font-weight: 700;
  font-size: .78rem;
  color: var(--primary-strong);
  background: rgba(29,124,69,.1);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* =============================================================
   STAT CARDS — KPIs, resumen, calculadoras
   ============================================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card__label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card__value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.stat-card__sub {
  font-size: .78rem;
  color: var(--muted);
}

.stat-card.is-primary { border-left: 3px solid var(--primary); }
.stat-card.is-accent  { border-left: 3px solid var(--accent); }
.stat-card.is-danger  { border-left: 3px solid var(--danger); }
.stat-card.is-ok      { border-left: 3px solid var(--ok); }

/* =============================================================
   SUMMARY STRIP — barra de resumen sobre tablas
   ============================================================= */

.summary-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 10px 16px;
  background: var(--surface-soft);
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: .84rem;
}

.summary-strip strong { font-weight: 800; }

.summary-strip .sep {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: var(--line);
  margin: 0 2px;
  vertical-align: middle;
}

/* =============================================================
   TABS — navegación intra-panel
   ============================================================= */

.tab-group {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-soft);
  border-radius: 9px;
  margin-bottom: 16px;
  width: fit-content;
}

.tab-btn {
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background .13s, color .13s;
}

.tab-btn.is-active,
.tab-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

.tab-btn.is-active {
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* =============================================================
   STICKY ACTION BAR — fija al fondo en forms/detalles largos
   ============================================================= */

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20;
}

/* =============================================================
   CALC SHELL — base reusable para calculadoras / módulos M36-M40
   ============================================================= */

.calc-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-shell { grid-template-columns: 1fr; }
}

.calc-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.calc-form__title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 16px;
}

.calc-form__group {
  margin-bottom: 14px;
}

.calc-form__group label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.calc-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calc-result__main {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border-radius: 14px;
  padding: 24px 28px;
}

.calc-result__main-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .8;
  margin-bottom: 8px;
}

.calc-result__main-value {
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.calc-result__main-sub {
  font-size: .86rem;
  opacity: .78;
  margin-top: 6px;
}

.calc-breakdown {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.calc-breakdown__title {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.calc-breakdown__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: .87rem;
  gap: 12px;
}

.calc-breakdown__row:last-child { border-bottom: none; }
.calc-breakdown__row.is-total { font-weight: 800; background: var(--surface-soft); }
.calc-breakdown__row.is-negative .calc-breakdown__val { color: var(--danger); }
.calc-breakdown__row.is-positive .calc-breakdown__val { color: var(--ok); }

.calc-breakdown__label { color: var(--muted); }
.calc-breakdown__val   { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.calc-explanation {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: .86rem;
  line-height: 1.55;
}

.calc-explanation__title {
  font-weight: 800;
  margin-bottom: 8px;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.calc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* =============================================================
   BREADCRUMB INLINE — dentro de paneles / detalles
   ============================================================= */

.panel-breadcrumb {
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}

.panel-breadcrumb a { color: var(--primary); font-weight: 600; }
.panel-breadcrumb .sep { color: var(--muted); }

/* =============================================================
   SCORE BADGE — para matching, IA, evaluaciones
   ============================================================= */

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid;
}

.score-badge.high   { background: #edfaf3; border-color: #99d9b6; color: #145c38; }
.score-badge.medium { background: #fffbf0; border-color: #f7e08a; color: #7a4e00; }
.score-badge.low    { background: #fef0ef; border-color: #f5b8b4; color: #8b1e1a; }

/* =============================================================
   RESULT TABLE — tablas de resultados en calculadoras
   ============================================================= */

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}

.result-table th {
  padding: 8px 12px;
  background: var(--surface-soft);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  text-align: left;
  border-bottom: 2px solid var(--line);
}

.result-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.result-table tr:last-child td { border-bottom: none; }
.result-table tr.is-total td { font-weight: 800; background: var(--surface-soft); }

/* =============================================================
   COMPARISON SIDE BY SIDE — comparativos M36-M40
   ============================================================= */

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .compare-grid { grid-template-columns: 1fr; }
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}

.compare-card__label {
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* =============================================================
   RESPONSIVE IMPROVEMENTS
   ============================================================= */

@media (max-width: 768px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ── mono-sm alias (same as mono-cell) ──────────────────────────── */
.mono-sm {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
}

/* ── Context chip — accounting status variants ───────────────────── */
.context-chip.is-warn {
  color: #92600a;
  border-color: rgba(196, 123, 33, .36);
  background: #fff6e6;
}
.context-chip.is-posted {
  color: #1a4e2c;
  border-color: rgba(20, 122, 69, .28);
  background: #d4edda;
}
.context-chip.is-pending {
  color: #555;
  border-color: rgba(100, 100, 100, .22);
  background: #f4f4f4;
}

/* ── Close icon-only button ──────────────────────────────────────── */
.button.icon-only {
  width: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Table responsive: horizontal scroll on small screens ─────────── */
@media (max-width: 860px) {
  .document-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .document-table {
    min-width: 720px;
  }
}

/* ── Toast notification system ───────────────────────────────────── */
#buho-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.buho-toast {
  padding: 11px 18px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  max-width: 360px;
  background: #1e2630;
  color: #f0f4f8;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: auto;
}
.buho-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.buho-toast--success {
  background: #1a4e2c;
  color: #d4edda;
}
.buho-toast--error {
  background: #7a1c13;
  color: #ffe5e1;
}
.buho-toast--info {
  background: #0e3556;
  color: #d6eaff;
}

/* ── Module cards: responsive grid fix on narrow screens ─────────── */
@media (max-width: 480px) {
  .module-cards {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Sidebar: prevent overlap on mobile ─────────────────────────── */
@media (max-width: 680px) {
  .shell-body {
    flex-direction: column;
  }
  .shell-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
