/* Estructura y neutros: Silia DS (DM Sans, radios 8/12, sombras tertiary).
   Color de marca: paleta del Área Chiapas Centro (telar: negro, dorado, crema, óxido). */
:root {
  --bg-layout: #F1EEE6;
  --bg-container: #FFFFFF;
  --text: #3C3C48;
  --text-strong: #21212F;
  --text-desc: #6A6A73;
  --text-icon: #9B9BA1;
  --border: #DEDEE0;
  --border-2: #F2F2F3;
  --fill: rgba(33,33,47,.06);

  --night: #1B140D;
  --earth: #54381E;
  --gold: #C08A3E;
  --gold-soft: #F6ECDA;
  --gold-text: #7A521C;
  --cream: #EFE8D8;
  --rust: #9C4A26;
  --rust-soft: #F7E7DF;

  --danger: #CF1322;
  --danger-bg: #FFF1F0;

  --r-sm: 8px;
  --r-lg: 12px;
  --shadow: 0 2px 4px rgba(0,0,0,.02), 0 1px 6px rgba(0,0,0,.02), 0 1px 2px rgba(0,0,0,.03);
  --shadow-2: 0 6px 16px rgba(0,0,0,.08), 0 3px 6px -4px rgba(0,0,0,.12);
  --max: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg-layout); color: var(--text);
  font: 400 14px/22px "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-text); }
h1, h2, h3, h4 { color: var(--text-strong); margin: 0; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 1000; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-in { max-width: var(--max); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-strong); min-width: 0; }
.brand-mark { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--night); display: grid; place-items: center; flex: none; }
.brand-mark img { width: 30px; height: 34px; object-fit: contain; }
.brand-txt { display: flex; flex-direction: column; line-height: 18px; white-space: nowrap; }
.brand-txt b { font-weight: 600; }
.brand-txt small { color: var(--text-desc); font-size: 12px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a { text-decoration: none; color: var(--text); padding: 6px 12px; border-radius: var(--r-sm); font-weight: 500; }
.nav-links a:hover { background: var(--fill); }

/* ---------- hero ---------- */
.hero { background: var(--night); color: var(--cream); position: relative; }
.hero-in { max-width: var(--max); margin: 0 auto; padding: 56px 16px 48px; display: grid; grid-template-columns: 220px 1fr; gap: 48px; align-items: center; }
.hero-logo { width: 220px; height: auto; }
.hero .eyebrow { color: var(--gold); }
.hero h1 { color: var(--cream); font-size: clamp(30px, 4.6vw, 48px); line-height: 1.08; letter-spacing: -.02em; max-width: 16ch; font-weight: 700; }
.hero .lead { color: rgba(239,232,216,.78); font-size: 16px; line-height: 26px; max-width: 56ch; margin: 16px 0 28px; }
.hero-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; border-left: 2px solid var(--gold); padding-left: 12px; }
.hero-stats b { font-size: 28px; line-height: 32px; color: var(--cream); font-weight: 600; }
.hero-stats span { font-size: 12px; color: rgba(239,232,216,.6); text-transform: uppercase; letter-spacing: .08em; }
.cintillo { height: 36px; background: url("/assets/cintillo_h.svg") repeat-x left center / auto 100%; }

/* ---------- secciones ---------- */
.section { max-width: var(--max); margin: 0 auto; padding: 64px 16px 8px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; line-height: 20px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-text); }
h2 { font-size: 28px; line-height: 34px; letter-spacing: -.01em; }
.sub { color: var(--text-desc); margin: 8px 0 0; max-width: 62ch; }
.card { background: var(--bg-container); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow); }

