/* ===========================================================
   Palomatic Producción — Design System
   Industrial Functional. Touch-first. High contrast.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* === TIPOGRAFÍA === */
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* === COLORES === */
  --bg-base: #f5f3f0;
  --bg-surface: #ffffff;
  --bg-surface-alt: #edeae5;
  --bg-inset: #e5e2dc;

  --text-primary: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-muted: #8a8a8a;
  --text-inverse: #ffffff;

  --state-pending: #2563eb;
  --state-progress: #d97706;
  --state-done: #16a34a;
  --state-urgent: #dc2626;

  --state-pending-bg: #eff6ff;
  --state-progress-bg: #fffbeb;
  --state-done-bg: #f0fdf4;
  --state-urgent-bg: #fef2f2;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-active: #1e40af;

  --border-light: #e5e2dc;
  --border-medium: #d1cdc6;
  --border-strong: #a8a29e;

  /* === ESPACIADO === */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;

  /* === RADIOS Y SOMBRAS === */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 100px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.10);

  --touch-min: 48px;
  --touch-comfortable: 56px;
  --touch-large: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { min-height: 100vh; }

button { font-family: inherit; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  min-height: 72px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--text-inverse);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 4px;
}

.app-header__spacer { flex: 1; }

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--state-done-bg);
  color: var(--state-done);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.connection-badge.is-offline {
  background: var(--state-urgent-bg);
  color: var(--state-urgent);
}
.connection-badge.is-syncing {
  background: var(--state-progress-bg);
  color: var(--state-progress);
}
.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  padding: 6px 14px 6px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
}
.user-chip:hover { background: var(--bg-inset); }
.user-chip__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: var(--text-sm);
}
.user-chip__name {
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.1;
}
.user-chip__role {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 2px;
}

/* ============================================================
   TAB BAR
   ============================================================ */
.tab-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 0 var(--space-xl);
  display: flex;
  gap: 0;
  overflow-x: auto;
  position: sticky;
  top: 72px;
  z-index: 40;
}
.tab-bar__btn {
  background: transparent;
  border: none;
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tab-bar__btn:hover { color: var(--text-primary); }
.tab-bar__btn[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.tab-bar__btn .count-pill {
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 24px;
  text-align: center;
}
.tab-bar__btn[aria-selected="true"] .count-pill {
  background: var(--accent);
  color: var(--text-inverse);
}

/* ============================================================
   PAGE
   ============================================================ */
.page {
  padding: var(--space-xl);
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
.page-sub {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: var(--space-xs) 0 0;
}

/* ============================================================
   COUNTER CARDS (dashboard)
   ============================================================ */
.counter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}
@media (max-width: 900px) {
  .counter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .counter-grid { grid-template-columns: 1fr; }
}

.counter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
}
.counter-card__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 600;
  margin: 0 0 var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.counter-card__value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.counter-card__delta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-sm);
}
.counter-card__accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
}
.counter-card--pending .counter-card__accent { background: var(--state-pending); }
.counter-card--progress .counter-card__accent { background: var(--state-progress); }
.counter-card--done .counter-card__accent { background: var(--state-done); }
.counter-card--urgent .counter-card__accent { background: var(--state-urgent); }

/* ============================================================
   STAT STRIP (compact counters)
   ============================================================ */
.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}
.stat {
  flex: 1 1 0;
  min-width: 160px;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  position: relative;
}
.stat + .stat { border-left: 1px solid var(--border-light); }
@media (max-width: 760px) {
  .stat + .stat { border-left: none; border-top: 1px solid var(--border-light); }
  .stat { flex: 1 1 100%; }
}
.stat__bar {
  width: 3px;
  align-self: stretch;
  border-radius: 100px;
  flex-shrink: 0;
}
.stat--pending  .stat__bar { background: var(--state-pending); }
.stat--progress .stat__bar { background: var(--state-progress); }
.stat--done     .stat__bar { background: var(--state-done); }
.stat--urgent   .stat__bar { background: var(--state-urgent); }
.stat__body { display: flex; flex-direction: column; min-width: 0; }
.stat__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stat__value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}
.stat__delta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   ROW LIST (compact, scan-friendly)
   ============================================================ */
