/* ---------- ERP tab ----------
   Neumorphic surfaces from the theme tokens, diagonal light (S8): --surface (fill = page
   background), --raised (double shadow), --inset (pressed / active) and --text-strong. Golden
   scale (--fs-*, --sp-*) with fallbacks, so the plain monitoring look survives a theme that
   defines none of them. The side bar and the section panels live next to their builders. */
@import url('./erp/side-nav.css');
@import url('./erp/view-panels.css');
@import url('./erp/kpis.css');
@import url('./erp/board.css');
@import url('./erp/order-detail.css');

.view-erp {
  --erp-alarm-strong: #a3191a;
  color: var(--text-strong, var(--hud-text));
}
/* Text that sits directly on the view backdrop (Umbrella: wine crystal, S24) uses the
   on-backdrop inks; text inside cards, the side nav, tables and kanban keeps the normal inks. */
.erp-main > .view-head h1 {
  color: var(--on-backdrop, var(--text-strong, var(--hud-text)));
}
.erp-main > .view-head .muted,
.erp-body > .erp-note,
.erp-body > .erp-toolbar :is(.erp-note, .erp-count, .erp-toolbar-field) {
  color: var(--on-backdrop-muted, var(--hud-muted));
}
.erp-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--sp-4, 34px);
  align-items: start;
}
.erp-main {
  min-width: 0;
}
.erp-sample {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface, #fff);
  box-shadow: var(--inset, none);
  border: 1px solid var(--surface-line, transparent);
  color: var(--text-strong, var(--hud-text));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.erp-sample::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.erp-card,
.erp-kpis > div,
.erp-select {
  border: 1px solid var(--surface-line, transparent);
  background: var(--surface, #fff);
  box-shadow: var(--raised, none);
}
.erp-card {
  border-radius: var(--radius, 12px);
}
/* Orders toolbar: status segmented control (inset track, extruded selection) + equipment select */
.erp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2, 13px) var(--sp-3, 21px);
  margin-bottom: var(--sp-3, 21px);
}
.erp-toolbar-field {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1, 8px);
  color: var(--hud-muted);
  font-size: 12px;
  font-weight: 600;
}
.erp-count {
  margin-left: auto;
  color: var(--hud-muted);
  font-variant-numeric: tabular-nums;
}
.erp-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: var(--inset, inset 0 0 0 1px var(--hud-border));
}
.erp-seg button,
.erp-select {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--text-strong, var(--hud-text));
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    box-shadow var(--t-fast, 120ms) var(--ease, ease),
    color var(--t-fast, 120ms) var(--ease, ease);
}
.erp-seg button {
  border: 0;
  background: transparent;
}
.erp-seg button:hover,
.erp-select:hover {
  color: var(--accent-strong, #7a4a00);
}
.erp-seg button[aria-pressed='true'] {
  background: var(--selected-bg, var(--accent));
  color: var(--selected-ink, #1b1c20);
  box-shadow: var(--selected, 3px 3px 0 #5c3800);
  transform: translate(-1px, -1px);
  font-weight: 700;
}
.erp-seg button:active {
  background: var(--selected-bg, var(--accent));
  color: var(--selected-ink, #1b1c20);
  box-shadow: var(--selected, 3px 3px 0 #5c3800);
  transform: translate(-1px, -1px);
  box-shadow: var(--selected-pressed, 1px 1px 0 #5c3800);
  transform: translate(1px, 1px);
}
.erp-select:active {
  box-shadow: var(--inset, none);
}
.erp-select {
  appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 52%,
    calc(100% - 11px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.view-erp :is(button, select, li[data-id]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
/* Tables */
.erp-table {
  overflow-x: auto;
  padding: 4px;
}
.erp-table table {
  width: 100%;
  border-collapse: collapse;
}
.erp-table th,
.erp-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--hud-border);
  text-align: left;
  vertical-align: middle;
}
.erp-table th {
  color: var(--hud-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.erp-table tbody tr:last-child td {
  border-bottom: 0;
}
.erp-table tr.group-start:not(:first-child) td {
  border-top: 2px solid var(--hud-border);
}
.erp-table tfoot td {
  border-top: 2px solid var(--hud-border);
  border-bottom: 0;
  font-weight: 600;
}
.erp-table td small {
  display: block;
  color: var(--hud-muted);
  font-size: 11px;
}
.erp-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.erp-table .mono {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}
.erp-table :is(tr[data-id], tr[data-order]) {
  cursor: pointer;
}
.erp-table tr[data-order]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.erp-table :is(tr[data-id], tr[data-order]):hover td {
  background: rgb(250 162 27 / 0.1);
}
.erp-table tr.row-vencida td:first-child,
.erp-table tr.low td:first-child {
  box-shadow: inset 4px 0 0 var(--state-alarm);
}
.erp-table tr.row-cerrada {
  opacity: 0.6;
}
.erp-note {
  margin: 10px 2px 0;
  color: var(--hud-muted);
}
.erp-empty {
  padding: 18px;
}

/* Narrow: stacked layout (the side bar becomes a strip, side-nav.css), KPI tiles 2 × 2. */
@media (max-width: 900px) {
  .erp-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-3, 21px);
  }
  .erp-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .erp-kpis {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Phone: the board comes before the KPI tiles, so the Kanban is the first thing in view. */
  .erp-main[data-section='tablero'] {
    display: flex;
    flex-direction: column;
  }
  .erp-main[data-section='tablero'] > .erp-body {
    order: 1;
    margin-bottom: var(--sp-3, 21px);
  }
  .erp-main[data-section='tablero'] > .erp-kpis {
    order: 2;
  }
  .erp-toolbar-field {
    flex-wrap: wrap;
  }
}
