/* =====================================================================
   FactoryFlow · Estilos
   Móvil primero. Azul principal, tarjetas redondeadas, cifras grandes.
   ===================================================================== */

:root {
  --primary: #1a62d6;
  --primary-600: #1552b5;
  --primary-700: #0f418f;
  --primary-50: #e8f0fd;
  --primary-100: #d3e2fb;

  --bg: #f1f4f9;
  --card: #ffffff;
  --line: #e6eaf0;
  --line-strong: #d5dbe4;
  --text: #16202e;
  --text-2: #4a5566;
  --muted: #7a8494;

  --ok: #16a34a;     --ok-50: #e3f6ea;
  --danger: #dc2626; --danger-50: #fde8e8;
  --warn: #d97706;   --warn-50: #fdf1dc;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 64, .04), 0 6px 20px rgba(16, 32, 64, .06);
  --shadow-lg: 0 10px 30px rgba(16, 32, 64, .14);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tabbar-h: 64px;
  --sidebar-w: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
:focus-visible { outline: 3px solid var(--primary-100); outline-offset: 2px; border-radius: 8px; }

/* ---------------------------------------------------------------------
   Estructura
   --------------------------------------------------------------------- */
.sidebar { display: none; }

.main { min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }

.hero {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 52px;
  border-radius: 0 0 28px 28px;
}
.hero-inner { max-width: 1120px; margin: 0 auto; }
.hero-row { display: flex; align-items: center; gap: 14px; }
.hero-titles { flex: 1; min-width: 0; }
.hero h1 { font-size: 1.5rem; font-weight: 700; }
.hero p { margin-top: 4px; font-size: .9rem; color: rgba(255, 255, 255, .82); }
.hero-back, .hero-brand {
  flex: none; width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); color: #fff;
}
.hero-brand .logo-mark { width: 26px; height: 26px; color: rgba(255,255,255,.0); }
.hero-back:active { background: rgba(255, 255, 255, .28); }

.content {
  max-width: 1120px;
  margin: -32px auto 0;
  padding: 0 16px;
  position: relative;
}

/* Barra inferior (móvil) */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tab .ico { width: 24px; height: 24px; }
.tab.is-active { color: var(--primary); }
.tab.is-active .ico { background: var(--primary-50); border-radius: 10px; padding: 3px; width: 44px; height: 30px; }

/* Escritorio: barra lateral */
@media (min-width: 960px) {
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
    background: var(--card); border-right: 1px solid var(--line);
    padding: 22px 14px;
  }
  .main { margin-left: var(--sidebar-w); padding-bottom: 48px; }
  .tabbar, .fab, .hide-mobile-only { display: none !important; }
  .hero { padding: 34px 32px 64px; border-radius: 0 0 0 32px; }
  .hero h1 { font-size: 1.85rem; }
  .content { padding: 0 32px; margin-top: -40px; }
  .hero-brand { display: none; }
}
@media (max-width: 959px) {
  .hide-mobile { display: none !important; }
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 22px; color: var(--text);
  font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em;
}
.logo-mark { width: 34px; height: 34px; color: var(--primary); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border-radius: 12px; border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-weight: 600; text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.is-active { background: var(--primary-50); color: var(--primary-700); }
.nav-item.is-active .ico { color: var(--primary); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.who { display: flex; align-items: center; gap: 12px; padding: 8px 14px; color: var(--muted); font-size: .9rem; }
.who .ico { width: 20px; height: 20px; }
.nav-logout:hover { color: var(--danger); background: var(--danger-50); }

/* ---------------------------------------------------------------------
   Componentes
   --------------------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(16, 32, 64, .04);
}

.section-title {
  font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 26px 6px 10px;
}

/* KPIs (cifras grandes) */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpis-3 > :last-child:nth-child(odd) { grid-column: span 2; }
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .kpis-3 { grid-template-columns: repeat(3, 1fr); }
  .kpis-3 > :last-child:nth-child(odd) { grid-column: auto; }
}
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; align-items: center; gap: 14px;
}
.kpi small { display: block; color: var(--muted); font-size: .85rem; font-weight: 500; }
.kpi strong { display: block; font-size: 1.9rem; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.tone-blue  { background: var(--primary-50); color: var(--primary); }
.tone-green { background: var(--ok-50); color: var(--ok); }
.tone-red   { background: var(--danger-50); color: var(--danger); }
.tone-amber { background: var(--warn-50); color: var(--warn); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 650; font-size: .95rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 20px; height: 20px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(26, 98, 214, .28); }
.btn-primary:hover { background: var(--primary-600); }
.btn-soft { background: var(--primary-50); color: var(--primary-700); }
.btn-soft:hover { background: var(--primary-100); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger-soft { background: var(--danger-50); color: var(--danger); }
.btn-ok-soft { background: var(--ok-50); color: var(--ok); }
.btn-on-hero { background: rgba(255, 255, 255, .18); color: #fff; }
.btn-on-hero:hover { background: rgba(255, 255, 255, .28); }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.02rem; }

.fab {
  position: fixed; z-index: 25; right: 18px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 58px; height: 58px; border-radius: 20px;
  display: grid; place-items: center;
  background: var(--primary); color: #fff; box-shadow: var(--shadow-lg);
}
.fab .ico { width: 26px; height: 26px; }

.pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--primary-50); color: var(--primary-700); font-size: .8rem; font-weight: 700;
}

