@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url("assets/fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url("assets/fonts/montserrat-latin-700-normal.woff2") format("woff2"); }
:root {
  --paper: #f6f1e7;
  --surface: #fffdf8;
  --ink: #191b1d;
  --muted: #67645e;
  --red: #8f1717;
  --red-bright: #c0261b;
  --red-soft: #f3dcda;
  --amber: #7a4b00;
  --amber-soft: #fff3d6;
  --blue: #174d77;
  --green: #356246;
  --line: #d8cebd;
  --shadow: 0 8px 24px rgba(50, 39, 23, .08);
  --radius: 16px;
  --sans: "Segoe UI", "DM Sans", system-ui, -apple-system, Roboto, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-family: var(--sans);
  color: var(--ink);
  background: #d9d1c4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body { margin: 0; background: #d9d1c4; }
button, input { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid rgba(23, 77, 119, .55); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; background: var(--ink); color: #fff; transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.app { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; background: var(--paper); position: relative; box-shadow: 0 0 60px rgba(30,25,20,.18); }

/* Cabecera */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; min-height: 68px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; background: rgba(246,241,231,.95); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(143,23,23,.15); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; text-decoration: none; }
.brand img { width: 34px; height: 53px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-town { font-family: var(--serif); font-size: 1.25rem; }
.brand-product { margin-top: 4px; color: var(--red); font-size: .66rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.icon-btn { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { border-color: var(--red); color: var(--red); }
.topbar.is-detail .brand { display: none; }
.topbar.is-detail #back-btn { margin-right: auto; }

.search-panel { padding: 10px 14px 12px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 68px; z-index: 29; }
.search-panel input { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

.banner { padding: 8px 14px; background: var(--amber-soft); color: var(--amber); font-size: .82rem; font-weight: 600; text-align: center; }

main { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.view { padding: 12px 14px 8px; animation: in .22s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

/* Chips y segmentado */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; margin: 0 -14px; padding-inline: 14px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .86rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.segment { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin: 2px 0 14px; background: #ebe3d3; border-radius: 12px; }
.segment button { min-height: 38px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; font-size: .88rem; color: var(--muted); cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--red); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* Tarjetas de aviso */
.list { display: flex; flex-direction: column; gap: 12px; }
.card { position: relative; display: block; width: 100%; text-align: left; padding: 16px 16px 14px; background: var(--surface); border: 1px solid #e4beb8; border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; }
.card:hover { border-color: var(--red); }
.card.is-urgent { border: 2px solid var(--red-bright); }
.card.is-important { border-color: #d9a441; }
.card.is-past { opacity: .78; }
.card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding-right: 44px; margin-bottom: 8px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.badge-cat { background: rgba(192,38,27,.1); color: var(--red-bright); }
.badge-urgent { background: var(--red-bright); color: #fff; }
.badge-important { background: var(--amber-soft); color: var(--amber); }
.badge-past { background: #ececec; color: #555; }
.card h3 { margin: 0 0 4px; font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.card time { display: block; margin-bottom: 8px; color: var(--muted); font-size: .8rem; }
.card p { margin: 0 0 10px; font-size: .92rem; line-height: 1.5; color: #2b2b2b; }
.datos { margin: 0 0 10px; padding: 0; list-style: none; font-size: .85rem; line-height: 1.55; }
.card-foot { display: flex; align-items: center; justify-content: space-between; color: var(--red); font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.clip { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; }
.clip svg { width: 16px; height: 16px; }
.star { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%; color: var(--red); cursor: pointer; }
.star svg { width: 24px; height: 24px; }
.star[aria-pressed="true"] svg { fill: currentColor; }

.urgent-banner { display: block; width: 100%; text-align: left; margin-bottom: 14px; padding: 14px 16px; border: 0; border-radius: var(--radius); background: var(--red-bright); color: #fff; cursor: pointer; }
.urgent-banner small { display: block; margin-bottom: 4px; font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .9; }
.urgent-banner strong { display: block; font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.urgent-banner span { display: block; margin-top: 4px; font-size: .88rem; opacity: .95; }

.empty { padding: 36px 14px; text-align: center; color: var(--muted); }
.empty button { margin-top: 12px; }

/* Detalle */
.detail-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius); margin-bottom: 14px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; color: var(--muted); font-size: .82rem; }
.detail h1 { margin: 0 0 14px; font-family: var(--serif); font-size: 1.55rem; line-height: 1.25; }
.detail-body { font-size: 1rem; line-height: 1.65; }
.detail-body p { margin: 0 0 1em; }
.detail-body a { color: var(--red); }
.detail-body img { border-radius: 8px; height: auto; }
.claves { margin: 18px 0; padding: 14px 16px; background: #fcf9f8; border: 1px solid #e4beb8; border-left: 4px solid var(--red); border-radius: 4px 12px 12px 4px; }
.claves h2, .adjuntos h2 { margin: 0 0 8px; color: var(--red); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.claves dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .95rem; }
.claves dt { font-weight: 700; }
.claves dd { margin: 0; }
.nota { margin: 16px 0; padding: 12px 14px; background: var(--amber-soft); color: var(--amber); border-radius: 10px; font-size: .9rem; }
.nota a { color: inherit; font-weight: 700; }
.adjuntos { margin: 18px 0; }
.adjunto { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 12px 14px; border: 1px solid #e4beb8; border-radius: 12px; background: var(--surface); color: var(--red); font-weight: 700; text-decoration: none; }
.adjunto .tipo { padding: 2px 6px; border-radius: 3px; background: var(--red); color: #fff; font-size: .65rem; letter-spacing: .05em; }
.adjunto-img { display: block; width: 100%; margin-bottom: 8px; border-radius: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 10px; }
.btn { min-height: 44px; padding: 0 18px; border: 1px solid var(--red); border-radius: 999px; background: var(--red); color: #fff; font-weight: 700; cursor: pointer; }
.btn-ghost { background: transparent; color: var(--red); }
.btn[aria-pressed="true"] { background: var(--red-soft); color: var(--red); }

/* Páginas */
.page-head { padding: 8px 0 14px; }
.kicker { margin: 0 0 4px; color: var(--red); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.page-head h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.7rem; line-height: 1.2; }
.page-head p { margin: 0; color: var(--muted); }

.sede-head { padding: 8px 0 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.sede-head h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 2rem; line-height: 1.15; letter-spacing: -.015em; }
.sede-head p { margin: 0; color: var(--muted); }
.tramites { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.tramite { position: relative; display: flex; flex-direction: column; gap: 9px; padding: 18px 14px 20px; background: var(--surface); color: var(--ink); text-decoration: none; }
.tramite:hover, .tramite:active { background: var(--paper); }
.tramite:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.tramite-ico { display: block; width: 40px; height: 40px; }
.tramite strong { font-family: var(--serif); font-size: 1rem; font-weight: 600; line-height: 1.25; }
.tramite small { margin-top: auto; padding-right: 22px; color: var(--muted); font-size: .8125rem; line-height: 1.4; background: url("assets/icons/sede-externo.svg") right bottom / 15px no-repeat; }
.tramites-mas { margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tramites-mas > summary { padding: 16px 0; cursor: pointer; font-size: .8rem; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; color: var(--red); }
.tramites-mas > summary:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.tramites-mas h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.05rem; }
.tramites-mas ul { margin: 0 0 18px; padding-left: 18px; font-size: .92rem; line-height: 1.5; }
.tramites-mas li + li { margin-top: 6px; }
.tramites-mas a { color: var(--ink); }
.tramites-cat { margin: 20px 0 0; font-weight: 700; }
.tramites-cat a { color: var(--red); text-decoration: none; }
.tramites-aviso { margin: 8px 0 0; color: var(--muted); font-size: .8125rem; line-height: 1.45; }

.grupo { margin-bottom: 18px; }
.grupo h2 { margin: 0 0 8px; color: var(--red); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; }
.contacto { margin-bottom: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.contacto h3 { margin: 0 0 4px; font-size: 1rem; }
.contacto p { margin: 2px 0; font-size: .88rem; color: var(--muted); }
.contacto .acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.contacto .btn { display: inline-flex; align-items: center; text-decoration: none; }
.grupo-emergencias .contacto { border: 2px solid var(--red-bright); }
.web-link { display: block; margin: 8px 0 16px; padding: 14px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-weight: 700; text-decoration: none; color: var(--red); }

.card-box { margin-bottom: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-box .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-box h2 { margin: 0 0 4px; font-size: 1.02rem; }
.card-box p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.card-box .note { margin-top: 10px; font-size: .8rem; }
.card-box .sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sub-title { margin-bottom: 6px !important; color: var(--ink) !important; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: .92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.settings-msg { margin-top: 8px !important; min-height: 1em; font-size: .82rem !important; }
.switch { flex: none; width: 54px; height: 32px; padding: 3px; border: 0; border-radius: 999px; background: #cfc6b5; cursor: pointer; transition: background .15s; }
.switch span { display: block; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch[aria-checked="true"] { background: var(--red); }
.switch[aria-checked="true"] span { transform: translateX(22px); }
.about { margin: 18px 0 6px; text-align: center; color: var(--muted); font-size: .76rem; }

/* Barra inferior */
.tabbar { position: fixed; left: 50%; bottom: 0; z-index: 40; transform: translateX(-50%); width: min(100%, 720px); display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 6px max(8px, env(safe-area-inset-bottom)); background: rgba(255,253,248,.97); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; padding-top: 6px; border-radius: 12px; color: var(--muted); font-size: .7rem; font-weight: 700; text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--red); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.3; }

/* Tarjeta clicable completa y aviso emergente */
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.star { z-index: 2; }
.urgent-banner { text-decoration: none; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60; transform: translate(-50%, 12px); padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .88rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.urgent-banner span { line-height: 1.45; }

/* Sede: réplica de la sección de la portada web */
#view-sede { --linea: #e4beb8; --titulos: "Montserrat", var(--sans); }
#view-sede .sede-head { border-bottom-color: var(--linea); }
#view-sede .sede-head h1 { font-family: var(--titulos); font-weight: 700; font-size: 1.9rem; letter-spacing: -.02em; }
#view-sede .tramites { border-color: var(--linea); background: var(--linea); }
#view-sede .tramite { background: #fff; }
#view-sede .tramite:active { background: var(--paper); }
#view-sede .tramite strong { font-family: var(--titulos); font-weight: 600; font-size: .95rem; }
#view-sede .tramites-mas, #view-sede .tramites-mas { border-color: var(--linea); }
#view-sede .tramites-mas h2 { font-family: var(--titulos); font-weight: 600; }
#view-sede .tramites-cat a { font-size: .8rem; letter-spacing: .035em; text-transform: uppercase; font-weight: 800; }
