:root {
  --teal:    #0d7377;
  --teal-d:  #084a4d;
  --teal-l:  #14a085;
  --sand:    #f5f0e8;
  --sand-d:  #e8e0d0;
  --ink:     #1a1a2e;
  --muted:   #5a6a75;
  --accent:  #e67e22;
  --accent-l:#fdebd0;
  --white:   #ffffff;
  --radius:  8px;
  --shadow:  0 2px 12px rgba(0,0,0,.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--sand); color: var(--ink); min-height: 100vh; }

/* NAV */
nav { background: var(--teal-d); color: #fff; padding: 0 2rem; display: flex; align-items: center; gap: 2rem; height: 58px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
nav .brand { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
nav .brand span { color: #7ecbcc; }
nav a { color: rgba(255,255,255,.85); text-decoration: none; font-size: .88rem; padding: .3rem .7rem; border-radius: var(--radius); transition: background .2s; }
nav a:hover, nav a.active { background: rgba(255,255,255,.15); color: #fff; }
nav .spacer { flex: 1; }
nav .badge { background: var(--accent); color: #fff; font-size: .75rem; padding: .15rem .5rem; border-radius: 20px; font-weight: 700; }

/* HERO */
.hero { background: linear-gradient(135deg, var(--teal-d) 0%, var(--teal) 60%, var(--teal-l) 100%); color: white; padding: 3rem 2rem 2.5rem; text-align: center; }
.hero h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: .02em; }
.hero p  { margin-top: .5rem; opacity: .85; font-size: 1rem; }
.hero-sub { font-size: .85rem; opacity: .65; margin-top: .3rem; }

/* PAGE */
.page { max-width: 1300px; margin: 0 auto; padding: 2rem 1.5rem; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1.3rem 1.2rem; box-shadow: var(--shadow); border-left: 4px solid var(--teal); }
.stat-card .num { font-size: 2.2rem; font-weight: 800; color: var(--teal); line-height: 1; }
.stat-card .lbl { font-size: .8rem; color: var(--muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .05em; }

/* CARDS */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { background: var(--teal); color: white; padding: .7rem 1.1rem; font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1rem 1.1rem; }

/* BAR CHART */
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.bar-row .lbl { font-size: .78rem; color: var(--ink); width: 160px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: var(--sand-d); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.bar-num { font-size: .75rem; color: var(--muted); width: 35px; text-align: right; }

/* TABLE */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--white); font-size: .86rem; }
th { background: var(--teal-d); color: white; padding: .7rem .9rem; text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td { padding: .6rem .9rem; border-bottom: 1px solid var(--sand-d); vertical-align: top; }
tr:hover td { background: #eef7f7; }
tr:last-child td { border-bottom: none; }
td a { color: var(--teal); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* BADGES */
.tag { display: inline-block; padding: .15rem .5rem; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.tag-tipo  { background: #d4edda; color: #155724; }
.tag-depto { background: var(--accent-l); color: #7d4306; }
.tag-caja  { background: #d1ecf1; color: #0c5460; }

/* SEARCH */
.search-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; position: relative; }
.form-group label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.form-group input { padding: .5rem .75rem; border: 1.5px solid #cdd9de; border-radius: var(--radius); font-size: .9rem; transition: border-color .2s; background: var(--sand); }
.form-group input:focus { border-color: var(--teal); outline: none; background: white; }
.btn-row { display: flex; gap: .7rem; margin-top: .5rem; flex-wrap: wrap; }
.btn { padding: .55rem 1.3rem; border: none; border-radius: var(--radius); font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .2s; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary   { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-d); }
.btn-secondary { background: var(--sand-d); color: var(--ink); }
.btn-secondary:hover { background: #d0ccc0; }
.btn-pdf       { background: var(--accent); color: white; }
.btn-pdf:hover { background: #c0651a; }

/* AUTOCOMPLETE */
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1.5px solid var(--teal); border-radius: 0 0 var(--radius) var(--radius); z-index: 200; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.autocomplete-list div { padding: .45rem .75rem; font-size: .85rem; cursor: pointer; border-bottom: 1px solid var(--sand-d); }
.autocomplete-list div:hover { background: #eef7f7; }

/* PAGINATION */
.pagination { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination button { padding: .35rem .75rem; border: 1.5px solid var(--teal); border-radius: var(--radius); background: white; color: var(--teal); cursor: pointer; font-size: .85rem; transition: all .2s; }
.pagination button:hover, .pagination button.active { background: var(--teal); color: white; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .info { color: var(--muted); font-size: .82rem; }

/* DETAIL */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.detail-field { background: var(--sand); border-radius: var(--radius); padding: .8rem 1rem; }
.detail-field .key { font-size: .73rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.detail-field .val { font-size: .92rem; color: var(--ink); line-height: 1.5; }
.detail-field.full { grid-column: 1 / -1; }

/* MISC */
.back { display: inline-flex; align-items: center; gap: .4rem; color: var(--teal); text-decoration: none; font-size: .9rem; margin-bottom: 1rem; }
.back:hover { text-decoration: underline; }
.results-meta { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.results-meta .count { font-weight: 700; color: var(--teal); }
.results-meta .time  { color: var(--muted); font-size: .82rem; }
.loader { text-align: center; padding: 2rem; color: var(--muted); }
.spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--sand-d); border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 3rem; color: var(--muted); }
.empty .icon { font-size: 3rem; }
footer { margin-top: 3rem; padding: 1.2rem 2rem; text-align: center; background: var(--teal-d); color: rgba(255,255,255,.6); font-size: .8rem; }

@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
  nav { gap: .8rem; padding: 0 1rem; }
  .hero h1 { font-size: 1.3rem; }
}