/* Avisos */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  font-size: .93rem; font-weight: 500;
}
.alert .ico { width: 20px; height: 20px; margin-top: 1px; }
.content > .alert { box-shadow: var(--shadow); }
.alert-ok { background: #ecfbf1; color: #14683a; }
.alert-error { background: var(--danger-50); color: #9b1c1c; }

/* Formularios */
.form { display: grid; gap: 16px; }
.form-card { padding: 20px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 720px) {
  .form-card { padding: 28px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 18px 20px; }
  .span-2 { grid-column: span 2; }
}
.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 650; color: var(--text-2); }
.field > span small { font-weight: 500; color: var(--muted); }
.req { color: var(--danger); font-weight: 700; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fbfcfe; font-size: 16px; /* evita zoom en iOS */
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px var(--primary-50);
}
.field.has-error input, .field.has-error textarea { border-color: var(--danger); background: #fffafa; }
.field .error { color: var(--danger); font-size: .82rem; font-weight: 600; }
.field .hint { color: var(--muted); font-size: .82rem; }

.form-actions {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}
@media (max-width: 719px) {
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

/* Interruptor en formularios */
.check-row { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; padding: 6px 0; }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 50px; height: 30px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background .2s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.check-row input:checked + .switch { background: var(--primary); }
.check-row input:checked + .switch::after { transform: translateX(20px); }
.check-row input:focus-visible + .switch { box-shadow: 0 0 0 4px var(--primary-100); }

/* Tarjeta de estado (activar / desactivar) */
.status-card {
  margin-top: 16px; padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.status-card p { margin-top: 2px; }
@media (max-width: 559px) {
  .status-card { flex-direction: column; align-items: stretch; }
}

/* Barra de filtros */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.segmented {
  display: flex; flex: 1 1 auto; background: var(--card); padding: 4px; border-radius: 14px;
  box-shadow: var(--shadow);
}
.segmented a {
  flex: 1; text-align: center; padding: 9px 10px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.segmented a b { font-weight: 700; color: var(--muted); margin-left: 2px; font-variant-numeric: tabular-nums; }
.segmented a.is-active { background: var(--primary); color: #fff; }
.segmented a.is-active b { color: rgba(255, 255, 255, .8); }
.search {
  position: relative; flex: 1 1 220px; display: flex; align-items: center;
}
.search .ico { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; padding: 0 14px 0 42px; border-radius: 14px;
  border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 16px;
}
.search input:focus { outline: none; box-shadow: var(--shadow), 0 0 0 3px var(--primary-100); }

/* Listados */
.list-card { overflow: hidden; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main, .row-main-form { flex: 1; min-width: 0; }
.row-main {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; color: inherit; background: none; border: 0; cursor: pointer; text-align: left;
}
.row-main:hover { background: #f8fafd; }
.row-text { flex: 1; min-width: 0; display: grid; }
.row-text strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-text small { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-go { color: var(--line-strong); }
.row.is-off .row-text strong, .row.is-off .avatar { opacity: .5; }
.row.is-off .row-text small::before { content: "Inactivo · "; color: var(--danger); font-weight: 600; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary-700);
  font-weight: 700; font-size: .9rem;
}
.avatar-sq { border-radius: 14px; font-size: .85rem; }
.avatar-ico { border-radius: 14px; }
.avatar-ico.tone-red { background: var(--danger-50); color: var(--danger); }

.row-toggle { padding: 0 16px 0 4px; }
.switch-btn {
  width: 52px; height: 32px; border-radius: 999px; border: 0; padding: 0; cursor: pointer;
  background: var(--line-strong); position: relative; transition: background .2s;
}
.switch-btn span {
  position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch-btn.is-on { background: var(--ok); }
.switch-btn.is-on span { transform: translateX(20px); }
.switch-btn[aria-busy="true"] { opacity: .6; }

/* Vacío */
.empty { display: grid; justify-items: center; gap: 12px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty > .ico { width: 44px; height: 44px; color: var(--primary); background: var(--primary-50); padding: 10px; border-radius: 16px; box-sizing: content-box; }
.empty-lg { padding: 56px 24px; }
.empty h2 { color: var(--text); font-size: 1.3rem; }
.empty p { max-width: 420px; }

/* ---------------------------------------------------------------------
   Acceso (login / setup)
   --------------------------------------------------------------------- */
body.auth {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -120px, var(--primary) 0%, var(--primary-600) 55%, transparent 56%),
    var(--bg);
}
.auth-wrap { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 44px) 16px 32px; }
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #fff; font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; margin-bottom: 30px;
}
.auth-brand .logo-mark { width: 44px; height: 44px; color: rgba(255, 255, 255, .2); }
.auth-card { background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 28px 22px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card > .muted { margin: 6px 0 22px; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 22px; }

/* Indicador de guardado (se usará en el uso diario) */
.save-status {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  padding: 8px 16px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: var(--text); color: #fff; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.save-status.is-visible { opacity: 1; }
@media (min-width: 960px) { .save-status { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =====================================================================
   Hoja de Control
   ===================================================================== */
.alert-info { background: var(--primary-50); color: var(--primary-700); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: .85rem; padding: 8px 6px;
}
.btn-link .ico { width: 16px; height: 16px; }
.btn-link:hover { color: var(--danger); }

/* Selector de día */
.daybar { display: flex; align-items: center; gap: 6px; padding: 6px; margin-bottom: 14px; }
.daybar-nav {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: var(--text-2); flex: none;
}
.daybar-nav:hover { background: var(--bg); }
.daybar-nav.is-disabled { opacity: .25; }
.daybar-date {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border-radius: 14px; font-weight: 700; cursor: pointer; color: var(--primary-700);
}
.daybar-date:hover { background: var(--primary-50); }
.daybar-date .ico { width: 18px; height: 18px; }
.daybar-date input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; }

/* Dashboard de 5 cifras */
.kpis-5 { grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.kpis-5 .kpi { grid-column: span 2; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
.kpis-5 .kpi:nth-child(n+4) { grid-column: span 3; flex-direction: row; align-items: center; gap: 12px; padding: 14px; }
.kpis-5 .kpi-ico { width: 34px; height: 34px; border-radius: 11px; }
.kpis-5 .kpi-ico .ico { width: 18px; height: 18px; }
.kpis-5 .kpi small { font-size: .78rem; }
.kpis-5 .kpi strong { font-size: 1.7rem; }
.kpi strong i { font-style: normal; font-size: .6em; color: var(--muted); font-weight: 600; }
.kpi-note { display: block; font-style: normal; font-size: .74rem; color: var(--muted); font-weight: 600; min-height: 1em; }
.kpi-note:empty { display: none; }
@media (min-width: 720px) {
  .kpis-5 { grid-template-columns: repeat(5, 1fr); gap: 16px; }
  .kpis-5 .kpi, .kpis-5 .kpi:nth-child(n+4) { grid-column: auto; flex-direction: row; align-items: center; gap: 14px; padding: 16px; }
  .kpis-5 .kpi-ico { width: 46px; height: 46px; border-radius: 14px; }
  .kpis-5 .kpi-ico .ico { width: 22px; height: 22px; }
  .kpis-5 .kpi small { font-size: .85rem; }
  .kpis-5 .kpi strong { font-size: 1.9rem; }
}

.control-bar { align-items: stretch; }
.control-bar .btn { flex: 1 1 100%; min-height: 50px; }
@media (min-width: 720px) { .control-bar .btn { flex: 0 0 auto; } }

/* Filas de operarios */
.ops { list-style: none; margin: 0; padding: 0; }
.op-head { display: none; }
.op { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; padding: 14px 14px 16px; border-bottom: 1px solid var(--line); }
.op:last-child { border-bottom: 0; }
.op[hidden] { display: none; }
.op-who { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.op-who .row-text strong { white-space: normal; line-height: 1.2; font-size: .95rem; }
.op-tag {
  flex: none; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis;
}
.tag-mesa { background: var(--primary-50); color: var(--primary-700); }
.tag-asig { background: #efe9fb; color: #5b34b5; }
.tag-sin  { background: var(--warn-50); color: #9a5a06; }
.tag-B, .tag-F { background: var(--danger-50); color: var(--danger); }
.tag-Pe { background: #eef0f3; color: var(--text-2); }

.estados { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.est {
  min-height: 46px; border-radius: 14px; border: 0; cursor: pointer;
  background: #eef1f6; color: var(--text-2); font-weight: 750; font-size: 1rem;
  transition: background .12s, color .12s, transform .05s;
}
.est:active { transform: scale(.97); }
.est:disabled { cursor: default; }
.est-P.is-on  { background: var(--ok); color: #fff; }
.est-B.is-on  { background: var(--danger); color: #fff; }
.est-F.is-on  { background: var(--warn); color: #fff; }
.est-Pe.is-on { background: #5b6b82; color: #fff; }

.op-field { display: grid; gap: 4px; min-width: 0; }
.op-field > span { font-size: .72rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.op-field select, .op-field input {
  width: 100%; min-height: 46px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); background: #fbfcfe; font-size: 16px; min-width: 0;
}
.op-field select:focus, .op-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); background: #fff; }
.op-field select:disabled, .op-field input:disabled { opacity: .5; background: var(--bg); }
.op-motivo { grid-column: 1 / -1; }
/* En móvil solo se ven los campos que aplican */
@media (max-width: 959px) {
  .op-field:has(:disabled) { display: none; }
  body.app .op[data-estado="P"] .op-motivo { display: none; }
}

@media (min-width: 960px) {
  .op-head, .op {
    display: grid; align-items: center; gap: 14px; padding: 12px 18px;
    grid-template-columns: minmax(220px, 1.5fr) 232px 150px 190px minmax(140px, 1fr);
  }
  .op-head { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: #f8fafd; border-bottom: 1px solid var(--line); }
  .op-who, .estados, .op-motivo { grid-column: auto; }
  .op-field > span { display: none; }
  .op-tag { display: none; }
  .est { min-height: 40px; border-radius: 12px; }
  .op-field select, .op-field input { min-height: 40px; font-size: .93rem; }
}

/* Reparto por mesa */
.section-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.reparto { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .reparto { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; } }
.mesa { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; min-width: 0; }
.mesa-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mesa-top b { font-size: 1.05rem; color: var(--primary-700); }
.mesa-top span { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary-700); font-size: .8rem; font-weight: 700; }
.mesa ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.mesa li { font-size: .82rem; color: var(--text-2); line-height: 1.25; }
.mesa p { font-size: .82rem; color: var(--muted); }
.mesa.is-empty { box-shadow: none; background: transparent; border: 1.5px dashed var(--line-strong); }
.mesa.is-empty .mesa-top b { color: var(--muted); }
.mesa.is-empty .mesa-top span { background: transparent; color: var(--muted); }
.mesa-asig .mesa-top b { color: #5b34b5; } .mesa-asig .mesa-top span { background: #efe9fb; color: #5b34b5; }
.mesa-sin { background: var(--warn-50); box-shadow: none; }
.mesa-sin .mesa-top b { color: #9a5a06; } .mesa-sin .mesa-top span { background: #fff; color: #9a5a06; }

/* Ventana modal */
.modal-back {
  position: fixed; inset: 0; z-index: 60; background: rgba(15, 25, 45, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  border-radius: 24px 24px 0 0; padding: 22px 18px calc(18px + var(--safe-b)); box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 1.25rem; margin-bottom: 10px; }
.modal-body { overflow-y: auto; flex: 1; min-height: 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; padding: 0 10px; }
@media (min-width: 720px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { border-radius: 24px; padding: 26px; }
  .modal-actions { justify-content: flex-end; } .modal-actions .btn { flex: 0 0 auto; padding: 0 18px; }
}
.prop { display: grid; gap: 2px; margin-top: 12px; }
.prop-row { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); }
.prop-row > b { color: var(--primary-700); padding-top: 3px; }
.prop-row > div { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.chip-new { background: var(--ok-50); color: #14683a; }
.chip-old { background: #eef1f6; color: var(--muted); }
