:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5b6676;
  --border: #dde1e7;
  --primary: #1f5fbf;
  --primary-hover: #184c99;
  --primary-soft: #e8f0fc;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
small, .muted { color: var(--muted); }

/* Navegación */
.topbar { background: #14213d; color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; margin-right: .5rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a, .nav summary { color: #d7deea; padding: .35rem .6rem; border-radius: 6px; cursor: pointer; list-style: none; }
.nav a:hover, .nav summary:hover, .nav a.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav details { position: relative; }
.nav details[open] .menu { display: block; }
.nav summary::-webkit-details-marker { display: none; }
.menu { display: none; position: absolute; top: 2.1rem; left: 0; z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 220px; padding: .3rem; }
.menu a, .menu button { display: block; width: 100%; text-align: left; color: var(--text); padding: .45rem .6rem; border-radius: 6px; background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--primary-soft); text-decoration: none; }
.userbox { display: flex; align-items: center; gap: .5rem; }
.bell { color: #fff; position: relative; padding: .3rem .5rem; }
.badge-count { background: #e0453a; color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .35rem; position: absolute; top: -2px; right: -4px; }
.mockbar { background: var(--warn-soft); color: var(--warn); text-align: center; padding: .3rem; font-size: .85rem; border-bottom: 1px solid #f3d9a8; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Tarjetas y layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f1b8b2; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .25rem .55rem; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font: inherit; }

/* Formularios */
form p { margin: 0 0 .8rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .92rem; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox] { width: auto; margin-right: .35rem; }
.checkbox-line { display: flex; align-items: center; font-weight: 500; }
.helptext, .help { color: var(--muted); font-size: .83rem; display: block; margin-top: .2rem; }
.errorlist { color: var(--danger); margin: .2rem 0; padding-left: 1rem; font-size: .88rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 650; padding: 0 .3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* Autocompletado */
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 1100; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.1); margin-top: 2px; max-height: 280px; overflow: auto; }
.ac-list:empty { display: none; }
.ac-item { display: block; width: 100%; text-align: left; padding: .5rem .6rem; border: 0; background: none; cursor: pointer; font: inherit; }
.ac-item:hover, .ac-item:focus { background: var(--primary-soft); }
.ac-selected { margin-top: .3rem; font-size: .88rem; color: var(--ok); }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f3f5f8; font-weight: 650; white-space: nowrap; position: sticky; top: 0; }
th a { color: var(--text); }
tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Etiquetas */
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; background: #eef1f5; color: var(--muted); margin: 0 .2rem .2rem 0; white-space: nowrap; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info { background: var(--primary-soft); color: var(--primary); }

/* Mensajes */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: .5rem; border: 1px solid var(--border); background: var(--surface); }
.msg-success { background: var(--ok-soft); border-color: #b5dfc5; color: #13532f; }
.msg-error { background: var(--danger-soft); border-color: #f3c0ba; color: #8a1c12; }
.msg-warning { background: var(--warn-soft); border-color: #f3d9a8; color: #6e4100; }
.msg-info { background: var(--primary-soft); border-color: #c4d7f5; color: #163f80; }

/* Progreso */
.progress { height: 10px; background: #e7eaef; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width .4s; }
progress { width: 100%; height: 10px; accent-color: var(--primary); }

/* Filtros */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem .8rem; align-items: end; }
.filters label { font-size: .82rem; }
.columns-picker { columns: 3 180px; font-size: .88rem; }
.columns-picker label { font-weight: 400; }

/* Mapa */
#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--border); }

/* Login */
.center-box { max-width: 420px; margin: 8vh auto; }
.google-btn { width: 100%; justify-content: center; padding: .7rem; font-weight: 600; }

/* Paginación */
.pagination { display: flex; gap: .4rem; align-items: center; margin-top: .8rem; flex-wrap: wrap; }

.review { border-bottom: 1px solid var(--border); padding: .6rem 0; }
.review:last-child { border-bottom: 0; }
.owner-reply { background: #f6f8fb; border-left: 3px solid var(--primary); padding: .4rem .6rem; margin-top: .4rem; font-size: .9rem; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
