/* Sistema visual MiniBile, calcado de minibile.com: tipografia Kanit, verde de marca
   #25B4A6, azul marino #00213C como tinta y esquinas muy redondeadas (pildora en los
   botones, 20 px en las tarjetas).

   Matiz importante sobre el verde: #25B4A6 puro no llega a contraste AA con texto blanco
   encima, asi que la marca vive en superficies grandes (--brand, el rail, los realces) y
   las acciones y los enlaces usan --accent, el mismo verde bajado de luminosidad. Asi el
   panel se ve como la web pero sigue siendo legible. */
:root {
  color-scheme: light;
  --brand: #25b4a6;          /* verde de marca, tal cual la web */
  --brand-soft: #83c1bd;     /* verde suave de los botones de la web */
  --brand-deep: #00213c;     /* azul marino de marca */
  --canvas: #ffffff;
  --canvas-deep: #f4f6f7;    /* fondos hundidos: inputs, filas, pistas */
  --surface: #ffffff;
  --surface-hi: #e8f7f4;
  --ink: #00213c;
  --ink-muted: #676767;
  --ink-faint: #9aa7b1;
  --line: #e8edf1;
  --line-strong: #d2dde4;
  --accent: #0e8c80;         /* acciones y texto de acento (AA sobre blanco) */
  --accent-ink: #ffffff;
  --accent-hover: #0a6f66;
  --accent-vivid: var(--brand);
  --accent-glow: rgba(37, 180, 166, 0.4);
  --accent-soft: rgba(37, 180, 166, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 33, 60, 0.05);
  --shadow-md: 0 18px 40px -28px rgba(0, 33, 60, 0.45);
  /* Fondos compuestos que cambian de receta entre temas (no solo de color). */
  --body-bg: var(--canvas-deep);
  --overlay: rgba(0, 33, 60, 0.45);
  --chip-bg: #ffffff;
  --hero-safe-bg: linear-gradient(120deg, rgba(37, 180, 166, 0.16), var(--surface) 62%);
  --hero-open-bg: linear-gradient(120deg, rgba(245, 158, 11, 0.14), var(--surface) 62%);
  --danger-zone-bg: #fffafa;
  /* El degradado teal -> azul de la cabecera de minibile.com, aqui en vertical. */
  --rail-bg: linear-gradient(180deg, #25b4a6 0%, #1f9bb0 52%, #1d6fa8 100%);
  --radius: 20px;
  --radius-sm: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font-display: "Kanit", "Segoe UI", sans-serif;
  --font-body: "Kanit", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--body-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.55;
}

body.modal-open { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; }
p { margin: 0; }
strong, b { font-weight: 600; }
::selection { background: var(--brand); color: #fff; }

.hidden { display: none !important; }
.muted { color: var(--ink-muted); }

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hint {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.stack { display: grid; gap: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ------------------------------------------------------------- formularios */

label > span:first-child {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--ink-muted);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"],
input[type="time"],
input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--canvas-deep);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

input::placeholder { color: var(--ink-faint); }

input:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="time"], input[type="number"] { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- botones */

/* Pildora total: es la forma que manda en toda la web de marca. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 200px;
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s var(--ease-out), background 0.16s var(--ease-out),
              border-color 0.16s var(--ease-out), opacity 0.16s var(--ease-out);
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 20px -12px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-hi);
  border-color: transparent;
  color: var(--accent);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); }

.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-faint); }

.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-sm { padding: 8px 16px; font-size: 0.86rem; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ------------------------------------------------------------- estados */

.status-line {
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--ink-muted);
}
.status-line.error { color: var(--danger); }
.status-line.success { color: var(--accent); }
.status-line.pending { color: var(--warn); }

.status-line.pending::before,
.status-line.success::before { margin-right: 6px; }
.status-line.pending::before { content: "◷"; }
.status-line.success::before { content: "✓"; }

.global-status:empty { min-height: 0; }

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-muted);
  text-align: center;
  background: var(--canvas-deep);
}

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  margin-bottom: 16px;
  background: var(--warn-soft);
  border: 1px solid rgba(180, 83, 9, 0.32);
  border-radius: 200px;
  color: var(--warn);
  font-size: 0.9rem;
}
.notice .link-btn { color: var(--warn); margin-left: auto; }

