:root {
  --ink: #182026;
  --muted: #68747d;
  --line: #dce2e6;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --green: #087f5b;
  --green-soft: #e5f5ee;
  --blue: #2563a8;
  --blue-soft: #e8f0fa;
  --amber: #b45f06;
  --amber-soft: #fff1d6;
  --red: #b42318;
  --red-soft: #feeceb;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: 0; }
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; letter-spacing: 0; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; padding: 18px 14px; background: #1e2928; color: white; display: flex; flex-direction: column; z-index: 10; }
.brand { display: flex; align-items: center; gap: 11px; color: white; padding: 4px 6px 20px; }
.brand span:last-child { display: grid; }
.brand small { color: #aebbb8; font-size: 11px; margin-top: 2px; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; background: #18a477; color: white; border-radius: 6px; font-weight: 800; font-size: 13px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { color: #cad3d1; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 9px 11px; border-radius: 6px; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a.active { background: #31403e; color: white; }
.sidebar svg { width: 18px; height: 18px; }
.sidebar-user { margin-top: auto; padding: 13px 8px 2px; border-top: 1px solid #3b4847; display: grid; grid-template-columns: 1fr auto; }
.sidebar-user span, .sidebar-user small { overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: #aebbb8; grid-column: 1; }
.sidebar-user a { grid-column: 2; grid-row: 1 / 3; color: #cad3d1; align-self: center; }
main { margin-left: 232px; padding: 24px 28px 50px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.topbar p, .panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.metrics article { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 15px; min-width: 0; }
.metrics article.attention { border-color: #e3a849; background: #fffbf2; }
.metrics article.profit-metric { border-color: var(--green); background: var(--green-soft); }
.metrics article.profit-metric strong { color: var(--green); }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin: 7px 0 4px; font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metrics small { color: var(--muted); font-size: 11px; }
.metric-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; }
.metrics .metric-info { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: 0 0 20px; color: var(--muted); border-radius: 50%; cursor: help; }
.metric-info svg { width: 14px; height: 14px; }
.metrics .metric-tooltip { position: absolute; z-index: 50; top: calc(100% + 8px); right: -8px; display: block; width: min(270px, 70vw); padding: 9px 11px; border: 1px solid #cfd7dc; border-radius: 6px; color: var(--ink); background: white; box-shadow: 0 8px 22px rgba(24,32,38,.16); font-size: 11px; font-weight: 400; line-height: 1.45; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-4px); transition: opacity .15s ease, transform .15s ease, visibility .15s; }
.metric-info:hover .metric-tooltip, .metric-info:focus .metric-tooltip, .metric-info:focus-visible .metric-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
.metric-info:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.metric-link { display: block; color: inherit; }
.status-list { display: flex; flex-wrap: wrap; gap: 5px; }
.metrics.compact { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; margin-bottom: 14px; overflow: hidden; }
.panel-heading { min-height: 58px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 15px; }
.chart-panel { min-height: 350px; }
.chart-wrap { height: 285px; padding: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 13px; background: #f8f9fa; color: #536069; text-align: left; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
td { padding: 11px 13px; border-top: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:hover { background: #fbfcfc; }
.total-row { background: #f1f7f5; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.status.sold { color: #086141; background: var(--green-soft); }
.status.cancelled, .status.returned { color: var(--red); background: var(--red-soft); }
.status.unknown { color: var(--amber); background: var(--amber-soft); }
.status.concentrated { color: #85520c; background: var(--amber-soft); }
.status.neutral { color: #505a63; background: #edf0f2; }
.text-status.sold { color: var(--green); }.text-status.cancelled, .text-status.returned { color: var(--red); }.text-status.unknown { color: var(--amber); }
.button, .icon-button { border: 1px solid transparent; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; }
.button { padding: 8px 13px; font-weight: 650; font-size: 13px; }
.button.primary { color: white; background: var(--green); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line); }
.button.danger { color: var(--red); background: white; border-color: #efc4c0; }
.button:disabled, .icon-button:disabled { opacity: .58; cursor: wait; }
.button svg, .icon-button svg { width: 16px; height: 16px; }
.icon-button { width: 36px; padding: 0; color: var(--ink); background: white; border-color: var(--line); }
.danger-icon { color: var(--red); border-color: #efc4c0; }
.filter-bar { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 12px; margin-bottom: 14px; display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filter-bar label, .edit-grid label, .stack-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.edit-grid label small { font-weight: 400; line-height: 1.3; }
input, select { min-height: 36px; padding: 7px 9px; border: 1px solid #cdd5da; border-radius: 5px; color: var(--ink); background: white; }
.filter-bar input[name=q] { min-width: 240px; }
.inline-form { display: flex; align-items: center; gap: 7px; }
.table-actions { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.table-actions form { margin: 0; }
.pending-catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.pending-catalog-grid article { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 7px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pending-catalog-grid article > div:first-child { display: grid; gap: 3px; }
.pending-catalog-grid span, .pending-catalog-grid small { color: var(--muted); font-size: 11px; }
.pending-catalog-grid strong { font-size: 22px; }
.pending-catalog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.dashboard-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-toolbar { display: grid; grid-template-columns: auto auto; justify-items: end; gap: 8px 12px; }
.period-form, .report-commands { display: flex; align-items: end; gap: 8px; }
.period-form label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 650; }
.excel-button { min-width: 154px; }
.freshness { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-height: 34px; color: var(--muted); font-size: 12px; }
.freshness svg { width: 16px; height: 16px; flex: 0 0 auto; }
.freshness span { display: grid; text-align: right; }
.freshness small { margin-top: 2px; color: var(--muted); }
.freshness.fresh { color: var(--green); }
.freshness.stale { color: var(--amber); }
.full-report-toolbar { grid-template-columns: 1fr; width: min(760px, 62vw); max-width: none; }
.full-period-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto auto; width: 100%; }
.full-search input { width: 100%; }
.full-report-toolbar .report-commands { justify-content: flex-end; }
.sync-progress { min-height: 112px; margin-bottom: 14px; padding: 14px 16px; border: 1px solid #b9dcca; border-radius: 7px; background: white; }
.sync-progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 13px; }
.sync-progress-copy strong { color: var(--green); }
.progress-track { position: relative; height: 10px; margin: 11px 0; border-radius: 5px; overflow: hidden; background: #e4ebe8; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .35s ease; }
.sync-progress.indeterminate .progress-track span { animation: indeterminate 1.2s ease-in-out infinite; }
.sync-progress-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 11px; }
.upload-progress { min-height: 126px; margin-bottom: 14px; padding: 16px; border: 1px solid #b9dcca; border-radius: 7px; background: linear-gradient(135deg, #fff 0%, #f4fbf8 100%); box-shadow: 0 8px 24px rgba(8,127,91,.08); }
.upload-progress-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.upload-progress-heading strong { color: var(--green); font-size: 15px; }
.upload-progress-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.upload-progress-heading > span { color: var(--green); font-size: 13px; font-weight: 750; }
.upload-progress.indeterminate .progress-track span { animation: indeterminate 1.2s ease-in-out infinite; }
.upload-progress.complete { border-color: #91cbb5; background: var(--green-soft); }
.upload-progress.failed { border-color: #efc4c0; background: var(--red-soft); }
.upload-progress.failed .upload-progress-heading strong, .upload-progress.failed .upload-progress-heading > span { color: var(--red); }
.upload-progress.failed .progress-track span { background: var(--red); }
.upload-progress-stats { display: flex; flex-wrap: wrap; gap: 7px 16px; min-height: 18px; color: var(--muted); font-size: 11px; }
.upload-progress > .button { margin-top: 11px; }
.source-warning { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; margin-bottom: 14px; border-left: 3px solid #d79521; background: #fff8e9; color: #70410d; font-size: 12px; line-height: 1.45; }
.source-warning svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.status.purchase-vigente { color: #086141; background: var(--green-soft); }
.status.purchase-mixta { color: #85520c; background: var(--amber-soft); }
.status.purchase-revertida { color: var(--red); background: var(--red-soft); }
.status.purchase-pendiente { color: #505a63; background: #edf0f2; }
.text-status.purchase-vigente { color: var(--green); }
.text-status.purchase-mixta { color: var(--amber); }
.text-status.purchase-revertida { color: var(--red); }
.text-status.purchase-pendiente { color: var(--muted); }
.table-note { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.rule-grid { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.rule-notes { grid-column: span 2; }
.audit-upload-form .file-field { grid-column: auto; }
.full-metrics { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.full-method-panel .panel-heading { border-bottom: 0; }
.full-report-table { min-width: 1560px; }
.full-report-table td small, .publication-cell small, .activity-cell small, .suggestion-cell small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.full-report-table .product-cell { min-width: 260px; max-width: 360px; line-height: 1.4; }
.publication-cell { min-width: 170px; }
.publication-cell strong { display: block; color: var(--blue); }
.logistic-breakdown { min-width: 155px; }
.logistic-breakdown span { display: inline-flex; justify-content: space-between; gap: 7px; min-width: 68px; margin: 2px 5px 2px 0; color: var(--muted); font-size: 11px; }
.logistic-breakdown strong { color: var(--ink); }
.activity-cell { min-width: 235px; }
.suggestion-cell { min-width: 120px; text-align: right; }
.suggestion-cell strong { color: var(--green); font-size: 19px; }
.full-candidate { background: #fbfefc; }
.audit-upload-form { padding: 16px; display: grid; grid-template-columns: minmax(280px, 1fr) auto; align-items: end; gap: 12px; }
.audit-metrics { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.audit-table { min-width: 1180px; }
.audit-items-table { min-width: 1500px; }
.audit-sku-cell { max-width: 320px; line-height: 1.4; }
.audit-product-cell { min-width: 260px; max-width: 420px; line-height: 1.4; }
.audit-alert-cell { min-width: 190px; color: var(--amber); font-size: 11px; line-height: 1.35; }
.audit-warning-row { background: #fffdf7; }
.audit-grids { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@keyframes indeterminate {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(330%); }
}
.compact-form { align-items: end; }
.form-panel { padding-bottom: 16px; }
.edit-grid { padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) auto; align-items: end; gap: 12px; }
.file-field { grid-column: span 2; }
.audit-upload-form .file-field { grid-column: auto; }
.toggle-field { display: flex !important; grid-template-columns: auto 1fr; align-items: center; min-height: 36px; }
.toggle-field input { min-height: auto; width: 17px; height: 17px; margin: 0; }
.pagination { min-height: 52px; padding: 9px 13px; border-top: 1px solid var(--line); display: flex; justify-content: center; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.notice { border: 1px solid #b9dcca; background: #edf8f3; color: #075c3e; border-radius: 6px; padding: 10px 13px; margin-bottom: 14px; font-size: 13px; }
.notice.error { background: var(--red-soft); color: var(--red); border-color: #f5c2bd; }
.empty { color: var(--muted); text-align: center; padding: 32px; }
.timeline { list-style: none; margin: 0; padding: 16px 20px; }
.timeline li { position: relative; display: grid; gap: 3px; padding: 0 0 18px 20px; border-left: 2px solid #c9ded6; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.timeline small { color: var(--muted); }
.detail-list { margin: 0; padding: 15px 18px; display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 13px; }
.detail-list dt { color: var(--muted); }.detail-list dd { margin: 0; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: #eef2f1; padding: 20px; }
.login-panel { width: min(400px, 100%); margin: 0; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 30px; }
.login-panel h1 { font-size: 21px; margin: 24px 0 18px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.stack-form { display: grid; gap: 14px; }
@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .full-metrics { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .audit-metrics { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .edit-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .rule-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; min-height: auto; padding: 10px; }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .sidebar nav a { justify-content: center; font-size: 0; }
  .sidebar-user { display: none; }
  .brand { padding-bottom: 10px; }
  main { margin-left: 0; padding: 18px 12px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar > * { width: 100%; }
  .report-toolbar { width: 100%; grid-template-columns: 1fr; justify-items: stretch; }
  .full-report-toolbar { width: 100%; }
  .period-form, .report-commands { width: 100%; }
  .period-form { display: grid; grid-template-columns: 1fr 1fr; }
  .full-period-form { grid-template-columns: 1fr 1fr; }
  .full-search { grid-column: 1 / -1; }
  .full-search input { width: 100%; }
  .period-form .button { grid-column: 1 / -1; }
  .report-commands > * { flex: 1; }
  .freshness { grid-column: 1; justify-content: flex-start; }
  .freshness span { text-align: left; }
  .dashboard-actions, .dashboard-actions .inline-form { width: 100%; }
  .dashboard-actions .inline-form { flex-wrap: wrap; }
  .metrics, .metrics.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .audit-upload-form, .audit-grids { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; }
  .filter-bar label { width: 100%; }
  .filter-bar input[name=q] { min-width: 0; width: 100%; }
  .panel-heading { align-items: flex-start; flex-wrap: wrap; }
  .panel-heading .table-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); white-space: normal; }
  .panel-heading .table-actions .button { min-width: 0; min-height: 52px; padding-inline: 8px; text-align: center; }
  .pending-catalog-grid { grid-template-columns: 1fr; }
  .pending-catalog-grid article { align-items: stretch; flex-direction: column; }
  .pending-catalog-actions { justify-content: space-between; }
  .edit-grid { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: 1fr; }
  .rule-notes { grid-column: auto; }
  .file-field { grid-column: auto; }
}
