/* PIBE LOGISTIC · Indicadores — encabezado verde de marca; resto en tonos pastel */
:root {
  --brand: #24662D;
  --brand-dark: #1B4F23;
  --brand-soft: #E5F2E8;
  --ink: #26332B;            /* texto principal */
  --ink-2: #3D4A42;
  --muted: #6E7A72;
  --line: #E2E8E4;
  --line-2: #EDF1EE;
  --bg: #F5F8F6;
  --card: #FFFFFF;
  --head: #EEF4F0;           /* encabezados de tabla (verde muy claro) */
  --track: #EAEFEC;

  /* Pastel: fondo / texto / barra */
  --ok-bg: #E5F2E8;   --ok: #2E6B45;   --ok-bar: #9FD1B0;
  --warn-bg: #FBF2DF; --warn: #8A6116; --warn-bar: #F2CE86;
  --bad-bg: #FBE4E4;  --bad: #9A3838;  --bad-bar: #EDA9A9;
  --route-bg: #E6EEF7; --route: #3E5F80; --route-bar: #A9C3DF;
  --idle-bg: #EEF1F4; --neutral: #55606E; --idle-bar: #C9D1DA;
  --shadow: 0 1px 2px rgba(30, 50, 40, .05), 0 2px 8px rgba(30, 50, 40, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14.5px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.strong { font-weight: 650; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); } .neutral { color: var(--neutral); }

/* ---------- Encabezado verde */
.topbar { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); color: #fff; position: sticky; top: 0; z-index: 5;
  box-shadow: 0 2px 10px rgba(27, 79, 35, .25); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 2px; }