/* ------------------------------------------------------------- acceso */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--rail-bg);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 40px 80px -40px rgba(0, 33, 60, 0.5);
}

.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-logo { width: 46px; height: 46px; border-radius: 14px; object-fit: contain; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-copy { color: var(--ink-muted); font-size: 0.94rem; }

/* ------------------------------------------------------------- shell de 3 columnas

   Rail de marca | columna del hijo | contenido. El rail y la columna del hijo son fijos:
   el padre siempre ve sobre quien esta actuando sin tener que volver arriba. */

.app-shell { display: flex; min-height: 100dvh; align-items: stretch; }

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 96px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px 10px;
  background: var(--rail-bg);
  color: #fff;
}

.rail-logo { width: 40px; height: 40px; border-radius: 12px; object-fit: contain; }
.rail-nav { display: grid; gap: 8px; width: 100%; }
.rail-foot { margin-top: auto; display: grid; gap: 6px; width: 100%; justify-items: center; }

.rail-item {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 100%;
  padding: 12px 4px;
  background: transparent;
  border: 0;
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.rail-item .icon { width: 21px; height: 21px; }
.rail-item:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* La seccion abierta se recorta en blanco sobre el degradado, como en el modelo. */
.rail-item.is-active {
  background: var(--canvas-deep);
  color: var(--accent);
  font-weight: 500;
}

.rail-email {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.75);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------- columna del hijo */

.child-nav {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 262px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 26px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.child-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-bottom: 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.child-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; text-align: center; }
.child-state { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--ink-muted); }

.child-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 7px 14px;
  background: var(--surface-hi);
  border: 0;
  border-radius: 200px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s var(--ease-out);
}
.child-switch:hover { background: var(--accent-soft); }
.child-switch .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------- secciones del hijo */

.tabbar { display: grid; gap: 4px; align-content: start; }

.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  background: transparent;
  border: 0;
  border-radius: 200px;
  color: var(--ink-muted);
  font-weight: 400;
  font-size: 0.94rem;
  white-space: nowrap;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.tab:hover { background: var(--canvas-deep); color: var(--ink); }
.tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
  box-shadow: 0 8px 18px -12px var(--accent-glow);
}

/* ------------------------------------------------------------- contenido */

.content {
  flex: 1;
  min-width: 0;
  padding: 30px clamp(18px, 4vw, 46px) 72px;
}
.content > * { width: min(980px, 100%); margin-inline: auto; }

.panel-title { font-size: 1.7rem; margin-bottom: 4px; }

.device-view { display: grid; gap: 20px; }
.tab-panel { display: grid; gap: 18px; }

/* ------------------------------------------------------------- selector de perfil

   Puerta de entrada al panel: hasta que el padre no elige una cara, no hay nada que
   administrar. Caras grandes y separadas para que la eleccion sea deliberada y no
   quepa confundir de hijo. */

.picker {
  display: grid;
  gap: 34px;
  justify-items: center;
  padding: clamp(20px, 7vh, 64px) 0 40px;
  text-align: center;
}

.picker-head { display: grid; gap: 8px; justify-items: center; }
.picker-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }

.profile-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(20px, 5vw, 46px);
}

.profile-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: 156px;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.profile-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition: color 0.18s var(--ease-out);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-card:hover .profile-name,
.profile-card:focus-visible .profile-name { color: var(--ink); }

.profile-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: -6px;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