/* ---------- controles (Silia: Input / Button / Segmented) ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); }
.input:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(192,138,62,.18); }
.input input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; height: 100%; }
.input svg { width: 16px; height: 16px; fill: none; stroke: var(--text-icon); stroke-width: 2; stroke-linecap: round; flex: none; }
.search { width: 240px; }
.segmented { display: inline-flex; padding: 2px; background: var(--fill); border-radius: var(--r-sm); gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 0 12px; height: 32px; border-radius: 6px; cursor: pointer; color: var(--text-desc); font-weight: 500; white-space: nowrap; }
.segmented button[aria-selected="true"] { background: #fff; color: var(--text-strong); box-shadow: var(--shadow); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text-strong); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--gold); color: var(--gold-text); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--text-strong); }
.btn-primary:hover { background: #CE9A4F; border-color: #CE9A4F; color: var(--text-strong); }
.btn-ghost { border-color: transparent; color: var(--text-desc); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.btn-icon { width: 36px; padding: 0; font-size: 18px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:focus-visible, .segmented button:focus-visible, .nav-links a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- directorio ---------- */
.map { height: 380px; overflow: hidden; margin-bottom: 20px; z-index: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.clin { display: flex; flex-direction: column; overflow: hidden; transition: box-shadow .2s, transform .2s; }
.clin:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.clin-photo { aspect-ratio: 16/10; background: var(--night); position: relative; overflow: hidden; }
.clin-photo img { width: 100%; height: 100%; object-fit: cover; }
.clin-photo.ph { display: grid; place-items: center; background: var(--night) url("/assets/cintillo_h.svg") repeat-x left bottom / auto 22px; }
.clin-photo.ph span { font-size: 44px; font-weight: 700; color: var(--gold); letter-spacing: -.02em; margin-top: -14px; }
.clin-photo.ph small { position: absolute; bottom: 30px; font-size: 12px; color: rgba(239,232,216,.55); }
.clin-num { position: absolute; top: 10px; left: 10px; background: rgba(27,20,13,.82); color: var(--cream); font-size: 12px; font-weight: 600; height: 24px; min-width: 24px; padding: 0 8px; border-radius: 12px; display: grid; place-items: center; }
.clin-more { position: absolute; bottom: 10px; right: 10px; background: rgba(27,20,13,.82); color: var(--cream); font-size: 12px; border-radius: 12px; padding: 0 8px; height: 24px; display: grid; place-items: center; }
.clin-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.clin-body h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
.clin-sub { color: var(--text-desc); font-size: 13px; line-height: 20px; }
.tag { align-self: flex-start; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: var(--gold-soft); color: var(--gold-text); margin-bottom: 4px; }
.tag.rust { background: var(--rust-soft); color: var(--rust); }
.tag.earth { background: #EDE6DD; color: var(--earth); }
.clin-meta { color: var(--text-desc); font-size: 13px; line-height: 20px; }
.clin-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }
.clin-actions .btn { flex: 1; height: 34px; padding: 0 10px; font-size: 13px; }
.empty { text-align: center; color: var(--text-desc); padding: 40px 0; }

/* leaflet */
.leaflet-container { font: inherit; }
.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--night); border: 2px solid var(--gold); display: grid; place-items: center; box-shadow: var(--shadow-2); }
.pin b { transform: rotate(45deg); color: var(--cream); font-size: 11px; font-weight: 600; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 20px; }
.leaflet-popup-content b { color: var(--text-strong); font-size: 14px; }
.leaflet-popup-content a { font-weight: 500; }

