/* DataChainDesign APS - hoja de estilos */
:root {
  --ink: #1d1d1b;
  --ink-2: #2b2b29;
  --blue: #009fe3;
  --blue-d: #0079b0;
  --blue-l: #e3f4fc;
  --gray: #878786;
  --bg: #f2f4f6;
  --card: #ffffff;
  --line: #e2e6ea;
  --line-2: #eef1f4;
  --text: #1d1d1b;
  --muted: #6b7178;
  --ok: #1e9e6a;
  --warn: #e8a33d;
  --bad: #d9483b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .05);
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
body { min-width: 360px; }
button, input, select, textarea { font-family: inherit; font-size: 13px; }
.num, td.n, .kpi-value { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- cabecera */
.topbar {
  background: var(--ink); color: #fff; display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 64px; position: sticky; top: 0; z-index: 40;
  border-bottom: 3px solid var(--blue);
}
.topbar .logo img { height: 30px; display: block; }
.topbar .divider { width: 1px; height: 30px; background: #3c3c3a; }
.product { display: flex; flex-direction: column; line-height: 1.15; }
.product b { font-size: 15px; letter-spacing: .3px; font-weight: 600; }
.product span { font-size: 11.5px; color: #a8a8a6; letter-spacing: .4px; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #cfcfcd; background: #2a2a28; padding: 6px 12px; border-radius: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); }
.dot.on { background: #34c48b; box-shadow: 0 0 0 3px rgba(52, 196, 139, .18); }
.dot.off { background: var(--bad); }
.tb-btn { background: transparent; color: #e8e8e6; border: 1px solid #4a4a48; padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.tb-btn:hover { border-color: var(--blue); color: #fff; }

/* ---------------------------------------------------------------- barra de escenario */
.scenebar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.scenebar .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 13px; }
.chip:hover { border-color: var(--blue); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.scene-desc { flex: 1 1 320px; color: var(--muted); font-size: 12.5px; min-width: 240px; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.inline-field input { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; padding: 20px 24px 40px; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.card { background: var(--card); 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: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h2, .card-h h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.card-h .sub { font-size: 12px; color: var(--muted); }
.card-b { padding: 16px 18px; }
.eyebrow { font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; color: var(--blue-d); font-weight: 700; }

/* ---------------------------------------------------------------- panel lateral */
.side { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field .flabel { font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; }
.field .flabel em { font-style: normal; color: var(--blue-d); font-weight: 600; }
select, input[type=number], input[type=text], input[type=datetime-local] {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 9px; background: #fff; color: var(--ink); width: 100%;
}
select:focus, input:focus, textarea:focus { outline: 2px solid rgba(0, 159, 227, .25); border-color: var(--blue); }
input[type=range] { width: 100%; accent-color: var(--blue); }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--blue); color: var(--blue-d); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
.btn.primary:hover { background: var(--blue-d); border-color: var(--blue-d); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.block { width: 100%; padding: 12px; font-size: 14px; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 11px; cursor: pointer; color: var(--muted); font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.events { list-style: none; margin: 8px 0 0; padding: 0; }
.events li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 6px 8px; background: var(--bg); border-radius: 6px; margin-bottom: 4px; }
.events li button { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 12px; }

/* ---------------------------------------------------------------- KPIs */
.main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1400px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line); }
.kpi.accent::before { background: var(--blue); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 6px; color: var(--ink); letter-spacing: -.5px; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 3px; letter-spacing: 0; }
.kpi-foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; min-height: 16px; }
.delta { font-weight: 600; }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--bad); }

/* ---------------------------------------------------------------- banda de resultado */
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 14px 18px; background: linear-gradient(90deg, #1d1d1b 0%, #262624 60%, #0d3a52 100%); color: #fff; border-radius: var(--radius); }
.verdict .v-main { font-size: 15px; font-weight: 600; }
.verdict .v-sub { font-size: 12.5px; color: #c9cfd4; }
.verdict .v-badge { background: var(--blue); color: #fff; padding: 5px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.verdict .v-stats { margin-left: auto; display: flex; gap: 22px; font-size: 12px; color: #c9cfd4; }
.verdict .v-stats b { display: block; color: #fff; font-size: 16px; font-weight: 600; }

/* ---------------------------------------------------------------- Gantt */
.gantt-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gantt-wrap { display: grid; grid-template-columns: 210px minmax(0, 1fr); border-top: 1px solid var(--line-2); }
.g-corner { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fbfcfd; display: flex; align-items: flex-end; padding: 0 12px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.g-axis { overflow: hidden; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.g-labels { overflow: hidden; border-right: 1px solid var(--line); background: #fbfcfd; max-height: 560px; }
.g-body { overflow: auto; max-height: 560px; }
.g-body svg, .g-axis svg { display: block; }
.gl-row { display: flex; flex-direction: column; justify-content: center; padding: 0 12px; border-bottom: 1px solid var(--line-2); overflow: hidden; white-space: nowrap; cursor: default; }
.gl-row b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.gl-row span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.gl-row .u { float: right; }
.gl-group { background: #f1f4f7; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; padding: 0 12px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }

.gbar { cursor: pointer; }
.gbar:hover rect.op { filter: brightness(1.08); }
.dim { opacity: .18; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.5; max-width: 320px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); display: none; }
.tooltip .tt-h { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.tooltip .tt-k { color: #a9b1b8; display: inline-block; min-width: 86px; }
.tooltip .late { color: #ff8a7f; font-weight: 600; }
.tooltip .ok { color: #6fe0ae; font-weight: 600; }

/* ---------------------------------------------------------------- pestanas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 13px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.tabs button:hover { color: var(--ink); }
.tabpane { display: none; padding: 18px; }
.tabpane.on { display: block; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1200px) { .grid2 { grid-template-columns: 1fr !important; } }
.panel-title { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.panel-sub { font-size: 12px; color: var(--muted); margin: 0 0 12px; }

/* ---------------------------------------------------------------- tablas */
.tbl-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 8px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; background: #f6f8fa; text-align: left; font-weight: 600; color: var(--ink-2); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; cursor: default; }
.tbl th.sortable { cursor: pointer; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; }
.tbl tr:hover td { background: #fafcfe; }
.tbl tr.chosen td { background: var(--blue-l); }
.tbl input, .tbl select { padding: 5px 6px; font-size: 12px; min-width: 60px; }
.tbl select { min-width: 120px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tag.ok { background: #e4f6ee; color: #137a50; }
.tag.late { background: #fde9e7; color: #b23427; }
.tag.risk { background: #fdf3e2; color: #9a6413; }
.tag.kind { background: #eef1f4; color: var(--ink-2); }
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-cell .bc { height: 8px; border-radius: 4px; background: var(--blue); }
.bar-cell .bc-bg { flex: 1; background: var(--line-2); border-radius: 4px; overflow: hidden; min-width: 60px; }

/* ---------------------------------------------------------------- graficos */
svg text { font-family: var(--font); }
.chart { width: 100%; display: block; }
.axis text { font-size: 11px; fill: var(--muted); }
.axis line, .axis path { stroke: var(--line); }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.mini { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.mini .l { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; font-weight: 600; }
.mini .v { font-size: 19px; font-weight: 600; margin-top: 3px; }

/* ---------------------------------------------------------------- textos metodologia */
.method { max-width: 980px; line-height: 1.6; color: #33363a; font-size: 13.5px; }
.method h4 { margin: 18px 0 6px; font-size: 14px; color: var(--ink); }
.method p { margin: 6px 0; }
.method ul { margin: 6px 0; padding-left: 20px; }
.method .refs li { margin-bottom: 4px; font-size: 12.5px; color: var(--muted); }
textarea.json { width: 100%; min-height: 260px; font-family: Consolas, "Courier New", monospace; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }

/* ---------------------------------------------------------------- overlay */
.overlay { position: fixed; inset: 0; background: rgba(20, 22, 24, .55); backdrop-filter: blur(2px); z-index: 90; display: none; align-items: center; justify-content: center; }
.overlay.on { display: flex; }
.ov-card { background: #fff; border-radius: 12px; width: min(440px, 92vw); padding: 26px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.ov-card h3 { margin: 0 0 4px; font-size: 16px; }
.ov-card p { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; }
.progress { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #59c6f2); transition: width .2s linear; }
.ov-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--muted); }
.ov-steps { margin-top: 14px; font-size: 12px; color: var(--ink-2); line-height: 1.8; }
.ov-steps span { color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 13px; z-index: 120; display: none; max-width: 420px; border-left: 3px solid var(--blue); }
.toast.err { border-left-color: var(--bad); }

footer { padding: 18px 24px 30px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--line); background: #fff; }
footer a { color: var(--blue-d); text-decoration: none; }

@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .product span, .topbar .divider, .status-pill, #btnPrint { display: none; }
  .topbar .logo img { height: 24px; }
  .scenebar, .layout { padding-left: 14px; padding-right: 14px; }
  .verdict .v-stats { margin-left: 0; }
}
@media print {
  .topbar, .scenebar, .side, .tabs, .gantt-tools, .tb-btn, footer, .overlay { display: none !important; }
  .layout { display: block; padding: 0; }
  .g-body, .g-labels { max-height: none !important; overflow: visible !important; }
  .tabpane { display: block !important; page-break-inside: avoid; }
  .card { box-shadow: none; }
}

/* ---------------------------------------------------------------- iconos, industrias y biblioteca (v3) */
.ic { display: inline-block; vertical-align: -3px; flex: none; }
[data-ic] > .ic { margin-right: 6px; }
h2[data-ic] { display: flex; align-items: center; }
h2[data-ic] > .ic { color: var(--blue); }
.tabs button > .ic { margin-right: 6px; opacity: .75; }
.tabs button.on > .ic { color: var(--blue); opacity: 1; }
.btn, .tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0; text-decoration: none; }
.scenebar { flex-direction: column; align-items: stretch; gap: 10px; }
.scene-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.scene-top .lbl { display: inline-flex; align-items: center; }
.scene-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inds { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.ind { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 11px; cursor: pointer; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.ind:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(0, 159, 227, .12); }
.ind-ic { width: 36px; height: 36px; border-radius: 8px; background: var(--blue-l); color: var(--blue-d); display: flex; align-items: center; justify-content: center; flex: none; }
.ind-t { display: flex; flex-direction: column; min-width: 0; }
.ind-t b { font-size: 13px; font-weight: 600; }
.ind-t small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ind.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.ind.active .ind-ic { background: var(--blue); color: #fff; }
.ind.active small { color: #b9bec3; }
.kpi-label { display: flex; align-items: center; gap: 7px; }
.kpi-ic { width: 24px; height: 24px; border-radius: 6px; background: var(--blue-l); color: var(--blue-d); display: inline-flex; align-items: center; justify-content: center; }
.kpi-ic .ic { vertical-align: 0; }
.ws-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ws-row code { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 12.5px; letter-spacing: .5px; font-family: Consolas, "Courier New", monospace; }
.ws-row input { flex: 1; }
.lib { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.lib li { display: flex; align-items: center; gap: 4px; padding: 8px 6px; border-bottom: 1px solid var(--line-2); }
.lib li.empty { color: var(--muted); font-size: 12px; border: 0; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-main b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-main span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 1px solid transparent; background: none; color: var(--ink-2); border-radius: 6px; padding: 5px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { border-color: var(--line); color: var(--blue-d); }
.icon-btn.del:hover, .icon-btn.armed { color: #fff; background: var(--bad); }
.tb-btn > .ic { margin-right: 6px; }
@media (max-width: 760px) { .inds { grid-template-columns: repeat(2, minmax(0, 1fr)); } .scene-actions .btn { flex: 1; } }
.scenebar > * { flex: none !important; }
.scene-desc { min-width: 0; }
.inds { grid-auto-rows: auto; align-items: start; }
.ws-row code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.scenebar { display: block !important; }
.scenebar > * + * { margin-top: 10px; }
.inds { align-content: start; }