/* Avatar sin foto: inicial sobre un color propio de cada telefono (hue via JS). */
.avatar {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border-radius: 32px;
  background: linear-gradient(150deg,
    hsl(var(--avatar-hue, 174) 58% 52%),
    hsl(calc(var(--avatar-hue, 174) + 26) 54% 40%));
  color: #fff;
  font-family: var(--font-display);
  font-size: 2.9rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out),
              outline-color 0.2s var(--ease-out);
  outline: 3px solid transparent;
  outline-offset: 5px;
}

.profile-card:hover .avatar,
.profile-card:focus-visible .avatar {
  transform: translateY(-4px) scale(1.04);
  outline-color: var(--brand);
  box-shadow: 0 18px 34px -22px rgba(0, 33, 60, 0.6);
}
.profile-card:focus-visible { outline: none; }

.avatar-add {
  background: transparent;
  border: 2px dashed var(--line-strong);
  color: var(--ink-faint);
}
.profile-add:hover .avatar-add { border-color: var(--brand); color: var(--accent); }
.avatar-add .icon { width: 40px; height: 40px; stroke-width: 1.6; }

.avatar-lg { width: 88px; height: 88px; border-radius: 26px; font-size: 2.1rem; }

.picker-empty { color: var(--ink-muted); font-size: 0.94rem; max-width: 46ch; }

.lamp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}
.lamp-dot.safe { background: var(--brand); }
.lamp-dot.open { background: #f59e0b; }

/* ------------------------------------------------------------- tarjetas */

.card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.05rem;
}
.card-head h2 .icon { color: var(--brand); }
.card-copy { color: var(--ink-muted); font-size: 0.9rem; margin-bottom: 14px; }

.pill {
  padding: 3px 12px;
  background: var(--accent-soft);
  border-radius: 200px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- resumen */

.state-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.state-hero.safe {
  background: var(--hero-safe-bg);
  border-color: var(--brand);
}
.state-hero.open {
  background: var(--hero-open-bg);
  border-color: rgba(180, 83, 9, 0.5);
}

.state-hero-main { display: flex; align-items: center; gap: 16px; }

.state-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--canvas-deep);
  color: var(--ink-faint);
}
.state-hero.safe .state-icon { background: var(--chip-bg); color: var(--accent); }
.state-hero.open .state-icon { background: var(--chip-bg); color: var(--warn); }
.state-icon .icon { width: 24px; height: 24px; }

.state-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }
.state-sub { color: var(--ink-muted); font-size: 0.9rem; max-width: 46ch; }
.state-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.stat {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.stat-label .icon { color: var(--brand); }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.stat-value.warn { color: var(--warn); }

.schedule-readout { display: grid; gap: 10px; }

.schedule-row {
  display: grid;
  grid-template-columns: 1.1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--canvas-deep);
  border-radius: var(--radius-sm);
}
.schedule-day { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 0.95rem; }
.schedule-day .icon { color: var(--brand); }
.schedule-range {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.schedule-range .arrow { color: var(--ink-faint); }
.schedule-quota { text-align: right; font-size: 0.88rem; color: var(--ink-muted); }

/* ------------------------------------------------------------- horarios */

.day-card { display: grid; gap: 16px; }
.time-pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.schedule-legend {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.schedule-legend .icon { flex: 0 0 auto; width: 1.1em; height: 1.1em; margin-top: 2px; color: var(--warn); }

.schedule-cross-link { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }

.schedule-shortcuts { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 4px; }

.schedule-day-row + .schedule-day-row { padding-top: 16px; border-top: 1px solid var(--line); }

.time-field { display: grid; gap: 8px; }
.time-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-muted);
}
.time-label .icon { color: var(--brand); width: 1em; height: 1em; }
/* `label > span:first-child` es mas especifico que `.time-label` y lo volvia display:block,
   con lo que el icono quedaba pegado al texto. Esta regla lo devuelve a flex. */
.time-field > .time-label { display: flex; }
.time-field input {
  font-size: 1.35rem;
  font-weight: 500;
  text-align: center;
  padding: 14px;
}