/* ---------- panfletos ---------- */
.panf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.panf { overflow: hidden; display: flex; flex-direction: column; }
.panf-cover { position: relative; aspect-ratio: 4/3; display: grid; place-items: center; padding: 20px; overflow: hidden; cursor: zoom-in; border: 0; width: 100%; }
.panf-cover.gold { background: var(--gold); }
.panf-cover.rust { background: var(--rust); }
.panf-cover.earth { background: var(--earth); }
.panf-cover canvas { max-height: 100%; max-width: 78%; width: auto !important; height: auto !important; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.35); border-radius: 2px; transform: rotate(-2deg); transition: transform .25s; }
.panf:hover .panf-cover canvas { transform: rotate(0) scale(1.03); }
.panf-cover .loading { color: rgba(255,255,255,.8); font-size: 13px; }
.panf-body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.panf-body h3 { font-size: 18px; line-height: 26px; }
.panf-body p { margin: 0; color: var(--text-desc); }
.panf-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }
.panf-actions .btn { flex: 1; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(27,20,13,.72); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--bg-layout); border-radius: var(--r-lg); width: min(900px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--border); }
.modal-head h4 { font-size: 16px; line-height: 24px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 8px; flex: none; }
.modal-body { overflow: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.modal-body canvas { width: 100%; max-width: 820px; height: auto; background: #fff; box-shadow: var(--shadow-2); border-radius: 2px; }
.modal-body .loading { padding: 40px; color: var(--text-desc); }

/* ---------- calendario ---------- */
.banner { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--r-lg); background: var(--gold-soft); border: 1px solid #EAD3AE; color: var(--gold-text); font-weight: 500; }
.banner span { flex: 1; min-width: 200px; }
.cal-bar { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h3 { font-size: 20px; line-height: 28px; min-width: 170px; text-align: center; text-transform: capitalize; }
.title-input { flex: 1; min-width: 220px; }
.title-input .lbl { color: var(--text-desc); font-size: 12px; white-space: nowrap; }
.cal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cal-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.form { padding: 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.form h4 { font-size: 16px; line-height: 24px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 12px; line-height: 20px; color: var(--text-desc); font-weight: 500; }
.field i { font-style: normal; color: var(--text-icon); font-weight: 400; }
.field input, .field select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; outline: 0; width: 100%; }
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(192,138,62,.18); }
.loc { font-size: 12px; line-height: 18px; color: var(--text-desc); background: var(--bg-layout); border-radius: var(--r-sm); padding: 8px 10px; margin-top: -4px; }
.loc:empty { display: none; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-actions .btn-primary { flex: 1; }

.cal-wrap { padding: 12px; overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head div { font-size: 12px; font-weight: 600; color: var(--text-desc); text-transform: uppercase; letter-spacing: .06em; padding: 4px 6px 8px; }
.day { min-height: 104px; border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; background: #fff; text-align: left; transition: border-color .15s, background .15s; min-width: 0; }
.day:hover { border-color: var(--gold); }
.day.out { background: transparent; border-color: transparent; cursor: default; }
.day.today .dnum { background: var(--night); color: var(--cream); }
.day.sel { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.dnum { font-size: 12px; font-weight: 600; color: var(--text); width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; }
.ev { font-size: 11px; line-height: 14px; padding: 4px 6px; border-radius: 4px; background: var(--gold-soft); color: var(--gold-text); border-left: 3px solid var(--gold); overflow: hidden; cursor: pointer; }
.ev b { display: block; color: var(--text-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev:hover { background: #F0DFC2; }

.list-wrap { padding: 16px; margin-bottom: 48px; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.list-head h4 { font-size: 16px; line-height: 24px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; background: var(--fill); color: var(--text); border-radius: 10px; padding: 0 8px; line-height: 20px; font-weight: 500; }
.row { display: grid; grid-template-columns: 110px 64px 1fr 1.3fr auto; gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--border-2); }
.row .d { font-weight: 600; color: var(--text-strong); text-transform: capitalize; }
.row .h { color: var(--text-desc); }
.row .g { font-weight: 500; color: var(--text-strong); }
.row .c small { display: block; color: var(--text-desc); font-size: 12px; line-height: 18px; }
.row-actions { display: flex; gap: 4px; }
.list-empty { color: var(--text-desc); padding: 24px 4px; text-align: center; border-top: 1px solid var(--border-2); }

/* ---------- footer / toast ---------- */
.foot { background: var(--night); color: rgba(239,232,216,.8); }
.foot-in { max-width: var(--max); margin: 0 auto; padding: 24px 16px 32px; font-size: 13px; }
.foot-in p { margin: 0 0 4px; }
.foot-in b { color: var(--cream); font-weight: 600; }
.muted { color: rgba(239,232,216,.5); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text-strong); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); font-weight: 500; opacity: 0; pointer-events: none; transition: .25s; z-index: 3000; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cal-layout { grid-template-columns: 1fr; }
  .form { position: static; }
  .row { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .row .d { grid-column: 1; } .row .h { grid-column: 2; grid-row: 1; text-align: right; }
  .row .g, .row .c { grid-column: 1 / -1; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (max-width: 720px) {
  .nav-links a { padding: 6px 8px; font-size: 13px; }
  .brand-txt small { display: none; }
  .hero-in { grid-template-columns: 1fr; gap: 24px; padding: 36px 16px 32px; }
  .hero-logo { width: 120px; }
  .search { width: 100%; }
  .toolbar { width: 100%; }
  .segmented { overflow-x: auto; max-width: 100%; }
  .map { height: 300px; }
  .day { min-height: 64px; padding: 4px; }
  .ev { font-size: 0; padding: 0; height: 6px; border-left: 0; background: var(--gold); }
  .ev b, .ev span { display: none; }
  .cal-head div { font-size: 10px; padding: 4px 2px; text-align: center; }
  .month-nav h3 { min-width: 0; flex: 1; font-size: 18px; }
  .month-nav { width: 100%; }
  .cal-actions { width: 100%; } .cal-actions .btn { flex: 1; }
}
@media (max-width: 440px) {
  .brand-txt { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
