/* HomeCrew — estilos de Gestión (escritorio primero) y pantallas de acceso.
   Contraste: el turquesa #16B8A6 NO llega a AA sobre blanco: como texto se usa --hc-teal-dark;
   los botones principales van en turquesa con texto navy (5,7:1). Estados: color + ícono + etiqueta. */

@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url(/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url(/fonts/inter-latin-700-normal.woff2) format('woff2'); }

:root {
  --hc-navy: #142B49;
  --hc-navy-700: #1E3A5F;
  --hc-teal: #16B8A6;
  --hc-teal-dark: #0B7A6E;
  --hc-bg: #F3F6FA;
  --hc-surface: #FFFFFF;
  --hc-text: #142B49;
  --hc-text-muted: #4A5B72;
  --hc-border: #D3DBE6;
  --hc-blue: #3B82F6;          /* solo estados de UI: info / selección */
  --hc-danger: #B42318;
  --hc-warn: #B54708;
  --hc-ok: #067647;
  /* estados de propiedades/tareas en el mapa */
  --st-idle: #5B6B82;
  --st-active: #0B7A6E;
  --st-late: #B42318;
  --st-done: #067647;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 43, 73, .08), 0 2px 8px rgba(20, 43, 73, .06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--hc-text); background: var(--hc-bg); -webkit-font-smoothing: antialiased; }
a { color: var(--hc-teal-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--hc-text-muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--hc-blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── botones y formularios ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .5rem 1rem;
  border-radius: 8px; border: 1px solid var(--hc-border); background: var(--hc-surface); color: var(--hc-navy);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--hc-navy); }
.btn.primary { background: var(--hc-teal); border-color: var(--hc-teal); color: var(--hc-navy); }
.btn.primary:hover { background: #12a594; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.danger { color: var(--hc-danger); border-color: #f1b5ae; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; min-height: 48px; }
label.field { display: block; margin-bottom: .85rem; }
label.field > span { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
input, select, textarea { font: inherit; color: var(--hc-text); width: 100%; min-height: 40px; padding: .5rem .65rem;
  border: 1px solid #A9B6C8; border-radius: 8px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--hc-teal-dark); vertical-align: middle; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--hc-danger); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .85rem; font-weight: 500; }
.err { color: var(--hc-danger); font-weight: 600; min-height: 1.2em; margin: .25rem 0 .75rem; }

/* ── pantallas de acceso ── */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--hc-navy); }
.auth-card { width: 100%; max-width: 420px; background: var(--hc-surface); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.brand img { width: 52px; height: 52px; background: var(--hc-navy); border-radius: 12px; padding: 6px; }
.brand b { display: block; font-size: 1.35rem; }
.brand small { color: var(--hc-text-muted); }
.tagline { color: var(--hc-text-muted); margin: -.5rem 0 1.25rem; }
.lang { display: flex; gap: .25rem; justify-content: flex-end; margin-bottom: .5rem; }
.lang button { min-height: 32px; padding: .2rem .6rem; font-size: .8rem; }
.lang button[aria-pressed=true] { background: var(--hc-navy); color: #fff; border-color: var(--hc-navy); }
.demo-roles { display: grid; gap: .5rem; margin-top: 1rem; }
.demo-roles button { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; }
.demo-roles small { font-weight: 400; color: var(--hc-text-muted); }
.qr { display: grid; place-items: center; margin: .75rem 0; }
.qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.codes { font-family: ui-monospace, monospace; background: var(--hc-bg); padding: .75rem; border-radius: 8px; columns: 2; }
.divider { text-align: center; color: var(--hc-text-muted); margin: 1.25rem 0 .5rem; font-size: .85rem; }

/* ── shell de Gestión ── */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.side { background: var(--hc-navy); color: #fff; display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; }
.side .brand { margin: 0 4px 18px; }
.side .brand img { width: 40px; height: 40px; background: transparent; padding: 0; }
.side .brand b { font-size: 1.1rem; color: #fff; }
.side .brand small { color: #C3CEDC; font-size: .72rem; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .6rem .7rem; border-radius: 8px; color: #E4EAF2; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--hc-navy-700); }
.nav a[aria-current=page] { background: var(--hc-navy-700); color: #fff; box-shadow: inset 3px 0 0 var(--hc-teal); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .soon { margin-left: auto; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; color: #9FB0C6; }
.side .grow { flex: 1; }
.side .who { border-top: 1px solid #2B4566; padding-top: 12px; font-size: .85rem; color: #C3CEDC; }
.side .who b { color: #fff; display: block; }
.side .who .btn { margin-top: .5rem; background: transparent; color: #fff; border-color: #3A5576; min-height: 34px; font-size: .85rem; }
.side .lang { justify-content: flex-start; margin: .5rem 0 0; }
.side .lang button { background: transparent; color: #C3CEDC; border-color: #3A5576; }
.side .lang button[aria-pressed=true] { background: var(--hc-teal); color: var(--hc-navy); border-color: var(--hc-teal); }
.main { overflow-y: auto; position: relative; display: flex; flex-direction: column; min-height: 0; }
#main { flex: 1; min-height: 0; outline: none; }
.page { padding: 24px 28px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1; }
.demo-banner { background: #FEF3C7; color: #7A2E0E; padding: .45rem 1rem; font-size: .85rem; font-weight: 600; text-align: center; }

.card { background: var(--hc-surface); border: 1px solid var(--hc-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.toolbar input[type=checkbox] { min-width: 0; }
.toolbar .check { margin: 0; }
table.list { width: 100%; border-collapse: collapse; background: var(--hc-surface); border: 1px solid var(--hc-border); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid #E6EBF2; vertical-align: top; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--hc-text-muted); background: #F8FAFC; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #F3F7FC; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 2rem; text-align: center; color: var(--hc-text-muted); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--hc-border); margin-bottom: 1rem; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .9rem; font: inherit; font-weight: 600; color: var(--hc-text-muted); cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--hc-navy); border-bottom-color: var(--hc-teal); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--hc-text-muted); font-size: .85rem; }
.kv dd { margin: 0; }

/* chips de estado: color + ícono + texto, nunca solo color */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; background: #fff; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.idle { color: var(--st-idle); } .chip.active { color: var(--st-active); } .chip.late { color: var(--st-late); } .chip.done { color: var(--st-done); }
.chip.info { color: #1D4ED8; } .chip.warn { color: var(--hc-warn); } .chip.neutral { color: var(--hc-text-muted); }

/* ── mapa ── */
.map-page { display: grid; grid-template-rows: auto 1fr; height: 100%; min-height: 480px; }
.map-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; padding: 12px 16px; background: var(--hc-surface); border-bottom: 1px solid var(--hc-border); }
.map-bar h1 { font-size: 1.15rem; margin: 0 .75rem 0 0; }
.map-bar select, .map-bar input { width: auto; min-width: 160px; min-height: 36px; }
.map-wrap { position: relative; min-height: 400px; }
#map { position: absolute; inset: 0; }
.legend { position: absolute; left: 12px; bottom: 24px; z-index: 500; background: #fff; border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); display: grid; gap: 4px; font-size: .8rem; }
.legend .note { color: var(--hc-text-muted); max-width: 220px; }
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; z-index: 600; background: #fff; border-left: 1px solid var(--hc-border); box-shadow: -4px 0 16px rgba(20,43,73,.12); overflow-y: auto; padding: 18px; }
.panel .close { position: absolute; top: 10px; right: 10px; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin svg { transform: rotate(45deg); width: 15px; height: 15px; color: #fff; }
.pin.idle { background: var(--st-idle); } .pin.active { background: var(--st-active); } .pin.late { background: var(--st-late); } .pin.done { background: var(--st-done); }
.pin.sel { outline: 3px solid var(--hc-blue); }
.pick-map { height: 320px; border-radius: 8px; border: 1px solid var(--hc-border); }

/* fotos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: #E6EBF2; display: block; }
.photos figcaption { font-size: .75rem; color: var(--hc-text-muted); }
.photos .del { position: absolute; top: 4px; right: 4px; min-height: 28px; padding: 0 .4rem; font-size: .75rem; }

/* modal y avisos */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 43, 73, .45); }
dialog .dlg-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--hc-border); }
dialog .dlg-head h2 { margin: 0; flex: 1; }
dialog .dlg-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--hc-border); background: #F8FAFC; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; background: var(--hc-navy); color: #fff; padding: .7rem 1.1rem; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500; max-width: calc(100vw - 32px); }
.toast.error { background: var(--hc-danger); }
.checklist-edit .item { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; margin-bottom: .5rem; }
.import-errors { max-height: 240px; overflow-y: auto; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; gap: 8px; }
  .side .brand { margin: 0; }
  .nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav a { white-space: nowrap; }
  .side .grow, .side .who { display: none; }
  .page { padding: 16px; }
  .panel { width: 100%; }
}