.row-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.row-list__head {
  display: grid;
  grid-template-columns: var(--row-cols, 130px 1.4fr 1.1fr 1.4fr 1fr 180px);
  gap: var(--space-md);
  align-items: center;
  padding: 10px var(--space-lg) 10px calc(var(--space-lg) + 4px);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface-alt);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.row {
  display: grid;
  grid-template-columns: var(--row-cols, 130px 1.4fr 1.1fr 1.4fr 1fr 180px);
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md) var(--space-lg) var(--space-md) calc(var(--space-lg) + 4px);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  position: relative;
  background: var(--bg-surface);
  transition: background 120ms;
  min-height: 64px;
  font-family: inherit;
  text-align: left;
  color: inherit;
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-surface-alt); }
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.row__accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
}
.row--pending  .row__accent { background: var(--state-pending); }
.row--progress .row__accent { background: var(--state-progress); }
.row--done     .row__accent { background: var(--state-done); }
.row--urgent   .row__accent { background: var(--state-urgent); }
.row--urgent { background: color-mix(in srgb, var(--state-urgent-bg) 60%, var(--bg-surface)); }
.row--urgent:hover { background: color-mix(in srgb, var(--state-urgent-bg) 85%, var(--bg-surface)); }

.row__code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.row__primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.row__title {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.25;
  /* Permitir wrap a 2 líneas: hace falta para ver descripciones largas como
     "Palo Aluminio 140 PRO PLASTIFICADO Azul Agujero (PLA)". Si una línea
     es muy larga la cortamos a la segunda línea con ellipsis. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.row__sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}
.row__cell {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 0;
}
.row__cell--strong {
  color: var(--text-primary);
  font-weight: 600;
}
.row__qty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.row__qty-text {
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.row__qty-text small {
  color: var(--text-muted);
  font-weight: 500;
}
.row__qty-bar {
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
  height: 4px;
  overflow: hidden;
}
.row__qty-bar > span {
  display: block;
  height: 100%;
  background: var(--state-progress);
  border-radius: inherit;
}
.row--done .row__qty-bar > span    { background: var(--state-done); }
.row--pending .row__qty-bar > span { background: var(--state-pending); }
.row__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.spec-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.spec-inline > span { display: inline-flex; align-items: center; gap: 4px; }
.spec-inline .sep {
  color: var(--border-medium);
}

/* Inline 3-check pills inside a row */
.checks-inline {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
  min-height: 32px;
  cursor: default;
  font-family: inherit;
}
.check-pill--done {
  background: var(--state-done-bg);
  color: var(--state-done);
  border-color: color-mix(in srgb, var(--state-done) 35%, transparent);
}
.check-pill--next {
  background: var(--state-pending);
  color: var(--text-inverse);
  border-color: var(--state-pending);
  cursor: pointer;
  min-height: 36px;
  padding: 8px 14px;
  font-size: var(--text-sm);
}
.check-pill--next:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.check-pill { font-family: inherit; }

/* Mobile collapse */
@media (max-width: 900px) {
  .row-list__head { display: none; }
  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "code  badge"
      "title actions"
      "specs actions"
      "qty   qty";
    padding: var(--space-md) var(--space-lg) var(--space-md) calc(var(--space-lg) + 4px);
    row-gap: var(--space-sm);
    align-items: flex-start;
  }
  .row > .row__code     { grid-area: code; }
  .row > .row__badge    { grid-area: badge; justify-self: end; }
  .row > .row__primary  { grid-area: title; }
  .row > .row__specs    { grid-area: specs; }
  .row > .row__qty      { grid-area: qty; }
  .row > .row__actions  { grid-area: actions; align-self: flex-start; }
  .row > .row__checks   { grid-column: 1 / -1; }
}

/* Inline layout switcher */
.view-switch {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}
.view-switch__btn {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}
.view-switch__btn:hover { color: var(--text-primary); background: var(--bg-surface-alt); }
.view-switch__btn[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--text-inverse);
}

/* ============================================================
   FILTER STYLES — 3 alternatives
   ============================================================ */

/* A. Native dropdowns */
.filters-dropdowns {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}
.filters-dropdowns__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}
.filters-dropdowns__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.filters-dropdowns .select {
  height: 48px;
}
.filters-dropdowns__reset {
  margin-left: auto;
  align-self: flex-end;
}

/* B. Status as primary tab bar + op as compact select */
.filters-tabs {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  flex-wrap: wrap;
}
.filters-tabs__primary {
  display: flex;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.filters-tabs__btn {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-light);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
  padding: var(--space-md) var(--space-xl);
  min-height: 56px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  position: relative;
}
.filters-tabs__btn:hover { background: var(--bg-surface-alt); }
.filters-tabs__btn[aria-pressed="true"] {
  background: var(--bg-base);
  color: var(--text-primary);
}
.filters-tabs__btn[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
}
.filters-tabs__btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.filters-tabs__btn .num {
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.filters-tabs__btn[aria-pressed="true"] .num {
  background: var(--accent);
  color: var(--text-inverse);
}
.filters-tabs__op {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-lg);
  border-left: 1px solid var(--border-light);
  min-width: 220px;
}
.filters-tabs__op .select { border: none; height: 56px; background-color: transparent; }

