/* OMA 126 — hoja de estilos única (sin frameworks, sin build). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e1e5eb;
  --line-strong: #c9d0da;
  --ink: #17202c;
  --ink-2: #4a5566;
  --ink-3: #7b8696;
  --navy: #13294b;
  --navy-2: #1d3b69;
  --primary: #1f5fbf;
  --primary-ink: #ffffff;
  --ok: #157f4c;      --ok-bg: #e5f5ec;
  --warn: #9a5b00;    --warn-bg: #fff3dc;
  --danger: #b42318;  --danger-bg: #fdecea;
  --info: #1d5ea8;    --info-bg: #e7f0fb;
  --violet: #6440b8;  --violet-bg: #efeafb;
  --muted-bg: #eef1f5;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .28);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .93em; white-space: nowrap; }
.prewrap .mono, .mono.wrap { white-space: normal; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-danger { color: var(--danger); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--navy); color: #c8d3e6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; color: #fff; text-decoration: none !important; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { background: #fff; border-radius: 6px; padding: 2px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { font-size: 11px; color: #9fb0cc; }
.sidebar nav { padding: 8px 8px 16px; flex: 1; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #7d90b0; padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: #d4ddec; text-decoration: none !important; font-size: 13.5px; }
.nav-link i { width: 16px; text-align: center; color: #8ea3c4; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.is-active { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 #f5b301; }
.nav-link.is-active i { color: #f5b301; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: #6f83a5; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; color: var(--ink-2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 6px; }
.topbar-user form { margin: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--ink); padding: 4px 8px; border-radius: 20px; text-decoration: none !important; }
.user-chip:hover { background: var(--muted-bg); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.only-mobile { display: none !important; }

/* ---------- page / cards ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
.breadcrumb a { color: var(--ink-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 16px; }
.kpi .kpi-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.kpi .kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: 12.5px; color: var(--ink-2); }
.kpi.warn { border-left: 4px solid #f5b301; } .kpi.danger { border-left: 4px solid var(--danger); } .kpi.ok { border-left: 4px solid var(--ok); }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 20px; }
.dl dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 2px; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.prewrap { white-space: pre-wrap; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.list-plain li:first-child { border-top: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: #b4bdc9; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1a52a6; border-color: #1a52a6; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: #106a3f; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #971c13; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 6px; color: var(--ink-2); cursor: pointer; }
.btn-icon:hover { background: var(--muted-bg); color: var(--ink); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* ---------- badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: #dfe9fb; color: #1a4fa0; }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-muted { background: var(--muted-bg); color: var(--ink-2); }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.alert-ok { background: var(--ok-bg); border-color: #b4e2c7; color: #0f5c37; }
.alert-warn { background: var(--warn-bg); border-color: #f4d391; color: #7a4800; }
.alert-error { background: var(--danger-bg); border-color: #f5c2bd; color: #8f1c13; }
.alert-info { background: var(--info-bg); border-color: #bcd4f2; color: #174b86; }

/* ---------- toolbar / table ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; flex: 1; }
.toolbar-actions { display: flex; gap: 10px; align-items: center; }
.search { position: relative; }
.search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 13px; }
.search input { padding-left: 32px !important; width: 240px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table tr[data-href] { cursor: pointer; }
.row-link { font-weight: 600; color: var(--ink); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact td, .table-compact th { padding: 7px 10px; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.empty i { font-size: 28px; margin-bottom: 10px; color: var(--line-strong); }
.pager { display: flex; gap: 4px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager a { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; }
.pager a.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.is-loading { opacity: .5; pointer-events: none; transition: opacity .15s; }

/* ---------- forms ---------- */
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; height: 34px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; font: inherit; color: var(--ink);
}
textarea { height: auto; min-height: 80px; resize: vertical; line-height: 1.45; }
.toolbar select { width: auto; min-width: 150px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 95, 191, .25); border-color: var(--primary); }
input[readonly], textarea[readonly], select:disabled { background: var(--surface-2); color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .req { color: var(--danger); font-weight: 700; }
.field .help { display: block; color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.field-error { display: block; color: var(--danger); font-size: 12px; margin-top: 3px; min-height: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.form-heading { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 6px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500 !important; cursor: pointer; margin: 0 !important; color: var(--ink) !important; font-size: 13.5px !important; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.file-current { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
input[type=file] { font-size: 13px; }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .22s ease; z-index: 60; display: flex; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 55; }
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
body.drawer-open { overflow: hidden; }
.drawer-body { flex: 1; display: flex; min-width: 0; }
.drawer-form { display: flex; flex-direction: column; width: 100%; margin: 0; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); font-weight: 700; }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-loading { padding: 40px; color: var(--ink-3); }

/* ---------- dialog / toasts ---------- */
dialog.confirm { border: 0; border-radius: 10px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog.confirm::backdrop { background: rgba(15, 23, 42, .45); }
dialog.confirm form { padding: 20px; margin: 0; }
dialog.confirm p { margin: 10px 0 18px; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
dialog.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; transition: opacity .4s, transform .4s; font-size: 13.5px; }
.toast-ok { background: #0f5c37; } .toast-error { background: #8f1c13; } .toast-warn { background: #7a4800; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 8px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 14px; font: inherit; font-weight: 550; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--muted-bg); font-size: 11px; margin-left: 4px; color: var(--ink-2); }

/* ---------- workflow (OT) ---------- */
.steps { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.steps li { flex: 1; min-width: 110px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-3); border-bottom: 3px solid var(--line); }
.steps li.done { color: var(--ok); border-color: var(--ok); }
.steps li.current { color: var(--primary); border-color: var(--primary); font-weight: 650; }
.task { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: start; }
.task:first-child { border-top: 0; }
.task-n { width: 26px; height: 26px; border-radius: 50%; background: var(--muted-bg); display: grid; place-items: center; font-weight: 650; font-size: 12px; color: var(--ink-2); }
.task.is-done .task-n { background: var(--ok-bg); color: var(--ok); }
.task-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.task-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.checks { display: grid; gap: 6px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; }
.blocker { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-size: 13px; }
.guide-row td:first-child { width: 48px; color: var(--ink-3); }
.result-picker { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.result-picker label { margin: 0; }
.result-picker input { position: absolute; opacity: 0; pointer-events: none; }
.result-picker span { display: block; padding: 4px 9px; font-size: 12px; font-weight: 600; cursor: pointer; border-left: 1px solid var(--line-strong); color: var(--ink-2); background: #fff; }
.result-picker label:first-child span { border-left: 0; }
.result-picker input:checked + span.r-ok { background: var(--ok); color: #fff; }
.result-picker input:checked + span.r-observacion { background: #d48806; color: #fff; }
.result-picker input:checked + span.r-no_conforme { background: var(--danger); color: #fff; }
.result-picker input:checked + span.r-no_aplica { background: #5b6575; color: #fff; }
.result-picker input:focus-visible + span { outline: 2px solid var(--primary); }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.progress { height: 6px; background: var(--muted-bg); border-radius: 3px; overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--ok); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #0d1f3b 0%, #13294b 55%, #1d3b69 100%); }
.auth-card { width: min(400px, 100%); background: #fff; border-radius: 12px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card .logo { display: block; margin: 0 auto 14px; height: 72px; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card .sub { text-align: center; color: var(--ink-3); margin: 4px 0 24px; font-size: 13px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; height: 40px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 70; transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .search input { width: 100%; }
  .toolbar-filters > * { flex: 1 1 140px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; }
  .table td::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; color: var(--ink-3); }
  .table td.col-actions { text-align: left; }
  .table td.col-actions::before { display: none; }
  .task { grid-template-columns: 28px 1fr; }
  .task-actions { grid-column: 2; justify-content: flex-start; }
}

/* ---------- impresión ---------- */
@media print {
  .sidebar, .topbar, .toolbar, .col-actions, .no-print, .drawer, .toasts { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* rechazo RII */
.rii-reject { position: relative; }
.rii-reject summary { list-style: none; }
.rii-reject summary::-webkit-details-marker { display: none; }
.rii-reject[open] form { position: absolute; right: 0; top: 34px; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 10px; display: flex; gap: 6px; width: 340px; }
.center { text-align: center; }
.matrix th.center, .matrix td.center { text-align: center; }

/* gráfico de barras de indicadores */
.bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 180px; padding: 18px 0 22px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 18px; }
.bar { width: 100%; max-width: 38px; background: #9fb4d6; border-radius: 3px 3px 0 0; }
.bar.is-ok { background: var(--ok); } .bar.is-bad { background: var(--danger); }
.bar-val { font-size: 10.5px; color: var(--ink-2); margin-bottom: 2px; }
.bar-lbl { position: absolute; bottom: -20px; font-size: 10.5px; color: var(--ink-3); }
.bars-meta { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--warn); z-index: 1; pointer-events: none; }
/* matriz OACI */
.heat { border-collapse: separate; border-spacing: 3px; }
.heat td, .heat th { width: 54px; height: 40px; text-align: center; font-size: 12px; border-radius: 5px; }
.heat th { color: var(--ink-3); font-weight: 600; }
.heat .h-intolerable { background: #f6c9c4; } .heat .h-tolerable { background: #fde3a7; } .heat .h-aceptable { background: #cdebd8; }
.heat td strong { font-size: 15px; }
