@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  --wine: #781d2b;
  --wine-dark: #591521;
  --wine-soft: #f7eaed;
  --ink: #262326;
  --muted: #777177;
  --line: #ece7e8;
  --surface: #fff;
  --bg: #faf8f8;
  --shadow: 0 12px 34px rgba(57, 24, 30, .07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', Arial, sans-serif;
  min-height: 100vh;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

/* Barra superior */

.topbar {
  position: relative;
  z-index: 10000;
  height: 82px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 5vw, 76px);
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  font-family: Manrope, sans-serif;
  font-size: 15px;
  letter-spacing: -.35px;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.connection {
  font-size: 12px;
  color: #5d665e;
  display: flex;
  align-items: center;
  gap: 7px;
}

.connection i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #39a66a;
}

.connection.offline i {
  background: #c44;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  background: #fff;
  color: var(--wine);
  font-weight: 700;
  cursor: pointer;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--wine-soft);
  color: var(--wine);
  font-weight: 700;
}

/* Navegación del módulo en la misma barra */

.module-navigation {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
}

.module-navigation[hidden] {
  display: none !important;
}

.module-navigation button {
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  background: var(--wine-soft);
  color: var(--wine);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#appTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

/* Pantalla principal */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 28px 20px;
}

.welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 32px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--wine);
  margin: 0 0 10px;
}

.welcome h1 {
  font-family: Manrope, sans-serif;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -1.4px;
  margin: 0;
}

.welcome-subtitle {
  color: var(--muted);
  font-size: 15px;
  margin: 10px 0 0;
}

.date-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 15px;
  color: #6e666b;
  font-size: 12px;
  white-space: nowrap;
}

/* Tarjetas de módulos */

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 27px;
  position: relative;
  display: flex;
  gap: 19px;
  min-height: 250px;
  box-shadow: 0 3px 12px rgba(50, 20, 25, .02);
  transition: transform .18s ease, box-shadow .18s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.module-orders {
  border-top: 3px solid #a04a58;
}

.module-delivery {
  border-top: 3px solid #6c927b;
}

.module-admin {
  border-top: 3px solid #b9a16a;
}

.module-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--wine-soft);
  color: var(--wine);
}

.module-delivery .module-icon {
  background: #eaf3ed;
  color: #397452;
}

.module-admin .module-icon {
  background: #f5f0e4;
  color: #8a7135;
}

.module-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-content {
  min-width: 0;
  padding-bottom: 36px;
}

.module-kicker {
  font-size: 10px;
  letter-spacing: 1.3px;
  font-weight: 700;
  color: #93888d;
}

.module-content h2 {
  font-family: Manrope, sans-serif;
  font-size: 22px;
  letter-spacing: -.5px;
  margin: 8px 0;
}

.module-content p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0;
  max-width: 320px;
}

.primary-button {
  position: absolute;
  bottom: 25px;
  left: 94px;
  border: 0;
  background: var(--wine);
  color: #fff;
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  gap: 18px;
  align-items: center;
  transition: background .15s;
}

.primary-button:hover {
  background: var(--wine-dark);
}

.primary-button span {
  font-size: 17px;
  line-height: 10px;
}

.device-tag {
  position: absolute;
  right: 20px;
  top: 18px;
  border-radius: 6px;
  background: #f5f1f2;
  color: #8a7d82;
  font-size: 10px;
  padding: 6px 8px;
}

.mobile-tag {
  background: #eaf3ed;
  color: #397452;
}

/* Nota móvil y pie */

.mobile-note {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: #f5f0f1;
  border: 1px solid #eee1e4;
  border-radius: 13px;
  padding: 16px 18px;
  margin-top: 22px;
}

.note-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  color: var(--wine);
  font-size: 19px;
  flex-shrink: 0;
}

.mobile-note strong {
  font-size: 12px;
}

.mobile-note p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin: 4px 0 0;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 20px 0 6px;
  margin-top: 35px;
  color: #91878c;
  font-size: 11px;
}

.footer b {
  padding: 0 5px;
  color: #c4b9bd;
}

.module-view {
  margin-top: 10px;
}

.back-button {
  border: 0;
  background: transparent;
  color: var(--wine);
  font-weight: 700;
  font-size: 13px;
  padding: 12px 0;
  cursor: pointer;
}

.view-panel {
  margin-top: 15px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 35px;
  max-width: 760px;
}

.view-symbol {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--wine-soft);
  display: grid;
  place-items: center;
  color: var(--wine);
  font-size: 23px;
  margin-bottom: 24px;
}

.view-panel h2 {
  font-family: Manrope, sans-serif;
  font-size: 28px;
  margin: 0 0 10px;
}

.view-panel > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.notice {
  margin-top: 24px;
  border-radius: 10px;
  padding: 15px;
  background: #faf6f6;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  line-height: 1.5;
}

.notice strong {
  color: var(--wine);
}

.notice span {
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #292326;
  color: #fff;
  padding: 12px 17px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  transition: .2s;
  z-index: 10001;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Aplicación embebida: ocupa todo debajo de la barra superior */

.app-container {
  position: fixed;
  top: 82px;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  background: #fff;
}

.app-container[hidden] {
  display: none !important;
}

/* La barra interna anterior ya no se utiliza */

.app-toolbar {
  display: none !important;
}

#appFrame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: #fff;
}

/* Escritorio */

@media (min-width: 1000px) {
  .module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .module-card {
    padding: 24px 22px;
    min-height: 275px;
    display: block;
  }

  .module-icon {
    margin-bottom: 20px;
  }

  .module-content {
    padding-bottom: 42px;
  }

  .primary-button {
    left: 22px;
    bottom: 24px;
  }

  .device-tag {
    top: 25px;
    right: 18px;
  }

  .module-content p {
    max-width: none;
  }
}

/* Móvil */

@media (max-width: 700px) {
  .topbar {
    height: 70px;
    padding: 0 12px;
    gap: 8px;
  }

  .brand {
    gap: 7px;
  }

  .brand-mark {
    width: 35px;
    height: 35px;
  }

  .brand-copy strong {
    font-size: 11px;
  }

  .brand-copy small {
    display: none;
  }

  .connection {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .module-navigation {
    gap: 6px;
  }

  .module-navigation button {
    padding: 8px;
    font-size: 11px;
  }

  #appTitle {
    font-size: 12px;
  }

  .page {
    padding: 31px 17px 16px;
  }

  .welcome {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 23px;
    gap: 15px;
  }

  .welcome h1 {
    font-size: 29px;
  }

  .welcome-subtitle {
    font-size: 13px;
    max-width: 310px;
    line-height: 1.5;
  }

  .date-chip {
    padding: 8px 11px;
  }

  .module-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .module-card {
    min-height: 220px;
    padding: 22px 20px;
    gap: 14px;
    border-radius: 15px;
  }

  .module-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .module-content h2 {
    font-size: 20px;
  }

  .module-content p {
    font-size: 12px;
  }

  .primary-button {
    left: 76px;
    bottom: 20px;
  }

  .device-tag {
    right: 12px;
    top: 12px;
    font-size: 9px;
  }

  .desktop-only {
    display: none;
  }

  .module-delivery {
    min-height: 225px;
  }

  .mobile-note {
    margin-top: 17px;
    padding: 14px;
  }

  .footer {
    margin-top: 27px;
    font-size: 10px;
  }

  .view-panel {
    padding: 24px 20px;
  }

  .view-panel h2 {
    font-size: 24px;
  }

  .app-container {
    top: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}