/* C. Minimal — colored status pills + op trigger */
.filters-minimal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.filters-minimal__pill {
  appearance: none;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.filters-minimal__pill:hover { border-color: var(--border-medium); color: var(--text-primary); }
.filters-minimal__pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.filters-minimal__pill .num {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--text-xs);
}
.filters-minimal__pill[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}
.filters-minimal__pill[aria-pressed="true"] .num { color: rgba(255,255,255,0.8); }
.filters-minimal__sep {
  width: 1px;
  height: 24px;
  background: var(--border-light);
  margin: 0 var(--space-sm);
}

/* ============================================================
   TABLE — clean table layout (variant A)
   ============================================================ */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tbl thead th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px var(--space-lg);
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.tbl tbody td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: var(--text-sm);
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; transition: background 120ms; }
.tbl tbody tr:hover { background: var(--bg-surface-alt); }
.tbl tbody tr.is-urgent { background: color-mix(in srgb, var(--state-urgent-bg) 50%, var(--bg-surface)); }
.tbl tbody tr.is-urgent:hover { background: color-mix(in srgb, var(--state-urgent-bg) 80%, var(--bg-surface)); }
.tbl__status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.tbl__status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.tbl__code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.tbl__product { font-weight: 700; color: var(--text-primary); }
.tbl__qty-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.tbl__qty-cell small { color: var(--text-muted); font-weight: 500; }
/* Sub-cabeceras de grupo dentro de tbody — mismo aspecto que thead pero
   colocadas tras cada fila de "tbl__group-header". */
.tbl__sub-header th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 8px var(--space-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.tbl__sub-header:hover { background: transparent !important; cursor: default; }
.tbl__group-header:hover { background: transparent !important; cursor: default; }
@media (max-width: 900px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tbody tr {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
  }
  .tbl tbody td { border: none; padding: 4px 0; }
}

/* ============================================================
   SECTIONS — grouped by status (variant B)
   ============================================================ */
.section-block { margin-bottom: var(--space-lg); }
.section-block__head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  margin-bottom: var(--space-sm);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 700;
  width: 100%;
  text-align: left;
  color: inherit;
}
.section-block__head:hover { background: var(--bg-surface-alt); }
.section-block__bar {
  width: 6px;
  height: 24px;
  border-radius: 100px;
}
.section-block--pending  .section-block__bar { background: var(--state-pending); }
.section-block--progress .section-block__bar { background: var(--state-progress); }
.section-block--done     .section-block__bar { background: var(--state-done); }
.section-block--urgent   .section-block__bar { background: var(--state-urgent); }
.section-block__count {
  margin-left: auto;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-inset);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}
.section-block__chevron {
  color: var(--text-muted);
  transition: transform 150ms;
}
.section-block--open .section-block__chevron { transform: rotate(90deg); }

.section-block__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.section-line {
  display: grid;
  grid-template-columns: 110px 1fr auto auto;
  gap: var(--space-lg);
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
  font-size: var(--text-sm);
  min-height: 56px;
  border: none;
  border-radius: 0;
  width: 100%;
}
.section-line:hover { background: var(--bg-surface-alt); }
.section-line__product {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.2;
}
.section-line__sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}
.section-line__qty {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  text-align: right;
}
.section-line__qty small { color: var(--text-muted); font-weight: 500; }
@media (max-width: 700px) {
  .section-line {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "code   qty"
      "title  action"
      "sub    action";
    row-gap: 4px;
  }
  .section-line > .row__code { grid-area: code; }
  .section-line > .section-line__main { grid-area: title; }
}

