/* ==========================================================================
   Embalatges Prats · Management panel
   ========================================================================== */
:root {
  --bg: #f3f5f9; --surface: #fff; --surface-2: #f7f9fc; --line: #e3e8ef; --line-2: #eef1f6;
  --text: #0f1a2b; --text-2: #4a5566; --text-3: #8591a3;
  --blue: #2a6fd1; --blue-600: #1f5aa6; --blue-50: #eaf2ff; --navy: #0b1526; --navy-2: #10203a;
  --wood: #d9a35b; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 16px; --shadow: 0 1px 2px rgba(15,26,43,.04), 0 8px 24px -12px rgba(15,26,43,.12);
  --side: 256px; --top: 64px;
  --font-head: 'Exo 2', system-ui, sans-serif; --font-body: 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #080f1c; --surface: #0f1b2e; --surface-2: #13223a; --line: #1e2f4a; --line-2: #182842;
  --text: #e6edf7; --text-2: #a9b6c9; --text-3: #71819a; --blue-50: rgba(42,111,209,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 1000; display: grid; background: var(--navy); overflow-y: auto; }
@media (min-width: 960px) { .login { grid-template-columns: 1.1fr 1fr; } }
.login.hide { display: none; }
.login-art { position: relative; display: none; background: url('../assets/img/storage.jpg') center/cover; }
.login-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(11,21,38,.9), rgba(31,90,166,.55)); }
.login-art .quote { position: absolute; left: 48px; right: 48px; bottom: 48px; z-index: 1; color: #fff; }
.login-art .quote h2 { font-family: var(--font-head); font-size: 40px; line-height: 1.1; margin: 0 0 10px; }
.login-art .quote p { color: #c7d5ea; margin: 0; max-width: 460px; }
@media (min-width: 960px) { .login-art { display: block; } }
.login-box { display: flex; flex-direction: column; justify-content: center; padding: 40px 20px; max-width: 460px; width: 100%; margin: 0 auto; color: #fff; }
.login-box .brand { margin-bottom: 36px; }
.login-box h1 { font-family: var(--font-head); font-size: 30px; margin: 0 0 6px; }
.login-box > p { color: #9fb0c8; margin: 0 0 28px; }
.login-box label { display: block; font-size: 13px; color: #9fb0c8; margin: 14px 0 6px; font-weight: 600; }
.login-box input { width: 100%; min-height: 50px; border-radius: 12px; border: 1px solid #243a5c; background: #0f1d33; color: #fff; padding: 0 14px; }
.login-box input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(42,111,209,.25); }
.login-box .row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 22px; font-size: 13px; color: #9fb0c8; }
.login-box .row label { margin: 0; display: flex; gap: 8px; align-items: center; font-weight: 500; }
.login-box .row input { width: auto; min-height: 0; accent-color: var(--blue); }
.login-box .demo-note { margin-top: 18px; font-size: 12.5px; color: #7f93b0; text-align: center; }
.login-box .back { margin-top: 24px; text-align: center; font-size: 13px; color: #9fb0c8; }
.login-box .back a { color: var(--wood); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand { flex-direction: column; align-items: flex-start; gap: 6px; }
.brand-logo { display: block; height: 34px; width: auto; }
.login-box .brand-logo { height: 48px; }
.brand small { display: block; font-size: 10px; letter-spacing: .22em; color: #7f93b0; text-transform: uppercase; padding-left: 2px; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #c2cee0; z-index: 60; display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.sidebar .brand { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.side-nav .grp { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #5f7291; margin: 14px 10px 6px; font-weight: 600; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 500; color: #b7c4d8; transition: background .2s, color .2s; position: relative; }
.side-nav a svg { width: 19px; height: 19px; opacity: .85; }
.side-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.side-nav a.on { background: linear-gradient(90deg, rgba(42,111,209,.35), rgba(42,111,209,.08)); color: #fff; }
.side-nav a.on::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #4d93f0; }
.side-nav .count { margin-left: auto; background: var(--wood); color: var(--navy); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.side-user { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.04); }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--blue), #4d93f0); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.side-user b { display: block; color: #fff; font-size: 13.5px; }
.side-user small { color: #7f93b0; font-size: 12px; }
.side-user button { margin-left: auto; border: 0; background: none; color: #7f93b0; padding: 6px; border-radius: 8px; }
.side-user button:hover { color: #fff; background: rgba(255,255,255,.08); }
.scrim { position: fixed; inset: 0; background: rgba(7,13,24,.5); z-index: 55; opacity: 0; visibility: hidden; transition: .3s; }
body.side-open .sidebar { transform: none; }
body.side-open .scrim { opacity: 1; visibility: visible; }
@media (min-width: 1100px) {
  .sidebar { transform: none; }
  .main { margin-left: var(--side); }
  .scrim, .menu-btn { display: none !important; }
}

.topbar { position: sticky; top: 0; z-index: 40; height: var(--top); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
@media (min-width: 768px) { .topbar { padding: 0 28px; } }
.topbar h1 { font-family: var(--font-head); font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; position: relative; color: var(--text-2); transition: .2s; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--bg); }
.gsearch { display: none; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; height: 40px; width: 300px; color: var(--text-3); }
.gsearch input { border: 0; background: none; outline: none; width: 100%; color: var(--text); }
.gsearch kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
@media (min-width: 900px) { .gsearch { display: flex; } }
.topbar .to-site { display: none; }
@media (min-width: 640px) { .topbar .to-site { display: inline-flex; } }
/* TEMPORARY: test-data buttons (icon only on phones) */
.topbar .test-btn { border-style: dashed; }
@media (max-width: 639px) { .topbar .test-btn span { display: none; } .topbar .test-btn { padding: 0 9px; } }

.content { padding: 18px 14px 100px; max-width: 1600px; }
@media (min-width: 768px) { .content { padding: 26px 28px 60px; } }
.view { display: none; animation: vin .35s cubic-bezier(.2,.8,.2,1); }
.view.on { display: block; }
@keyframes vin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* bottom nav (mobile) */
.bnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 4px 0; position: relative; }
.bnav a svg { width: 22px; height: 22px; }
.bnav a.on { color: var(--blue); }
.bnav .count { position: absolute; top: 0; left: 55%; background: var(--bad); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; }
@media (min-width: 768px) { .bnav { display: none; } }

/* ---------- common UI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-family: var(--font-head); font-size: 16px; }
.card-h small { color: var(--text-3); }
.card-b { padding: 16px 18px 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent; background: var(--blue); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; transition: .2s; }
.btn:hover { background: var(--blue-600); }
.btn svg { width: 17px; height: 17px; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn--wood { background: var(--wood); color: var(--navy); }
.btn--wood:hover { background: #c98f45; }
.btn--danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.web { color: #7c3aed; background: rgba(124,58,237,.1); border-color: transparent; }
.chip.alta { color: var(--bad); background: rgba(220,38,38,.1); border-color: transparent; }
.chip.media { color: var(--warn); background: rgba(217,119,6,.1); border-color: transparent; }
.chip.baja { color: var(--ok); background: rgba(22,163,74,.1); border-color: transparent; }
.chip.new { background: var(--wood); color: var(--navy); border-color: transparent; animation: glow 1.8s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(217,163,91,.25); } }
.input, .select { height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; min-width: 0; color: var(--text); }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,111,209,.18); }
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; width: 100%; }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; color: var(--text-3); flex: 1 1 240px; min-width: 0; }
.search-box input { border: 0; outline: none; background: none; width: 100%; color: var(--text); }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,111,209,.18); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .select { flex: 0 1 auto; }
.muted { color: var(--text-3); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--text-3); }

/* ---------- dashboard ---------- */
.greet { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.greet h2 { font-family: var(--font-head); font-size: clamp(22px, 3vw, 28px); margin: 0; }
.greet p { margin: 2px 0 0; color: var(--text-2); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--blue); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { padding: 16px; position: relative; overflow: hidden; }
.kpi .k-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .k-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.kpi .k-ico svg { width: 18px; height: 18px; }
.kpi small { display: block; color: var(--text-3); font-size: 12.5px; font-weight: 500; margin-top: 12px; }
.kpi b { display: block; font-family: var(--font-head); font-size: clamp(20px, 2.4vw, 26px); line-height: 1.2; letter-spacing: -.01em; }
.kpi .delta { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.kpi .delta.up { color: var(--ok); background: rgba(22,163,74,.1); }
.kpi .delta.down { color: var(--bad); background: rgba(220,38,38,.1); }
.kpi canvas.spark { position: absolute; right: 0; bottom: 0; width: 55% !important; height: 38px !important; opacity: .9; pointer-events: none; }
.dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.dgrid > * { min-width: 0; }
@media (min-width: 1100px) {
  .dgrid { grid-template-columns: repeat(12, 1fr); }
  .c-8 { grid-column: span 8; } .c-4 { grid-column: span 4; } .c-6 { grid-column: span 6; } .c-12 { grid-column: span 12; } .c-5 { grid-column: span 5; } .c-7 { grid-column: span 7; }
}
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 320px; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 3px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .grow small { color: var(--text-3); }
.list .clickable { cursor: pointer; }
.list .clickable:hover b { color: var(--blue); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 8px 0; cursor: pointer; }
.bar-row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), #4d93f0); transform-origin: left; animation: grow 1s cubic-bezier(.2,.8,.2,1); }
@keyframes grow { from { transform: scaleX(0); } }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 13.5px; }
.alert-item.warn { background: rgba(217,119,6,.1); color: var(--text); }
.alert-item.bad { background: rgba(220,38,38,.1); }
.alert-item.info { background: var(--blue-50); }
.alert-item svg { width: 18px; height: 18px; margin-top: 1px; }
.alert-item.warn svg { color: var(--warn); } .alert-item.bad svg { color: var(--bad); } .alert-item.info svg { color: var(--blue); }
.alert-item b { cursor: pointer; }
.funnel { display: grid; gap: 8px; }
.funnel div { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 13.5px; margin: 0 auto; transition: width 1s; min-width: 58%; }

/* ---------- kanban ---------- */
.kanban-wrap { margin: 0 -14px; }
@media (min-width: 768px) { .kanban-wrap { margin: 0; } }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(84vw, 1fr); gap: 12px; overflow-x: auto; padding: 0 14px 16px; scroll-snap-type: x mandatory; scroll-padding: 14px; align-items: start; min-height: 60vh; }
@media (min-width: 600px) { .kanban { grid-auto-columns: minmax(300px, 1fr); } }
@media (min-width: 768px) { .kanban { padding: 0 0 16px; scroll-padding: 0; } }
@media (min-width: 1100px) { .kanban { grid-auto-columns: minmax(268px, 1fr); } }
@media (min-width: 1700px) { .kanban { grid-auto-columns: minmax(240px, 1fr); } }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); scroll-snap-align: start; min-height: 200px; transition: background .2s, border-color .2s; }
.kcol.over { background: var(--blue-50); border-color: var(--blue); border-style: dashed; }
.kcol-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.kcol-h i { width: 10px; height: 10px; border-radius: 3px; }
.kcol-h b { font-family: var(--font-head); font-size: 14.5px; }
.kcol-h .n { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.kcol-sum { font-size: 12px; color: var(--text-3); padding: 6px 14px 0; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 80px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; cursor: grab; box-shadow: 0 1px 2px rgba(15,26,43,.05); transition: box-shadow .2s, transform .2s, border-color .2s; user-select: none; -webkit-user-select: none; position: relative; touch-action: pan-y; }
.kcard:hover { box-shadow: 0 8px 22px -12px rgba(15,26,43,.35); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.kcard::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, var(--blue)); }
.kcard .kc-top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.kcard .code { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--blue); }
.kcard h4 { margin: 6px 0 2px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.kcard p { margin: 0; font-size: 12.5px; color: var(--text-3); }
.kcard .kc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.kcard .kc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12.5px; }
.kcard .kc-foot b { font-family: var(--font-head); font-size: 15px; }
.kcard .late { color: var(--bad); font-weight: 600; }
.kcard.ghost { opacity: .35; }
.kcard.dragging { position: fixed; z-index: 999; pointer-events: none; transform: rotate(3deg) scale(1.03); box-shadow: 0 24px 50px -12px rgba(7,13,24,.45); cursor: grabbing; }
.kcard.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--wood); } }
.drop-ph { border: 2px dashed var(--blue); border-radius: 13px; background: var(--blue-50); flex: none; }
.kanban-hint { font-size: 12.5px; color: var(--text-3); margin: -6px 0 12px; }
body.dragging-card { cursor: grabbing; user-select: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tbody tr { transition: background .15s; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t tr.click { cursor: pointer; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 767px) {
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 10px; padding: 8px 12px; background: var(--surface); }
  table.t.stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.t.stack td::before { content: attr(data-l); color: var(--text-3); font-size: 12px; font-weight: 600; text-align: left; }
  table.t.stack td.num { text-align: right; }
  table.t.stack td.head { font-size: 15px; font-weight: 600; text-align: left; }
  table.t.stack td.head::before { display: none; }
  .table-wrap.cardless { border: 0; background: none; box-shadow: none; }
}

/* ---------- clients ---------- */
.client-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .client-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1300px) { .client-grid { grid-template-columns: repeat(3, 1fr); } }
.ccard { padding: 16px; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.ccard:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.ccard .cc-top { display: flex; gap: 12px; align-items: center; }
.ccard .avatar { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.ccard h4 { margin: 0; font-size: 15px; line-height: 1.25; }
.ccard .cc-top small { color: var(--text-3); }
.ccard .cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.ccard .cc-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px; }
.ccard .cc-stats small { display: block; font-size: 11px; color: var(--text-3); }
.ccard .cc-stats b { font-size: 14px; font-family: var(--font-head); }
.tier { font-family: var(--font-head); font-weight: 800; font-size: 12px; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; margin-left: auto; flex: none; }
.tier.A { background: rgba(217,163,91,.2); color: #a86b1f; } .tier.B { background: var(--blue-50); color: var(--blue); } .tier.C { background: var(--surface-2); color: var(--text-3); }
mark { background: rgba(217,163,91,.35); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- inventory ---------- */
.stock-bar { width: 100%; min-width: 90px; height: 8px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.stock-bar i { display: block; height: 100%; border-radius: 6px; background: var(--ok); }
.stock-bar i.low { background: var(--bad); } .stock-bar i.mid { background: var(--warn); }
.qty-ctrl { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty-ctrl button { border: 0; background: var(--surface-2); width: 32px; height: 32px; font-size: 16px; font-weight: 700; color: var(--text-2); }
.qty-ctrl button:hover { background: var(--blue-50); color: var(--blue); }
.qty-ctrl span { min-width: 56px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- drawer / modal ---------- */
.drawer { position: fixed; inset: 0; z-index: 200; visibility: hidden; }
.drawer.on { visibility: visible; }
.drawer .ov { position: absolute; inset: 0; background: rgba(7,13,24,.45); opacity: 0; transition: opacity .3s; }
.drawer.on .ov { opacity: 1; }
.drawer .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); box-shadow: -20px 0 60px -20px rgba(7,13,24,.4); transform: translateX(100%); transition: transform .38s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.on .panel { transform: none; }
.drawer .p-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer .p-h h3 { margin: 0; font-family: var(--font-head); font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer .p-b { flex: 1; overflow-y: auto; padding: 18px; overscroll-behavior: contain; }
.drawer .p-f { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 8px; flex-wrap: wrap; }
.drawer .p-f .btn { flex: 1 1 140px; }
@media (max-width: 767px) {
  .drawer .panel { top: auto; height: 92vh; width: 100%; border-radius: 20px 20px 0 0; transform: translateY(100%); }
  .drawer .p-h { border-radius: 20px 20px 0 0; }
  .drawer .p-h::before { content: ''; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
}
.sec { margin-bottom: 18px; }
.sec h5 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kv div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kv small { display: block; font-size: 11.5px; color: var(--text-3); }
.kv b { font-weight: 600; word-break: break-word; }
.kv .wide { grid-column: 1 / -1; }
.status-steps { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.status-steps button { flex: 1 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 12px; font-weight: 600; padding: 8px 10px; color: var(--text-2); white-space: nowrap; }
.status-steps button.done { background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); border-color: transparent; }
.status-steps button.cur { background: var(--c); color: #fff; border-color: var(--c); }
.hist { list-style: none; margin: 0; padding: 0; position: relative; }
.hist li { position: relative; padding: 0 0 12px 22px; font-size: 13.5px; }
.hist li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--blue)); }
.hist li::after { content: ''; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.hist li:last-child::after { display: none; }
.hist small { color: var(--text-3); margin-left: 6px; }
.attach { display: flex; flex-wrap: wrap; gap: 6px; }
.attach span { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.price-big { font-family: var(--font-head); font-size: 30px; font-weight: 800; letter-spacing: -.01em; }

.modal { position: fixed; inset: 0; z-index: 300; background: rgba(7,13,24,.5); display: none; align-items: flex-end; justify-content: center; }
.modal.on { display: flex; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
.modal .m-card { background: var(--surface); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px; animation: up .35s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); } }
@media (min-width: 700px) { .modal { align-items: center; padding: 20px; } .modal .m-card { max-width: 620px; border-radius: 20px; padding: 26px; } }
.modal h3 { margin: 0 0 16px; font-family: var(--font-head); font-size: 20px; }
.fgrid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 480px) { .fgrid { grid-template-columns: 1fr; } }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.fld .input, .fld .select { width: 100%; }
.m-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.m-actions .btn { flex: 0 1 auto; }
@media (max-width: 480px) { .m-actions .btn { flex: 1 1 auto; } }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.checks input { accent-color: var(--blue); width: 16px; height: 16px; }
.quote-preview { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--blue-50); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.quote-preview b { font-family: var(--font-head); font-size: 22px; color: var(--blue); }

/* notifications */
.notif { position: absolute; top: calc(var(--top) - 6px); right: 12px; width: min(380px, calc(100vw - 24px)); z-index: 80; display: none; }
.notif.on { display: block; animation: vin .25s; }
.notif .list li { padding: 10px 14px; cursor: pointer; }
.notif .list li:hover { background: var(--surface-2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 30px); opacity: 0; z-index: 900; background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 16px 40px -12px rgba(7,13,24,.5); transition: .35s cubic-bezier(.2,.8,.2,1); display: flex; gap: 10px; align-items: center; max-width: calc(100% - 24px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast button { border: 0; background: none; color: var(--wood); font-weight: 700; padding: 0 0 0 6px; }
@media (min-width: 768px) { .toast { bottom: 24px; } }

/* settings / rates */
.rates-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .rates-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .rates-grid { grid-template-columns: repeat(3, 1fr); } }
.rate { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; }
.rate label { font-weight: 600; font-size: 13.5px; }
.rate small { display: block; color: var(--text-3); font-size: 12px; font-weight: 400; }
.rate input { width: 110px; text-align: right; }

/* messages */
.msg { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.msg.unread { background: var(--blue-50); }
.msg b { font-weight: 600; }
.msg p { margin: 6px 0 0; color: var(--text-2); }

/* print (budget) */
.print-doc { display: none; }
@media print {
  body > *:not(.print-doc) { display: none !important; }
  .print-doc { display: block !important; color: #000; font-family: var(--font-body); padding: 10mm; }
  .print-doc h1 { font-family: var(--font-head); }
  .print-doc table { width: 100%; border-collapse: collapse; }
  .print-doc td, .print-doc th { border-bottom: 1px solid #ccc; padding: 6px 4px; text-align: left; }
}
.drawer.on ~ .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- orders · rows view ---------- */
table.orows td { vertical-align: middle; }
table.orows tbody tr { box-shadow: inset 3px 0 0 var(--c, transparent); }
table.orows .ocode { font-family: var(--font-head); font-weight: 700; color: var(--blue); white-space: nowrap; }
table.orows .wood-in { width: 110px; height: 34px; }
table.orows .st-sel { height: 34px; min-width: 150px; font-weight: 600; color: var(--c); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
table.orows .st-sel option { color: var(--text); background: var(--surface); }
@media (max-width: 767px) {
  table.orows.stack tr { box-shadow: inset 4px 0 0 var(--c, transparent); cursor: pointer; }
  table.orows .wood-in { width: 120px; }
  table.orows .st-sel { min-width: 0; max-width: 60%; }
}

/* ==========================================================================
   Production panel additions (Firebase, Excel calculator)
   ========================================================================== */
.login-msg { min-height: 20px; margin: 14px 0 0; font-size: 13.5px; color: #fca5a5; text-align: center; }
.login-msg.ok { color: #86efac; }
.login-box button[disabled] { opacity: .6; cursor: wait; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 60px 16px; color: var(--text-3); }
.boot[hidden] { display: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip.ok { color: var(--ok); background: rgba(22,163,74,.1); border-color: transparent; }
.chip.wood { color: #8a5a1c; background: rgba(217,163,91,.18); border-color: transparent; }
.attach a { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--blue); }
.msg-body { white-space: pre-wrap; margin: 0; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check-row input { width: 16px; height: 16px; accent-color: var(--blue); }

/* requests inbox */
.req-list li { padding: 12px 16px; }
.req-list li.unread { background: var(--blue-50); }
.req-list .k-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.req-list .grow b { white-space: normal; }
.req-list .grow b .chip { margin-left: 4px; vertical-align: 1px; }

/* wide modal (order editor, mapping) */
@media (min-width: 700px) { .modal .m-card.wide { max-width: min(1500px, 96vw); width: 96vw; } }
.oe-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.oe-head h3 { margin: 0 !important; }
.oe { display: grid; gap: 18px; }
@media (min-width: 1100px) { .oe { grid-template-columns: minmax(320px, 400px) 1fr; align-items: start; } }
.oe-form { align-content: start; }
.oe-newclient { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.oe-newclient[hidden] { display: none; }
.oe-calc { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.oe-results { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.oe-r { flex: 1 1 140px; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.oe-r small { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.oe-r .input { height: 36px; font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.oe-r .input[readonly] { background: transparent; border-color: transparent; padding-left: 0; }
.oe-r b { font-family: var(--font-head); font-size: 18px; }
.oe-r em { font-style: normal; font-size: 11.5px; color: var(--text-3); }
.oe-r.big { flex: 2 1 220px; background: var(--blue-50); border-color: transparent; }
.oe-r.big .input { font-size: 22px; color: var(--blue); }
.oe-err { flex-basis: 100%; margin: 0; color: var(--bad); font-size: 13px; font-weight: 600; }

/* spreadsheet */
.xl-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); min-width: 0; }
.xl-tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.xl-tabs button { border: 1px solid transparent; border-bottom: 0; background: none; padding: 7px 14px; border-radius: 9px 9px 0 0; font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.xl-tabs button.on { background: var(--surface); border-color: var(--line); color: var(--blue); margin-bottom: -1px; }
.xl-scroll { overflow: auto; max-height: min(62vh, 640px); }
table.xl { border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; font-variant-numeric: tabular-nums; }
table.xl th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 11.5px; text-align: center; padding: 4px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line); }
table.xl tbody th { position: sticky; left: 0; z-index: 1; border-bottom: 1px solid var(--line-2); }
table.xl thead th:first-child { left: 0; z-index: 3; }
table.xl td { position: relative; height: 28px; padding: 0 6px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
table.xl td.b { font-weight: 700; }
table.xl td.f { background: color-mix(in srgb, var(--surface-2) 60%, transparent); text-align: right; color: var(--text-2); }
table.xl td.in { padding: 0; }
table.xl td.in input { width: 100%; height: 27px; border: 0; background: transparent; padding: 0 6px; font: inherit; color: inherit; }
table.xl td.in input:focus { outline: 2px solid var(--blue); outline-offset: -2px; background: var(--surface); }
table.xl td.role-in { background: #fff7d6 !important; box-shadow: inset 0 0 0 2px #e6b800; }
table.xl td.role-out { background: #e3eeff !important; box-shadow: inset 0 0 0 2px var(--blue); color: var(--blue); font-weight: 700; }
[data-theme="dark"] table.xl td.role-in { background: rgba(230,184,0,.16) !important; }
[data-theme="dark"] table.xl td.role-out { background: rgba(42,111,209,.2) !important; }
.xl-badge { position: absolute; top: -1px; right: 2px; font-size: 9px; font-weight: 700; letter-spacing: .02em; color: var(--text-3); pointer-events: none; text-transform: uppercase; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
td.role-in .xl-badge { color: #8a6d00; }
td.role-out .xl-badge { color: var(--blue); }
.xl-note { margin: 8px 10px; font-size: 12px; }
#mapSheet table.xl td { cursor: crosshair; }
#mapSheet table.xl td:hover { outline: 2px dashed var(--blue); outline-offset: -2px; }

/* template settings + mapping editor */
.tpl-active { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.tpl-active .grow { flex: 1; min-width: 0; }
.tpl-active .grow b { display: block; font-family: var(--font-head); font-size: 16px; }
.tpl-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: rgba(22,163,74,.12); color: var(--ok); flex: none; }
.map-sum { display: grid; gap: 6px; margin: 14px 0; }
.map-sum div { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-empty ol { padding-left: 20px; line-height: 1.7; }
.tpl-h { margin: 20px 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.map-ed { display: grid; gap: 16px; }
@media (min-width: 1100px) { .map-ed { grid-template-columns: minmax(360px, 440px) 1fr; align-items: start; } }
.map-fields { max-height: 66vh; overflow-y: auto; padding-right: 4px; }
.map-fields h5 { margin: 14px 0 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.map-fields h5:first-child { margin-top: 0; }
.map-row { display: grid; grid-template-columns: 1fr minmax(140px, 180px) auto; gap: 6px; align-items: center; padding: 5px 6px; border-radius: 10px; }
.map-row.picking { background: var(--blue-50); }
.map-l { font-size: 13px; font-weight: 600; }
.map-ref { height: 34px; font-size: 12.5px; }
.map-v { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-3); margin-top: -2px; }
.map-v:empty { display: none; }
@media (max-width: 1099px) { .map-fields { max-height: 40vh; } }
[hidden] { display: none !important; }

/* ---------- order editor: pricing mode + Jaula Josep calculator ---------- */
.oe-mode { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.oe-mode > small { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.oe-mode .seg button { padding: 6px 12px; }
/* calculator: tabs on top (Formulario · Hoja · Vista de impresión) */
.jx-tabs { align-items: flex-end; flex-wrap: wrap; overflow: visible; }
.jx-tools { margin-left: auto; display: flex; gap: 6px; padding: 0 4px 6px; }
.jx-tools .btn { height: 32px; }
/* form: the 'Medidas Jaula' cells field by field, in the workbook's column order */
.jx-params { max-height: min(64vh, 680px); overflow: auto; padding: 12px; display: grid; gap: 12px; }
.jx-cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-items: start; }
.jx-col { display: grid; gap: 12px; min-width: 0; }
.jx-g { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 10px; margin: 0; min-width: 0; background: var(--surface); display: grid; gap: 6px; }
.jx-g legend { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 0 6px; }
.jx-g > p { margin: 0; font-size: 12px; }
.jx-g .jx-f { display: grid; grid-template-columns: 1fr 92px; align-items: center; gap: 8px; min-width: 0; }
.jx-f > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 4px; min-width: 0; }
.jx-f > span i { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }
.jx-f > span button { border: 0; background: none; color: #b7791f; font-weight: 700; padding: 0 2px; cursor: pointer; }
.jx-f .input, .jx-acc .input, .jx-acc .select { height: 32px; width: 100%; font-variant-numeric: tabular-nums; text-align: right; }
.jx-acc .select { text-align: left; }
.jx-f.auto .input::placeholder { color: var(--text-2); opacity: 1; font-style: italic; }
.jx-f.auto .input { background: var(--surface-2); }
.jx-legend { margin: 0; font-size: 12px; }
.jx-key.lnk { background: var(--blue-50); color: var(--blue); }
.jx-f.ovr .input { border-color: #e6b800; background: color-mix(in srgb, #e6b800 9%, var(--surface)); }
.jx-f.linked .input { background: var(--blue-50); border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); }
.jx-sep > span { color: var(--text-3); }
.jx-sep b { text-align: right; font-variant-numeric: tabular-nums; padding-right: 10px; }
.jx-del { position: absolute; top: -2px; right: 8px; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text-3); display: grid; place-items: center; cursor: pointer; }
.jx-del svg { width: 12px; height: 12px; }
.jx-del:hover { color: var(--bad); border-color: var(--bad); }
.jx-add { display: flex; gap: 6px; flex-wrap: wrap; }
.jx-add:empty { display: none; }
.jx-costs { display: grid; gap: 12px; }
.jx-fields { display: grid; gap: 8px 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
table.jx-acc { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
table.jx-acc th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.jx-acc td { padding: 3px 6px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
table.jx-acc td:nth-child(2), table.jx-acc td:nth-child(3), table.jx-acc td:nth-child(4) { width: 92px; }
table.jx-acc td:nth-child(2):has(select) { width: 150px; }
.jx-acc .r, table.jx-acc th.r { text-align: right; }
.jx-total { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; background: var(--blue-50); border-radius: 12px; padding: 10px 12px; }
.jx-total > div, .jx-total > .jx-f { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.jx-total small { font-size: 12px; font-weight: 600; color: var(--text-3); }
.jx-total b { font-family: var(--font-head); font-size: 18px; font-variant-numeric: tabular-nums; }
.jx-total .input { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.jx-total .neg { color: var(--bad); }
.jx-sum { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); padding: 2px 2px 0; }
.jx-sum b { color: var(--text); font-variant-numeric: tabular-nums; }
/* the sheets, drawn like Excel (always light, as the workbook) */
.jx-scroll { background: #fff; max-height: min(64vh, 660px); }
table.xl.jx { font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12.5px; color: #000; background: #fff; }
table.xl.jx th { background: #f3f3f3; color: #444; font-weight: 400; font-size: 11.5px; border-right: 1px solid #d4d4d4; border-bottom: 1px solid #c6c6c6; }
table.xl.jx td { height: 20px; padding: 0 3px; color: #000; background: #fff; border-right: 1px solid #e1e1e1; border-bottom: 1px solid #e1e1e1; }
table.xl.jx td.f { background: #fff; color: #000; text-align: left; }
table.xl.jx td.b { font-weight: 700; }
table.xl.jx td.r { text-align: right; }
table.xl.jx td:not(.in):not(.r) { overflow: visible; text-overflow: clip; }
table.xl.jx td.e, table.xl.jx td.neg { color: #c00000; }
table.xl.jx td.in { padding: 0; box-shadow: inset 0 0 0 1px #8fb3e0; }
table.xl.jx td.in input { height: 19px; width: 100%; border: 0; background: transparent; padding: 0 3px; text-align: right; font: inherit; color: #000; }
table.xl.jx td.in.txt input { text-align: left; }
table.xl.jx td.in input:focus { outline: 2px solid #217346; outline-offset: -2px; background: #fff; }
table.xl.jx td.in.auto { background: #f2f2f2; box-shadow: inset 0 0 0 1px #c6c6c6; }
table.xl.jx td.in.auto input::placeholder { color: #000; opacity: 1; }
table.xl.jx td.in.ovr { box-shadow: inset 0 0 0 2px #e6b800; }
table.xl.jx td.in.lnk { box-shadow: inset 0 0 0 1px #217346; }
table.xl.jx tr.tall td { height: 37px; }
table.xl.jx tr.short td { height: 12px; }
table.xl.jx td.pa-t { border-top: 2px dashed #217346; }
table.xl.jx td.pa-l { border-left: 2px dashed #217346; }
table.xl.jx td.pa-r { border-right: 2px dashed #217346; }
.jx-key { font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 3px; }
.jx-key.auto { background: #f2f2f2 !important; border: 1px solid #c6c6c6; }
.jx-key.ovr { box-shadow: inset 0 0 0 2px #e6b800; }
/* workshop sheet: preview + print (A20:N80) */
.jx-paper { max-height: min(62vh, 640px); overflow: auto; background: var(--surface-2); padding: 16px; }
.jx-sheet { background: #fff; color: #000; width: 198mm; max-width: none; margin: 0 auto; padding: 6mm; box-shadow: 0 6px 24px -10px rgba(7,13,24,.35); }
table.jp { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: Arial, Helvetica, sans-serif; font-size: 8.5pt; line-height: 1.15; color: #000; }
table.jp td { padding: 0 1mm; white-space: nowrap; overflow: visible; vertical-align: middle; }
table.jp td.r { text-align: right; }
table.jp td.b { font-weight: 700; }
table.jp td.e { color: #b00; }
table.jp tr.tall td { height: 8.6mm; }
table.jp tr.short td { height: 2.6mm; }
table.jp td.box { border: 1px solid #000; white-space: normal; line-height: 1.1; overflow: hidden; }
table.jp td.boxh { border-top: 1px solid #000; border-bottom: 1px solid #000; }
table.jp td.boxh.bl { border-left: 1px solid #000; }
table.jp td.boxh.br { border-right: 1px solid #000; }
table.jp td.boxh.mid { padding: 0; text-align: center; }
/* reference image in place of the per-crate block (A49:G68) */
table.jp td.jimg { padding: 1mm; text-align: center; vertical-align: middle; }
table.jp td.jimg img { display: block; margin: 0 auto; max-width: 100%; max-height: 74mm; object-fit: contain; }
/* A4 page preview: the print area scaled (zoom) to fit one sheet, like the PDF */
.jx-page { background: #fff; color: #000; width: 210mm; height: 297mm; box-sizing: border-box; padding: 7mm 6mm; margin: 0 auto; overflow: hidden; box-shadow: 0 6px 24px -10px rgba(7,13,24,.35); }
.jx-page .jfit, .print-doc .jfit { width: 198mm; }
.jx-page table.jp, .print-doc .jfit table.jp { width: 100%; }
.jx-fitnote { text-align: center; font-size: 12px; margin: 8px 0 0; }
table.jp td.mid { text-align: center; }
table.xl.jx td.pa-b { border-bottom: 2px dashed #217346; }
.jx-sheets { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 4px; }
.jx-sheets .chip { cursor: pointer; }
.jx-sheets .chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.jx-gf { display: grid; gap: 6px; }
.jx-wideg { display: grid; gap: 8px; }
table.jx-acc td.auto .input { background: var(--surface-2); font-style: italic; }
table.jx-acc td.ovr .input { border-color: #e6b800; }
@media print {
  body:has(.print-doc.jaula-print) { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  .print-doc.jaula-print { padding: 0; }
  .print-doc.jaula-print table.jp { width: 198mm; }
  .print-doc.jaula-print td { border-bottom: 0; padding: 0 1mm; }
  .print-doc.jaula-print td.box { border: 1px solid #000; }
  .print-doc.jaula-print td.boxh { border-top: 1px solid #000; border-bottom: 1px solid #000; }
  .print-doc.jaula-print td.boxh.bl { border-left: 1px solid #000; }
  .print-doc.jaula-print td.boxh.br { border-right: 1px solid #000; }
  .print-doc.jaula-print { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc.jaula-print .jfit { break-inside: avoid; page-break-inside: avoid; overflow: hidden; }
  .print-doc.jaula-print .jfit table.jp { width: 100%; }
}
/* order editor: results + delivery date */
.oe-res { display: contents; }
.oe-mode .select { height: 36px; min-width: 220px; font-weight: 600; }

/* ---------- Ajustes · plantillas de cálculo ---------- */
.tpl-intro { font-size: 13px; margin: 0 0 4px; }
.tpl-list .tpl-row { align-items: center; gap: 12px; flex-wrap: wrap; }
.tpl-row .tpl-ico { width: 38px; height: 38px; border-radius: 10px; }
.tpl-row .grow { min-width: 220px; }
.tpl-row .grow small { display: block; }
.tpl-row.off { opacity: .6; }
.tpl-notes { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.tpl-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-empty-type { font-size: 13px; margin: 0 0 6px; }
.tpl-menu { display: grid; gap: 8px; margin: 14px 0 4px; }
.tpl-menu .btn { justify-content: flex-start; }
.tpl-test-links { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 8px; }
.se { display: grid; gap: 14px; }
@media (min-width: 1100px) { .se { grid-template-columns: minmax(380px, 460px) 1fr; align-items: start; } }
.se-left { max-height: min(70vh, 760px); overflow: auto; padding-right: 6px; display: grid; gap: 6px; align-content: start; }
.se-left h5 { margin: 14px 0 2px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.se-row { display: grid; grid-template-columns: 150px 1fr; gap: 4px 8px; align-items: center; font-size: 13px; }
.se-row .se-v, .se-p .se-v { grid-column: 2; font-size: 11.5px; color: var(--text-3); margin-top: -2px; }
.se-p .se-v { grid-column: 1 / -1; }
.se-row .input, .se-row .select, .se-p .input, .se-gh .input { height: 32px; }
.se-ref { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.se-g { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin: 0; display: grid; gap: 6px; }
.se-gh { display: grid; grid-template-columns: 1fr auto auto auto; gap: 4px; }
.se-gh .input { font-weight: 700; }
.se-p { display: grid; grid-template-columns: 1fr 130px auto auto; gap: 4px 6px; align-items: center; }
.se-out { font-size: 11.5px; color: var(--text-3); display: flex; gap: 3px; align-items: center; }
.se-opt { font-size: 12px; color: var(--text-3); }
.se-doubts { background: color-mix(in srgb, #e6b800 12%, var(--surface)); border: 1px solid color-mix(in srgb, #e6b800 40%, var(--line)); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; }
.se-doubts.ai { background: var(--blue-50); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); }
.se-doubts ul { margin: 4px 0 0; padding-left: 18px; }
.se-doubts p { margin: 4px 0 0; }

/* ---------- inventario · importar Excel ---------- */
.imp-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.imp-sum > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.imp-sum b { display: block; font-family: var(--font-head); font-size: 22px; }
.imp-sum small { color: var(--text-3); font-size: 12px; }
.imp-list { margin: 0 0 6px; padding-left: 18px; font-size: 13px; line-height: 1.6; max-height: 180px; overflow: auto; }
.imp-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; cursor: pointer; }
.imp-opt:has(input:checked) { border-color: var(--blue); background: var(--blue-50); }
.imp-opt span { display: grid; gap: 2px; }
.imp-opt small { color: var(--text-2); font-size: 12.5px; }

/* ---------- order reference image / drawing ---------- */
.oe-ref { display: grid; gap: 8px; }
.oe-ref-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.oe-ref-img { display: block; max-width: 100%; max-height: 220px; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
.oe-ref-empty { margin: 0; font-size: 12.5px; }
.d-ref { display: block; max-width: 100%; max-height: 260px; margin: 6px auto 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
/* sketch editor (full screen, above the order editor) */
.sk { position: fixed; inset: 0; z-index: 400; background: rgba(7,13,24,.55); display: flex; align-items: center; justify-content: center; padding: 12px; animation: fadein .2s; }
.sk-card { background: var(--surface); color: var(--text); border-radius: 16px; width: min(1180px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 14px; box-shadow: 0 30px 80px -20px rgba(7,13,24,.6); }
.sk-top { display: flex; align-items: center; gap: 12px; }
.sk-top h3 { margin: 0; font-family: var(--font-head); font-size: 18px; white-space: nowrap; }
.sk-hint { margin: 0; font-size: 12.5px; flex: 1; min-width: 0; }
.sk-x { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.sk-x svg { width: 16px; height: 16px; }
.sk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sk-grp { display: flex; gap: 3px; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.sk-tool { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.sk-tool svg { width: 20px; height: 20px; }
.sk-tool:hover { background: var(--surface); color: var(--text); }
.sk-tool.on { background: var(--blue); color: #fff; }
.sk-tool:disabled { opacity: .35; cursor: default; background: none; }
.sk-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line); cursor: pointer; margin: 0 2px; }
.sk-color.on { box-shadow: 0 0 0 2px var(--blue); }
.sk-width { width: 34px; height: 30px; border: 0; border-radius: 8px; background: none; display: grid; place-items: center; cursor: pointer; }
.sk-width i { display: block; width: 20px; background: var(--text); border-radius: 4px; }
.sk-width.on { background: var(--surface); box-shadow: inset 0 0 0 2px var(--blue); }
.sk-opts { gap: 12px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.sk-opts label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.sk-opts .input { width: 64px; height: 28px; padding: 0 6px; }
.sk-stage { position: relative; flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start; background: var(--surface-2); border-radius: 12px; padding: 8px; }
.sk-stage canvas { display: block; width: min(100%, calc((100vh - 230px) * 1.2)); aspect-ratio: 6 / 5; height: auto; background: #fff; border-radius: 6px; box-shadow: 0 4px 18px -8px rgba(7,13,24,.35); touch-action: none; }
.sk-text { position: absolute; z-index: 2; transform: translate(-2px, -80%); min-width: 120px; font: 600 16px Arial, Helvetica, sans-serif; padding: 3px 6px; border: 2px solid var(--blue); border-radius: 6px; background: #fff; outline: none; }
.sk-text.c { transform: translate(-50%, -50%); text-align: center; width: 120px; min-width: 0; }
.sk-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sk-mode { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); flex: none; }
.sk-mode button { border: 0; background: none; min-width: 44px; height: 30px; border-radius: 7px; font-weight: 700; font-size: 13px; color: var(--text-2); cursor: pointer; }
.sk-mode button.on { background: var(--blue); color: #fff; }
.sk3 { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.sk3[hidden] { display: none; }
.sk3-txt { width: auto; padding: 0 10px; gap: 6px; display: flex; font-size: 12.5px; font-weight: 600; }
.sk3-txt svg { width: 18px; height: 18px; }
.sk3-size .select { height: 28px; padding: 0 26px 0 8px; width: auto; font-size: 12.5px; }
.sk3-size .input { width: 64px; }
.sk3-size label[hidden] { display: none; }
.sk3-block { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 6px 10px; border: 1px solid var(--line); border-left: 3px solid #ef6c00; border-radius: 11px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.sk3-block[hidden] { display: none; }
.sk3-block label { display: flex; align-items: center; gap: 5px; }
.sk3-block .input { width: 64px; height: 28px; padding: 0 6px; }
.sk3-block [data-b="n"] { width: 130px; }
.sk3-view { position: relative; width: min(100%, calc((100vh - 300px) * 1.2)); aspect-ratio: 6 / 5; background: #fff; border-radius: 6px; box-shadow: 0 4px 18px -8px rgba(7,13,24,.35); overflow: hidden; }
.sk3-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; aspect-ratio: auto; background: transparent; box-shadow: none; border-radius: 0; }
.sk3-ov { pointer-events: none; }
.sk3-gl { touch-action: none; }
.sk3-msg { margin: 40px auto; text-align: center; padding: 0 20px; }
@media (max-width: 640px) { .sk { padding: 0; } .sk-card { border-radius: 0; height: 100%; } .sk-hint { display: none; } .sk-stage canvas { width: 100%; } .sk3-view { width: 100%; } .sk3-size { flex-wrap: wrap; } .sk3-size .input { width: 52px; } .sk3-size .select { max-width: 120px; } .sk-top h3 { font-size: 16px; } .sk3-txt span { display: none; } }

/* ---------- delivery note (albarán) entry ---------- */
.dn-pages { display: flex; gap: 10px; flex-wrap: wrap; }
.dn-pages:empty { display: none; }
.dn-page { position: relative; margin: 0; width: 96px; text-align: center; font-size: 12px; color: var(--text-3); }
.dn-page img, .dn-pdf { width: 96px; height: 128px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; }
.dn-pdf small { font-weight: 400; font-size: 10px; padding: 0 6px; word-break: break-all; }
.dn-page button { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; display: grid; place-items: center; }
.dn-page button svg { width: 14px; height: 14px; }
.dn-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin: 12px 0 0; }
.dn-note svg { width: 18px; height: 18px; flex: none; }
.dn-note.warn { background: rgba(220,38,38,.08); color: var(--bad); }
.dn-lines .select { min-width: 200px; max-width: 100%; }
.dn-lines tr.off td { opacity: .45; }
.dn-qty { display: inline-flex; align-items: center; gap: 6px; }
.dn-qty .input { width: 110px; text-align: right; }
@media (max-width: 767px) {
  .dn-lines td[data-l="Material"] { flex-wrap: wrap; justify-content: flex-end; }
  .dn-lines .select { min-width: 0; flex: 1 1 100%; }
  .dn-lines td[data-l="Línea"] b { font-size: 13.5px; }
}
.dn-basis { font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: inherit; }
/* background reading queue */
.dn-queue-card { padding: 14px 18px 6px; margin-bottom: 16px; }
.dn-queue-card .card-h { padding: 0 0 6px; }
.dn-queue li { flex-wrap: wrap; }
.dn-queue .grow small { display: block; }
.dn-queue .chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; }
.dn-q-actions { display: inline-flex; gap: 6px; }
@media (max-width: 639px) { .dn-q-actions { width: 100%; justify-content: flex-end; } }
.dn-reg { padding: 14px 16px; margin-bottom: 10px; display: grid; gap: 10px; }
.dn-reg-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.dn-reg-head .btn { flex: none; }
.linklike { justify-self: start; background: none; border: 0; padding: 0; color: var(--blue); font: inherit; font-size: 13px; cursor: pointer; }

/* ---------- Inspección ---------- */
.chip.warn { color: var(--warn); background: rgba(217,119,6,.12); border-color: transparent; }
.linklike.danger { color: var(--bad); }
/* ---------- informes: report tabs ---------- */
.rtabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: -4px 0 18px; }
.rtabs::-webkit-scrollbar { display: none; }
.rtabs button { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-3); border-bottom: 2.5px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; white-space: nowrap; cursor: pointer; }
.rtabs button svg { width: 16px; height: 16px; }
.rtabs button:hover { color: var(--text); background: var(--surface-2); }
.rtabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.insp-bar .spacer { flex: 1; }
.insp-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.insp-date .input { width: auto; }
.insp-meta { font-size: 12.5px; margin: -4px 0 14px; line-height: 1.7; }
.insp-meta code, .sec code { font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.insp-empty { max-width: 640px; margin: 24px auto; padding: 28px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.insp-empty .k-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.insp-empty .k-ico svg { width: 26px; height: 26px; }
.insp-empty h3 { margin: 0; }
.insp-empty p { margin: 0 0 6px; }
.insp-rec { width: 100px; text-align: right; padding: 6px 8px; height: 34px; }
.insp-issues li { padding: 6px 0; }
.insp-issues .linklike { display: inline-flex; gap: 8px; align-items: center; color: var(--text); font-size: 13.5px; text-align: left; }
.insp-ok { display: flex; gap: 8px; align-items: center; color: var(--ok); font-weight: 600; }
.insp-ok svg { width: 18px; height: 18px; flex: none; }
.insp-table tr.iss-err td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.insp-table tr.iss-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.insp-table tr.iss-row td { padding-top: 0; border-top: 0; }
.insp-table tr.iss-row .chip { margin: 0 4px 4px 0; }
.insp-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.insp-sum div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.insp-sum small { display: block; color: var(--text-3); font-size: 12px; }
.insp-sum b { font-size: 17px; }
.insp-cols { display: flex; flex-wrap: wrap; gap: 6px; }
table.t tfoot td { border-top: 2px solid var(--line); padding-top: 10px; }
@media (max-width: 700px) { .insp-bar .spacer { display: none; } .insp-date { flex: 1 1 140px; } .insp-date .input { flex: 1; } }
.sh-others { display: grid; gap: 6px; max-height: 180px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.sh-others small { margin-left: 4px; }

/* ---------- order statuses (Ajustes) + customer emails + closed orders ---------- */
.seg-n:empty { display: none; }
.seg-n { font-size: 11px; opacity: .75; margin-left: 2px; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; font-weight: 700; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.st-intro { font-size: 13px; margin: 0 0 12px; }
.st-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.st-row { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 12px; background: var(--surface); min-width: 0; }
.st-row .st-n { width: 16px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-3); }
.st-row .st-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.st-row .grow { flex: 1 1 calc(100% - 50px); min-width: 0; }
.st-row .grow b { display: block; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.st-row .grow small { display: block; color: var(--text-3); font-size: 12px; line-height: 1.35; }
.st-chips { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.st-chips .chip { font-size: 11px; padding: 2px 7px; }
.st-flag { color: var(--blue); background: var(--blue-50); border-color: transparent; }
.st-mailchip { color: #7c3aed; background: rgba(124,58,237,.1); border-color: transparent; }
.st-acts { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.st-acts .icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.st-acts .btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.st-ed { display: grid; gap: 18px; }
@media (min-width: 1000px) { .st-ed { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.st-form h5, .st-prev h5 { margin: 18px 0 8px; font-size: 13px; }
.st-colors { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.st-colors input[type=color] { width: 40px; height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--surface); }
.st-sw { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.st-flags { display: flex; flex-direction: column; gap: 6px; }
.st-flagrow { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; }
.st-flagrow input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.st-flagrow b { display: block; font-size: 13.5px; }
.st-flagrow small { display: block; color: var(--text-3); font-size: 12px; }
.st-flagrow em { color: var(--warn); font-style: normal; font-weight: 600; }
.st-flagrow.off { opacity: .55; cursor: default; }
.st-help { font-size: 13px; }
.st-mail { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
#stMail.off { opacity: .45; }
.st-mode { align-self: flex-start; flex-wrap: wrap; }
.st-html { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.45; min-height: 220px; }
.st-vars > div { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.st-vars .chip { cursor: pointer; font-family: ui-monospace, Consolas, monospace; font-weight: 500; }
.st-vars .chip:hover { color: var(--blue); border-color: var(--blue); }
.st-mail-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.st-prev { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.st-prev-h { display: flex; gap: 8px; align-items: center; }
.st-prev-h .select { flex: 1; min-width: 0; height: 34px; }
.st-prev-subj { font-size: 13.5px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
.mail-frame { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-top: 12px; }
.mail-frame.tall { height: min(62vh, 640px); margin-top: 0; }
.mail-log li { padding: 8px 0; }
.kcol-close { border-style: dashed; background: color-mix(in srgb, var(--c) 6%, var(--surface-2)); }
.kcol-close .kcol-body { align-items: center; justify-content: center; text-align: center; gap: 12px; }
.kclose-msg { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); margin: 0; max-width: 220px; }
.kclose-msg svg { width: 26px; height: 26px; color: var(--c); }
@media (min-width: 1400px) { .kpis.k8 { grid-template-columns: repeat(4, 1fr); } }
/* outgoing mail (Ajustes) */
.mail-intro { font-size: 13px; margin: 0 0 12px; }
.mail-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.mail-presets .chip { cursor: pointer; }
.mail-presets .chip:hover { color: var(--blue); border-color: var(--blue); }
.mail-port { grid-template-columns: 1fr 1.4fr; gap: 12px; }
.mail-form small.muted { font-size: 11.5px; }
.mail-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.mail-acts .grow { flex: 1; }
.mail-acts .input { width: 240px; max-width: 100%; height: 40px; }
@media (max-width: 560px) { .mail-acts .input, .mail-acts .btn { width: 100%; } }
.mail-foot { font-size: 12.5px; margin: 10px 0 0; }
.st-tpl { height: 34px; width: auto; max-width: 100%; }

/* ---------- role «trabajador»: only Pedidos (production steps) and Stock, no money ---------- */
.is-worker [data-v]:not([data-v="pedidos"]):not([data-v="inventario"]),
.is-worker .side-nav .grp,
.is-worker .gsearch, .is-worker #bellBtn, .is-worker .test-btn,
.is-worker #newOrder, .is-worker #kViewSeg, .is-worker #kStatusCfg, .is-worker #kStatus,
.is-worker #invScan, .is-worker #invNotes, .is-worker #invMoves, .is-worker #invXlsOut, .is-worker #invXlsIn, .is-worker #newItem, .is-worker #dnQueue { display: none !important; }

/* ---------- phones: «Siguiente» button above the keyboard (touch-fields.js) ---------- */
.next-fab { position: fixed; right: 12px; bottom: 12px; z-index: 10000; height: 44px; padding: 0 18px; border: 0; border-radius: 22px;
  background: var(--blue); color: #fff; font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1; box-shadow: 0 6px 18px rgba(0, 0, 0, .28); touch-action: manipulation; }
.next-fab[hidden] { display: none; }
.next-fab:active { transform: scale(.96); }
/* pesetas ⇄ euros pair in the template form */
.jx-f.conv input { border-style: dashed; }

/* ==========================================================================
   Excel editor (xl-editor.js)
   ========================================================================== */
.xe-host { min-width: 0; }
.xe { position: relative; display: flex; flex-direction: column; min-width: 0; }
.xe-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.xe-b { height: 30px; min-width: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.xe-b svg { width: 15px; height: 15px; }
.xe-b:hover { border-color: var(--blue); color: var(--blue); }
.xe-sepv { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.xe-fills { display: inline-flex; gap: 2px; }
.xe-fillb { width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-size: 11px; color: var(--text-3); padding: 0; cursor: pointer; }
.xe-sel { height: 30px; font-size: 12.5px; padding: 0 26px 0 8px; width: auto; max-width: 200px; }
.xe-find { height: 30px; width: 130px; font-size: 13px; }
.xe-fx { position: relative; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); background: var(--surface); }
.xe-name { width: 92px; flex: none; border: 0; border-right: 1px solid var(--line); padding: 0 8px; font: 600 13px/1 ui-monospace, Consolas, monospace; color: var(--text-2); background: var(--surface-2); }
.xe-fxl { flex: none; padding: 0 8px; display: flex; align-items: center; font-style: italic; font-weight: 700; color: var(--text-3); font-family: Georgia, serif; }
.xe-formula { flex: 1; min-width: 0; height: 34px; border: 0; padding: 0 8px; font: 14px/1 ui-monospace, Consolas, monospace; background: transparent; color: var(--text); outline: none; }
.xe-formula:focus { box-shadow: inset 0 -2px 0 var(--blue); }
.xe-ac { position: absolute; top: 100%; left: 130px; z-index: 30; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; }
.xe-ac div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.xe-ac div small { color: var(--text-3); font-size: 11px; }
.xe-ac div.on, .xe-ac div:hover { background: var(--blue-50); color: var(--blue); }
.xe-info { font-size: 12px; padding: 0 10px; }
.xe-info:not(:empty) { padding: 5px 10px; border-bottom: 1px solid var(--line-2); background: var(--blue-50); color: var(--text-2); }
.xe-grid { position: relative; overflow: auto; max-height: min(64vh, 680px); outline: none; background: var(--surface); -webkit-overflow-scrolling: touch; }
.xe-t { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; font-size: 12.5px; user-select: none; -webkit-user-select: none; }
.xe-t th { position: sticky; z-index: 3; background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 11.5px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: default; }
.xe-t thead th { top: 0; height: 22px; }
.xe-t tbody th { left: 0; text-align: center; }
.xe-t .xe-corner { left: 0; z-index: 4; }
.xe-t th.on { background: color-mix(in srgb, var(--blue) 18%, var(--surface-2)); color: var(--blue); }
.xe-t td { border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 0 4px; white-space: nowrap; overflow: hidden; color: var(--text); height: 22px; cursor: cell; }
.xe-t td.n { text-align: right; font-variant-numeric: tabular-nums; }
.xe-t td.e { color: #c62828; }
.xe-t td.b { font-weight: 700; }
.xe-t td.al-center { text-align: center; }
.xe-t td.al-right { text-align: right; }
.xe-t td.al-left { text-align: left; }
.xe-t td.lnk { box-shadow: inset 0 0 0 9999px rgba(42,111,209,.10); }
.xe-t td.out { box-shadow: inset 0 0 0 9999px rgba(46,125,50,.14); font-weight: 700; }
.xe-t td.ovr { color: #b45309; font-style: italic; }
.xe-t td.sel { box-shadow: inset 0 0 0 9999px rgba(42,111,209,.16); }
.xe-t td.act { outline: 2px solid var(--blue); outline-offset: -2px; }
.xe-t td.pt { outline: 2px dashed #e65100; outline-offset: -2px; }
.xe-t td.fillt { outline: 1px dashed var(--blue); outline-offset: -1px; }
.xe-fill { position: absolute; width: 8px; height: 8px; background: var(--blue); border: 1px solid #fff; z-index: 5; cursor: crosshair; touch-action: none; }
.xe-fill[hidden] { display: none; }
.xe-cellin { position: absolute; z-index: 6; border: 2px solid var(--blue); padding: 0 3px; font: 13px/1 ui-monospace, Consolas, monospace; background: var(--surface); color: var(--text); outline: none; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.xe-cellin[hidden] { display: none; }
.xe-tabs { display: flex; gap: 2px; padding: 0 6px; background: var(--surface-2); border-top: 1px solid var(--line); overflow-x: auto; }
.xe-tab { border: 1px solid transparent; border-top: 0; background: none; padding: 6px 13px; border-radius: 0 0 8px 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; cursor: pointer; }
.xe-tab.on { background: var(--surface); border-color: var(--line); color: #2e7d32; margin-top: -1px; }
.xe-tadd, .xe-tdel { color: var(--text-3); }
.xe-tabin { height: 28px; width: 140px; font-size: 12.5px; margin: 2px 0; }
.xe-menu { position: absolute; z-index: 40; width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.2); padding: 4px; }
.xe-menu[hidden] { display: none; }
.xe-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; font-size: 13px; color: var(--text); cursor: pointer; }
.xe-menu button:hover { background: var(--blue-50); color: var(--blue); }
.xe-menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }
@media (max-width: 700px) { .xe-find { width: 100px; } .xe-sel { max-width: 140px; } .xe-grid { max-height: 58vh; } }

/* ==========================================================================
   Mis archivos (views/files.js)
   ========================================================================== */
.fs-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 10px; font-size: 14px; }
.fs-crumbs a { padding: 4px 8px; border-radius: 7px; color: var(--text-2); font-weight: 600; text-decoration: none; }
.fs-crumbs a:last-of-type { color: var(--text); }
.fs-crumbs a:hover, .fs-crumbs a.drop { background: var(--blue-50); color: var(--blue); }
.fs-crumbs .sep { color: var(--text-3); }
.fs-list { padding: 4px 14px; }
.fs-ul .fs-row { cursor: pointer; padding: 9px 4px; border-radius: 8px; }
.fs-ul .fs-row:hover { background: var(--surface-2); }
.fs-ul .fs-row.drop { background: var(--blue-50); outline: 2px dashed var(--blue); }
.fs-row .grow b { font-weight: 600; }
.fs-row .grow small { display: block; margin-top: 2px; }
.fs-ico { width: 30px; height: 30px; flex: none; }
.fs-ico.folder { fill: #f2b84b; }
.fs-ico.book { fill: #2e7d32; }
.fs-ico.tpl { fill: #6d4fc2; }
.fs-more { font-weight: 700; letter-spacing: 1px; }
.fs-empty { padding: 26px 6px; text-align: center; }
.fs-h { margin: 14px 4px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.fs-foot { padding: 10px 4px; text-align: right; }
#v-archivos.fs-dropping .fs-list { outline: 3px dashed var(--blue); outline-offset: 4px; }
.fs-menu { position: fixed; z-index: 500; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.22); padding: 5px; }
.fs-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.fs-menu button:hover { background: var(--blue-50); color: var(--blue); }
.fs-menu button.neg { color: #c62828; }
.fs-pick .fs-ul { max-height: 46vh; overflow: auto; }
.fs-pickbox { padding: 12px; }
.fs-pickh { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.fs-pickh b { flex: 1; min-width: 160px; }
.fs-pickh .input { width: 200px; height: 34px; }

/* file window */
.fv { position: fixed; inset: 0; z-index: 250; background: var(--bg); display: flex; flex-direction: column; }
.fv-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.fv-title { min-width: 0; }
.fv-title b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-title small { display: block; font-size: 12px; }
.fv-dirty { font-size: 12px; font-weight: 600; color: #b45309; }
.fv-dirty[hidden] { display: none; }
.fv-body { flex: 1; overflow: auto; padding: 12px; }
.fv-panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fv .xe-grid { max-height: calc(100vh - 250px); }

/* order editor: «Mis archivos» buttons */
.oe-mode { flex-wrap: wrap; }
.oe-xlstate { font-size: 12px; }

/* dialogs over anything (ui.popup) */
.pop { position: fixed; inset: 0; z-index: 450; background: rgba(7,13,24,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pop-card { background: var(--surface); color: var(--text); border-radius: 16px; padding: 20px; width: 100%; max-width: 440px; max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.pop-card.pop-wide { max-width: 620px; }
.pop-card h3 { margin: 0 0 12px; font-size: 18px; }
.pop-card .fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pop-text { white-space: pre-line; margin: 0 0 14px; line-height: 1.45; }
.pop .m-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.xe-kb { position: absolute; width: 2px; height: 18px; opacity: 0; border: 0; padding: 0; z-index: 1; pointer-events: none; caret-color: transparent; }

/* Excel tab in full screen (TplPanel.setFull) */
.tp-back { display: none; }
.tp-full { position: fixed; inset: 0; z-index: 350; border-radius: 0; border: 0; margin: 0; display: flex; flex-direction: column; background: var(--surface); max-width: none; }
.tp-full .tp-back { display: inline-flex; margin: 0 8px 6px 0; align-self: center; }
.tp-full > .jx-tabs { flex: none; padding-top: max(6px, env(safe-area-inset-top)); }
.tp-full > .jx-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tp-full .xe-host, .tp-full .xe { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tp-full .xe-grid { flex: 1; max-height: none; }
.tp-fullsum { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.tp-fullsum:empty, .tp-fullsum { display: none; }
.tp-full .tp-fullsum:not(:empty) { display: inline; margin-right: 6px; }
.tp-fullbtn[hidden] { display: none; }
html.tp-full-on, html.tp-full-on body { overflow: hidden; }
@media (max-width: 700px) {
  .tp-full .tp-fullsum:not(:empty) { display: block; width: 100%; order: 9; margin: 2px 0 0; }
  .tp-full .jx-tools [data-reset], .tp-full .jx-tools [data-print] { display: none; }
}
.xl-tabs .tp-back { background: var(--blue); color: #fff; border: 0; border-radius: 9px; padding: 7px 14px; font-weight: 700; }
.xl-tabs .tp-back:hover { background: var(--blue-600); color: #fff; }
.tp-full .xl-tabs .tp-fullbtn { color: var(--blue); }
@media (max-width: 700px) { .tp-full .tp-fullsum:not(:empty) { white-space: normal; } .tp-full .jx-tools { flex-wrap: wrap; min-width: 0; max-width: 100%; } }
