/* Panel del maestro: tema claro y sobrio. Móvil primero; 760px = pestañas abajo → barra lateral; tablas apiladas bajo 720px. */
body.maestro {
  --bg: #f3f6f4; --card: #fff; --ink: #17261f; --muted: #5a6b64; --line: #e1e8e4; --brand: #1f6b50; --brand-d: #174f3b; --brand-l: #e4f2ec;
  --gold: #f2b632; --danger: #b8341f; --danger-l: #fdeae6; --ok-l: #e1f4e9; --radius: 14px; --sombra: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .06);
  --nav-h: 64px; --top-h: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; line-height: 1.5;
  background: var(--bg); color: var(--ink); padding-top: var(--top-h); padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.maestro :focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
body.maestro h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); margin: .2em 0 .35em; letter-spacing: -.01em; }
body.maestro h2 { font-size: 1.15rem; margin: 0 0 .6em; }
body.maestro h3 { font-size: 1rem; }
body.maestro p { margin: .4em 0 .8em; }
body.maestro a { color: var(--brand); text-underline-offset: 3px; }
body.maestro .mini { color: var(--muted); font-size: .85rem; }

/* ---------- Barra superior ---------- */
.m-salto { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--brand); color: #fff !important; padding: 10px 14px; border-radius: 8px; }
.m-salto:focus { top: 8px; }
.m-top { position: fixed; inset: 0 0 auto 0; z-index: 40; height: var(--top-h); padding: 0 14px; padding-top: env(safe-area-inset-top, 0); box-sizing: content-box;
  display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); }
.m-marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-marca svg { width: 26px; height: 26px; flex: none; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.m-marca b { font-size: 1.05rem; white-space: nowrap; }
.m-marca small { display: none; opacity: .75; font-size: .8rem; border-left: 1px solid rgba(255, 255, 255, .35); padding-left: 10px; }
body.maestro .m-salir { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #fff; text-decoration: none; font-weight: 600; transition: background .15s; }
body.maestro .m-salir:hover { background: rgba(255, 255, 255, .15); }
.m-salir svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 420px) { .m-salir span { display: none; } .m-salir { width: 44px; justify-content: center; padding: 0; } }

/* ---------- Navegación: pestañas abajo en móvil ---------- */
.m-nav { position: fixed; inset: auto 0 0 0; z-index: 40; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 12px rgba(16, 40, 30, .08); }
body.maestro .m-nav a { flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; transition: color .15s, background .15s; }
.m-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.maestro .m-nav a[aria-current] { color: var(--brand); background: var(--brand-l); box-shadow: inset 0 3px 0 var(--brand); }
body.maestro .m-nav a:hover { color: var(--brand); }

.cont { width: 100%; max-width: 1100px; margin: 0 auto; padding: 18px 14px 28px; }

/* ---------- Escritorio: barra lateral ---------- */
@media (min-width: 760px) {
  body.maestro { padding-bottom: 0; padding-left: 224px; }
  .m-top { padding: 0 20px; padding-top: 0; }
  .m-marca small { display: inline; }
  .m-nav { inset: var(--top-h) auto 0 0; width: 224px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line); box-shadow: none; }
  body.maestro .m-nav a { flex: none; min-height: 46px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 10px; font-size: .95rem; }
  body.maestro .m-nav a[aria-current] { box-shadow: none; }
  .m-top { left: 0; padding-left: 20px; }
  .cont { padding: 28px 28px 48px; }
}
@media (min-width: 1280px) { body.maestro { padding-left: 248px; } .m-nav { width: 248px; } }

