/* Orden de cascada: componentes compartidos, necesidades del módulo, interfaz común.
   Las reglas sin capa de este archivo definen la apariencia final. */
@layer components, modules;

/* The bootstrap only enables this state when JavaScript is available.
   Visibility preserves measurements used by the existing ERP initialisers. */
html[data-ui-loading] body { visibility: hidden; }
html[data-ui-loading]::before {
  content: 'Cargando FRENOSIL…';
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  background: #f4f6f8;
  color: #315442;
  font: 500 14px/1.5 system-ui, sans-serif;
}

:root {
  color-scheme: light;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f6f8;
  --surface: #fff;
  --ink: #20332d;
  --muted: #61736c;
  --line: #dce4e0;
  --brand: #176447;
  --brand-hover: #104d36;
  --brand-soft: #edf5f0;
  --danger: #a93131;
  --radius: 12px;
  --shadow: 0 2px 8px #20332d06, 0 12px 28px #20332d04;
  font-family: var(--font);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14px/1.55 var(--font); }
button, input, select, textarea { font: inherit; }
a { color: var(--brand); text-underline-offset: 3px; }
h1, h2, h3 { color: inherit; line-height: 1.3; letter-spacing: -.025em; }
h1 { font-size: clamp(22px, 2.2vw, 28px); margin: 0; }
h2 { font-size: 19px; margin: 0 0 18px; font-weight: 650; }
h3 { font-size: 16px; margin: 22px 0 12px; font-weight: 650; }
p { margin: 10px 0; }
body > header { background: #153d30; color: white; padding: 23px 32px; border: 0; }
body > header small { color: #c6dbd1; display: block; margin-top: 5px; }
main, main.wrap, .wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 28px 48px; }
.panel, main > section, .fr-wh-fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin: 0 0 20px; }
.panel .panel, .panel section { box-shadow: none; }
.grid { gap: 18px 20px; }
.grid > *, .extra-row > * { min-width: 0; }
label { display: block; color: #344a40; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), select, textarea {
  display: block; width: 100%; min-height: 42px; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #bdccc4; border-radius: 8px; color: var(--ink); background: white;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #738078; opacity: 1; font-weight: 400; }
input:hover, select:hover, textarea:hover { border-color: #829e8e; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #17644714; }
input[readonly], textarea[readonly] { background: #f3f6f4; color: #52665b; }
input:disabled, select:disabled, textarea:disabled { background: #f0f3f1; color: #6e7d74; cursor: not-allowed; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 18px; height: 18px; }
textarea { min-height: 88px; resize: vertical; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 10px 16px; border: 1px solid transparent; border-radius: 8px; background: var(--brand); color: white; font-weight: 600; font-size: 13px; line-height: 1.3; cursor: pointer; transition: background .15s, box-shadow .15s; }
button:hover { background: var(--brand-hover); box-shadow: 0 2px 5px #153d3014; }
button.secondary, button.alt, button.gray, button.grey { background: #f0f4f2; border-color: var(--line); color: #315241; }
button.secondary:hover, button.alt:hover, button.gray:hover { background: #e3ece7; }
button.danger, button.red { background: #fff2f1; color: var(--danger); border-color: #efcfcb; }
button.danger:hover, button.red:hover { background: #ffe3df; }
button.orange { background: #fff5e6; color: #845007; border-color: #ead4af; }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid #25845f; outline-offset: 3px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.actions button { margin: 0; }
.muted, .hint, .note { color: var(--muted); font-size: 13px; line-height: 1.6; }
small { font-size: 12px; }
.scroll, .history-table, .ui-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border-radius: 8px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e6ece8; text-align: left; vertical-align: middle; }
th { background: #f2f6f4; color: #4b6356; font-size: 12px; font-weight: 650; white-space: nowrap; }
tbody tr:hover { background: #f7faf8; }
td input:not([type=checkbox]) { min-width: 80px; }
td button { min-height: 34px; padding: 7px 11px; }
.totals, .total { font-variant-numeric: tabular-nums; }
.totals { margin-top: 20px; padding: 16px; background: var(--brand-soft); color: #174e36; border-radius: 8px; font-size: 17px; }
summary { cursor: pointer; padding: 12px 0; color: #315442; font-weight: 600; }
summary:hover { color: var(--brand); }
details[open] > summary { margin-bottom: 12px; }
.tabs, main nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tabs button, main nav button { background: #f0f4f2; color: #395647; border: 1px solid var(--line); }
.tabs button.active, main nav button.active { color: #fff; background: var(--brand); border-color: var(--brand); }
[hidden], .hidden { display: none !important; }
/* La guía es una ayuda secundaria, accesible sin tapar el formulario. */
#fr-guide, #fr-client-guide, #fr-supplier-guide, .fr-wh-guide, .fr-sales-guide, #fr-compras-guide, .fr-guide, .fr-fact-guide, .fr-alb-guide, .fr-fv-guide, .fr-r-guide, .fr-treas-guide, .fr-acc-guide {
  position: relative; top: auto; z-index: auto; background: #f0f6f2; border: 1px solid #cddfd3; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; box-shadow: none;
}
.ui-guide-toggle { float: right; min-height: 32px; padding: 6px 10px; margin: 0 0 8px 12px; background: white; border-color: #cddfd3; color: #315442; }
.ui-guide-collapsed > :not(h2):not(b):not(strong):not(.ui-guide-toggle) { display: none !important; }
.ui-guide-collapsed::after { content: ''; display: block; clear: both; }
.ui-skip { position: fixed; top: -100px; left: 16px; z-index: 2147483647; padding: 12px 20px; border-radius: 8px; background: white; color: var(--brand); box-shadow: var(--shadow); }
.ui-skip:focus { top: 12px; }
.ui-table-scroll:focus-visible { outline-offset: -3px; }
@media (max-width: 900px) {
  main, main.wrap, .wrap { padding: 20px 18px 36px; }
  .grid, .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide { grid-column: 1 / -1; }
  .panel, main > section { padding: 20px; }
}
@media (max-width: 580px) {
  body > header { padding: 20px; }
  main, main.wrap, .wrap { padding: 16px 12px 28px; }
  .panel, main > section { padding: 18px 16px; border-radius: 10px; margin-bottom: 14px; }
  .grid, .history-filters, .extra-row, .extra-row.address { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .wide { grid-column: 1 / -1; }
  .actions { gap: 8px; }
  button { min-height: 44px; }
  th, td { padding: 10px; }
  table { display: table; }
  .totals { font-size: 15px; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media print {
  body { background: white; }
  .ui-guide-toggle, .ui-skip { display: none !important; }
  .panel { box-shadow: none; break-inside: avoid; }
  main, main.wrap { padding: 0; max-width: none; }
}
@media (max-width: 580px) {
  .grid > [data-ui-style] { grid-column: auto; }
}
.status { color: var(--brand); font-weight: 600; }
body > header b { font-size: 24px; font-weight: 700; }
.ui-guide button:not(.ui-guide-toggle), #wizardSteps button {
  background: #fff; color: #315442; border-color: #ccded2; font-weight: 600;
}
.ui-guide button:not(.ui-guide-toggle):hover, #wizardSteps button:hover { background: #e2eee6; }
.ui-guide button:is(.selected,.fr-selected,.fr-active,.active,[aria-current="step"]), #wizardSteps button.current {
  color: #fff; background: var(--brand); border-color: var(--brand);
}
#fr-article-options button { display: block; text-align: left; background: white; color: var(--ink); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 14px; box-shadow: none; }
#fr-article-options button:hover, #fr-article-options button[aria-selected="true"] { background: var(--brand-soft); color: #154f35; outline: 2px solid var(--brand); outline-offset: -2px; }

/* El módulo integrado ocupa su altura natural: el desplazamiento lo lleva la página. */
html.ui-embedded, html.ui-embedded body { height: auto; min-height: 0; }
html.ui-embedded main, html.ui-embedded main.wrap, html.ui-embedded .wrap {
  max-width: none; margin: 0; padding: 0 0 24px;
}
html.ui-embedded body > header {
  padding: 0 0 20px; background: transparent; color: var(--ink);
}
html.ui-embedded body > header small { color: var(--muted); }
