/* Tema claro corporativo LPS: blanco, gris claro y naranjo */
:root {
  color-scheme: light;
  --bg: #f5f6f7; --surface: #ffffff; --text: #26313b; --muted: #687582; --line: #dfe4e8;
  --brand: #ef6b35; --brand-ink: #fff; --brand-soft: #fff0e8;
  --ok: #23834d; --ok-soft: #e6f4eb; --warn: #a96c13; --warn-soft: #fff4dc; --bad: #c43e35; --bad-soft: #fdecea;
  --info: #426b9a; --info-soft: #eaf1f8; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { font-weight: 800; letter-spacing: -.02em; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: inline-block; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.sm { padding: 3px 8px; font-size: 13px; font-weight: 500; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; }
.grid.cols3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.pcard { cursor: pointer; transition: border-color .15s; }
.pcard:hover { border-color: var(--brand); }
.pcard h3 { font-size: 17px; margin-bottom: 2px; }
.pcard .meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.mini { display: flex; gap: 18px; }
.mini b { display: block; font-size: 22px; }
.mini span { color: var(--muted); font-size: 12px; }

.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat .h { font-size: 12px; margin-top: 4px; color: var(--muted); }
.v.ok { color: var(--ok); } .v.warn { color: var(--warn); } .v.bad { color: var(--bad); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.tbl { overflow-x: auto; padding: 0; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.gray { background: var(--line); color: var(--muted); }

/* Look-ahead */
.la { overflow-x: auto; padding: 0; }
.la table { min-width: 860px; table-layout: fixed; }
.la th.w { text-align: center; }
.la td.name { width: 260px; }
.la td.name small { display: block; color: var(--muted); }
.cell { border-radius: 8px; padding: 7px 6px; text-align: center; font-size: 12.5px; font-weight: 700; border: 1px solid transparent; cursor: pointer; min-height: 38px; display: flex; flex-direction: column; justify-content: center; user-select: none; }
.cell small { font-weight: 500; opacity: .85; }
.cell.free { background: var(--ok-soft); color: var(--ok); }
.cell.blocked { background: var(--bad-soft); color: var(--bad); }
.cell.commit { background: var(--info-soft); color: var(--info); }
.cell.done { background: var(--ok); color: #fff; }
.cell.miss { background: var(--bad); color: #fff; }
.cell.off { background: transparent; color: var(--line); cursor: default; }
.la tfoot td { font-weight: 700; text-align: center; background: var(--bg); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* Formularios */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(560px, 94vw); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 14, 20, .5); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog h2 { font-size: 18px; }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 400; width: 100%; }
.full { grid-column: 1 / -1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }

.auth { max-width: 400px; margin: 9vh auto; }
.auth h1 { font-size: 26px; margin-bottom: 4px; }
.auth form { display: grid; gap: 12px; margin-top: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }

.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-l { stroke: var(--line); }
.bar { fill: var(--brand); }
.bar.cat { fill: var(--info); }
.line-ppc { stroke: var(--brand); fill: none; stroke-width: 2.5; }
.line-cum { stroke: var(--info); fill: none; stroke-width: 2; }
.goal { stroke: var(--ok); stroke-dasharray: 5 4; }
.cardtitle { font-weight: 700; margin-bottom: 8px; }
.cardsub { color: var(--muted); font-size: 13px; margin: -4px 0 8px; }

.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.weeknav b { min-width: 190px; text-align: center; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } .grid.two { grid-template-columns: 1fr; } }


/* Mejoras LPS: importación, reprogramación, detalle CNC e impresión */
.report-filters { justify-content:flex-end; align-items:end; margin:0 0 12px; }
.report-filters label { min-width:135px; }
.report-filters select { width:100%; }
.la .cell[draggable="true"] { cursor:grab; }
.la .cell[draggable="true"]:active { cursor:grabbing; }
.la .cell.off { border:1px dashed transparent; }
.la .cell.off:hover { border-color:var(--info); color:var(--info); background:var(--info-soft); }
.cause-entry { display:grid; gap:6px; min-width:180px; }
.cause-entry input { min-width:180px; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background:#fff !important; color:#111 !important; font-size:10pt; }
  .topbar, .tabs, .weeknav button, #toast, .actions, button, .spacer { display:none !important; }
  main { max-width:none !important; padding:0 !important; margin:0 !important; }
  .card { box-shadow:none !important; border:1px solid #aaa !important; background:#fff !important; color:#111 !important; break-inside:avoid; }
  table { width:100% !important; border-collapse:collapse !important; }
  th, td { color:#111 !important; border:1px solid #999 !important; padding:5px !important; }
  th { background:#eee !important; }
  .pill { color:#111 !important; background:#eee !important; }
  .muted, small { color:#444 !important; }
  input, select, textarea { border:0 !important; color:#111 !important; }
}

/* Programa maestro tipo Pull Session / EDT */
.master-table { overflow:auto; max-height:68vh; }
.master-table table { min-width:920px; }
.master-summary td { background:var(--bg); font-weight:700; border-top:1px solid var(--muted); }
.master-milestone td { color:var(--info); }
.master-table tr:hover td { background:var(--brand-soft); }
.la .drop-target { outline:2px dashed var(--brand); outline-offset:-3px; background:var(--brand-soft); }
.la td { min-width:112px; }
.la td.name { min-width:260px; }

.master-timeline { overflow:auto; max-height:60vh; }
.master-timeline table { min-width:850px; table-layout:fixed; }
.master-timeline th.w { text-align:center; }
.master-timeline td.name { min-width:280px; }
.master-week { text-align:center; min-width:90px; vertical-align:middle; }
.master-bar { height:20px; border-radius:4px; background:var(--info); color:#fff; font-size:10px; line-height:20px; overflow:hidden; white-space:nowrap; }
.master-bar.summary { background:var(--brand); }
.master-bar.milestone { background:var(--warn); color:#111; }

/* v0.3.1: navegación de proyecto siempre visible y acceso directo a Look-ahead */
.tabs { display:flex !important; visibility:visible !important; min-height:42px; position:relative; z-index:2; }
.tab { display:inline-flex !important; align-items:center; }
.tab-lookahead { color:var(--text); }
.tab-lookahead[aria-selected="true"] { color:var(--brand); border-bottom-color:var(--brand); }
.la-shortcut { border-color:var(--brand); color:var(--brand); }
@media print { .tabs, .la-shortcut { display:none !important; } }

/* v0.3.3: interacción de arrastre y paneles de planificación */
.drag-list { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.drag-chip { border:1px solid #f2b294; background:#fff7f2; color:#713b25; border-radius:8px; padding:7px 10px; cursor:grab; font-size:13px; }
.drag-chip:active { cursor:grabbing; }
.cell.dragging { opacity:.45; }
.la th.drop-target { background:var(--brand-soft); outline:2px dashed var(--brand); outline-offset:-3px; }
.backlog { margin-bottom:12px; background:#fff; }
.callout { background:#fff8f4; border-color:#f4c8b4; margin-bottom:12px; }
.callout p { margin:5px 0 0; }
.btn.primary { box-shadow:0 1px 2px rgba(90,45,20,.12); }


/* v0.3.6: Look-ahead visual por seis semanas y programa maestro mensual */
.la-toolbar { margin-bottom:12px; }
.la-board { display:grid; grid-template-columns:repeat(6,minmax(190px,1fr)); gap:9px; align-items:stretch; overflow-x:auto; padding-bottom:5px; }
.la-week { min-width:190px; background:var(--surface); border:1px solid var(--line); border-radius:11px; overflow:hidden; min-height:260px; }
.la-week.drop-target { outline:2px dashed var(--brand); outline-offset:2px; background:var(--brand-soft); }
.la-week-head { display:grid; gap:3px; padding:11px; background:var(--bg); border-bottom:1px solid var(--line); text-align:center; }
.la-week-head b { color:var(--brand); font-size:14px; }
.la-week-head span { font-size:13px; font-weight:600; }
.la-week-head small { color:var(--muted); }
.la-week-body { display:grid; align-content:start; gap:8px; padding:8px; min-height:205px; }
.la-drop-empty { border:1px dashed var(--line); color:var(--muted); border-radius:8px; min-height:90px; display:grid; place-items:center; text-align:center; font-size:12px; padding:8px; }
.la-task { border:1px solid var(--line); border-left:4px solid var(--ok); border-radius:8px; padding:9px; background:var(--ok-soft); cursor:grab; display:grid; gap:7px; font-size:12px; overflow-wrap:anywhere; }
.la-task:active { cursor:grabbing; }
.la-task.blocked { border-left-color:var(--bad); background:var(--bad-soft); }
.la-task.commit { border-left-color:var(--info); background:var(--info-soft); }
.la-task.done { border-left-color:var(--ok); background:var(--ok); color:#fff; }
.la-task.miss { border-left-color:var(--bad); background:var(--bad); color:#fff; }
.la-task.dragging { opacity:.4; }
.la-task-meta { display:grid; gap:3px; color:var(--muted); }
.la-task.done .la-task-meta,.la-task.miss .la-task-meta { color:inherit; opacity:.9; }
.la-blocked-note { color:var(--bad); font-size:12px; margin:6px 0 0; max-width:440px; }
.master-timeline table { min-width:max(100%, 980px); table-layout:fixed; }
.master-timeline th:first-child,.master-timeline td:first-child { position:sticky; left:0; z-index:1; background:var(--surface); min-width:320px; }
.master-timeline th:first-child { z-index:2; background:var(--bg); }
.master-month { text-align:center; vertical-align:middle; min-width:95px; }
.master-timeline .master-bar { min-width:24px; }
@media(max-width:900px) { .la-board { grid-template-columns:repeat(6,minmax(210px,1fr)); } }


/* v0.4.0: alertas visuales de restricciones en Look-ahead */
.la-restriction-alert { display:grid; gap:4px; margin-top:2px; }
.la-restriction-chip { display:flex; align-items:flex-start; gap:5px; padding:5px 6px; border:1px solid #e5a39a; border-radius:7px; background:#fff0ed; color:#8f2e25; font-size:11px; line-height:1.35; }
.la-restriction-icon { flex:0 0 20px; font-size:15px; text-align:center; }
.la-task.blocked { border-left-width:5px; }
.backlog { margin-top:14px; margin-bottom:0; }


/* v0.4.2: programa maestro integrado en una sola carta Gantt tipo MS Project */
.master-timeline { overflow:auto; max-height:72vh; }
.master-timeline table { min-width:max(100%, 1320px); table-layout:auto; border-collapse:separate; border-spacing:0; }
.master-timeline th,.master-timeline td { white-space:nowrap; }
.master-timeline th:first-child,.master-timeline td.master-wbs { position:sticky; left:0; z-index:3; background:var(--surface); min-width:82px; }
.master-timeline th:nth-child(2),.master-timeline td.master-activity { position:sticky; left:82px; z-index:3; background:var(--surface); min-width:260px; max-width:360px; white-space:normal; }
.master-timeline th:nth-child(3),.master-timeline td.master-resource { position:sticky; left:342px; z-index:3; background:var(--surface); min-width:160px; max-width:220px; white-space:normal; }
.master-timeline th:nth-child(4),.master-timeline td:nth-child(4),.master-timeline th:nth-child(5),.master-timeline td:nth-child(5) { position:sticky; z-index:3; background:var(--surface); min-width:100px; }
.master-timeline th:nth-child(4),.master-timeline td:nth-child(4) { left:502px; }
.master-timeline th:nth-child(5),.master-timeline td:nth-child(5) { left:602px; }
.master-timeline thead th { position:sticky; top:0; z-index:5; background:var(--bg); text-align:center; }
.master-timeline thead tr:first-child th { top:0; }
.master-timeline thead tr:nth-child(2) th { top:34px; }
.master-timeline thead th:first-child,.master-timeline thead th:nth-child(2),.master-timeline thead th:nth-child(3),.master-timeline thead th:nth-child(4),.master-timeline thead th:nth-child(5) { z-index:7; }
.master-timeline .master-year { background:var(--brand-soft); color:var(--text); font-weight:800; }
.master-timeline .master-month { text-align:center; vertical-align:middle; min-width:64px; }
.master-timeline td.master-date { font-variant-numeric:tabular-nums; }
.master-timeline tbody tr:hover td { background:var(--brand-soft); }
.master-timeline .master-bar { min-width:24px; }
