/* ==========================================================================
   styles.css — Calculadora de Cuadrillas de Mano de Obra (RLOPSRM)
   Sistema visual híbrido El Precio Unitario + Pizarrón Técnico
   ========================================================================== */

:root {
  --bg-app: #090d14;
  --bg-surface: #111722;
  --bg-surface-2: #182132;
  --bg-input: #0c111b;
  --bg-canvas: #05070b;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.30);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --epu-indigo: #1b1464;
  --epu-indigo-hi: #4f46e5;
  --epu-slate: #384457;
  --epu-green: #6c934a;
  --epu-green-hi: #7fb055;

  --c-sr: #86efac;
  --c-sky: #7dd3fc;
  --c-orange: #ff8c42;
  --c-amber: #fcd34d;
  --c-violet: #c084fc;
  --c-danger: #ff3b30;

  --shadow-card: 0 8px 28px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.24);
  --exp-bg: rgba(148, 163, 184, 0.22);

  --radius-card: 14px;
  --radius-sub: 10px;
  --radius-ctrl: 7px;

  --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Roboto Condensed", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input: #ffffff;
  --bg-canvas: #ffffff;
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --epu-green-hi: #5a7d3c;

  --c-sr: #15803d;
  --c-sky: #0284c7;
  --c-orange: #ea580c;
  --c-amber: #d97706;
  --c-violet: #9333ea;
  --c-danger: #dc2626;

  --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 2px 8px rgba(15, 23, 42, 0.06);
  --exp-bg: rgba(15, 23, 42, 0.10);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.48;
  min-height: 100vh;
}

.epu-ribbon {
  height: 4px;
  width: 100%;
  background: linear-gradient(115deg, #1b1464 0%, #1b1464 20%, #384457 20%, #384457 38%, #6c934a 38%, #6c934a 100%);
  position: fixed;
  top: 0; left: 0; z-index: 60;
}

.topbar {
  position: sticky;
  top: 4px;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-box {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-surface-2); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-nav-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.back-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--epu-green-hi);
  text-decoration: none; padding: 2px 9px; border-radius: 999px;
  background: rgba(108, 147, 74, 0.13); border: 1px solid rgba(108, 147, 74, 0.30);
  transition: background 0.15s, border-color 0.15s;
}
.back-pill:hover { background: rgba(108, 147, 74, 0.24); border-color: var(--epu-green-hi); }

.sibling-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; color: var(--c-sky);
  text-decoration: none; padding: 2px 9px; border-radius: 999px;
  background: rgba(125, 211, 252, 0.12); border: 1px solid rgba(125, 211, 252, 0.30);
  transition: background 0.15s, border-color 0.15s;
}
.sibling-pill:hover { background: rgba(125, 211, 252, 0.22); border-color: var(--c-sky); }

.brand-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand-title-row h1 {
  margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text-main); line-height: 1.1;
}

.skew-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: #ffffff;
  background: var(--epu-green); transform: skewX(-15deg);
}
.skew-badge > span { transform: skewX(15deg); }
.skew-badge.indigo { background: var(--epu-indigo); }

.brand-subtitle {
  margin: 0; font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.ctrl-select {
  background: var(--bg-input); color: var(--text-main);
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctrl);
  padding: 6px 10px; font-family: var(--font-ui); font-size: 12.5px;
  cursor: pointer; max-width: 290px;
}
.ctrl-select:focus, input:focus, select:focus {
  outline: none; border-color: var(--epu-green-hi);
  box-shadow: 0 0 0 2px rgba(108, 147, 74, 0.25);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong); background: var(--bg-surface-2);
  color: var(--text-main); font-family: var(--font-ui); font-size: 12.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--epu-green-hi); background: rgba(108, 147, 74, 0.12); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--epu-green); border-color: var(--epu-green); color: #ffffff; }
