/* LEXA — Custom styles on top of Tailwind */

:root {
  --bg: #0a0e15;
  --bg-card: #0f1622;
  --bg-card-hover: #131c2e;
  --border: rgba(212, 175, 55, 0.15);
  --border-hover: rgba(212, 175, 55, 0.4);
  --gold: #d4af37;
  --gold-soft: #e9c860;
  --gold-dark: #a8862a;
  --text: #e6e6e6;
  --text-dim: #9ba3af;
  --success: #10b981;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Anti-overflow root guard: nothing should ever cause horizontal page scroll. */
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Flex children default `min-width: auto` is the #1 cause of mobile overflow:
   a long word/title inside a flex item refuses to shrink, busting the viewport.
   Allow flex children to shrink below their intrinsic content size. */
nav, header, main, section, article, aside, footer, .filters-pane,
.lic-shell, .dir-shell, .editor-shell, .form-pane, .preview-pane,
.lic-card, .dir-card, .modal-body, .lic-shell > div, .dir-shell > div {
  min-width: 0;
}

/* Long words/URLs/numbers must wrap rather than push the viewport. */
.lic-title, .dir-nombre, .modal-title, .page-hero h1, .page-hero p,
.lic-meta-value, .lic-dep, .dir-contact, .modal-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Subtle radial accent on landing */
body.landing {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 175, 55, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(212, 175, 55, 0.04), transparent),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

.brand {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #f5e29c 0%, var(--gold) 70%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft) 0%, var(--gold) 100%);
  color: #1a1300;
  border-color: var(--gold-dark);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 4px 12px rgba(212, 175, 55, 0.2);
}
.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 6px 18px rgba(212, 175, 55, 0.3);
  color: #1a1300;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: rgba(212, 175, 55, 0.04);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

/* Landing badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  color: var(--gold-soft);
  font-size: 0.78rem;
  font-weight: 500;
}
.badge-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

/* Template cards */
.tpl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
}
.tpl-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212,175,55,0.06) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.tpl-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.tpl-card:hover::before { opacity: 1; }
.tpl-card > * { position: relative; }
.tpl-card .icon {
  font-size: 2rem;
  line-height: 1;
}
.tpl-card .nombre {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.tpl-card .desc {
  font-size: 0.875rem;
  color: var(--text-dim);
  line-height: 1.5;
  flex-grow: 1;
}
.tpl-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.tpl-card .meta .tiempo {
  color: var(--gold);
  font-weight: 500;
}

/* Header / footer */
header.site-header, footer.site-footer {
  border-color: var(--border);
}

/* Editor layout */
.editor-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.form-pane {
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem 1.75rem 6rem;
}

.preview-pane {
  background: #f5f5f0;
  overflow-y: auto;
  padding: 2rem 1.5rem 6rem;
}

@media (max-width: 1024px) {
  .editor-shell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .form-pane { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 2rem; }
  .preview-pane { padding: 1.5rem 1rem 6rem; max-height: 80vh; }
}

/* Form */
.form-section {
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: var(--bg-card);
  margin-bottom: 1rem;
  overflow: hidden;
}
.form-section summary {
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.form-section summary::-webkit-details-marker { display: none; }
.form-section summary::after {
  content: '▾';
  font-size: 0.75rem;
  color: var(--gold);
  transition: transform 0.2s ease;
}
.form-section[open] summary::after { transform: rotate(180deg); }
.form-section summary:hover { background: rgba(212, 175, 55, 0.04); }
.form-section .fields {
  padding: 0.5rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.field-input, .field-select, .field-textarea {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--gold);
  background: rgba(0,0,0,0.35);
}
.field-input.invalid { border-color: var(--danger); }
.field-textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23d4af37' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
.field-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}
.field-error {
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 0.25rem;
  display: none;
}
.field-input.invalid ~ .field-error { display: block; }

/* Floating action buttons */
.fab-bar {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 50;
}
.fab-bar .btn {
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
  padding: 0.7rem 1.2rem;
}

/* Document preview — legal style */
.doc-preview {
  background: #ffffff;
  color: #111;
  padding: 3.5rem 3rem;
  border-radius: 0.5rem;
  max-width: 720px;
  margin: 0 auto;
  font-family: 'Times New Roman', Georgia, serif;
  font-size: 12pt;
  line-height: 1.6;
  text-align: justify;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  min-height: 80vh;
}

.doc-preview h1 {
  font-size: 16pt;
  text-align: center;
  font-weight: bold;
  margin: 0 0 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.doc-preview h2 {
  font-size: 13pt;
  text-align: center;
  font-weight: bold;
  margin: 1.5rem 0 1rem;
  text-transform: uppercase;
}
.doc-preview p {
  margin: 0 0 0.9rem;
  text-indent: 0;
}
.doc-preview p.lugar {
  text-align: right;
  font-style: italic;
  margin-bottom: 1.5rem;
}
.doc-preview p.monto-grande {
  text-align: center;
  font-size: 15pt;
  margin: 1.5rem 0;
  letter-spacing: 0.02em;
}
.doc-preview strong { font-weight: bold; }
.doc-preview .firmas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 4rem;
  page-break-inside: avoid;
}
.doc-preview .firma {
  text-align: center;
  font-size: 11pt;
}
.doc-preview .firma .linea {
  border-top: 1px solid #111;
  margin-bottom: 0.5rem;
  height: 1px;
}
.doc-preview .firma p {
  margin: 0.2rem 0;
  text-align: center;
}

/* Counter on landing */
.counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.counter-pill strong { color: var(--gold); font-weight: 600; }

/* Toast */
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--success);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  z-index: 100;
  animation: slideIn 0.25s ease, fadeOut 0.4s ease 2.6s forwards;
  font-size: 0.9rem;
}
.toast.error { border-color: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* Scrollbar (only visible on hover for cleanliness) */
.form-pane::-webkit-scrollbar, .preview-pane::-webkit-scrollbar { width: 8px; }
.form-pane::-webkit-scrollbar-track, .preview-pane::-webkit-scrollbar-track { background: transparent; }
.form-pane::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.15); border-radius: 4px; }
.form-pane::-webkit-scrollbar-thumb:hover { background: rgba(212, 175, 55, 0.3); }
.preview-pane::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

