:root {
  --ink: #1f2933; --muted: #6b7785; --line: #e3e7ec; --bg: #f5f7fa; --card: #fff;
  --brand: #1d4ed8; --brand-2: #1e3a8a; --ok: #2f9e44; --warn: #f59f00; --bad: #e03131; --tr: #1c7ed6;
  --ws1: #4c6ef5; --ws2: #12b886; --ws3: #f76707; --ws4: #ae3ec9; --ws5: #e64980; --ws6: #15aabf;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
small { color: var(--muted); font-weight: normal; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 22px; background: var(--brand-2); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand img { height: 30px; background: #fff; border-radius: 6px; padding: 2px; }
.who { display: flex; align-items: center; gap: 10px; }
.who .btn-ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.wrap { max-width: 1400px; margin: 0 auto; padding: 18px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card h2 { margin: 0 0 10px; font-size: 19px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; }
.cardhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.login { max-width: 420px; margin: 40px auto; }
label { display: block; margin: 8px 0; font-size: 14px; font-weight: 500; }
label.inline, form.inline, .inline { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 0 0; }
input, select { font: inherit; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; background: #fff; }
label > input, label > select { display: block; width: 100%; margin-top: 4px; }
input.sm { width: 160px; padding: 4px 6px; font-size: 13px; }
input:disabled, select:disabled { background: #f1f3f5; color: #868e96; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn-big { font-size: 17px; padding: 11px 26px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.alert { background: #fff0f0; border: 1px solid #ffc9c9; color: #a51111; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.ok { background: #ebfbee; border: 1px solid #b2f2bb; color: #1b6e2a; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.note { background: #e7f5ff; border: 1px solid #a5d8ff; color: #1864ab; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.pill { display: inline-block; font-size: 12px; background: #e7f5ff; color: #1864ab; border-radius: 99px; padding: 2px 10px; vertical-align: middle; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.tabs a { padding: 9px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a.preview { margin-left: auto; color: var(--brand); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; }
.grid4 small { display: block; margin-top: 3px; }
.checks label { font-weight: normal; }

.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
.tbl th { background: #f8f9fb; font-weight: 600; }
.tbl tr.hl td, .tbl tr.hl th { background: #fff9db; }
.tbl tr.dim td { opacity: .5; }
.tblwrap { overflow-x: auto; }
.actions { white-space: nowrap; }

/* Pasos */
.steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 10px 0; }
.stepcell { border: 1px solid var(--line); border-radius: 9px; padding: 6px; text-align: center; background: #fff; border-top: 4px solid #ced4da; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.stepcell img { width: 100%; height: 58px; object-fit: contain; }
.stepcell b { font-size: 13px; }
.stepcell .t { font-size: 12px; color: var(--muted); }
.stepcell input, .stepcell select { width: 100%; padding: 4px; font-size: 13px; }
.ws-c1 { border-top-color: var(--ws1); } .ws-c2 { border-top-color: var(--ws2); } .ws-c3 { border-top-color: var(--ws3); }
.ws-c4 { border-top-color: var(--ws4); } .ws-c5 { border-top-color: var(--ws5); } .ws-c6 { border-top-color: var(--ws6); }
.ws-bg1 { background: var(--ws1); } .ws-bg2 { background: var(--ws2); } .ws-bg3 { background: var(--ws3); }
.ws-bg4 { background: var(--ws4); } .ws-bg5 { background: var(--ws5); } .ws-bg6 { background: var(--ws6); }

.bars { max-width: 760px; }
.barrow { display: grid; grid-template-columns: 120px 1fr 70px; align-items: center; gap: 10px; margin: 5px 0; }
.bar { position: relative; height: 18px; background: #f1f3f5; border-radius: 5px; overflow: visible; }
.bar .fill { height: 100%; border-radius: 5px; }
.bar .takt { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--bad); }
.barrow .val { font-variant-numeric: tabular-nums; font-size: 13px; }

/* Línea */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.controls label { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
.controls label select { margin: 0; width: auto; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; min-width: 120px; }
.progress { height: 5px; background: #eef1f5; border-radius: 3px; margin: 10px 0 14px; overflow: hidden; }
.progress div { height: 100%; background: var(--brand); width: 0; }
.line { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 6px 2px 10px; }
.ws { flex: 0 0 150px; border: 3px solid #ced4da; border-radius: 11px; padding: 6px; background: #fff; display: flex; flex-direction: column; align-items: center; transition: border-color .2s, background .2s; }
.wshead { font-weight: 700; }
.wsimg { position: relative; width: 100%; height: 80px; display: flex; align-items: center; justify-content: center; }
.wsimg img { max-width: 100%; max-height: 80px; }
.badge { position: absolute; top: 0; left: 0; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 5px; }
.wsstep { font-size: 12px; min-height: 17px; }
.pbar { width: 100%; height: 5px; background: #eef1f5; border-radius: 3px; overflow: hidden; margin: 3px 0; }
.pbar div { height: 100%; background: var(--ok); width: 0; }
.wsstate { font-size: 12px; font-weight: 600; text-align: center; min-height: 32px; }
.ws.st-processing { border-color: var(--ok); }
.ws.st-processing .wsstate { color: var(--ok); }
.ws.st-transport { border-color: var(--tr); }
.ws.st-transport .wsstate { color: var(--tr); }
.ws.st-starved { border-color: var(--warn); background: #fff9db; }
.ws.st-starved .wsstate { color: #b06d00; }
.ws.st-blocked { border-color: var(--bad); background: #fff0f0; }
.ws.st-blocked .wsstate { color: var(--bad); }
.arrow { flex: 0 0 56px; position: relative; display: flex; align-items: center; justify-content: center; }
.arrow .ar { font-size: 30px; color: #adb5bd; font-weight: 700; transition: color .2s; }
.arrow.on .ar { color: var(--tr); }
.arrow .transit { position: absolute; top: calc(50% - 30px); width: 30px; height: 20px; object-fit: contain; }
.buffer, .client { flex: 0 0 auto; min-width: 110px; max-width: 190px; border: 2px dashed #ced4da; border-radius: 10px; padding: 6px; background: #fafbfc; display: flex; flex-direction: column; align-items: center; }
.buffer.isfull { border-color: var(--bad); }
.bhead { font-weight: 700; font-size: 13px; }
.slots { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 6px 0; max-width: 170px; }
.slot { width: 36px; height: 26px; border: 1px dashed #ced4da; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.slot img { max-width: 32px; max-height: 22px; visibility: hidden; }
.slot.full { border-style: solid; border-color: #868e96; background: #fff; }
.slot.full img { visibility: visible; }
.bcount { font-size: 12px; text-align: center; }
.client { min-width: 150px; max-width: 260px; border-style: solid; border-color: #b2f2bb; background: #f4fdf6; }
.trucks { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; justify-content: center; }
.truck { width: 34px; height: 24px; object-fit: contain; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .st-processing { background: var(--ok); } .legend .st-transport { background: var(--tr); }
.legend .st-starved { background: var(--warn); } .legend .st-blocked { background: var(--bad); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fcfdff; }
.kpi .kl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .kv { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .ks { font-size: 12px; color: var(--muted); }
.kpi.good { border-color: #b2f2bb; background: #f4fdf6; }
.kpi.warn { border-color: #ffd8a8; background: #fff9f0; }
#gantt { width: 100%; display: block; }
.creds { border-color: #ffd43b; }

@media print { .topbar, .tabs, form, .foot { display: none !important; } .creds { display: block; } }
label > input[type=checkbox] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: -2px; }
.ws { flex-basis: 134px; }
.arrow { flex-basis: 38px; }
.arrow .ar { font-size: 26px; }
.buffer { min-width: 96px; }
.slot { width: 32px; height: 24px; }

/* v2: scenarios, language switch, steady state */
.langs { font-size: 13px; opacity: .9; }
.langs a { color: #fff; text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.langs a.on { background: rgba(255,255,255,.22); font-weight: 700; }
.who { gap: 14px; }
.tabs .sctab { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ced4da; }
.dot.dot-on { background: var(--ok); }
.tabform { margin: 0; }
.tabbtn { font: inherit; font-weight: 600; color: var(--brand); background: none; border: 1px dashed #a5b4fc; border-radius: 8px; padding: 6px 12px; margin: 3px 4px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #ced4da; border-radius: 22px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }
.switchlabel { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; margin-top: 4px; display: block; }
.phase { padding: 8px 12px; border-radius: 8px; font-size: 13.5px; margin: 8px 0; }
.phase.tr { background: #f1f3f5; color: #495057; border: 1px dashed #adb5bd; }
.phase.ss { background: #e6fcf5; color: #087f5b; border: 1px solid #96f2d7; }
.kpi.main { border-color: #91a7ff; background: #edf2ff; }
.legend .st-transient { background: repeating-linear-gradient(45deg, #fff, #fff 3px, #ced4da 3px, #ced4da 5px); border: 1px solid #adb5bd; }
.tbl.cmp td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl.cmp th { white-space: pre; }
.tbl.cmp tr:first-child th { white-space: normal; }