.quota-field { display: grid; gap: 8px; }
.quota-inputs { display: flex; align-items: center; gap: 8px; }
.quota-inputs input { width: 84px; text-align: center; font-size: 1.1rem; font-weight: 500; }
.quota-inputs .unit { color: var(--ink-muted); font-size: 0.9rem; }

.save-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 -10px 30px -24px rgba(0, 33, 60, 0.5);
  position: sticky;
  bottom: 12px;
}
.save-bar .status-line { flex: 1; min-width: 200px; }

/* ------------------------------------------------------------- apps */

.app-toolbar { display: flex; gap: 12px; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 0 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 200px;
}
.search .icon { color: var(--ink-faint); }
.search input {
  border: 0;
  background: transparent;
  padding: 12px 0;
}
.search input:focus-visible { box-shadow: none; }

.app-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.app-card { display: grid; align-content: start; }

.app-list {
  display: grid;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 6px;
}

.app-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 13px;
  border-radius: 200px;
  cursor: pointer;
  font-size: 0.93rem;
  transition: background 0.14s var(--ease-out);
}

.app-row.is-forced { opacity: 0.72; }
.app-row.is-forced input { cursor: not-allowed; }
.compact-form { max-width: 560px; }
.app-row:hover { background: var(--surface-hi); }
.app-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}
.app-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inventory summary { cursor: pointer; list-style: none; margin-bottom: 14px; }
.inventory summary::-webkit-details-marker { display: none; }
.inventory summary h2 {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 1.05rem;
}
.inventory summary h2::before { content: "▸"; color: var(--brand); }
.inventory[open] summary h2::before { content: "▾"; }
.inventory-list { max-height: 320px; }
.inventory-row {
  padding: 7px 12px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.inventory-row:nth-child(odd) { background: var(--canvas-deep); }

/* --------------------------------------------------------------- tutores */

.guardian-list { display: grid; gap: 8px; margin-bottom: 14px; }

.guardian-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.guardian-row.is-pending { border-style: dashed; }
.guardian-email { font-weight: 500; margin-right: auto; word-break: break-all; }
.guardian-role {
  font-size: 0.82rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ------------------------------------------------------------- ubicacion */

.location-card { display: grid; gap: 16px; }

.map-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  /* Altura propia en vez de una proporcion fija: con 16/10 el mapa heredaba el ancho de la
     tarjeta y en un movil de 390 px quedaba en ~194 px de alto, dos dedos de pantalla. */
  height: clamp(320px, 55vh, 560px);
}
.map-frame #locationMap { width: 100%; height: 100%; }

/* Pantalla completa sin depender de la Fullscreen API (iOS la sirve a medias en Safari). */
.map-frame.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 60;
  height: 100%;
  border-radius: 0;
  border: 0;
}

.map-expand {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 500; /* por encima de los controles de Leaflet */
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.map-expand:hover { background: var(--surface-hi); }

/* Marcador propio: evita servir los PNG de Leaflet. */
.map-pin span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #25B4A6;
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 33, 60, 0.45);
}

/* La hora de la posicion manda sobre el mapa: si el punto es viejo, hay que verlo. */
#locationWhen[data-freshness="fresh"] { color: #12866f; }
#locationWhen[data-freshness="recent"] { color: #a86b00; }
#locationWhen[data-freshness="old"] { color: var(--danger); }

.location-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.location-meta p { font-size: 0.92rem; }
.location-meta a { margin-left: auto; text-decoration: none; }

.locating {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 38px 20px;
  text-align: center;
}
.locating p:first-of-type { font-weight: 500; }
.locating .muted { font-size: 0.88rem; max-width: 42ch; }

/* Con mapa previo a la vista, el buscador se encoge a una linea sobre el mapa atenuado. */
.locating.compact {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  justify-items: start;
  align-items: center;
  gap: 12px;
  padding: 0;
  text-align: left;
}
.locating.compact .radar { width: 22px; height: 22px; }
.locating.compact .muted { display: none; }