/* ==========================================================================
   LICITACIONES & DIRECTORIO MODULES
   ========================================================================== */

/* Navbar tabs (in header) */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.nav-tab {
  padding: 0.4rem 0.85rem;
  border-radius: 0.45rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-tab:hover {
  color: var(--text);
  background: rgba(212, 175, 55, 0.06);
}
.nav-tab.active {
  color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
}
@media (max-width: 640px) {
  .nav-tab { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
}

/* Page hero (smaller than landing hero) */
.page-hero {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.page-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
.page-hero p { color: var(--text-dim); font-size: 0.95rem; }

/* Tabs (Todas / Carga / Especializado) — wrapped so we can add a fade hint */
.lic-tabs-wrap {
  position: relative;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 1.25rem;
}
/* Fade-out gradient on right edge in mobile, hints scrollable content */
@media (max-width: 900px) {
  .lic-tabs-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 36px;
    background: linear-gradient(to right, transparent, var(--bg) 80%);
    pointer-events: none;
    z-index: 1;
  }
}

/* Dual label: full text on desktop, short text on tiny mobile screens */
.tab-short { display: none; }
@media (max-width: 560px) {
  .tab-full  { display: none; }
  .tab-short { display: inline; }
}

.lic-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
  min-width: 0;
}
.lic-tabs::-webkit-scrollbar { display: none; }
.lic-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}
.lic-tab:hover { color: var(--text); }
.lic-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.lic-tab .count {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  background: rgba(212, 175, 55, 0.12);
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--gold-soft);
}

/* ==========================================================================
   Two-column layout: filters sidebar + grid
   - Desktop (>900px): sidebar sticky on the left
   - Mobile (≤900px): sidebar becomes a drawer (closed by default)
   ========================================================================== */
.lic-shell, .dir-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Filters sidebar — DESKTOP DEFAULT */
.filters-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
}
.filters-pane h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-soft);
  margin: 0 0 0.85rem;
  font-weight: 600;
}
.filters-pane .filter-group { margin-bottom: 1rem; }
.filters-pane .filter-group:last-of-type { margin-bottom: 1.25rem; }
.filters-pane label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

