:root {
  --bg: #f3f5f7; --card: #ffffff; --text: #1d2733; --muted: #5b6b7b;
  --brand: #0f6e56; --brand-dark: #0b5442; --brand-soft: #e3f1ec; --line: #dde3e9;
  --danger: #b42318; --danger-bg: #fdecea; --ok: #0f6e56; --ok-bg: #e3f1ec; --warn: #8a5a00; --warn-bg: #fff4d6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg);
       color: var(--text); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.right { text-align: right; }

/* cabecera y navegación */
header.top { background: var(--brand); color: #fff; }
header.top .wrap { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px 14px; padding: 10px 16px; }
header.top .brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; }
header.top .who { font-size: .85rem; text-align: right; line-height: 1.2; }
header.top .who a { color: #fff; text-decoration: none; font-weight: 600; }
header.top .who small { display: block; opacity: .8; }
header.top nav { grid-column: 1 / -1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
header.top nav::-webkit-scrollbar { display: none; }
header.top nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: .92rem; opacity: .9; }
header.top nav a.on { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }
@media (min-width: 900px) {
  header.top .wrap { grid-template-columns: auto 1fr auto auto; }
  header.top nav { grid-column: auto; margin: 0; padding: 0; }
}

/* botones */
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 11px 16px; font-size: .98rem; font-weight: 600;
       background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--brand-dark); }
.btn.block { width: 100%; text-align: center; }
.btn.big { font-size: 1.3rem; padding: 22px; border-radius: 16px; }
.btn.small { padding: 7px 11px; font-size: .85rem; border-radius: 8px; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); }
.btn.light { background: rgba(255,255,255,.16); }
.btn.light:hover { background: rgba(255,255,255,.28); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* tarjetas y rejilla */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: 1fr 1fr 1fr; } }
.module h3 { margin: 0 0 4px; }
.module p { margin: 0 0 8px; }
.stat { font-size: 1.8rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.tag { display: inline-block; font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--line); color: var(--text); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* formularios */
label { display: block; font-size: .88rem; font-weight: 600; margin: 12px 0 5px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-family: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input.err, select.err { border-color: var(--danger); }
.err-msg { color: var(--danger); font-size: .82rem; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; }
.check input { width: 18px; height: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px 14px; margin: 14px 0; }
legend { font-weight: 700; padding: 0 6px; color: var(--brand-dark); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* mensajes */
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--danger-bg); color: var(--danger); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-top: 14px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; background: #fff; border: 1px dashed var(--brand); border-radius: 8px; padding: 6px 10px; user-select: all; }

/* tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; background: #fff; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f8fafb; }
tr:hover td { background: #fafcfb; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap, span.nowrap { white-space: nowrap; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* listas definidas */
dl.def { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.def dt { color: var(--muted); font-size: .88rem; }
dl.def dd { margin: 0; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
footer { text-align: center; padding: 24px 16px; color: var(--muted); font-size: .85rem; }
.login-box { max-width: 440px; margin: 40px auto 0; }

/* tareas y procesos */
.paso { border-left: 4px solid var(--line); }
.paso.hecho { border-left-color: var(--ok); }
.num-paso { display: inline-block; min-width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%;
            background: var(--brand-soft); color: var(--brand-dark); font-size: .85rem; margin-right: 4px; }
.paso.hecho .num-paso { background: var(--ok); color: #fff; }
.check-mark { font-size: 1.4rem; color: var(--ok); font-weight: 700; min-width: 24px; text-align: right; }
.thumb { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }
.file-btn { cursor: pointer; }
.file-btn.disabled { opacity: .5; pointer-events: none; }
.foto-msg.ok { color: var(--ok); } .foto-msg.err { color: var(--danger); } .foto-msg.warn { color: var(--warn); }
.paso-form { margin-bottom: 10px; }

[hidden] { display: none !important; }

/* calendario de procesos */
.cal { display: grid; grid-template-columns: 1fr; gap: 6px; }
.cal-head { display: none; }
@media (min-width: 900px) {
  .cal { grid-template-columns: repeat(7, 1fr); }
  .cal-head { display: block; font-size: .78rem; text-transform: uppercase; color: var(--muted); text-align: center; }
  .cal-fecha span { display: none; }
}
.cal-dia { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-height: 70px; }
.cal-dia.hoy { border: 2px solid var(--brand); }
.cal-dia.fuera { opacity: .45; }
.cal-fecha { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cal-item { font-size: .8rem; border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; border-left: 4px solid var(--line); background: #f8fafb; }
.cal-item .muted { font-size: .74rem; }
.cal-item.c-rojo { border-left-color: var(--danger); background: var(--danger-bg); }
.cal-item.c-amarillo { border-left-color: #c08a00; background: var(--warn-bg); }
.cal-item.c-verde { border-left-color: var(--ok); background: var(--ok-bg); }

/* semáforo y matriz */
.semaf { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--line); vertical-align: middle; }
.s-verde, .m-verde { background: var(--ok) !important; color: #fff; }
.s-amarillo, .m-amarillo { background: #e0a800 !important; color: #1d2733; }
.s-rojo, .m-rojo { background: var(--danger) !important; color: #fff; }
.mcell { display: inline-block; min-width: 64px; padding: 4px 6px; border-radius: 6px; font-size: .78rem; text-align: center; background: #eef1f4; color: var(--muted); }

/* ayuda / manual */
:root { --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
.ayuda-contenido code { background: #eef1f4; border-radius: 4px; padding: 1px 5px; }
.ayuda-contenido pre { background: #eef1f4; border-radius: 8px; padding: 10px; overflow-x: auto; }
.ayuda { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ayuda > * { min-width: 0; }
.ayuda-contenido { overflow-wrap: break-word; }
.ayuda-contenido th, .ayuda-contenido td { overflow-wrap: normal; word-break: normal; min-width: 7.5em; }
@media (min-width: 900px) { .ayuda { grid-template-columns: 260px minmax(0, 1fr); } .ayuda-lateral { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; } }
.ayuda-lateral input { margin-bottom: 8px; }
.ayuda-indice { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.ayuda-indice ol { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: .92rem; }
.ayuda-indice li { margin: 4px 0; }
.ayuda-contenido h2 { margin-top: 0; scroll-margin-top: 12px; }
.ayuda-contenido h3 { margin-top: 16px; scroll-margin-top: 12px; }
.ayuda-contenido table { margin: 8px 0; display: block; overflow-x: auto; }
.ayuda-contenido li { margin: 3px 0; }
.ayuda-link { font-size: .85rem; font-weight: 600; text-decoration: none; margin-left: 8px; vertical-align: middle; }
@media print {
  header.top, footer, .ayuda-lateral, .ayuda-link, .flash { display: none !important; }
  body { background: #fff; } .ayuda { display: block; } .card { border: 0; padding: 0; }
  .ayuda-seccion { break-before: page; page-break-before: always; } .ayuda-seccion[hidden] { display: block !important; }
  a { color: inherit; text-decoration: none; }
}