#locationResult.is-searching { opacity: 0.4; transition: opacity 0.2s var(--ease-out); }

/* Radar: senal visual de "el telefono esta buscando el GPS ahora mismo". */
.radar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--brand);
}
.radar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  animation: radar-pulse 1.6s var(--ease-out) infinite;
}
@keyframes radar-pulse {
  from { transform: scale(0.7); opacity: 0.9; }
  to { transform: scale(1.7); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .radar::after { animation: none; }
}

/* ------------------------------------------------------------- zona de riesgo */

/* Desvincular vive al final de Ajustes, lejos de los controles de uso diario,
   para que nadie lo pulse sin querer. */
.danger-zone { border-color: rgba(220, 38, 38, 0.35); background: var(--danger-zone-bg); }
.danger-zone .card-head h2 { color: var(--danger); }
.danger-zone .card-head h2 .icon { color: var(--danger); }

/* ------------------------------------------------------------- modales */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.modal-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 30px 70px -30px rgba(0, 33, 60, 0.5);
  max-height: 88dvh;
  overflow-y: auto;
}
.modal-card h2 { font-size: 1.25rem; }
.modal-copy { color: var(--ink-muted); font-size: 0.94rem; }

.modal-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: var(--warn-soft);
  color: var(--warn);
}
.modal.is-danger .modal-icon { background: var(--danger-soft); color: var(--danger); }
.modal-icon .icon { width: 22px; height: 22px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.pair-result { display: grid; gap: 14px; justify-items: center; text-align: center; }
.qr-box {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  line-height: 0;
}
.qr-box img, .qr-box canvas { display: block; }

.credential-manual { width: 100%; font-size: 0.85rem; color: var(--ink-muted); }
.credential-manual summary { cursor: pointer; }
.credential-fields { display: grid; gap: 10px; margin-top: 10px; text-align: left; }
.credential-fields code {
  display: block;
  padding: 8px 12px;
  background: var(--canvas-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  word-break: break-all;
  color: var(--ink);
}

/* ------------------------------------------------------------- responsive

   Por debajo de 900 px las tres columnas se apilan: el rail pasa a barra superior y la
   columna del hijo a una cabecera con sus secciones en scroll horizontal. */

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }

  .rail {
    position: static;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }
  .rail-logo { width: 32px; height: 32px; }
  .rail-nav { display: flex; width: auto; }
  .rail-foot { margin-top: 0; margin-left: auto; display: flex; align-items: center; gap: 6px; }
  .rail-item { width: auto; grid-auto-flow: column; align-items: center; gap: 8px; padding: 8px 14px; }
  .rail-item span { white-space: nowrap; }

  .child-nav {
    position: static;
    height: auto;
    width: 100%;
    padding: 16px 14px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .child-card {
    grid-auto-flow: column;
    grid-template-columns: auto 1fr auto;
    justify-items: start;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
  }
  .child-card .child-name { text-align: left; }
  .child-switch { margin-top: 0; }
  .avatar-lg { width: 52px; height: 52px; border-radius: 18px; font-size: 1.3rem; }

  .tabbar {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabbar::-webkit-scrollbar { display: none; }

  .content { padding: 22px 16px 60px; }
}

@media (max-width: 820px) {
  .stat-row { grid-template-columns: 1fr; }
  .app-columns { grid-template-columns: 1fr; }
  .time-pair { grid-template-columns: 1fr; }
  .schedule-row { grid-template-columns: 1fr; gap: 8px; }
  .schedule-quota { text-align: left; }
  .state-hero-actions { width: 100%; }
  .state-hero-actions .btn { flex: 1; }
  .save-bar { position: static; }
}

@media (max-width: 560px) {
  .btn-text { display: none; }

  /* El mapa a sangre dentro de la tarjeta: en un movil los 24 px de padding a cada lado son
     una quinta parte del ancho util. */
  .location-card .map-frame {
    margin-inline: -24px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    height: clamp(340px, 62vh, 560px);
  }

  /* En movil caben dos caras por fila sin encogerlas hasta ser irreconocibles.
     Solo las de la rejilla: el avatar de la cabecera ya tiene su tamano en .avatar-lg. */
  .profile-card { width: 132px; }
  .profile-card .avatar { width: 96px; height: 96px; border-radius: 26px; font-size: 2.3rem; }

  /* Cabecera del hijo en dos filas: cara a la izquierda, nombre y estado a su derecha,
     y el boton de cambiar debajo ocupando su propia linea. */
  .child-card {
    grid-auto-flow: row;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 2px 14px;
  }
  .child-card .avatar-lg { grid-row: 1 / span 2; }
  .child-name { grid-column: 2; align-self: end; }
  .child-state { grid-column: 2; align-self: start; }
  .child-switch { grid-column: 1 / -1; justify-self: start; margin-top: 10px; }
}

/* ------------------------------------------------------------- modo oscuro

   El lienzo es el azul marino de marca (#00213C). El tema efectivo lo decide un data-theme
   en <html>: el script del <head> lo pone segun lo que el padre eligio (localStorage) o,
   si no ha elegido nunca, segun el tema de su sistema. Solo se redefinen tokens, ninguna
   regla de layout, asi que /panel y /admin cambian de piel a la vez. Sobre el marino, el
   verde de marca SI contrasta de sobra y manda tambien en las acciones. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #00213c;
    --canvas-deep: #001628;
    --surface: #0a3054;
    --surface-hi: #0f3d68;
    --ink: #eef7fb;
    --ink-muted: #a7bccd;
    --ink-faint: #6d8ba5;
    --line: #14416b;
    --line-strong: #1d5487;
    --accent: #45cfbe;
    --accent-ink: #00213c;
    --accent-hover: #6ee0d1;
    --accent-glow: rgba(69, 207, 190, 0.45);
    --accent-soft: rgba(69, 207, 190, 0.14);
    --brand: #45cfbe;
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.12);
    --shadow-sm: none;
    --shadow-md: 0 30px 80px -50px #000;
    --overlay: rgba(0, 12, 22, 0.74);
    --chip-bg: var(--canvas-deep);
    --danger-zone-bg: transparent;
    --hero-safe-bg: linear-gradient(120deg, var(--surface-hi), var(--surface));
    --hero-open-bg: linear-gradient(120deg, rgba(251, 191, 36, 0.1), var(--surface));
    --body-bg: var(--canvas-deep);
    --rail-bg: linear-gradient(180deg, #0f766e 0%, #0e5a73 52%, #0d3f6b 100%);
}

/* Sobre marino, el verde hace de tinta: los bordes activos y el texto del hover
   necesitan el contrario del claro. */
:root[data-theme="dark"] .btn-danger:hover:not(:disabled) { color: var(--canvas-deep); }
:root[data-theme="dark"] .notice { border-color: rgba(251, 191, 36, 0.4); }
:root[data-theme="dark"] .state-hero.open { border-color: rgba(251, 191, 36, 0.55); }
:root[data-theme="dark"] .lamp-dot.safe { box-shadow: 0 0 8px var(--accent-glow); }
:root[data-theme="dark"] .lamp-dot.open { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
:root[data-theme="dark"] .save-bar { box-shadow: none; }
:root[data-theme="dark"] .empty-state { background: transparent; }
:root[data-theme="dark"] .danger-zone { border-color: rgba(251, 113, 133, 0.35); }
:root[data-theme="dark"] ::selection { background: var(--brand); color: var(--canvas); }
:root[data-theme="dark"] .rail-item.is-active { background: var(--canvas-deep); color: var(--accent); }
/* Sobre el lienzo marino, los avatares se apagan un punto para no deslumbrar. */
:root[data-theme="dark"] .avatar {
  background: linear-gradient(150deg,
    hsl(var(--avatar-hue, 174) 48% 46%),
    hsl(calc(var(--avatar-hue, 174) + 26) 46% 34%));
}
:root[data-theme="dark"] .profile-card:hover .avatar,
:root[data-theme="dark"] .profile-card:focus-visible .avatar { box-shadow: 0 18px 40px -24px var(--accent-glow); }

/* ------------------------------------------------------------- boton de tema */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.16s var(--ease-out), border-color 0.16s var(--ease-out);
}
.icon-btn:hover { color: var(--accent); border-color: var(--brand); }
.icon-btn .icon { width: 17px; height: 17px; }

/* Se muestra el icono del tema al que vas a cambiar, no el actual. */
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

/* ------------------------------------------------------------------
   Lista blanca de apps: cada fila lleva su tiempo diario y su franja.
   ------------------------------------------------------------------ */
.allow-intro { margin-bottom: 14px; }

.allow-list { max-height: 520px; }

.app-row.allow-row {
  display: block;
  border-radius: 14px;
  padding: 10px 13px;
  cursor: default;
}

.app-row.allow-row.is-allowed { background: var(--surface-hi); }

/* Pestana "Apps": la fila es solo permitir/bloquear, sin bloque de tiempos debajo. */
.app-row.allow-row-simple {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}

.allow-head {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}

.allow-details {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0 2px 28px;
}

.allow-details.hidden { display: none; }

.allow-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.allow-field input {
  width: 132px;
  padding: 6px 9px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.88rem;
}

/* Selector de 3 estados por app (bloqueada / indispensable / opcional) y de 2 estados para el
   modo de reparto de tiempo (por app / bolsa comun). Mismo lenguaje visual que .tab. */
.status-row { display: block; border-radius: 14px; padding: 10px 13px; }
.status-row.is-active { background: var(--surface-hi); }
.status-row-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
}
.status-row-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-toggle { display: flex; gap: 6px; }
.status-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 200px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.14s var(--ease-out), color 0.14s var(--ease-out), border-color 0.14s var(--ease-out);
}
.status-btn:hover { border-color: var(--brand); }
.status-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.time-mode-toggle { display: flex; gap: 6px; margin-bottom: 10px; max-width: 620px; }
.time-mode-hint { color: var(--ink-muted); font-size: 0.85rem; margin: 2px 0 12px; }
.pool-field { max-width: 220px; }