.btn-primary:hover { background: #5b7e3d; border-color: #5b7e3d; }
.btn-icon { padding: 6px 9px; font-size: 14px; }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-danger-ghost { color: var(--c-danger); border-color: rgba(255, 59, 48, 0.28); background: transparent; }
.btn-danger-ghost:hover { background: rgba(255, 59, 48, 0.14); border-color: var(--c-danger); }

.segmented {
  display: flex; background: var(--bg-input);
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctrl);
  padding: 2px; gap: 2px;
}
.segmented button {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 600;
  padding: 6px 6px; border-radius: 5px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.segmented button.active { background: var(--epu-green); color: #ffffff; }
.segmented.indigo-mode button.active { background: var(--epu-indigo); color: #ffffff; }

.workspace {
  max-width: 1520px; margin: 0 auto; padding: 18px 20px 36px;
  display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 18px; align-items: start;
}

.sidebar {
  position: sticky; top: 78px; max-height: calc(100vh - 94px);
  overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 14px 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.card-title-group { display: flex; align-items: center; gap: 9px; }
.step-badge {
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--epu-indigo); color: #ffffff; font-family: var(--font-display);
  font-weight: 700; font-size: 13px; transform: skewX(-12deg); flex-shrink: 0;
}
.step-badge > span { transform: skewX(12deg); }
.card-header h2 {
  margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 700;
  letter-spacing: 0.01em; text-transform: uppercase; color: var(--text-main);
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.field-row:last-child { margin-bottom: 0; }
.field label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.field-hint { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.input-text, .input-select {
  width: 100%; background: var(--bg-input); color: var(--text-main);
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctrl);
  padding: 7px 10px; font-family: var(--font-ui); font-size: 13px;
}
.input-with-unit {
  display: flex; align-items: stretch; background: var(--bg-input);
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctrl); overflow: hidden;
}
.input-with-unit:focus-within { border-color: var(--epu-green-hi); box-shadow: 0 0 0 2px rgba(108, 147, 74, 0.25); }
.input-with-unit input {
  width: 100%; min-width: 0; border: none; background: transparent;
  color: var(--text-main); font-family: var(--font-mono); font-size: 13px; font-weight: 600; padding: 7px 9px;
}
.input-with-unit input:focus { box-shadow: none; }
.input-unit {
  display: inline-flex; align-items: center; padding: 0 8px;
  background: var(--bg-surface-2); color: var(--text-dim); font-family: var(--font-mono);
  font-size: 11px; border-left: 1px solid var(--border); white-space: nowrap;
}

.add-row {
  display: flex; gap: 6px; margin: 8px 0 10px;
}
.add-row select { flex: 1; min-width: 0; }

.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-item {
  background: var(--bg-surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 10px; display: flex; flex-direction: column; gap: 7px;
}
.member-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.member-name-input {
  flex: 1; min-width: 0; background: transparent; border: none; border-bottom: 1px dashed var(--border-strong);
  color: var(--text-main); font-family: var(--font-ui); font-size: 12.5px; font-weight: 700; padding: 2px 4px;
}
.member-name-input:focus { outline: none; border-bottom-color: var(--epu-green-hi); box-shadow: none; }
.member-grid {
  display: grid; grid-template-columns: 82px 1fr; gap: 8px; align-items: center;
}
.member-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
}
.member-foot strong { color: var(--c-sr); }

.mini-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.mini-box {
  background: var(--bg-surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 6px; text-align: center;
}
.mini-box .k { display: block; font-size: 10px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; }
.mini-box .v { display: block; font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--c-sky); margin-top: 2px; }

details.advanced-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
}
details.advanced-card summary {
  padding: 13px 16px; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-size: 14.5px; font-weight: 700;
  text-transform: uppercase; color: var(--text-main); user-select: none;
}
details.advanced-card summary::-webkit-details-marker { display: none; }
details.advanced-card summary::after { content: "▾"; font-size: 14px; color: var(--text-muted); transition: transform 0.2s; }
details.advanced-card[open] summary::after { transform: rotate(180deg); }
.advanced-body { padding: 8px 16px 16px; border-top: 1px solid var(--border); }

.stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-top: 3px solid var(--epu-green-hi); border-radius: var(--radius-sub);
  box-shadow: var(--shadow-soft); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-card.kpi-day   { border-top-color: var(--epu-green-hi); }
.kpi-card.kpi-unit  { border-top-color: var(--c-sky); }
.kpi-card.kpi-hmes  { border-top-color: var(--c-orange); }
.kpi-card.kpi-sched { border-top-color: var(--c-violet); }

.kpi-label { font-family: var(--font-display); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.kpi-value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text-main); line-height: 1.15; }
.kpi-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }

