/* Sistema visual al estilo shadcn/ui (tokens HSL, radios, bordes finos, focus ring), con la paleta de
   Patagonia Big Family: turquesa de lago glaciar (primario), atardecer sobre el muelle de Natales (acento),
   granito (neutros) y la alfombra de colores del living (franja decorativa). */
:root {
  --background: 0 0% 100%;
  --foreground: 200 25% 10%;
  --card: 0 0% 100%;
  --muted: 200 15% 96%;
  --muted-foreground: 200 8% 42%;
  --border: 200 14% 89%;
  --input: 200 14% 84%;
  --ring: 190 80% 32%;
  --primary: 190 82% 27%;
  --primary-foreground: 185 60% 98%;
  --secondary: 195 20% 94%;
  --secondary-foreground: 200 25% 15%;
  --accent: 22 92% 52%;
  --accent-foreground: 0 0% 100%;
  --accent-soft: 30 100% 95%;
  --destructive: 0 72% 48%;
  --destructive-soft: 0 85% 96%;
  --success: 152 60% 32%;
  --success-soft: 145 60% 94%;
  --warning: 32 95% 38%;
  --warning-soft: 45 100% 93%;
  --info-soft: 190 70% 94%;
  --radius: 0.75rem;
  --shadow-sm: 0 1px 2px hsl(200 30% 10% / .05);
  --shadow: 0 1px 3px hsl(200 30% 10% / .08), 0 1px 2px hsl(200 30% 10% / .04);
  --rug: linear-gradient(90deg, #d7263d 0 16%, #f46036 16% 32%, #f9c22e 32% 48%, #2e86ab 48% 64%, #1b998b 64% 80%, #7b2cbf 80% 100%);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --background: 200 30% 6%;
  --foreground: 190 15% 94%;
  --card: 200 28% 9%;
  --muted: 200 22% 14%;
  --muted-foreground: 195 10% 64%;
  --border: 200 18% 18%;
  --input: 200 18% 24%;
  --ring: 186 70% 50%;
  --primary: 186 72% 45%;
  --primary-foreground: 200 40% 6%;
  --secondary: 200 20% 15%;
  --secondary-foreground: 190 15% 92%;
  --accent: 24 95% 58%;
  --accent-foreground: 200 40% 6%;
  --accent-soft: 24 60% 14%;
  --destructive: 0 75% 60%;
  --destructive-soft: 0 50% 14%;
  --success: 150 55% 52%;
  --success-soft: 150 40% 12%;
  --warning: 40 95% 60%;
  --warning-soft: 40 60% 12%;
  --info-soft: 190 50% 13%;
  --shadow-sm: none;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: hsl(var(--background)); color: hsl(var(--foreground));
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: hsl(var(--primary)); text-underline-offset: 3px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: .85rem; }
.xs { font-size: .75rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: .5rem; }
.sep { height: 1px; background: hsl(var(--border)); margin: .25rem 0; }

/* Card */
.card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { padding: 1.25rem 1.25rem .5rem; display: grid; gap: .35rem; }
.card-content { padding: .75rem 1.25rem 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid hsl(var(--border)); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: .6rem; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap;
  height: 2.5rem; padding: 0 1rem; border-radius: calc(var(--radius) - 4px); border: 1px solid transparent;
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-sm);
  transition: background-color .15s, opacity .15s, box-shadow .15s;
}
.btn:hover { background: hsl(var(--primary) / .9); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .textarea:focus-visible, .tab:focus-visible, .chip:focus-visible, .check:focus-within {
  outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-outline { background: hsl(var(--background)); color: hsl(var(--foreground)); border-color: hsl(var(--input)); }
.btn-outline:hover { background: hsl(var(--muted)); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); box-shadow: none; }
.btn-secondary:hover { background: hsl(var(--secondary) / .75); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); box-shadow: none; }
.btn-ghost:hover { background: hsl(var(--muted)); }
.btn-accent { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-accent:hover { background: hsl(var(--accent) / .9); }
.btn-destructive { background: hsl(var(--destructive)); color: #fff; }
.btn-destructive:hover { background: hsl(var(--destructive) / .9); }
.btn-whatsapp { background: #128c4a; color: #fff; }
.btn-whatsapp:hover { background: #0f7a40; }
.btn-sm { height: 2.1rem; padding: 0 .75rem; font-size: .85rem; }
.btn-lg { height: 3rem; padding: 0 1.5rem; font-size: 1rem; }
.btn-icon { width: 2.5rem; padding: 0; }
.btn-block { width: 100%; }

/* Formularios */
.field { display: grid; gap: .4rem; min-width: 0; }
.label { font-size: .85rem; font-weight: 500; }
.label .opt { font-weight: 400; color: hsl(var(--muted-foreground)); }
.hint { font-size: .78rem; color: hsl(var(--muted-foreground)); }
.input, .select, .textarea {
  width: 100%; height: 2.6rem; padding: 0 .8rem; border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background)); color: hsl(var(--foreground)); font: inherit; font-size: 16px; box-shadow: var(--shadow-sm);
}
.textarea { height: auto; min-height: 5rem; padding: .6rem .8rem; resize: vertical; }
.select { appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23738690' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: hsl(var(--destructive)); }
.error-text { font-size: .78rem; color: hsl(var(--destructive)); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

.check { display: flex; gap: .7rem; align-items: flex-start; padding: .9rem 1rem; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px); cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: .15rem 0 0; accent-color: hsl(var(--primary)); flex: none; }

/* Segmented / tabs */
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: hsl(var(--muted)); border-radius: calc(var(--radius) - 2px); flex-wrap: wrap; }
.tab { border: 0; background: transparent; color: hsl(var(--muted-foreground)); font: inherit; font-size: .85rem; font-weight: 500; padding: .4rem .8rem; border-radius: calc(var(--radius) - 4px); cursor: pointer; text-decoration: none; }
.tab[aria-selected="true"], .tab.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: var(--shadow); }
.chip { border: 1px solid hsl(var(--input)); background: hsl(var(--background)); color: hsl(var(--foreground)); font: inherit; font-size: .85rem; padding: .45rem .8rem; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: transparent; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge-outline { border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge-draft { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge-submitted { background: hsl(var(--info-soft)); color: hsl(var(--primary)); }
.badge-needs_fix { background: hsl(var(--warning-soft)); color: hsl(var(--warning)); }
.badge-approved { background: hsl(var(--success-soft)); color: hsl(var(--success)); }
.badge-cancelled { background: hsl(var(--destructive-soft)); color: hsl(var(--destructive)); }
.badge-accent { background: hsl(var(--accent-soft)); color: hsl(var(--accent)); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; display: inline-block; }

/* Alertas */
.alert { display: grid; gap: .25rem; padding: .9rem 1rem; border-radius: calc(var(--radius) - 2px); border: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.alert-title { font-weight: 600; font-size: .92rem; }
.alert-info { background: hsl(var(--info-soft)); border-color: hsl(var(--primary) / .25); }
.alert-warn { background: hsl(var(--warning-soft)); border-color: hsl(var(--warning) / .3); }
.alert-error { background: hsl(var(--destructive-soft)); border-color: hsl(var(--destructive) / .3); }
.alert-success { background: hsl(var(--success-soft)); border-color: hsl(var(--success) / .3); }

/* Tabla */
.table-wrap { overflow-x: auto; }
table.table { display: table; width: 100%; border-collapse: collapse; font-size: .9rem; } /* display: la clase .stack (tarjetas en celular) no debe volverla grid en escritorio */
.table th { text-align: left; font-weight: 500; color: hsl(var(--muted-foreground)); font-size: .8rem; padding: .7rem .9rem; border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.table td { padding: .75rem .9rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background-color .1s; }
.table tbody tr:hover { background: hsl(var(--muted) / .6); }
.table tr:last-child td { border-bottom: 0; }

/* Toast */
.toaster { position: fixed; bottom: 1rem; right: 1rem; left: 1rem; display: grid; justify-items: end; gap: .5rem; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; max-width: 26rem; padding: .8rem 1rem; border-radius: calc(var(--radius) - 2px); background: hsl(var(--foreground)); color: hsl(var(--background)); box-shadow: 0 10px 30px hsl(200 30% 5% / .25); font-size: .9rem; animation: toast-in .2s ease-out; }
.toast.error { background: hsl(var(--destructive)); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* Diálogo */
dialog { border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0; width: min(32rem, calc(100vw - 2rem)); background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 20px 50px hsl(200 30% 5% / .3); }
dialog::backdrop { background: hsl(200 30% 5% / .55); backdrop-filter: blur(2px); }

/* Skeleton / spinner */
.spinner { width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 2.5rem 1rem; text-align: center; color: hsl(var(--muted-foreground)); }

.rug { height: 4px; background: var(--rug); border-radius: 999px; }
.ico { display: inline-flex; }
.ico svg, .btn svg { width: 1rem; height: 1rem; flex: none; }

/* Botón de tema (claro/oscuro) */
.theme-toggle { width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 999px; display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background) / .8); color: hsl(var(--foreground)); backdrop-filter: blur(6px); }
.theme-toggle:hover { background: hsl(var(--muted)); }
.theme-toggle svg { width: 1rem; height: 1rem; }
.on-photo .theme-toggle { background: hsl(0 0% 100% / .16); border-color: hsl(0 0% 100% / .3); color: #fff; }
.on-photo .theme-toggle:hover { background: hsl(0 0% 100% / .28); }

/* Combobox de país (bandera + búsqueda) */
.cbx { position: relative; }
.cbx-trigger { display: flex; align-items: center; gap: .55rem; text-align: left; cursor: pointer; background-image: none; }
.cbx-flag { font-size: 1.15rem; line-height: 1; font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.cbx-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-ph { flex: 1; color: hsl(var(--muted-foreground)); }
.cbx-chev { width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); flex: none; margin-left: auto; }
.cbx-panel { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; min-width: 16rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px); box-shadow: 0 10px 30px hsl(200 30% 5% / .18); overflow: hidden; }
.cbx-search { width: 100%; height: 2.6rem; border: 0; border-bottom: 1px solid hsl(var(--border)); padding: 0 .85rem; font: inherit; font-size: 16px; background: transparent; color: inherit; outline: none; }
.cbx-list { list-style: none; margin: 0; padding: .25rem; max-height: 16rem; overflow-y: auto; }
.cbx-list li[data-code] { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: calc(var(--radius) - 5px); cursor: pointer; font-size: .92rem; }
.cbx-list li.active, .cbx-list li[data-code]:hover { background: hsl(var(--muted)); }
.cbx-check { margin-left: auto; color: hsl(var(--primary)); font-weight: 700; }
.cbx-sep { height: 1px; background: hsl(var(--border)); margin: .25rem .2rem; }
.cbx-empty { padding: .8rem; color: hsl(var(--muted-foreground)); font-size: .88rem; text-align: center; }
[aria-invalid="true"] > .cbx-trigger, .cbx-trigger[aria-invalid="true"] { border-color: hsl(var(--destructive)); }

/* Menú lateral (Sheet) */
.menu-btn { width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 999px; display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background) / .8); color: hsl(var(--foreground)); backdrop-filter: blur(6px); }
.menu-btn svg { width: 1.15rem; height: 1.15rem; }
.on-photo .menu-btn { background: hsl(0 0% 100% / .16); border-color: hsl(0 0% 100% / .3); color: #fff; }
.on-photo .menu-btn:hover { background: hsl(0 0% 100% / .28); }
html.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-overlay { position: absolute; inset: 0; background: hsl(210 40% 4% / .55); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s; }
.sheet-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(22rem, 88vw); background: hsl(var(--card)); color: hsl(var(--foreground));
  border-left: 1px solid hsl(var(--border)); box-shadow: -20px 0 50px hsl(210 40% 4% / .25); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.sheet.open .sheet-overlay { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-head { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1rem 1rem 1.2rem; border-bottom: 1px solid hsl(var(--border)); }
.sheet-head img { border-radius: 10px; flex: none; }
.sheet-name { display: grid; gap: .1rem; min-width: 0; flex: 1; }
.sheet-name b { font-size: 1rem; }
.sheet-name span { font-size: .75rem; color: hsl(var(--muted-foreground)); line-height: 1.35; }
.sheet-nav { display: grid; gap: .2rem; padding: .8rem; overflow-y: auto; }
.sheet-nav a { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: calc(var(--radius) - 4px); color: inherit; text-decoration: none; font-weight: 500; }
.sheet-nav a svg { width: 1.2rem; height: 1.2rem; color: hsl(var(--muted-foreground)); flex: none; }
.sheet-nav a:hover { background: hsl(var(--muted)); }
.sheet-nav a.active { background: hsl(var(--secondary)); }
.sheet-nav a.active svg { color: hsl(var(--primary)); }
.sheet-nav a.sheet-cta { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); margin-bottom: .4rem; }
.sheet-nav a.sheet-cta svg { color: inherit; }
.sheet-nav a.sheet-cta:hover { background: hsl(var(--accent) / .9); }
.sheet-foot { margin-top: auto; padding: 1rem 1.2rem 1.25rem; border-top: 1px solid hsl(var(--border)); display: grid; gap: .6rem; }
.sheet-links { display: grid; gap: .2rem; }
.sheet-links a { display: flex; align-items: center; gap: .6rem; padding: .45rem .3rem; color: inherit; text-decoration: none; font-size: .9rem; border-radius: 8px; }
.sheet-links a:hover { background: hsl(var(--muted)); }
.sheet-links svg { width: 1rem; height: 1rem; }

/* Botones de esquina (nav.js): instalar la app y acceso a /admin. Abajo a la izquierda; los avisos (toaster) van a la derecha. */
.corner-actions { position: fixed; left: max(.75rem, env(safe-area-inset-left)); bottom: max(.75rem, env(safe-area-inset-bottom)); z-index: 40; display: flex; gap: .4rem; align-items: flex-end; }
.corner-btn { display: inline-flex; align-items: center; gap: .35rem; height: 2.1rem; padding: 0 .6rem; border-radius: 999px; border: 1px solid hsl(var(--border)); background: hsl(var(--background) / .82); backdrop-filter: blur(6px); color: hsl(var(--foreground)); font-family: inherit; font-size: .75rem; font-weight: 500; line-height: 1; text-decoration: none; cursor: pointer; box-shadow: 0 2px 10px hsl(210 40% 4% / .18); opacity: .8; transition: opacity .15s, background .15s; }
.corner-btn:hover, .corner-btn:focus-visible { opacity: 1; background: hsl(var(--background)); }
.corner-btn[hidden] { display: none; }
.corner-btn svg { width: 1rem; height: 1rem; flex: none; }
.corner-btn[data-admin] { width: 2.1rem; padding: 0; justify-content: center; }
.corner-btn[data-admin] span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.corner-tip { position: absolute; left: 0; bottom: calc(100% + .5rem); width: min(18rem, calc(100vw - 1.5rem)); padding: .75rem .85rem; border-radius: .6rem; border: 1px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); font-size: .85rem; box-shadow: 0 8px 30px hsl(210 40% 4% / .25); display: grid; gap: .5rem; }
.corner-tip[hidden] { display: none; }
.corner-tip p { margin: 0; }
.corner-tip button { justify-self: end; }
@media print { .corner-actions { display: none; } }
