:root {
  --bg: #f3f4f7; --panel: #ffffff; --line: #e1e4ea; --text: #1d2330; --muted: #6b7380;
  --accent: #1f6feb; --accent-soft: #e7f0ff; --danger: #d63a3a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid; grid-template-columns: 300px 1fr; grid-template-rows: 46px 1fr auto;
  grid-template-areas: "top top" "side view" "side bottom"; overflow: hidden;
}
button {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #b9c1cd; background: #f8f9fb; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
input, select {
  font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; width: 100%;
  background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: #f6f7f9; }

#top { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: 8px; }
.brand b { font-size: 16px; letter-spacing: .2px; }
.brand span { color: var(--muted); font-size: 12px; }
.grp { display: flex; gap: 4px; align-items: center; }
.grp.right { margin-left: auto; }
.lbl { color: var(--muted); margin-right: 2px; }
.chk { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.chk input { width: auto; }

#side { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding-bottom: 20px; }
details { border-bottom: 1px solid var(--line); padding: 4px 12px 10px; }
summary { font-weight: 600; padding: 6px 0; cursor: pointer; user-select: none; }
.row { margin: 6px 0; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btns.seg button { flex: 1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
label { display: block; color: var(--muted); font-size: 12px; }
label input, label select { margin-top: 2px; color: var(--text); font-size: 13px; }
label.full { margin: 6px 0; }
label.chk { color: var(--text); font-size: 13px; margin: 6px 0; }
.note { color: var(--muted); font-size: 12px; margin: 4px 0; }
#anaSummary { margin-top: 8px; font-size: 12px; }
#anaSummary .big { font-size: 15px; font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600; }
.warn { color: var(--danger); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; margin: 4px 0; }
.kv span:nth-child(odd) { color: var(--muted); }

#view { grid-area: view; position: relative; min-height: 0; }
#canvas { position: absolute; inset: 0; }
#canvas canvas { display: block; }
#hint { position: absolute; left: 12px; top: 10px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 12px; pointer-events: none; }
#hint:empty { display: none; }
#legend { position: absolute; right: 12px; top: 10px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; display: flex; gap: 10px; font-size: 12px; }
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

#bottom { grid-area: bottom; background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; height: 250px; }
#bottom.collapsed { height: 36px; }
#bottom nav { display: flex; gap: 4px; align-items: center; padding: 5px 10px; border-bottom: 1px solid var(--line); }
#bottom nav button { border-color: transparent; }
#bottom nav button.on { background: var(--accent-soft); color: var(--accent); }
#totals { margin-left: auto; color: var(--muted); font-size: 12px; }
.tab { display: none; overflow: auto; flex: 1; padding: 0 10px 10px; }
.tab.on { display: block; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f6f8fb; }
.tab h4 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.bar { display: flex; height: 16px; border-radius: 3px; overflow: hidden; background: #eceff3; margin: 2px 0 6px; max-width: 900px; }
.bar div { background: #9fb4d6; border-right: 2px solid #fff; font-size: 10px; color: #1d2330; padding-left: 3px; overflow: hidden; }
.tab td input { width: 90px; padding: 2px 4px; }
.sub { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 8px 0; background: #fafbfc; }
.sub > b { font-size: 12px; }
#itemList { margin-top: 6px; }
.itemRow { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.itemRow span { flex: 1; }
.itemRow.sel span { color: var(--accent); font-weight: 600; }
.itemRow button { padding: 0 6px; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl3d { position: absolute; left: 0; top: 0; font-size: 11px; font-weight: 600; white-space: nowrap; padding: 1px 6px; border-radius: 10px; margin: -24px 0 0 10px; background: #fff; border: 1px solid var(--line); color: var(--text); }
.lbl3d.load { color: #b02a2a; }
.lbl3d.crit { background: #2e9e5b; color: #fff; border-color: transparent; }
.lbl3d.crit.warn { background: #e07b22; }
.lbl3d.crit.bad { background: #d63a3a; }
.lbl3d.probe { background: #b620e0; color: #fff; border-color: transparent; white-space: pre; line-height: 1.35; font-weight: 500; }
#probeInfo .kv { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
#top { overflow-x: auto; }

/* ---------- Nube ---------- */
.cloudProj { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cloudProj b { color: var(--text); }
#account button.user { background: #f6f8fb; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.modalWrap { position: fixed; inset: 0; background: rgba(20, 24, 32, .45); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 440px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: 920px; }
.modalHead { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.modalHead .mClose { border: 0; font-size: 20px; line-height: 1; padding: 0 6px; }
.modalBody { padding: 12px 16px 16px; max-height: 76vh; overflow: auto; }
.pjGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 8px; }
.pjCard { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.pjCard.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.pjThumb { aspect-ratio: 16 / 10; background: #f1f3f6; }
.pjThumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pjInfo { padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.pjInfo b { font-size: 13px; }
.pjCard .btns { padding: 6px 10px 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.pill.st-borrador { background: #8a919c; } .pill.st-revision { background: #c9b02a; } .pill.st-aprobado { background: #2e9e5b; }
.pill.st-fabricacion { background: #1f6feb; } .pill.st-entregado { background: #5a3fc0; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: #1d2330; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); }
body.readonly #top::after { content: 'Solo lectura'; background: #c9b02a; color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