/* h + min: mismo patron visual que la cuota global de la pestana Horarios. */
.duration-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--ink-muted); }
.duration-inputs { display: flex; align-items: center; gap: 6px; }
.duration-inputs input { width: 56px; text-align: center; padding: 6px 4px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 0.88rem; }
.duration-inputs .unit { color: var(--ink-muted); font-size: 0.8rem; }
.duration-inputs.is-disabled input { opacity: 0.45; pointer-events: none; }

/* Interruptor "todo el rato": oculta/deshabilita el h+min y fuerza sin limite. */
.unlimited-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-muted); cursor: pointer; margin-top: 2px; }
.unlimited-toggle input { margin: 0; }

/* Franjas horarias por app: 1 a 4, cada una con dias + horas. */
.windows-field { display: flex; flex-direction: column; gap: 8px; flex-basis: 100%; }
.window-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.window-row .allow-field { font-size: 0.75rem; }
.window-row .allow-field input[type="time"] { width: 108px; }
.window-days-select { width: 150px; }
.window-days-checks { display: flex; flex-wrap: wrap; gap: 6px; max-width: 220px; }
.window-days-checks label { display: flex; align-items: center; gap: 3px; font-size: 0.72rem; color: var(--ink-muted); }
.window-remove-btn { align-self: center; }
.windows-add-btn { align-self: flex-start; }

/* Modo "tiempo por ano": aviso de apps sin presupuesto asignado. */
.yearly-field input { width: 84px; }