.canvas-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.canvas-toolbar {
  padding: 9px 14px; background: var(--bg-surface-2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.canvas-hint { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.canvas-hint .dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--epu-green-hi); display: inline-block; }
.canvas-wrap { width: 100%; background: var(--bg-canvas); }
.canvas-wrap canvas { display: block; width: 100%; }

.tabs-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.tabs-header {
  display: flex; align-items: center; gap: 4px; padding: 8px 12px 0;
  background: var(--bg-surface-2); border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-display); font-size: 13.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.02em; padding: 9px 14px;
  border-bottom: 2.5px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--epu-green-hi); border-bottom-color: var(--epu-green-hi); }

.tab-panel { display: none; padding: 16px 18px; }
.tab-panel.active { display: block; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sub); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th {
  background: var(--bg-surface-2); color: var(--text-muted);
  font-family: var(--font-display); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; text-align: left;
  padding: 9px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
table.data-table th.num, table.data-table td.num { text-align: right; font-family: var(--font-mono); }
table.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: rgba(108, 147, 74, 0.07); }
table.data-table tbody tr.clickable { cursor: pointer; }
table.data-table tbody tr.row-sub td { background: var(--bg-surface-2); font-weight: 700; }
table.data-table tbody tr.row-total td { background: rgba(108, 147, 74, 0.14); font-weight: 700; }

.sched-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.sched-pill {
  background: var(--bg-surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--epu-green-hi); border-radius: 8px; padding: 10px 12px;
}
.sched-pill .sk { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.sched-pill .sv { display: block; font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--text-main); margin-top: 2px; }
.sched-pill .ss { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.alert-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.alert-box {
  padding: 10px 13px; border-radius: var(--radius-sub); border: 1px solid var(--border);
  border-left: 4px solid var(--epu-green-hi); background: var(--bg-surface-2); font-size: 12.5px;
}
.alert-box.warning { border-left-color: var(--c-amber); background: rgba(252, 211, 77, 0.10); }
.alert-box.info    { border-left-color: var(--c-sky);   background: rgba(125, 211, 252, 0.10); }
.alert-box strong { display: block; margin-bottom: 2px; color: var(--text-main); }

.closure-banner {
  margin-top: 14px; padding: 11px 14px; border-radius: var(--radius-sub);
  background: rgba(108, 147, 74, 0.12); border: 1px solid rgba(108, 147, 74, 0.35);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12.5px;
}
.closure-banner code { font-family: var(--font-mono); font-weight: 700; color: var(--c-sr); }

.eq-grid { display: flex; flex-direction: column; gap: 12px; }
.eq-card {
  background: var(--bg-surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--epu-green-hi); border-radius: var(--radius-sub); padding: 14px 16px;
}
.eq-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.eq-card-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; text-transform: uppercase; color: var(--epu-green-hi); }
.eq-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.eq-formula { font-family: var(--font-mono); font-size: 16px; line-height: 1.85; color: var(--text-main); overflow-x: auto; padding: 2px 0; }
.eq-formula .eq-res { color: var(--c-sr); font-weight: 700; }
.eq-formula .eq-var { color: var(--c-sky); font-weight: 600; }
.eq-note { margin-top: 6px; font-size: 12px; color: var(--text-muted); }

.section-ribbon-title {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border);
}
.section-ribbon-title:first-child { margin-top: 0; }
.section-ribbon-title h3 {
  margin: 0; display: inline-block; padding: 4px 12px; background: var(--epu-green);
  color: #ffffff; font-family: var(--font-display); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; transform: skewX(-15deg);
}
.section-ribbon-title h3 > span { display: inline-block; transform: skewX(15deg); }
.section-ribbon-title .sec-meta { font-size: 12px; color: var(--text-muted); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(4px); z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-dialog {
  width: 100%; max-width: 460px; background: var(--bg-surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.modal-head { padding: 14px 18px; background: var(--bg-surface-2); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 16px; text-transform: uppercase; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.watermark-notice {
  padding: 9px 12px; border-radius: 8px; background: rgba(108, 147, 74, 0.12);
  border: 1px solid rgba(108, 147, 74, 0.30); font-size: 12px; color: var(--text-muted);
}
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.app-footer {
  max-width: 1520px; margin: 0 auto; padding: 14px 20px 28px;
  border-top: 1px solid var(--border); display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-dim);
}
.app-footer a { color: var(--epu-green-hi); text-decoration: none; font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .workspace { padding: 12px 12px 24px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .brand-subtitle { white-space: normal; }
}
