/* Huella Municipal — sistema de diseño base. Componentes documentados en DESIGN.md */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #1b2421;
  --ink-2: #4f5b56;
  --line: #ddd8cc;
  --brand: #0e5c55;          /* verde petróleo: confianza institucional */
  --brand-ink: #ffffff;
  --brand-soft: #dcebe7;
  --accent: #e39a2d;         /* ámbar: calidez, mascotas */
  --accent-soft: #fbecd3;
  --ok: #2f7d4f;   --ok-soft: #e1f1e6;
  --warn: #a8660b; --warn-soft: #fbefd9;
  --crit: #b4372f; --crit-soft: #f8e2df;
  --info: #2c5f9e; --info-soft: #e2ecf8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27,36,33,.06), 0 4px 16px rgba(27,36,33,.06);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); }
a:hover { color: #08423d; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar__in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .92rem; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.nav__user { font-size: .85rem; color: var(--ink-2); padding: 0 8px; border-left: 1px solid var(--line); margin-left: 8px; }
.navtoggle { display: none; margin-left: auto; min-height: 40px; padding: 6px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; }
@media (max-width: 820px) {
  .navtoggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .nav.is-open { display: flex; }
  .nav__user { border: 0; margin: 8px 0 0; padding: 8px 12px; }
}

/* Contenedor */
.main { max-width: 1180px; margin: 0 auto; padding: 28px 16px 64px; }
.main--wide { max-width: none; padding: 0; }
.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot__in { max-width: 1180px; margin: 0 auto; padding: 18px 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); }
.is-bare .foot { display: none; }

/* Encabezado de página */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.pagehead p { color: var(--ink-2); margin: 0; }

/* Tarjetas y rejillas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card__title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }

/* Indicadores */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat__label { font-size: .82rem; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat__value { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.stat--alert { border-color: var(--crit); background: var(--crit-soft); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { background: #0a4a44; color: #fff; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #2a1a00; }
.btn--accent:hover { background: #cf8a20; color: #2a1a00; }
.btn--danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Formularios */
.form { display: grid; gap: 16px; }
.form--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 700; font-size: .9rem; }
.field .hint { font-size: .82rem; color: var(--ink-2); }
.field .error { font-size: .85rem; color: var(--crit); font-weight: 600; }
.input, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #c9c3b5; border-radius: var(--radius-sm);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.pin { letter-spacing: .5em; font-size: 1.3rem; text-align: center; max-width: 220px; }

/* Tablas */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #faf9f5; }

/* Etiquetas */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--crit { background: var(--crit-soft); color: var(--crit); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--mute { background: var(--surface-2); color: var(--ink-2); }

/* Alertas */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 600; border: 1px solid; }
.alert--ok { background: var(--ok-soft); color: var(--ok); border-color: #b9dcc5; }
.alert--warn { background: var(--warn-soft); color: var(--warn); border-color: #edd3a5; }
.alert--err { background: var(--crit-soft); color: var(--crit); border-color: #eebcb6; }
.alert--info { background: var(--info-soft); color: var(--info); border-color: #bcd2ee; }

/* Tarjeta de animal (vitrina, listas) */
.pet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.pet__img { aspect-ratio: 4/3; object-fit: cover; width: 100%; background: var(--surface-2); }
.pet__body { padding: 14px 16px 16px; display: grid; gap: 6px; flex: 1; }
.pet__name { font-weight: 800; font-size: 1.1rem; }
.pet__meta { font-size: .88rem; color: var(--ink-2); }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery img { aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }

/* Lista de definición (fichas) */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.dl dt { color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.dl dd { margin: 0; }

/* Línea de tiempo (historial) */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }

/* Vacío */
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }

/* Impresión (carnet, actas) */
@media print {
  .topbar, .foot, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card { box-shadow: none; }
}
