:root {
  --blue: #004494;
  --blue-dark: #003776;
  --blue-light: #e6ecf5;
  --yellow: #FFD617;
  --text: #171a22;
  --muted: #515560;
  --grey: #f3f6fc;
  --border: #cfdaf5;
  --white: #ffffff;
  --green: #1e7a3c;
  --red: #b3261e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font-family: Arimo, Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--yellow); padding: 8px; z-index: 10; }

/* Barra global */
.globan { background: #404040; color: #fff; font-size: 13px; }
.globan-inner { display: flex; gap: 12px; align-items: center; min-height: 32px; flex-wrap: wrap; }
.globan-link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.globan-panel p { margin: 0; padding: 8px 0 12px; }

/* Cabecera */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 20px; padding-bottom: 20px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--blue); }
.flag { width: 72px; height: 48px; display: block; }
.logo-org { font-size: 17px; line-height: 1.15; color: var(--blue); display: block; padding-left: 14px; border-left: 1px solid var(--border); }
.header-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.header-login { font-weight: 700; text-decoration: none; padding: 8px 4px; }
.header-login::before { content: "🔒 "; }
.lang select { border: 1px solid var(--border); background: #fff; padding: 8px 10px; font: inherit; color: var(--blue); font-weight: 700; border-radius: 0; }
.search { display: flex; }
.search input { border: 1px solid var(--blue); border-right: 0; padding: 8px 10px; font: inherit; width: 200px; border-radius: 0; }
.search button { background: var(--blue); color: #fff; border: 1px solid var(--blue); padding: 0 12px; cursor: pointer; }

.site-name { background: var(--blue); color: #fff; font-size: 22px; font-weight: 700; padding: 14px 0; line-height: 1.3; }

.main-nav { background: #fff; border-bottom: 1px solid var(--border); }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.main-nav a { display: block; padding: 14px 16px; text-decoration: none; color: var(--blue); font-weight: 700; border-bottom: 4px solid transparent; }
.main-nav a:hover, .main-nav a.active { border-bottom-color: var(--blue); background: var(--grey); }
.nav-toggle { display: none; background: none; border: 0; color: var(--blue); font: inherit; font-weight: 700; padding: 14px 0; cursor: pointer; }

.breadcrumb { font-size: 14px; color: var(--muted); padding-top: 14px; padding-bottom: 14px; }
.breadcrumb a { color: var(--blue); }

/* Cabecera de página */
.page-header { background: var(--grey); padding: 36px 0 40px; border-bottom: 1px solid var(--border); }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 38px; line-height: 1.15; margin: 0 0 16px; color: var(--text); max-width: 900px; }
h2 { font-size: 28px; line-height: 1.2; margin: 0 0 20px; }
h3 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
.intro { font-size: 19px; max-width: 820px; margin: 0; color: #2a2e38; }

.notice { margin: 28px 0 0; border-left: 6px solid var(--yellow); background: #fffbe6; padding: 14px 18px; }

.section { padding: 48px 0; }
.wrap.section { padding-left: 16px; padding-right: 16px; }
.section-grey { background: var(--grey); }
.muted { color: var(--muted); font-size: 14px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { border-top: 4px solid var(--blue); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 20px; }
.kpi-num { font-size: 36px; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 15px; color: var(--muted); }

/* Comisionado */
.commissioner { display: grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: start; }
.com-photo { width: 100%; aspect-ratio: 5 / 6; object-fit: cover; display: block; background: #d8dde6; }
.com-photo[hidden] { display: none; }
.com-photo-placeholder svg { width: 100%; height: 100%; display: block; }
.photo-upload { display: inline-block; margin-top: 10px; font-size: 14px; color: var(--blue); text-decoration: underline; cursor: pointer; }
.photo-upload input { display: none; }
.com-role { font-size: 18px; color: var(--muted); margin-top: -12px; }
blockquote { margin: 24px 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--blue); font-size: 19px; font-style: italic; }
.mission { padding-left: 20px; }
.mission li { margin-bottom: 6px; }

/* Tarjetas */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card { border: 1px solid var(--border); padding: 24px; background: #fff; }
.card-tag { display: inline-block; background: var(--blue-light); color: var(--blue); font-size: 13px; font-weight: 700; padding: 2px 8px; margin-bottom: 12px; }
.card p { margin: 0; color: #2a2e38; }

/* Tabla */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); }
.reg-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.reg-table th { text-align: left; background: var(--blue-light); color: var(--blue-dark); padding: 12px 14px; white-space: nowrap; }
.reg-table td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.reg-table td:first-child { font-family: "Courier New", monospace; font-size: 13px; width: 170px; }
.reg-table td:nth-child(2) { min-width: 280px; }
.reg-table tr.derogada td:nth-child(2) { text-decoration: line-through; color: var(--muted); }
.status { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 8px; white-space: nowrap; }
.status-pend { background: #fff3cd; color: #7a5b00; }
.status-ok { background: #dff3e5; color: var(--green); }
.reg-footer { display: flex; gap: 16px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

.btn { font: inherit; font-weight: 700; padding: 10px 18px; cursor: pointer; border: 2px solid var(--blue); border-radius: 0; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: #9aa5b8; border-color: #9aa5b8; cursor: default; }
.btn-secondary { background: #fff; color: var(--blue); padding: 6px 12px; font-size: 14px; }
.btn-secondary:hover { background: var(--grey); }
.btn-secondary:disabled { color: #9aa5b8; border-color: #cfd6e2; cursor: default; }

.fila-nueva td { background: #fffbe6; }
.badge-new { display: inline-block; background: var(--yellow); color: var(--text); font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }

.kpi-alert { border-top-color: var(--red); }
.kpi-alert .kpi-num { color: var(--red); }
.kpi-note { display: block; font-size: 13px; font-style: italic; }

.kpi-source { margin-top: 12px; }

/* IDUE */
.lead-text { font-size: 18px; max-width: 820px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 24px; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 12px; }
.req-table { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 20px; }
.req-table th, .req-table td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.req-table th { width: 42%; background: var(--grey); }
a.btn { display: inline-block; text-decoration: none; }
a.btn-primary { color: #fff; }

/* Sede electrónica */
.sede { background: #fff; border: 1px solid var(--border); max-width: 760px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.sede-bar { background: var(--blue-dark); color: #fff; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 20px; font-size: 14px; }
.sede-brand { font-weight: 700; }
.sede-meta { font-family: "Courier New", monospace; font-size: 13px; }
.sede-body { padding: 28px 24px; min-height: 240px; }
.sede-body h3 { font-size: 21px; margin-bottom: 14px; }
.sede-body ul { padding-left: 20px; }
.sede-alert { border-left: 4px solid var(--red); background: #fdf0ef; padding: 12px 14px; margin-bottom: 14px; }
.sede-field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 14px; max-width: 420px; }
.sede-field select { font: inherit; font-weight: 400; padding: 9px; border: 1px solid #7a8090; border-radius: 0; background: #fff; }
.sede-help { font-size: 14px; color: var(--muted); }
.sede-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.sede-actions .btn-secondary { padding: 10px 18px; font-size: 16px; }
.sede-foot { border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 20px; font-size: 13px; color: var(--muted); }

.sede-check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; font-size: 15px; }
.sede-check input { margin-top: 4px; width: 16px; height: 16px; flex: none; }

.info-box { margin-top: 20px; background: var(--blue-light); border-left: 4px solid var(--blue); padding: 14px 18px; font-size: 15px; }
.tram-table td:first-child { width: 110px; white-space: nowrap; }

/* Sala de espera */
.queue { position: fixed; inset: 0; background: var(--grey); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.queue[hidden] { display: none; }
.queue-box { background: #fff; border-top: 6px solid var(--blue); box-shadow: 0 2px 12px rgba(0,0,0,.12); max-width: 560px; width: 100%; padding: 32px; }
.queue-flag { width: 60px; height: 40px; margin-bottom: 16px; }
.queue-box h2 { font-size: 26px; margin-bottom: 12px; }
.queue-data { margin: 20px 0; border: 1px solid var(--border); }
.queue-data div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.queue-data div:first-child { border-top: 0; }
.queue-data dt { color: var(--muted); }
.queue-data dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-progress { height: 8px; background: var(--blue-light); margin-bottom: 16px; }
.queue-progress div { height: 100%; width: 0; background: var(--blue); }

/* Cookies */
.cookie { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 4px solid var(--blue); box-shadow: 0 -2px 12px rgba(0,0,0,.15); z-index: 30; padding: 18px 0; }
.cookie[hidden] { display: none; }
.cookie-inner { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cookie-inner p { margin: 4px 0 0; font-size: 14px; max-width: 640px; }
.cookie-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Noticias: PDF */
.news-pdf { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 700; }
.news-pdf::before { content: "PDF · "; color: var(--red); }

/* Metadatos de página */
.page-meta { padding-top: 32px; padding-bottom: 32px; border-top: 1px solid var(--border); }
.feedback { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 20px; background: var(--grey); margin-bottom: 20px; }
.feedback span { font-weight: 700; margin-right: 8px; }
.qr-box { display: flex; gap: 18px; align-items: center; border: 1px solid var(--border); padding: 14px 18px; margin-bottom: 20px; max-width: 620px; }
.qr-box svg { width: 120px; height: 120px; flex: none; }
.qr-box div { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.meta-list { margin: 0 0 12px; font-size: 14px; }
.meta-list div { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.meta-list dt { color: var(--muted); }
.meta-list dt::after { content: ":"; }
.meta-list dd { margin: 0; }
.mono { font-family: "Courier New", monospace; }

/* Organigrama */
.org-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.org-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.org-tools .btn-secondary { min-width: 40px; }
.org-count { display: flex; gap: 20px; font-size: 15px; color: var(--muted); }
.org-count strong { color: var(--blue); font-size: 22px; }

.org-viewport { overflow: auto; max-height: 900px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background:
  linear-gradient(var(--grey) 1px, transparent 1px) 0 0 / 24px 24px,
  linear-gradient(90deg, var(--grey) 1px, transparent 1px) 0 0 / 24px 24px, #fff; }
.org-chart { display: inline-block; min-width: 100%; padding: 32px 24px 40px; --line: #7f93b8; }

.oc-box { background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--blue); padding: 8px 10px; font-size: 13px; line-height: 1.3; text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.oc-code { display: block; font-family: "Courier New", monospace; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.oc-box em { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 3px; }

.oc-top { display: flex; flex-direction: column; align-items: center; }
.oc-level { display: flex; align-items: center; }
.oc-hline { width: 36px; border-top: 2px dashed var(--line); }
.oc-vline { height: 28px; border-left: 2px solid var(--line); }
.oc-chief { display: flex; gap: 12px; align-items: center; min-width: 280px; padding: 12px 16px; border-top: 5px solid var(--yellow); background: var(--blue); color: #fff; border-color: var(--blue); }
.oc-photo { width: 56px; height: 67px; flex: none; background: #cfd8e6; overflow: hidden; }
.oc-photo img, .oc-photo svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.oc-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.oc-name { font-size: 17px; font-weight: 700; }
.oc-staff { width: 200px; border-top-color: #7f93b8; }
.oc-staff strong, .oc-staff span { display: block; }
.oc-staff span { color: var(--muted); font-size: 12px; }

.oc-row { display: flex; justify-content: center; }
.oc-col { flex: 0 0 250px; padding: 28px 8px 0; position: relative; }
.oc-col::before { content: ""; position: absolute; top: 0; left: 50%; height: 28px; border-left: 2px solid var(--line); }
.oc-col::after { content: ""; position: absolute; top: 0; left: 0; right: 0; border-top: 2px solid var(--line); }
.oc-col:first-child::after { left: 50%; }
.oc-col:last-child::after { right: 50%; }
.oc-dir { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); border-top-color: var(--yellow); font-weight: 700; font-size: 14px; min-height: 64px; }
.oc-dir .oc-code { color: #c9d6ee; }

.oc-subs, .oc-units, .oc-sectors { list-style: none; margin: 0; padding: 0; }
.oc-subs { margin-left: 14px; }
.oc-subs > li, .oc-units > li, .oc-sectors > li { position: relative; padding: 10px 0 0 18px; }
.oc-subs > li::before, .oc-units > li::before, .oc-sectors > li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--line); }
.oc-subs > li:last-child::before, .oc-units > li:last-child::before, .oc-sectors > li:last-child::before { bottom: auto; height: 28px; }
.oc-subs > li::after, .oc-units > li::after, .oc-sectors > li::after { content: ""; position: absolute; left: 0; top: 28px; width: 18px; border-top: 2px solid var(--line); }
.oc-sub { width: 100%; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; border-top-color: #2f6fc1; }
.oc-sub:hover { background: var(--grey); }
.oc-toggle { display: block; font-weight: 400; color: var(--blue); font-size: 11px; margin-top: 4px; }
.oc-closed > .oc-units { display: none; }
.oc-units { margin-left: 10px; }
.oc-unit { border-top-color: #7f93b8; }
.oc-sectors { margin-left: 10px; }
.oc-sectors > li { padding-top: 6px; }
.oc-sectors > li::after { top: 20px; }
.oc-sectors > li:last-child::before { height: 20px; }
.oc-sector { border-top: 1px solid var(--border); border-left: 3px solid #b8c4da; font-size: 12px; padding: 5px 8px; }
.oc-new { background: #fffbe6; border-top-color: var(--yellow); animation: flash 1.5s ease-out; }
@keyframes flash { from { background: var(--yellow); } to { background: #fffbe6; } }

.oc-committees { margin-top: 40px; border-top: 2px dashed var(--line); padding-top: 20px; }
.oc-committees-title { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; text-align: center; }
.oc-committees-list { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.oc-committee { width: 210px; border: 1px dashed var(--line); border-top: 3px solid var(--line); }

/* Comisario y Subcomisario */
.com-photo-frame { box-shadow: 0 2px 8px rgba(0,0,0,.15); background: #cfd8e6; }
.com-name { font-size: 30px; margin: 0 0 16px; }
.commissioner + .commissioner { margin-top: 48px; padding-top: 48px; border-top: 1px solid var(--border); }
.commissioner-sub .com-photo-wrap { max-width: 220px; }
.com-text h4 { font-size: 17px; margin: 20px 0 8px; }
.legal { font-size: 15px; color: #2a2e38; border-left: 3px solid var(--border); padding-left: 14px; }
.agenda-title { margin-top: 48px; }
.agenda td:first-child { width: 80px; font-weight: 700; color: var(--blue); }

.modal-list { padding-left: 20px; font-size: 15px; }
.modal-list li { margin-bottom: 4px; }

/* Noticias */
.news { display: grid; gap: 0; }
.news-item { padding: 20px 0; border-bottom: 1px solid var(--border); }
.news-item:first-child { padding-top: 0; }
.news-meta { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.news-type { font-weight: 700; color: var(--blue); }
.news-item h3 a { text-decoration: none; }
.news-item h3 a:hover { text-decoration: underline; }
.news-item p { margin: 0; }

/* Consulta */
.consulta { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.cons-form { background: #fff; border: 1px solid var(--border); padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.cons-form label { font-weight: 700; }
.cons-form input { font: inherit; padding: 10px; border: 1px solid #7a8090; border-radius: 0; }
.cons-form .btn { align-self: flex-start; }
.cons-result:empty { display: none; }
.cons-result { border-left: 4px solid var(--green); background: #f0f8f2; padding: 12px 14px; font-size: 15px; }

/* Pie */
.site-footer { background: var(--blue); color: #fff; margin-top: 0; }
.site-footer a { color: #fff; }
.footer-top { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-top: 36px; padding-bottom: 28px; }
.footer-title { font-weight: 700; font-size: 17px; margin: 0 0 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer p { margin: 0 0 8px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.25); font-size: 13px; padding: 14px 0; }
.footer-bottom .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.satire { opacity: .75; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; max-width: 520px; width: 100%; padding: 28px; border-top: 6px solid var(--blue); }
.modal-box h3 { font-size: 22px; margin-bottom: 12px; }
.modal-actions { margin-top: 20px; text-align: right; }
.form-ref { font-family: "Courier New", monospace; background: var(--grey); padding: 2px 6px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .commissioner { grid-template-columns: 1fr; }
  .com-photo-wrap { max-width: 260px; }
  .consulta { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 16px; }
  .footer-top { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  h1 { font-size: 28px; }
  h2 { font-size: 23px; }
  .site-name { font-size: 18px; }
  .search input { width: 140px; }
  .cards { grid-template-columns: 1fr; }
  .kpi-num { font-size: 28px; }
  .nav-toggle { display: block; }
  .main-nav ul { display: none; flex-direction: column; }
  .main-nav ul.open { display: flex; }
}