/* ============================================================
   KANBAN — columns by status (variant C)
   ============================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-lg);
}
@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
}
.kanban__col {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.kanban__head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px var(--space-sm) var(--space-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.kanban__head .dot { width: 10px; height: 10px; border-radius: 50%; }
.kanban__head--pending  .dot { background: var(--state-pending); }
.kanban__head--progress .dot { background: var(--state-progress); }
.kanban__head--done     .dot { background: var(--state-done); }
.kanban__head .count {
  margin-left: auto;
  font-size: var(--text-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  font-weight: 700;
  color: var(--text-secondary);
}
.k-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-align: left;
  font-family: inherit;
  color: inherit;
  width: 100%;
  border-left-width: 1px;
}
.k-card:hover { border-color: var(--border-medium); }
.k-card.is-urgent {
  border-left: 3px solid var(--state-urgent);
  background: color-mix(in srgb, var(--state-urgent-bg) 50%, var(--bg-surface));
}
.k-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.k-card__code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.k-card__title {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}
.k-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.k-card__qty {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.k-card__qty small { color: var(--text-muted); font-weight: 500; }
.k-card__bar {
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
  height: 3px;
  overflow: hidden;
}
.k-card__bar > span { display: block; height: 100%; }
.k-card__action { margin-top: 4px; }

/* ============================================================
   TASK CARD
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1400px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl) var(--space-lg) calc(var(--space-xl) + 4px);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms;
}
.task-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}
.task-card__accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.task-card--pending .task-card__accent { background: var(--state-pending); }
.task-card--progress .task-card__accent { background: var(--state-progress); }
.task-card--done .task-card__accent { background: var(--state-done); }
.task-card--urgent .task-card__accent { background: var(--state-urgent); }
.task-card--urgent { border-color: color-mix(in srgb, var(--state-urgent) 30%, var(--border-light)); }

.task-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
}
.task-card__codes {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.task-card__code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.task-card__title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.task-card__operation {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* Specs row */
.spec-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg) var(--space-xl);
}
.spec {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.spec__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.spec__value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.spec__value--mono { font-family: var(--font-mono); }

.color-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.color-swatch__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border-medium);
  display: inline-block;
}

/* Quantity */
.qty-bar {
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
  position: relative;
}
.qty-bar__fill {
  height: 100%;
  background: var(--state-progress);
  border-radius: inherit;
  transition: width 250ms;
}
.qty-bar--done .qty-bar__fill { background: var(--state-done); }
.qty-bar--pending .qty-bar__fill { background: var(--state-pending); }

.qty-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-xs);
}
.qty-text {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.qty-text__total {
  color: var(--text-muted);
  font-weight: 500;
}
.qty-pct {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Card footer */
.task-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.task-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.task-card__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-medium);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  padding: 0 var(--space-xl);
  height: var(--touch-comfortable);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  letter-spacing: -0.005em;
  min-width: 56px;
  transition: background 150ms, border-color 150ms, transform 80ms;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent-active); border-color: var(--accent-active); }

.btn--ghost {
  background: transparent;
  border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-surface-alt); }

.btn--outline {
  background: var(--bg-surface);
  border-color: var(--border-medium);
}
.btn--outline:hover { background: var(--bg-surface-alt); }

.btn--done {
  background: var(--state-done);
  color: var(--text-inverse);
  border-color: var(--state-done);
  height: var(--touch-large);
  font-size: var(--text-lg);
}
.btn--done:hover { background: #15803d; border-color: #15803d; }

.btn--urgent {
  background: transparent;
  color: var(--state-urgent);
  border-color: var(--state-urgent);
  border-width: 2px;
}
.btn--urgent:hover { background: var(--state-urgent-bg); }

.btn--sm { height: 40px; font-size: var(--text-sm); padding: 0 var(--space-lg); }
.btn--lg { height: var(--touch-large); font-size: var(--text-lg); padding: 0 var(--space-2xl); }
.btn--block { width: 100%; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1.1;
}
.badge--pending { background: var(--state-pending-bg); color: var(--state-pending); }
.badge--progress { background: var(--state-progress-bg); color: var(--state-progress); }
.badge--done { background: var(--state-done-bg); color: var(--state-done); }
.badge--urgent { background: var(--state-urgent-bg); color: var(--state-urgent); }
.badge--draft { background: var(--bg-inset); color: var(--text-secondary); }
.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================================
   FILTERS / TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-xl);
}
.chip-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.chip {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { color: var(--text-primary); }
.chip[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--text-inverse);
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  min-height: 48px;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--text-base);
  font-family: inherit;
  flex: 1;
  height: 48px;
  color: inherit;
}

/* ============================================================
   OPERATOR SELECT SCREEN
   ============================================================ */
.operator-screen {
  min-height: 100vh;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
}
.operator-screen__top {
  padding: var(--space-2xl) var(--space-xl) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}
.operator-screen__hero {
  padding: var(--space-xl);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.operator-screen__title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-sm);
  line-height: 1.1;
}
.operator-screen__sub {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin: 0 0 var(--space-2xl);
}
.operator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg);
}
.operator-btn {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  min-height: 180px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: transform 120ms, border-color 120ms, box-shadow 120ms;
  position: relative;
  overflow: hidden;
}
.operator-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.operator-btn:active { transform: scale(0.985); }
.operator-btn__avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: 0.02em;
}
.operator-btn__name {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0;
}
.operator-btn__role {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}
.operator-btn__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}
.operator-btn__cta {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.operator-btn:hover .operator-btn__cta { color: var(--accent); }

.role-tag {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--state-pending-bg);
  color: var(--state-pending);
}
.role-tag--operario { background: var(--bg-inset); color: var(--text-secondary); }

