/* =========================================================
   RutaDev · layout.css
   Estructura general: barra superior, panel lateral y panel principal
   ========================================================= */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 14px;
}

/* ---------- barra superior ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px 0;
  min-width: 0;
}
.marca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px 6px 4px 0;
  border-radius: 10px;
  flex: none;
}
.marca-logo { width: 34px; height: 34px; display: block; }
.marca-logo .t1 { fill: oklch(var(--lib-L) var(--lib-C) 340); }
.marca-logo .t2 { fill: oklch(var(--lib-L) var(--lib-C) 265); }
.marca-logo .t3 { fill: oklch(var(--lib-L) var(--lib-C) 165); }
.marca-logo .ruta { stroke: var(--muted); stroke-width: 2.2; fill: none; stroke-dasharray: 3 4; stroke-linecap: round; }
.marca-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.marca-nombre { font: 800 1.3rem/1 var(--font-display); letter-spacing: -0.02em; }
.marca-nombre b { color: var(--accent); font-weight: 800; }
.marca-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 4px; }

.buscar {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 520px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 42px;
  color: var(--muted);
}
.buscar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.buscar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--fg);
  height: 100%;
}
.buscar kbd {
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}
.top-acc { display: flex; align-items: center; gap: 6px; flex: none; }
.estado {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted);
  font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.estado .ic { width: 15px; height: 15px; }
.estado-ok .ic { color: var(--ok); stroke-width: 2.4; }
.estado-guardando .ic { animation: girar 1s linear infinite; }
.estado-error, .estado-conflicto, .estado-local { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.estado-clave { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
@keyframes girar { to { transform: rotate(-360deg); } }

/* ---------- cuerpo ---------- */
.shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}
.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.main {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  outline: none;
  scroll-behavior: smooth;
}
.vista {
  max-width: 880px;
  margin-inline: auto;
  padding: 28px clamp(16px, 4vw, 44px) 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.scrim { display: none; }
.topbar .solo-movil { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar .solo-movil { display: inline-grid; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(88vw, 360px);
    border-radius: 0 var(--r) var(--r) 0;
    border-left: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    transform: translateX(-104%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .app.menu-abierto .sidebar { transform: none; }
  .app.menu-abierto .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--scrim);
  }
  .marca-sub { display: none; }
}
@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .buscar { order: 3; flex-basis: 100%; max-width: none; }
  .top-acc { margin-left: auto; }
  .buscar kbd { display: none; }
  .estado span { display: none; }
  .estado { width: 38px; padding: 0; justify-content: center; }
  .vista { padding-top: 20px; }
}