/* Drawer chrome (close X + apply button): hidden on desktop, shown on mobile.
   .drawer-close is ALWAYS sized 48x48 with absolute positioning so it can't
   collapse inside a flex container. Display toggled by media query below. */
.drawer-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: #d4af37 !important;
  color: #0a0e15 !important;
  border: none;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.2);
  padding: 0;
  margin: 0;
}
.drawer-close:hover,
.drawer-close:active,
.drawer-close:focus {
  background: #e9c860 !important;
  outline: none;
  transform: scale(0.95);
}
.drawer-apply {
  display: none;
}

/* Mobile filter toggle button: hidden on desktop, shown on mobile */
.mobile-filter-btn {
  display: none;
  margin-bottom: 1rem;
}

/* Drawer backdrop: hidden on desktop, fades in on mobile open */
.drawer-backdrop {
  display: none;
}

/* ---------- MOBILE (≤900px) ---------- */
@media (max-width: 900px) {
  .lic-shell, .dir-shell { grid-template-columns: 1fr; }

  /* Sidebar becomes a slide-in drawer. ALWAYS closed by default. */
  .filters-pane {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    z-index: 90;
    background: var(--bg-card);
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem 1.25rem 5.5rem;  /* bottom padding for fixed apply button */
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    will-change: transform;
  }
  .filters-pane.open {
    transform: translateX(0);
  }

  /* Big touch-friendly close X — base styles already set above (48x48 absolute).
     Here we just flip display:none → flex and bump padding-top of the drawer
     so first content does not sit under the close button. */
  .drawer-close {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  .filters-pane { padding-top: 4rem !important; }

  /* Apply & close button — fixed bottom of drawer */
  .drawer-apply {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    width: min(320px, 88vw);
    padding: 0.9rem 1.25rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 91;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
  }
  .filters-pane.open ~ .drawer-apply,
  body.drawer-open .drawer-apply {
    transform: translateX(0);
  }
  .drawer-apply .btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 0.95rem;
    justify-content: center;
  }

  /* Backdrop overlay */
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 85;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Lock body scroll when drawer open */
  body.drawer-open {
    overflow: hidden;
  }

  /* Mobile filter toggle: visible */
  .mobile-filter-btn {
    display: inline-flex;
  }
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}
.search-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}
.search-bar input:focus { border-color: var(--gold); }
.search-bar input::placeholder { color: var(--text-dim); }

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Licitacion card */
.lic-grid, .dir-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
@media (min-width: 1200px) {
  .lic-grid { grid-template-columns: 1fr 1fr; }
  .dir-grid { grid-template-columns: 1fr 1fr; }
}

