/* INGENIUM Corpus (CMMS) · estilos */
:root {
  --brand: #1f4e79;
  --brand-2: #2e6da4;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e2e6ec;
  --green: #1a7f4b; --green-bg: #e3f5eb;
  --amber: #9a5b00; --amber-bg: #fff2d6;
  --red: #b42318;   --red-bg: #fde7e5;
  --blue: #1d4f91;  --blue-bg: #e3edfb;
  --gray: #555f6d;  --gray-bg: #eceff3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; color: var(--brand); }
code { background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- barra superior y menú ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; height: 54px; padding: 0 1rem; background: var(--brand); color: #fff; }
.topbar .brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.topbar .brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 7px; background: #fff; padding: 2px; flex: 0 0 auto; }
.brand-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.brand-text { font-weight: 400; }
.brand-text b { font-weight: 700; }
.brand-text small { font-weight: 600; opacity: .7; margin-left: .45rem; letter-spacing: .06em; font-size: .72rem; text-transform: uppercase; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userbox .uname { color: #fff; font-size: .9rem; }
.userbox .uname small { opacity: .7; }
.userbox .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 0 .3rem; }
.shell { display: flex; min-height: calc(100vh - 54px); }
.sidenav { width: 196px; flex: 0 0 196px; background: #fff; border-right: 1px solid var(--line); padding: .8rem .5rem; position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto; }
.sidenav a { display: block; padding: .5rem .8rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.sidenav a:hover { background: var(--gray-bg); text-decoration: none; }
.sidenav a.active { background: var(--blue-bg); color: var(--brand); }
.content { flex: 1; min-width: 0; padding: 1.2rem 1.4rem 3rem; max-width: 1400px; }

/* ---------- estructura ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow, form.narrow { max-width: 680px; }
.narrow-right { max-width: 680px; text-align: right; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.card-head h2 { margin: 0 0 .6rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > * { min-width: 0; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .grid2, .grid2 + .card, .card + .grid2, .kpis + .grid2 { margin-top: 1rem; }
.mt { margin-top: 1.1rem; }
.right { text-align: right; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); color: var(--text); }
a.kpi:hover { text-decoration: none; border-color: var(--brand-2); }
.kpi span { display: block; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi strong { display: block; font-size: 1.5rem; margin: .15rem 0; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.small-kpis .kpi strong { font-size: 1.15rem; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; white-space: nowrap; }
tfoot th { background: #fafbfc; }
tbody tr:hover { background: #fafcff; }
td.num, th.num, dd.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.thumb-cell { width: 52px; padding: .3rem; }
.thumb-cell img { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; display: block; border: 1px solid var(--line); }
.thumb-ph { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 6px; background: var(--gray-bg); color: var(--muted); font-weight: 700; }
.bar-col { width: 110px; }
.bar { display: block; height: 10px; background: var(--brand-2); border-radius: 5px; min-width: 2px; margin-top: .35rem; }
tr.picked { background: #f0f7ff; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--gray-bg); color: var(--gray); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: var(--gray-bg); color: var(--gray); }
.chip { display: inline-block; margin: 0 .3rem .4rem 0; padding: .25rem .6rem; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: .85rem; }

/* ---------- formularios ---------- */
label { display: block; margin-bottom: .75rem; font-size: .85rem; font-weight: 600; color: #344054; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem; font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid #cfd5dd; border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(46,109,164,.25); border-color: var(--brand-2); }
input[type=checkbox] { display: inline-block; width: auto; margin: 0 .4rem 0 0; vertical-align: middle; transform: scale(1.15); }
input[type=file] { padding: .4rem; }
label.check { font-weight: 500; display: flex; align-items: flex-start; gap: .1rem; }
label.check input { margin-top: .2rem; }
label.check.inline { display: inline-flex; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 700; color: var(--brand); padding: 0 .3rem; }
.row2, .row3, .row4 { display: grid; gap: 0 .9rem; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: repeat(3, 1fr); }
.row4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; margin: 0; }
.filters .grow { flex: 1 1 220px; }
.filters.sticky { position: sticky; top: 54px; z-index: 5; background: var(--bg); padding: .5rem 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem; }
.inline-form input, .inline-form select { width: auto; margin: 0; }
.inline-form .grow { flex: 1 1 180px; }
.w80 { width: 80px !important; } .w120 { width: 120px !important; } .w160 { width: 160px !important; }
form.inline { display: inline; margin: 0; }
details > summary { cursor: pointer; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid #cfd5dd; background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f1b8b3; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }
.btn.tiny { padding: .1rem .4rem; font-size: .8rem; }
.btn.block { width: 100%; }

/* ---------- avisos ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--green-bg); color: var(--green); border-color: #b5e2c8; }
.flash.error { background: var(--red-bg); color: var(--red); border-color: #f4c1bc; }

/* ---------- ficha / listas de definición ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: .35rem .8rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }
.gallery .main-photo img { width: 100%; max-height: 360px; object-fit: contain; background: #f6f7f9; border-radius: 8px; border: 1px solid var(--line); }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.thumb { width: 92px; text-align: center; }
.thumb img { width: 92px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb small { display: block; font-size: .72rem; color: var(--muted); }
.thumb-actions { display: flex; justify-content: center; gap: .2rem; margin-top: .15rem; }
.no-photo { height: 180px; display: flex; align-items: center; justify-content: center; background: var(--gray-bg); color: var(--muted); border-radius: 8px; }
.datasheet { white-space: normal; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; background: #fafbfc; padding: .8rem; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- login / instalación ---------- */
.login-card { max-width: 380px; margin: 8vh auto; }
.login-card h1 { color: var(--brand); font-size: 1.35rem; font-weight: 400; letter-spacing: .03em; }
.login-card h1 b { font-weight: 700; }
.login-logo { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto .8rem; }
.install { max-width: 900px; margin: 0 auto; }
.checks { list-style: none; padding: 0; columns: 2; }
.checks li.ok { color: var(--green); } .checks li.bad { color: var(--red); font-weight: 600; }

/* ---------- móvil ---------- */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .row3, .row4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .menu-btn { display: block; }
  .sidenav { position: fixed; left: 0; top: 54px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 16px rgba(0,0,0,.12); }
  body.nav-open .sidenav { transform: none; }
  .content { padding: 1rem .8rem 3rem; }
  .row2, .row3, .row4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .userbox .uname small, .brand-text small { display: none; }
  .dl { grid-template-columns: 110px 1fr; }
  h1 { font-size: 1.2rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi strong { font-size: 1.2rem; }
  .checks { columns: 1; }
}

/* ---------- impresión de pantallas normales ---------- */
@media print {
  .topbar, .sidenav, .page-head .actions, .filters, .no-print, form.inline, .inline-form, details, .form-actions { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: .3rem 0; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  a { color: inherit; }
}