.topbar-sub { color: #CDE3D0; font-size: 12.5px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions form { margin: 0; }
.who { color: #CDE3D0; font-size: 12.5px; margin-right: 6px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 14px; font-weight: 600; font-size: 13.5px; }
.btn:hover { background: var(--head); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); width: 100%; padding: 11px; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.light { background: #fff; color: var(--brand); border-color: #fff; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.btn.ghost.dark { color: var(--ink); border-color: var(--line); }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 4px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Menú (debajo del encabezado verde) */
.subnav { background: #fff; border-bottom: 1px solid var(--line); }
.subnav-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; }
.subnav a { color: var(--ink-2); text-decoration: none; padding: 10px 14px; font-size: 13.5px; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--brand); background: var(--brand-soft); }
.subnav a.on { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Estructura */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px; display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--brand); letter-spacing: .3px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { color: var(--muted); font-size: 12px; margin: 10px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; color: var(--ink-2); font-size: 13.5px; }
.chip:hover { background: var(--brand-soft); }
.chip.on { background: var(--brand-soft); color: var(--brand); border-color: #A9D3B5; font-weight: 650; }
select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); max-width: 100%; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.filter { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.filter select { width: 100%; font-size: 14px; }
.filter.active span { color: var(--brand); font-weight: 700; }
.filter.active select { border-color: #A9D3B5; background: var(--brand-soft); }

/* ---------- Resumen principal */
.summary { display: grid; grid-template-columns: minmax(240px, 1fr) 2.2fr; gap: 14px; margin-bottom: 4px; }
.sum-card { background: #FBFCFB; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; text-align: left; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
button.sum-card { justify-content: center; }
button.sum-card:hover { border-color: #C9D8CE; }
.eyebrow { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.big { font-size: 60px; font-weight: 700; line-height: 1; letter-spacing: -1px; color: var(--ink); }
.big.ok { color: var(--ok); } .big.warn { color: var(--warn); } .big.bad { color: var(--bad); }
.big.plain { background: none; border: 0; padding: 0; text-align: left; margin-top: 6px; }
.big.plain:hover { color: var(--brand); }
.sum-sub { font-size: 13.5px; color: var(--muted); }
.progress { position: relative; height: 10px; background: var(--track); border-radius: 5px; margin-top: 4px; }
.progress .fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--idle-bar); }
.progress .fill.ok { background: var(--ok-bar); } .progress .fill.warn { background: var(--warn-bar); } .progress .fill.bad { background: var(--bad-bar); }
.progress .goal { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--brand); }

.mini-stats { display: flex; gap: 10px; }
.mini { background: var(--route-bg); border: 1px solid #D3E0EE; border-radius: 10px; padding: 8px 14px; display: grid; text-align: left; min-width: 120px; color: var(--route); }
.mini:hover { filter: brightness(.98); }
.mini-val { font-size: 30px; font-weight: 700; line-height: 1.1; }
.mini-lbl { font-size: 12.5px; }

.stack { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--track); margin-top: 6px; }
.stack span { display: block; height: 100%; cursor: pointer; }
.stack span + span { box-shadow: inset 2px 0 0 #fff; }
.seg-ok { background: var(--ok-bar); } .seg-route { background: var(--route-bar); } .seg-idle { background: var(--idle-bar); }
.seg-warn { background: var(--warn-bar); } .seg-bad { background: var(--bad-bar); }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 12px; }
.leg { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; text-align: left; }
.leg:hover { border-color: #C9D8CE; }
.sw { width: 12px; height: 12px; border-radius: 3px; }
.leg-lbl { font-size: 14px; color: var(--ink-2); }
.leg-val { font-weight: 700; font-size: 20px; }
.leg-pct { font-size: 13px; color: var(--muted); min-width: 44px; text-align: right; }

/* ---------- Grupos de indicadores (fondo pastel por grupo) */
.groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.group { background: var(--gbg); border: 1px solid transparent; border-radius: 14px; padding: 12px; min-width: 0; }
.group.wide { grid-column: 1 / -1; }
.group-title { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 6px 10px; }
.group-title span { font-size: 13px; font-weight: 700; letter-spacing: .4px; color: var(--gc); }
.group-title small { font-size: 11.5px; color: var(--gc); opacity: .75; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
@media (min-width: 1000px) { .group.wide .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: #fff; border: 1px solid rgba(0, 0, 0, .04); border-radius: 10px; padding: 14px 16px; text-align: left; display: grid; gap: 3px;
  box-shadow: 0 1px 2px rgba(30, 50, 40, .05); }
.tile:hover { box-shadow: 0 3px 10px rgba(30, 50, 40, .1); }
.tlbl { font-size: 14px; color: var(--ink-2); line-height: 1.25; min-height: 2.5em; }
.tval { font-size: 34px; font-weight: 700; color: var(--ink); line-height: 1.15; letter-spacing: -.5px; }
.tmeta { font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; justify-self: start; padding: 2px 8px; border-radius: 10px;
  background: var(--idle-bg); color: var(--neutral); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle-bar); flex: none; }
.lvl-ok .tval { color: var(--ok); } .lvl-ok .tmeta { background: var(--ok-bg); color: var(--ok); } .lvl-ok .dot { background: var(--ok); }
.lvl-warn .tval { color: var(--warn); } .lvl-warn .tmeta { background: var(--warn-bg); color: var(--warn); } .lvl-warn .dot { background: var(--warn); }
.lvl-bad .tval { color: var(--bad); } .lvl-bad .tmeta { background: var(--bad-bg); color: var(--bad); } .lvl-bad .dot { background: var(--bad); }
.lvl-muted .tval { color: var(--muted); }

/* ---------- Tablas */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { background: var(--head); color: var(--brand); font-weight: 650; font-size: 12.5px; padding: 9px 10px; text-align: left; white-space: nowrap; }
.tbl th:first-child { border-radius: 8px 0 0 8px; } .tbl th:last-child { border-radius: 0 8px 8px 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #F7FAF8; }
.tbl tr.grp td { background: var(--brand-soft); font-weight: 650; color: var(--brand-dark); }
.tbl tr.tot td { background: #DCEBE0; font-weight: 700; color: var(--brand-dark); }
.pill { display: inline-block; border-radius: 10px; padding: 1px 9px; font-weight: 650; font-size: 12.5px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.bname { font-weight: 600; }
.bar { height: 6px; background: var(--track); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--route-bar); border-radius: 3px; }

.schips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 12px; }
.schip { border-radius: 12px; padding: 10px 12px; background: var(--idle-bg); color: var(--neutral); }
.schip.primary { background: var(--brand-soft); color: var(--brand); }
.schip.accent { background: var(--route-bg); color: var(--route); }
.schip.ok { background: var(--ok-bg); color: var(--ok); } .schip.bad { background: var(--bad-bg); color: var(--bad); }
.sval { font-size: 30px; font-weight: 700; line-height: 1.15; }
.slbl { font-size: 12.5px; opacity: .85; }

/* ---------- Gráfica de barras */
.chart { display: grid; gap: 7px; margin: 10px 0 16px; }
.crow { display: grid; grid-template-columns: minmax(90px, 230px) 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.clbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ctrack { position: relative; height: 14px; background: var(--track); border-radius: 7px; }
.cbar { position: absolute; inset: 0 auto 0 0; border-radius: 7px; }
.cbar.ok { background: var(--ok-bar); } .cbar.warn { background: var(--warn-bar); } .cbar.bad { background: var(--bad-bar); }
.cgoal { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--brand); }
.cval { color: var(--muted); white-space: nowrap; font-size: 12px; min-width: 96px; text-align: right; }

/* ---------- Administración: avisos, etiquetas y formularios */
.full { grid-column: 1 / -1; }
.wrap.narrow { max-width: 760px; }
.notice { margin: 0; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.error { background: var(--bad-bg); color: var(--bad); display: grid; gap: 4px; margin-bottom: 12px; }
.notice.info { background: var(--route-bg); color: var(--route); margin-bottom: 12px; }
.badge { display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--route-bg); color: var(--route); }
.badge.neutral { background: var(--idle-bg); color: var(--neutral); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin-top: 8px; }
.form-grid.one { grid-template-columns: 1fr; max-width: 420px; }
.form-grid label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.form-grid input:not([type=checkbox]), .form-grid select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14.5px; color: var(--ink); background: #fff; width: 100%; }
.form-grid input[readonly] { background: var(--head); color: var(--muted); }
.form-grid input:focus, .form-grid select:focus, .filters input:focus { outline: 2px solid #A9D3B5; outline-offset: 1px; }
.form-grid small { font-size: 11.5px; color: var(--muted); }
.checks { display: grid; gap: 8px; align-content: center; }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 14px !important; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.sites { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.sites legend { font-size: 12.5px; color: var(--muted); padding: 0 6px; }
.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; max-height: 240px; overflow: auto; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.btn.primary.auto { width: auto; padding: 8px 16px; text-decoration: none; display: inline-block; }
a.btn { text-decoration: none; display: inline-block; }
.filters input[type=date] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; color: var(--ink); width: 100%; }
.filter-actions { display: flex; gap: 8px; align-items: end; }
.tbl td.actions { white-space: nowrap; }
.tbl td.actions a, .tbl td.actions .link { margin-right: 10px; font-size: 13px; color: var(--brand); font-weight: 600; text-decoration: none; }
.tbl td.actions .link.danger { color: var(--bad); }
form.inline { display: inline; margin: 0; }
.profile { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 18px; }
.profile div { background: var(--head); border-radius: 10px; padding: 8px 12px; }
.profile dt { font-size: 11.5px; color: var(--muted); }
.profile dd { margin: 2px 0 0; font-weight: 650; }

/* ---------- Detalle de folios */
dialog { border: 0; border-radius: 14px; padding: 18px; width: min(1120px, 96vw); max-height: 90vh; box-shadow: 0 20px 50px rgba(20, 40, 28, .25); }
dialog::backdrop { background: rgba(27, 79, 35, .35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dlg-head h3 { margin: 0; font-size: 16px; color: var(--brand); }
.dlg-tools { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.dlg-tools input { flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.dlg-body { max-height: 62vh; overflow: auto; }
.dlg-body .tbl th { position: sticky; top: 0; }

/* ---------- Acceso */
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #E5F2E8, #F5F8F6 55%, #E6EEF7); padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 30px 26px; width: min(380px, 100%); box-shadow: 0 16px 40px rgba(30, 60, 40, .12); text-align: center; border-top: 5px solid var(--brand); }
.login-card h1 { margin: 12px 0 0; color: var(--brand); font-size: 21px; letter-spacing: 2px; }
.login-card form { display: grid; gap: 14px; margin-top: 20px; text-align: left; }
.login-card label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; color: var(--ink); }
.login-card input:focus, select:focus, .dlg-tools input:focus { outline: 2px solid #A9D3B5; outline-offset: 1px; }
.alert { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.brand-mark { width: 56px; height: 56px; margin: 0 auto; border-radius: 14px; background: var(--brand); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 14px 13px; background: #fff; clip-path: polygon(50% 0, 100% 22%, 100% 78%, 50% 100%, 0 78%, 0 22%); }

/* ---------- Pantallas anchas */
@media (min-width: 1100px) {
  .wrap { grid-template-columns: 1fr 1fr; }
  .wrap > .full, #pie { grid-column: 1 / -1; }
}
/* ---------- Tablet y celular */
@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .groups { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .topbar { position: static; }
  .wrap { padding: 12px; gap: 12px; }
  .card { padding: 14px; }
  .big { font-size: 46px; }
  .tval { font-size: 28px; }
  .schips { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-stats { width: 100%; }
  .mini { flex: 1; min-width: 0; }
  .who { display: none; }
}
