:root {
  --ops: #0b93d1;
  --ops-dark: #0a6fa3;
  --navy: #0c2233;
  --navy-2: #133349;
  --shell-red: #dd1d21;
  --shell-yellow: #fbce07;
  --bg: #f3f6f9;
  --card: #ffffff;
  --line: #e1e7ee;
  --text: #15232e;
  --muted: #627485;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(12, 34, 51, .06), 0 8px 24px rgba(12, 34, 51, .06);
  --dE: #f59e0b; --dI: #0b93d1; --dM: #6366f1; --dP: #10b981; --dC: #a16207; --dT: #db2777; --dF: #dc2626; --dQ: #0d9488; --dS: #475569; --dX: #64748b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
kbd { font: 12px/1 ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; color: var(--muted); background: #fff; }

.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; }
.boot img { height: 64px; margin-bottom: 8px; }
.boot p { margin: 0; color: var(--muted); max-width: 52ch; }

/* ---------- Botones ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600; transition: .15s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { border-color: #c5d0db; background: #f8fafc; }
.btn.primary { background: var(--ops); border-color: var(--ops); color: #fff; }
.btn.primary:hover { background: var(--ops-dark); border-color: var(--ops-dark); }
.btn.danger { color: #b42318; }
.btn.block { width: 100%; padding: 12px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid rgba(11, 147, 209, .35); outline-offset: 2px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  position: relative; color: #fff; display: flex; align-items: center; padding: 64px;
  background:
    radial-gradient(900px 500px at 110% 110%, rgba(251, 206, 7, .22), transparent 60%),
    radial-gradient(700px 500px at -10% -10%, rgba(11, 147, 209, .55), transparent 60%),
    linear-gradient(135deg, #0c2233 0%, #0e3550 100%);
  overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(120deg, transparent 20%, #000 100%);
}
.login-hero-inner { position: relative; z-index: 1; max-width: 520px; }
.eyebrow { display: inline-block; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--shell-yellow); margin-bottom: 18px; }
.login-hero h1 { font-size: clamp(40px, 5vw, 64px); font-weight: 800; letter-spacing: -.02em; }
.login-hero p { font-size: 17px; color: #c9dbe8; margin: 20px 0 36px; max-width: 46ch; }
.login-stats { list-style: none; padding: 0; margin: 0; display: flex; gap: 28px; flex-wrap: wrap; }
.login-stats li { display: flex; flex-direction: column; }
.login-stats b { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.login-stats span { font-size: 13px; color: #9fb9cb; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login-logos { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.login-logos img { height: 54px; }
.login-logos img.shell { height: 58px; }
.login-card h2 { font-size: 26px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #3b4d5c; }
.login-card label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=password], input[type=search], select {
  border: 1px solid #cfd8e1; border-radius: 10px; padding: 11px 12px; background: #fff; width: 100%; transition: .15s;
}
input:focus, select:focus { outline: none; border-color: var(--ops); box-shadow: 0 0 0 4px rgba(11, 147, 209, .15); }
.pw { position: relative; display: block; }
.pw input { padding-right: 56px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ops-dark); font-size: 13px; font-weight: 600; padding: 6px 8px; border-radius: 6px; }
.form-error { color: #b42318; font-size: 13px; min-height: 18px; margin: 0; }
.fine { font-size: 12.5px; color: var(--muted); text-align: center; margin: 4px 0 0; }

/* ---------- Topbar ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex: none; }
.brand img { height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.search { flex: 1; max-width: 720px; margin: 0 auto; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 14px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { padding: 11px 44px 11px 42px; border-radius: 999px; background: #f3f6f9; border-color: transparent; }
.search input:focus { background: #fff; }
.search kbd { position: absolute; right: 12px; }
.top-right { display: flex; align-items: center; gap: 14px; flex: none; }
.shell-mini { height: 34px; }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px 4px 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.user-name { font-weight: 600; font-size: 13.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 230px; padding: 6px; display: flex; flex-direction: column; }
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); }
.menu button { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: #f1f5f9; }
.menu button.danger { color: #b42318; }

/* ---------- Catálogo ---------- */
.view { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; display: flex; flex-direction: column; min-width: 96px; }
.kpi b { font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 20px; }
.fgroup { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fgroup > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: .12s; }
.chip:hover { border-color: #b8c6d3; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--dX)); }
.chip em { font-style: normal; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.on em { color: #a9c0d1; }
.filters select { width: auto; padding: 7px 10px; font-size: 13px; border-radius: 9px; max-width: 320px; }
.filters .clear { margin-left: auto; border: 0; background: transparent; color: var(--ops-dark); font-weight: 600; font-size: 13px; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-size: 17px; }
.section-title span { color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c9d5e0; }
.tcard-thumb { position: relative; aspect-ratio: 4 / 3; background: #e9eef3; overflow: hidden; border-bottom: 1px solid var(--line); }
.tcard-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.tcard-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(12, 34, 51, .18)); }
.badge { display: inline-flex; align-items: center; font: 700 12.5px/1 ui-monospace, Consolas, monospace; letter-spacing: .03em; padding: 6px 9px; border-radius: 8px; color: #fff; background: var(--c, var(--dX)); }
.tcard-thumb .badge { position: absolute; left: 10px; top: 10px; z-index: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.phase { font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: #eef2f6; color: #3b4d5c; white-space: nowrap; }
.phase.B { background: #e7f6ee; color: #136c43; }
.phase.A { background: #e8f3fb; color: #0a5c8a; }
.tcard-thumb .phase { position: absolute; right: 10px; top: 10px; z-index: 1; background: rgba(255, 255, 255, .94); }
.tcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tcard-body h3 { font-size: 15px; font-weight: 650; }
.tcard-meta { margin-top: auto; display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding-top: 6px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); background: #fff; border: 1px dashed #cdd7e1; border-radius: var(--radius); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.rows { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 74px minmax(140px, 1.1fr) 2fr 1.4fr; gap: 14px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; font-size: 13.5px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #f7fafc; }
.row .tag { font: 600 13px ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); }
mark { background: #fff1a8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Detalle ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--ops-dark); text-decoration: none; font-weight: 600; }
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head .badge { font-size: 16px; padding: 9px 12px; border-radius: 10px; }
.detail-head h1 { font-size: 24px; }
.detail-head .sp { flex: 1; }
.detail { display: grid; grid-template-columns: 290px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.panel-head h3 { font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 small { font-weight: 500; color: var(--muted); }
.panel-head input, .panel-head select { padding: 8px 10px; font-size: 13px; border-radius: 8px; }
.side { position: sticky; top: 76px; }
.exlist { max-height: calc(100vh - 250px); overflow: auto; padding: 6px; }
.ex { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 10px; align-items: center; }
.ex:hover { background: #f3f6f9; }
.ex.on { background: #e8f3fb; box-shadow: inset 3px 0 0 var(--ops); }
.ex img { width: 44px; height: 57px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 5px; background: #eef2f6; flex: none; }
.ex-t { min-width: 0; display: flex; flex-direction: column; }
.ex-t b { font: 600 13px ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.ex-t span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.viewer { display: flex; flex-direction: column; overflow: hidden; }
.vbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.vbar .sp { flex: 1; }
.vbar .info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ibtn { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 9px; display: grid; place-items: center; font-size: 17px; font-weight: 600; line-height: 1; }
.ibtn:hover { background: #f3f6f9; }
.ibtn:disabled { opacity: .4; cursor: default; }
.stage { position: relative; height: calc(100vh - 235px); min-height: 460px; background: #dfe6ed; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.stage.drag { cursor: grabbing; }
.stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 6px 30px rgba(12, 34, 51, .25); background: #fff; max-width: none; -webkit-user-drag: none; }
.stage .hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(12, 34, 51, .78); color: #fff; font-size: 12px; padding: 6px 12px; border-radius: 999px; pointer-events: none; transition: opacity .4s; white-space: nowrap; }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.pstrip { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); overflow-x: auto; }
.pstrip button { border: 2px solid transparent; background: #eef2f6; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pstrip button.on { border-color: var(--ops); background: #e8f3fb; }
.viewer.fs { position: fixed; inset: 0; z-index: 60; border-radius: 0; }
.viewer.fs .stage { height: auto; flex: 1; }

.info-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; font-size: 13.5px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.steps b { display: block; }
.steps span { color: #4a5c6b; }
.checks { margin: 0; padding-left: 20px; font-size: 13px; color: #33434f; display: flex; flex-direction: column; gap: 5px; max-height: 320px; overflow: auto; }
.note { font-size: 12px; color: var(--muted); background: #f6f8fa; border-radius: 8px; padding: 8px 10px; }
details.acc { border-top: 1px solid var(--line); }
details.acc summary { padding: 12px 14px; font-weight: 650; font-size: 14px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details.acc summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 18px; line-height: 1; }
details.acc[open] summary::after { content: "–"; }
details.acc > div { padding: 0 14px 14px; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(12, 34, 51, .5); display: grid; place-items: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-card h2 { font-size: 20px; margin-bottom: 4px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #3b4d5c; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
table.users { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 12px; }
table.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
table.users td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users td:last-child { text-align: right; white-space: nowrap; }
.role { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #eef2f6; }
.role.admin { background: #fff3c4; color: #7a5b00; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 90; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }

/* ---------- Administración ---------- */
.form-grid .full { grid-column: 1 / -1; }
.sub-form { background: #f6f8fa; border: 1px dashed #cdd7e1; border-radius: 10px; padding: 0 12px; }
.sub-h { margin-top: 20px; font-size: 15px; }
.modal-card label small { font-weight: 400; }
.modal-card input[type=file] { border: 1px dashed #b8c6d3; border-radius: 10px; padding: 12px; background: #f8fafc; width: 100%; }
select.mini { width: auto; padding: 6px 8px; font-size: 13px; border-radius: 8px; }
.admin-row { display: flex; gap: 8px; }
.login-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; color: #c9dbe8; font-size: 15px; }
.login-points li::before { content: "✓"; color: var(--shell-yellow); font-weight: 700; margin-right: 10px; }
.kpis { align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .detail { grid-template-columns: 250px minmax(0, 1fr); }
  .detail .info { grid-column: 1 / -1; position: static; }
}
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-hero { padding: 36px 24px; }
  .login-hero p, .login-points { display: none; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .search kbd, .brand-text small, .user-name, .shell-mini { display: none; }
  .top-right { margin-left: auto; }
  .view { padding: 14px; }
  .detail { grid-template-columns: 1fr; }
  .side { position: static; }
  .exlist { max-height: 240px; }
  .stage { height: 70vh; }
  .row { grid-template-columns: 64px 1fr; }
  .row .sub { grid-column: 2; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .topbar, .side, .vbar, .crumbs, .pstrip, .filters { display: none !important; }
  .detail { display: block; }
  .stage { height: auto; overflow: visible; background: #fff; }
  .stage img { position: static; transform: none !important; width: 100% !important; height: auto !important; box-shadow: none; }
}
