/* Portal MAINE ENGINEERING */
:root {
  --navy: #0E1621;
  --navy-2: #16212F;
  --ink: #0E1621;
  --text: #2B3442;
  --muted: #5B6575;
  --line: #E3E7ED;
  --soft: #F4F6F9;
  --bg: #F6F7F9;
  --white: #ffffff;
  --blue: #2F5BDB;
  --blue-ink: #1F45B5;
  --blue-soft: #E8EEFC;
  --red: #DA3A2B;
  --red-ink: #B42F22;
  --red-soft: #FCEBEA;
  --green: #1E8E3E;
  --green-soft: #E6F4EA;
  --amber: #B26B00;
  --amber-soft: #FDF1DD;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(14, 22, 33, .06), 0 4px 16px rgba(14, 22, 33, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Barlow', 'Inter', sans-serif; color: var(--ink); line-height: 1.15; margin: 0; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 10px; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.ico { width: 18px; height: 18px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #8FA9FF; outline-offset: 2px; }

/* Encabezado */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; flex: none; }
.brand:hover { text-decoration: none; }
.brand img { height: 36px; width: auto; }
.brand span { font-family: 'Barlow', sans-serif; font-weight: 600; font-size: 15px; color: #C3CBD8; border-left: 1px solid #2B3A4F; padding-left: 12px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #C3CBD8; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.nav a:hover { color: #fff; background: var(--navy-2); text-decoration: none; }
.nav a.on { color: #fff; background: #1D2A3B; }
.user { display: flex; align-items: center; gap: 10px; flex: none; }
.user .who { text-align: right; line-height: 1.2; }
.user .who b { display: block; color: #fff; font-size: 13.5px; font-weight: 600; }
.user .who small { color: #8E99AA; font-size: 12px; }
.user form { margin: 0; }
.btn-ghost { background: transparent; border: 1px solid #2B3A4F; color: #C3CBD8; border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { color: #fff; border-color: #4A5A72; }
.demo-banner { background: #FFF6E0; color: #6B4500; border-bottom: 1px solid #F1D9A6; font-size: 13.5px; }
.demo-banner div { max-width: 1240px; margin: 0 auto; padding: 8px 24px; }

/* Contenido */
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-hidden] { color: #A3ACBA; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > *, .grid-side > *, .stack > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.card-b { padding: 18px 20px; }
.card-b.flush { padding: 0; }
.empty { color: var(--muted); padding: 22px 20px; font-size: 14px; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-family: 'Barlow', sans-serif; font-size: 34px; line-height: 1.1; color: var(--ink); margin-top: 6px; }
.kpi span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi.tone-green b { color: var(--green); }
.kpi.tone-amber b { color: var(--amber); }
.kpi.tone-red b { color: var(--red); }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.bar.amber i { background: var(--amber); }
.bar.red i { background: var(--red); }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: var(--blue); color: #fff; font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 8px; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--blue-ink); text-decoration: none; color: #fff; }
.btn.secondary { background: var(--white); color: var(--ink); border-color: #CBD2DC; }
.btn.secondary:hover { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: var(--red-ink); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Fichas */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.4; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-red { background: var(--red-soft); color: var(--red-ink); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-blue { background: var(--blue-soft); color: var(--blue-ink); }
.chip-gray { background: var(--soft); color: var(--muted); }
.tag { font-family: 'Barlow', sans-serif; font-weight: 700; color: var(--ink); letter-spacing: .01em; }

/* Tablas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FAFBFD; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl small { color: var(--muted); display: block; font-size: 12.5px; }
.tbl-group td { background: var(--soft); font-weight: 600; color: var(--ink); font-size: 13px; }

/* Ficha de datos */
dl.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; margin: 0; }
dl.facts div { min-width: 0; }
dl.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
dl.facts dd { margin: 2px 0 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }

/* Programa anual */
.months { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.months li { background: var(--soft); border-radius: 8px; padding: 8px 2px 10px; text-align: center; }
.months .m-name { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.m-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-top: 6px; background: transparent; border: 2px solid transparent; vertical-align: middle; }
.m-hecho .m-dot { background: var(--green); border-color: var(--green); }
.m-vencido .m-dot { background: var(--red); border-color: var(--red); }
.m-en_curso .m-dot { border-color: var(--amber); }
.m-programado .m-dot { border-color: var(--blue); }
.m-extra .m-dot { width: 8px; height: 8px; background: var(--muted); border-color: var(--muted); }
.m-libre .m-dot { width: 4px; height: 4px; background: #CBD2DC; border: 0; margin-top: 11px; }
.months li.m-vencido { background: var(--red-soft); }
.months-compact { gap: 3px; }
.months-compact li { padding: 4px 0 6px; border-radius: 6px; }
.months-compact .m-name { font-size: 10.5px; }
.months-compact .m-dot { width: 10px; height: 10px; margin-top: 3px; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .m-dot { margin-top: 0; }

/* Plantas */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.site { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); transition: border-color .15s, transform .15s; }
.site:hover { border-color: #B7C4E8; transform: translateY(-2px); text-decoration: none; }
.site h3 { margin-bottom: 2px; }
.site p { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.site ul { list-style: none; margin: auto 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.site li b { display: block; font-family: 'Barlow', sans-serif; font-size: 22px; color: var(--ink); }
.site li span { font-size: 12px; color: var(--muted); }

/* Alertas */
.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.flash-ok { background: var(--green-soft); border-color: #BFE3C9; color: #165F2B; }
.flash-error { background: var(--red-soft); border-color: #F3C4BF; color: var(--red-ink); }
.flash-info { background: var(--blue-soft); border-color: #C9D6F6; color: var(--blue-ink); }
.note { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--muted); }

/* Hallazgos */
.findings { list-style: none; margin: 0; padding: 0; }
.findings li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.findings li:last-child { border-bottom: 0; }
.findings .f-meta { grid-column: 2; font-size: 13px; color: var(--muted); }
.findings .f-desc { color: var(--ink); font-weight: 500; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photos a { display: block; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); color: var(--muted); }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photos span { display: block; padding: 7px 10px; font-size: 12.5px; font-weight: 600; }

/* QR */
.qr-box { text-align: center; }
.qr-box svg { width: 180px; height: 180px; margin: 0 auto; display: block; }
.qr-box code { display: inline-block; margin-top: 8px; font-size: 13px; background: var(--soft); padding: 3px 8px; border-radius: 6px; color: var(--ink); letter-spacing: .08em; }
.side-actions { display: grid; gap: 8px; margin-top: 16px; }
.side-actions .btn { justify-content: center; }

/* Formularios */
form.form { display: grid; gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field small { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid #C9CFD8; border-radius: 8px; padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 91, 219, .18); }
input[type=date] { height: 42px; }
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; color: var(--muted); }
input[type=file]::file-selector-button { font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid #CBD2DC; border-radius: 8px; padding: 8px 12px; margin-right: 10px; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--soft); }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(150px, 230px); gap: 8px 16px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
.check-row .q { color: var(--ink); font-weight: 500; }
.seg { display: inline-flex; border: 1px solid #C9CFD8; border-radius: 8px; overflow: hidden; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 7px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-left: 1px solid #C9CFD8; min-width: 72px; text-align: center; }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span.ok { background: var(--green); color: #fff; }
.seg input:checked + span.falla { background: var(--red); color: #fff; }
.seg input:checked + span.na { background: var(--muted); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid #8FA9FF; outline-offset: -3px; }
.check-row .nota { min-width: 0; }
.check-row .nota input { min-height: 36px; font-size: 14px; padding: 6px 10px; }
.meas { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 8px 16px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.meas:last-child { border-bottom: 0; }
.unit { display: flex; align-items: center; gap: 8px; }
.unit span { color: var(--muted); font-size: 13px; white-space: nowrap; flex: none; width: 44px; }
#delta-t { font-family: 'Barlow', sans-serif; font-weight: 700; font-size: 18px; color: var(--muted); text-align: right; }
#delta-t.ok { color: var(--green); }
#delta-t.bad { color: var(--red-ink); }
.meas small { display: block; color: var(--muted); font-size: 12.5px; }
.rows { display: grid; gap: 8px; }
.row-3 { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px; gap: 8px; }
.row-find { display: grid; grid-template-columns: minmax(0, 1.2fr) 170px minmax(0, 1fr); gap: 8px; }
.files-list { display: flex; flex-wrap: wrap; gap: 10px; }
.files-list > div { display: grid; gap: 4px; width: 140px; font-size: 12.5px; color: var(--muted); }
.files-list img { width: 140px; height: 105px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.sticky-bar { position: sticky; bottom: 0; background: var(--bg); box-shadow: 0 -8px 16px -8px rgba(14, 22, 33, .12); border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; z-index: 5; }
.sticky-bar .hint { margin-right: auto; color: var(--muted); font-size: 13.5px; }

.sec-ok { margin-left: auto; }
.show-m { display: none; }

/* Acceso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #1C2A3D 0%, var(--navy) 55%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-card .logo { height: 54px; width: auto; margin: 0 auto 18px; }
.auth-card h1 { font-size: 24px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.auth-links { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-foot { text-align: center; color: #8E99AA; font-size: 12.5px; margin-top: 18px; }
.auth-foot a { color: #C3CBD8; }

footer.foot { max-width: 1240px; margin: 0 auto; padding: 0 24px 32px; color: #8E99AA; font-size: 12.5px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr); }
  dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .top-in { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px 12px; }
  .brand img { height: 30px; }
  .brand span { display: none; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 2px; }
  .user .who { display: none; }
  .user { margin-left: auto; }
  main { padding: 20px 16px 56px; }
  h1 { font-size: 25px; }
  .grid-2, .fields, .fields.three { grid-template-columns: minmax(0, 1fr); }
  .kpi b { font-size: 28px; }
  .months { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .months-compact { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .row-3, .row-find { grid-template-columns: minmax(0, 1fr); }
  .meas { grid-template-columns: minmax(0, 1fr) 150px; }
  .unit span { width: 34px; }
  .seg span { min-width: 0; padding: 7px 10px; }
  .check-row { grid-template-columns: minmax(0, 1fr); }
  .check-row .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .check-row .seg span { padding: 10px 6px; }
  .sticky-bar { gap: 8px; padding: 8px 0; flex-wrap: nowrap; }
  .sticky-bar .btn { padding: 9px 11px; }
  .sticky-bar label { font-size: 13.5px; }
  .card-h, .card-b { padding-left: 16px; padding-right: 16px; }
  .findings li { padding: 12px 16px; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .demo-banner div { padding: 8px 16px; }
  .sticky-bar .hint { display: none; }
  .hide-m { display: none; }
  .show-m { display: inline; }
}
@media (max-width: 420px) {
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  dl.facts { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .top, .actions, .sticky-bar, .demo-banner, footer.foot { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