/* ---------- Tarjetas y avisos ---------- */
body.maestro .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--sombra); }
body.maestro .panel > :last-child { margin-bottom: 0; }
body.maestro .aviso-ok, body.maestro .aviso-mal { border: 0; border-left: 4px solid; border-radius: 10px; padding: 12px 16px; margin: 14px 0; }
body.maestro .aviso-ok { background: var(--ok-l); border-color: var(--brand); }
body.maestro .aviso-mal { background: var(--danger-l); border-color: var(--danger); }
body.maestro .error { color: var(--danger); }
body.maestro .codigo { font-size: 1.05rem; letter-spacing: 3px; background: var(--brand-l); color: var(--brand-d); padding: 3px 12px; border-radius: 99px; vertical-align: middle; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 700; }
body.maestro .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 0 18px; }
body.maestro .panel.dato b { font-size: 1.9rem; display: block; line-height: 1.1; color: var(--brand-d); }
body.maestro .pill { background: #eef2f0; color: var(--ink); padding: 3px 10px; font-weight: 700; }
body.maestro .pill.ok { background: var(--ok-l); color: #14603a; } body.maestro .pill.mal { background: var(--danger-l); color: var(--danger); }

/* ---------- Botones ---------- */
body.maestro .btn { min-height: 44px; padding: 0 20px; border-radius: 10px; font-size: .95rem; font-weight: 700; background: var(--brand); color: #fff; box-shadow: none; text-decoration: none; transition: background .15s, transform .1s, box-shadow .15s; }
body.maestro .btn:hover { background: var(--brand-d); }
body.maestro .btn:active { transform: scale(.98); box-shadow: none; }
body.maestro .btn.sec { background: #fff; color: var(--brand-d); border: 1.5px solid var(--line); }
body.maestro .btn.sec:hover { background: var(--brand-l); border-color: var(--brand); }
body.maestro .btn.rojo { background: #fff; color: var(--danger); border: 1.5px solid #efc3ba; }
body.maestro .btn.rojo:hover { background: var(--danger-l); border-color: var(--danger); }
body.maestro .btn.chico { min-height: 40px; padding: 0 14px; font-size: .85rem; border-radius: 9px; }
body.maestro .btn.grande { width: 100%; font-size: 1rem; margin-top: 14px; }
body.maestro .link { background: none; border: 0; color: var(--danger); font-weight: 600; padding: 10px; min-height: 44px; text-decoration: underline; }
body.maestro .fila { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; } body.maestro .fila .btn { flex: 1 1 160px; }

/* ---------- Formularios ---------- */
body.maestro label { font-weight: 600; font-size: .88rem; margin: 14px 0 6px; color: var(--ink); }
body.maestro input[type=text], body.maestro input[type=email], body.maestro input[type=password], body.maestro input[type=number], body.maestro select, body.maestro textarea {
  min-height: 44px; padding: 10px 14px; border: 1.5px solid #cfd9d4; border-radius: 10px; background: #fff; font-size: 1rem; transition: border-color .15s, box-shadow .15s; }
body.maestro input:hover, body.maestro select:hover, body.maestro textarea:hover { border-color: #9db3a9; }
body.maestro input:focus, body.maestro select:focus, body.maestro textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(31, 107, 80, .18); }
body.maestro textarea { min-height: 110px; line-height: 1.5; }
body.maestro input[type=radio], body.maestro input[type=checkbox] { accent-color: var(--brand); }
body.maestro .preg { background: #fafcfb; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; margin: 14px 0; }
body.maestro .op { gap: 10px; } body.maestro .op input[type=radio] { width: 22px; height: 22px; }
body.maestro .en-linea > * { min-width: min(100%, 160px); }

/* ---------- Tablas ---------- */
body.maestro .tabla-wrap { overflow-x: auto; }
body.maestro table { width: 100%; border-collapse: collapse; font-size: .92rem; }
body.maestro th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
body.maestro td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
body.maestro tr:last-child td { border-bottom: 0; }
body.maestro tbody tr:hover td, body.maestro tr:hover > td { background: #f8fbf9; }
body.maestro td form { display: inline-block; margin: 2px 4px 2px 0; }
@media (max-width: 719px) {
  body.maestro table, body.maestro tbody, body.maestro tr, body.maestro td { display: block; width: 100%; }
  body.maestro tr:first-child:has(th) { display: none; }
  body.maestro tr { padding: 10px 4px; border-bottom: 1px solid var(--line); }
  body.maestro tr:last-child { border-bottom: 0; }
  body.maestro td { border: 0; padding: 5px 8px; display: flex; gap: 12px; align-items: center; justify-content: space-between; text-align: right; background: none !important; }
  body.maestro td[data-l]::before { content: attr(data-l); flex: none; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; text-align: left; }
  body.maestro td:last-child { justify-content: flex-start; flex-wrap: wrap; padding-top: 10px; }
  body.maestro td .cara, body.maestro td .av { margin: 0; }
}

/* ---------- Gráfica de PPM y selector ---------- */
body.maestro .barras { height: 130px; gap: 8px; padding-top: 22px; }
body.maestro .barras div { background: linear-gradient(var(--brand), #3a9672); border-radius: 8px 8px 0 0; }
body.maestro .barras span { color: var(--ink); font-weight: 700; }

/* ---------- Inicio de sesión ---------- */
.login-m { max-width: 420px; margin: 8vh auto 0; padding: 0 14px; }
body.maestro .login-m.panel { padding: 28px 24px; }
body.maestro .login-m h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
body.maestro .login-m h1 svg { width: 30px; height: 30px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.maestro.m-login { padding: 0; background: linear-gradient(160deg, #e4f2ec, #f3f6f4 55%); min-height: 100vh; }

@media (prefers-reduced-motion: reduce) { body.maestro * { transition: none !important; animation: none !important; } }

/* filtros tipo chip */
body.maestro .filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 4px; }
body.maestro .filtros a { min-height: 40px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; transition: background .15s, border-color .15s; }
body.maestro .filtros a:hover { border-color: var(--brand); }
body.maestro .filtros a[aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }
body.maestro .filtros .mini { margin-left: auto; }