/* ============================================================
   CHECK PROGRESS (Pedidos)
   ============================================================ */
.check-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}
.check-step {
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border: 1px solid transparent;
  min-height: 64px;
}
.check-step--done {
  background: var(--state-done-bg);
  border-color: color-mix(in srgb, var(--state-done) 30%, transparent);
}
.check-step--next {
  background: var(--state-pending-bg);
  border-color: color-mix(in srgb, var(--state-pending) 40%, transparent);
}
.check-step__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.check-step--done .check-step__icon {
  background: var(--state-done);
  border-color: var(--state-done);
  color: var(--text-inverse);
}
.check-step--next .check-step__icon {
  background: var(--state-pending);
  border-color: var(--state-pending);
  color: var(--text-inverse);
}
.check-step__label {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.1;
}
.check-step__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.check-step--done .check-step__meta { color: var(--state-done); }
.check-step__btn {
  appearance: none;
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: inherit;
  text-align: left;
  color: inherit;
  padding: 0;
}

/* ============================================================
   FORM
   ============================================================ */
.form-screen {
  max-width: 720px;
  margin: 0 auto;
}
.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}
.form-row__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.form-row__label .required { color: var(--state-urgent); }
.form-row__hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-xl);
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-grid .form-row { margin-bottom: 0; }

.input, .select, .textarea {
  appearance: none;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 var(--space-lg);
  height: var(--touch-comfortable);
  width: 100%;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.textarea { padding: var(--space-md) var(--space-lg); height: auto; min-height: 100px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path fill='none' stroke='%235c5c5c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

.form-row--error .input,
.form-row--error .select,
.form-row--error .textarea {
  border-color: var(--state-urgent);
}
.form-error {
  font-size: var(--text-sm);
  color: var(--state-urgent);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Segmented for priority */
.segmented {
  display: inline-flex;
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}
.segmented__btn {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 var(--space-lg);
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 96px;
}
.segmented__btn[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.segmented__btn--urgent[aria-pressed="true"] {
  background: var(--state-urgent);
  color: var(--text-inverse);
}

/* ============================================================
   DETAIL SCREEN
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-xl);
}
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}
.panel__title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-lg);
  letter-spacing: -0.01em;
}

.detail-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg) var(--space-xl);
}
@media (max-width: 640px) {
  .detail-specs { grid-template-columns: 1fr; }
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline__item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  position: relative;
}
.timeline__item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: -8px;
  width: 2px;
  background: var(--border-light);
}
.timeline__dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-medium);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  z-index: 1;
  flex-shrink: 0;
}
.timeline__item--done .timeline__dot {
  background: var(--state-done);
  border-color: var(--state-done);
  color: var(--text-inverse);
}
.timeline__item--progress .timeline__dot {
  background: var(--state-progress);
  border-color: var(--state-progress);
  color: var(--text-inverse);
}
.timeline__main {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.3;
}
.timeline__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-stack {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}
.toast {
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 200ms ease-out;
  max-width: 90vw;
}
.toast--success { background: var(--state-done); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-muted);
  border: 1.5px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--bg-surface-alt);
}
.empty h3 {
  margin: 0 0 var(--space-sm);
  color: var(--text-secondary);
  font-weight: 700;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .app-header { padding: var(--space-md); gap: var(--space-md); }
  .brand-sub { display: none; }
  .page { padding: var(--space-lg) var(--space-md); }
  .page-title { font-size: var(--text-2xl); }
  .tab-bar { padding: 0 var(--space-md); top: 68px; }
  .tab-bar__btn { padding: var(--space-md) var(--space-lg); }
  .counter-card__value { font-size: 2rem; }
}

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

/* ============================================================
   ICON
   ============================================================ */
.ico {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.125em;
}
.ico--md { width: 18px; height: 18px; }
.ico--lg { width: 22px; height: 22px; }

/* Group header (Pedidos) */
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin: var(--space-xl) 0 var(--space-sm);
  padding: 0 var(--space-md);
  flex-wrap: wrap;
}
.group-header:first-of-type { margin-top: var(--space-md); }
.group-header__left {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.group-header__code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 600;
}
.group-header__title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.group-header__date {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.back-link {
  appearance: none;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  margin-bottom: var(--space-md);
}
.back-link:hover { color: var(--text-primary); }