.lic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.lic-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.lic-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.lic-num {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  color: var(--text-dim);
  font-size: 0.72rem;
}
.lic-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid;
  text-decoration: none;
}
.lic-badge.carga { background: rgba(96, 165, 250, 0.1); border-color: rgba(96, 165, 250, 0.3); color: #93c5fd; }
.lic-badge.esp { background: rgba(168, 85, 247, 0.1); border-color: rgba(168, 85, 247, 0.3); color: #c4b5fd; }
.lic-badge.watch { background: rgba(212, 175, 55, 0.12); border-color: rgba(212, 175, 55, 0.4); color: var(--gold); }
.lic-badge.urgent { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }
.lic-badge.neutral { background: rgba(155, 163, 175, 0.08); border-color: rgba(155, 163, 175, 0.25); color: var(--text-dim); }

.lic-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
}
.lic-dep { font-size: 0.82rem; color: var(--text-dim); }
.lic-dep-link {
  color: var(--gold-soft);
  text-decoration: none;
  font-weight: 500;
}
.lic-dep-link:hover { text-decoration: underline; color: var(--gold); }
.lic-sep { margin: 0 0.4rem; color: var(--text-dim); }

.lic-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
@media (max-width: 500px) {
  .lic-meta { grid-template-columns: 1fr 1fr; }
}
.lic-meta-item { display: flex; flex-direction: column; gap: 0.15rem; }
.lic-meta-label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.lic-meta-value { color: var(--text); font-weight: 500; }
.lic-meta-value.gold { color: var(--gold); font-weight: 600; }
.lic-meta-value.urgent { color: #fca5a5; }
.lic-meta-value small { color: var(--text-dim); font-weight: 400; }

.lic-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.lic-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 0.875rem;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
}
.lic-modal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); border-color: var(--border-hover); }
.modal-body {
  padding: 1.5rem 1.75rem 1.75rem;
  overflow-y: auto;
  flex: 1;
}
.modal-section { margin-bottom: 1.5rem; }
.modal-section:last-of-type { margin-bottom: 0; }
.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}
.modal-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.modal-value { color: var(--text); font-weight: 500; font-size: 0.9rem; }
.modal-value.gold { color: var(--gold); font-weight: 600; }
.modal-value.urgent { color: #fca5a5; }
.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 640px) {
  .modal-grid { grid-template-columns: 1fr 1fr; }
}
.modal-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.modal-list li {
  font-size: 0.85rem;
  padding-left: 1.2rem;
  position: relative;
  color: var(--text);
}
.modal-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-weight: bold;
}
.modal-contact {
  background: rgba(212, 175, 55, 0.04);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
}
.contact-grid { display: flex; flex-direction: column; gap: 0.25rem; }
.text-gold-soft { color: var(--gold-soft); }
.text-gold-soft:hover { color: var(--gold); }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* Directorio cards */
.dir-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: all 0.18s ease;
}
.dir-card:hover { border-color: var(--border-hover); }
.dir-card.highlight {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}
.dir-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.dir-alias {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.dir-nombre {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.15rem;
  line-height: 1.3;
}
.dir-badges {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}
.dir-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  font-size: 0.82rem;
}
.dir-section { font-size: 0.82rem; }
.dir-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.dir-tag {
  display: inline-flex;
  padding: 0.18rem 0.55rem;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--gold-soft);
}
.dir-contact {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}
.dir-notes {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 0.6rem 0.85rem;
  background: rgba(212, 175, 55, 0.04);
  border-left: 2px solid var(--gold-dark);
  border-radius: 0.3rem;
}
.dir-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   PWA Install button
   ========================================================================== */
#btn-install {
  white-space: nowrap;
}
#btn-install[hidden] {
  display: none !important;
}

/* When installed (standalone), hide install button forever */
@media (display-mode: standalone) {
  #btn-install { display: none !important; }
}

/* Hide install button on very small screens — saves nav real estate */
@media (max-width: 560px) {
  #btn-install { display: none !important; }
}

/* ==========================================================================
   Mobile header polish + anti-overflow nav
   ========================================================================== */

/* Nav tabs: always allow horizontal scroll inside the container so tabs never
   widen the page itself. Scrollbar hidden visually but kept functional. */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;        /* Firefox */
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;               /* take leftover space, but allow shrink */
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs > * {
  flex-shrink: 0;               /* tabs themselves don't shrink */
  white-space: nowrap;
}

/* Brand wordmark should never be cut. Lock its layout. */
.site-header a.flex {
  flex-shrink: 0;
}
.brand {
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .site-header > div {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    column-gap: 0.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }
}
@media (max-width: 560px) {
  .site-header { padding-top: 0.25rem; padding-bottom: 0.25rem; }
  .nav-tab { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
  .brand { font-size: 1rem !important; }
  .site-header img { width: 26px; height: 26px; }
}

/* Same scroll-instead-of-overflow treatment for licitaciones inner tabs */
.lic-tabs {
  max-width: 100%;
  min-width: 0;
}

/* Hero text must wrap, never overflow */
.page-hero h1 {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}
@media (max-width: 560px) {
  .page-hero h1 { font-size: 1.35rem; line-height: 1.25; }
  .page-hero p  { font-size: 0.88rem; }
  .page-hero    { padding: 1.25rem 0 1rem; }
}

/* Cards never exceed viewport */
.lic-card, .dir-card, .tpl-card {
  max-width: 100%;
  width: 100%;
}

/* Counter pill: don't break the navbar in mobile (squash if needed) */
@media (max-width: 560px) {
  .counter-pill { display: none; }
}

/* Subtle pulse to draw attention to the install CTA */
#btn-install:not([hidden]) {
  animation: install-pulse 2.2s ease-in-out 1s 2 forwards;
}
@keyframes install-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.18); }
}
