:root {
  --inacap-red: #e30613;
  --inacap-dark-red: #c90000;
  --dark: #171717;
  --muted: #6f6f6f;
  --line: rgba(0, 0, 0, 0.12);
  --white: #ffffff;
  --soft: #f5f5f5;
  --success: #2eb872;
  --warning: #f2c94c;
  --full: #ee5b2a;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.20);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--dark);
  background: #eeeeee;
  display: grid;
  place-items: center;
}

.app-shell {
  width: min(100vw, 430px);
  min-height: 100svh;
  position: relative;
  overflow: hidden;
  background: #ffffff;
}

@media (min-width: 700px) {
  body { padding: 26px; }
  .app-shell {
    min-height: 850px;
    border-radius: 34px;
    box-shadow: var(--shadow);
  }
}

/* Welcome page */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(28px, 7vw, 42px) 24px 36px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.80) 0%, rgba(255,255,255,0.40) 48%, rgba(255,255,255,0.06) 100%),
    url("assets/studyhub-bg.png") center / cover no-repeat;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.65), transparent 32%);
  pointer-events: none;
}
.brand-card, .welcome-block, .login-cta { position: relative; z-index: 1; }
.brand-card {
  width: min(84%, 320px);
  min-height: 132px;
  display: grid;
  place-items: center;
  padding: 18px 22px;
  border-radius: 42px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}
.brand-logo { width: 100%; max-width: 260px; height: auto; display: block; }
.welcome-block {
  margin-top: clamp(46px, 12vh, 118px);
  text-align: center;
  width: 100%;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--inacap-red);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.welcome-block h1 {
  margin: 0;
  font-size: clamp(1.45rem, 7vw, 2rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.045em;
}
.welcome-text {
  max-width: 320px;
  margin: 14px auto 0;
  color: #333;
  font-size: 0.98rem;
  line-height: 1.4;
  font-weight: 600;
}
.primary-button, .action-button, .outline-button, .danger-button {
  border: 0;
  border-radius: 999px;
  min-height: 58px;
  padding: 0 24px;
  width: 100%;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.primary-button, .action-button {
  background: var(--inacap-red);
  color: white;
  box-shadow: 0 12px 28px rgba(227, 6, 19, 0.30);
}
.login-cta { width: min(76%, 310px); margin-top: auto; margin-bottom: clamp(18px, 5vh, 46px); }

/* INACAP institutional auth page */
.auth-page {
  width: min(100vw, 746px);
  min-height: 100svh;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: stretch;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
}
@media (min-width: 800px) {
  .auth-page { min-height: 894px; box-shadow: var(--shadow); }
}
.auth-card {
  width: 100%;
  min-height: 100svh;
  padding: clamp(42px, 7vw, 64px) clamp(28px, 10vw, 76px) 34px;
  display: flex;
  flex-direction: column;
}
.auth-logo-wrap { margin-bottom: clamp(72px, 12vh, 96px); }
.auth-logo { width: min(360px, 78vw); height: auto; display: block; }
.auth-form { display: grid; gap: 12px; }
.auth-label { font-size: clamp(1rem, 3.1vw, 1.25rem); margin-bottom: 24px; letter-spacing: 0.01em; }
.auth-form input[type="text"], .auth-form input[type="password"] {
  width: 100%; height: 44px; border: 1px solid #bcbcbc; border-radius: 0; padding: 0 10px;
  font-size: clamp(0.95rem, 2.8vw, 1.1rem); outline: none; background: #fff;
}
.auth-form input:focus { border-color: #d50000; box-shadow: 0 0 0 2px rgba(213, 0, 0, 0.08); }
.remember-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: clamp(1rem, 3vw, 1.2rem); }
.remember-row input { width: 18px; height: 18px; accent-color: #d50000; }
.form-error { min-height: 18px; margin: 6px 0 0; color: #d50000; font-size: 0.9rem; font-weight: 700; }
.auth-submit {
  width: 184px; height: 46px; border: 0; margin-top: 14px; background: #d50000; color: white; font-size: 1.05rem; cursor: pointer;
}
.recover-text { margin-top: 40px; font-size: clamp(1rem, 3vw, 1.15rem); }
.recover-text a, .auth-footer a { color: #d50000; text-decoration: none; }
.auth-footer { margin-top: auto; display: flex; gap: 28px; flex-wrap: wrap; font-size: 0.95rem; padding-top: 28px; }
@media (max-width: 420px) {
  .auth-card { padding-left: 26px; padding-right: 26px; }
  .auth-logo-wrap { margin-bottom: 66px; }
  .auth-submit { width: 100%; }
  .auth-footer { gap: 16px; justify-content: center; text-align: center; }
}

/* Internal app pages */
.app-page {
  padding: 22px 22px 34px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f6 100%);
  overflow-y: auto;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 34px; }
.topbar-logo { width: min(156px, 42vw); height: auto; display: block; }
.logout-button {
  color: var(--inacap-red); text-decoration: none; font-weight: 900; border: 1px solid rgba(227, 6, 19, 0.20);
  border-radius: 999px; padding: 9px 12px; font-size: 0.78rem; background: #fff;
}
.menu-hero { margin-top: 44px; }
.menu-hero p { margin: 0 0 6px; color: var(--muted); font-weight: 800; font-size: 1.05rem; }
.menu-hero h1, .page-title h1 { margin: 0; font-size: clamp(1.7rem, 8vw, 2.45rem); letter-spacing: -0.06em; line-height: 1.02; }
.app-tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 42px;
}
.app-tile {
  min-height: 156px;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  padding: 18px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 34px rgba(0,0,0,0.14);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.app-tile:active { transform: scale(0.98); }
.app-tile::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  right: -38px;
  bottom: -38px;
  background: rgba(255,255,255,0.16);
}
.tile-icon {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: rgba(255,255,255,0.22);
  display: grid;
  place-items: center;
  font-size: 1.45rem;
}
.app-tile strong { font-size: 1.05rem; line-height: 1.1; z-index: 1; }
.app-tile small { font-size: 0.78rem; line-height: 1.2; opacity: 0.86; z-index: 1; }
.red-tile { color: #fff; background: linear-gradient(145deg, #f51b23 0%, #bd0000 100%); }
.dark-tile { color: #fff; background: linear-gradient(145deg, #2b2b2b 0%, #080808 100%); }
.light-tile {
  grid-column: span 2;
  aspect-ratio: auto;
  min-height: 130px;
  color: #111;
  background: linear-gradient(145deg, #ffffff 0%, #eeeeee 100%);
  border: 1px solid var(--line);
}
.light-tile .tile-icon { background: rgba(227,6,19,0.12); }

.back-link { color: var(--inacap-red); font-weight: 900; text-decoration: none; display: inline-block; margin-bottom: 12px; }
.page-title { margin-bottom: 22px; }
.page-title p { color: var(--muted); line-height: 1.42; margin: 12px 0 0; font-weight: 600; }

.reservation-form, .survey-form { display: grid; gap: 12px; }
.reservation-form label, .survey-form label, .survey-form legend { font-weight: 900; }
.reservation-form select, .reservation-form input, .survey-form select, .survey-form textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 0 14px;
  font-size: 1rem; font-family: inherit; outline: none;
}
.survey-form textarea { padding-top: 12px; resize: vertical; }
.availability-box {
  min-height: 52px; border-radius: 16px; padding: 14px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-weight: 800;
}
.availability-box.ok { color: #0f7b45; background: rgba(46,184,114,0.10); border-color: rgba(46,184,114,0.35); }
.availability-box.bad { color: #b32121; background: rgba(227,6,19,0.08); border-color: rgba(227,6,19,0.28); }
.form-main-button { margin-top: 10px; }

.reservation-list { display: grid; gap: 14px; margin-bottom: 20px; }
.reservation-card {
  background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}
.reservation-card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.reservation-card p { margin: 4px 0; color: var(--muted); font-weight: 700; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.outline-button { background: #fff; color: var(--dark); border: 1px solid var(--line); box-shadow: none; min-height: 48px; }
.danger-button { background: #d50000; color: #fff; min-height: 48px; }
.full-width { width: 100%; }
.empty-state { text-align: center; color: var(--muted); font-weight: 700; padding: 34px 16px; background: #fff; border-radius: 20px; border: 1px dashed var(--line); }
.confirm-modal {
  position: fixed; inset: 0; display: none; place-items: center; padding: 20px; background: rgba(0,0,0,0.45); z-index: 10;
}
.confirm-modal.open { display: grid; }
.confirm-card { max-width: 360px; background: #fff; border-radius: 24px; padding: 20px; }
.confirm-card h2 { margin: 0 0 10px; }
.confirm-card p { color: var(--muted); line-height: 1.4; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.survey-form fieldset { border: 1px solid var(--line); border-radius: 20px; padding: 16px; background: #fff; }
.scale-help { color: var(--muted); margin: 8px 0 12px; font-weight: 800; }
.rating-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.rating-grid label input { position: absolute; opacity: 0; pointer-events: none; }
.rating-grid span {
  display: grid; place-items: center; height: 42px; border-radius: 12px; border: 1px solid var(--line); font-weight: 900; background: #f9f9f9;
}
.rating-grid input:checked + span { background: var(--inacap-red); color: #fff; border-color: var(--inacap-red); }
.success-message { min-height: 18px; color: #0f7b45; font-weight: 900; }

.legend { display: grid; gap: 8px; margin-bottom: 16px; background: #fff; padding: 14px; border-radius: 18px; border: 1px solid var(--line); }
.legend span { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; font-weight: 800; color: var(--muted); }
.legend-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.legend-dot.available { background: var(--success); }
.legend-dot.moderate { background: var(--warning); }
.legend-dot.full { background: var(--full); }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.map-building {
  min-height: 150px; border-radius: 24px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
  color: #111; border: 3px solid transparent; box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.map-building.available { background: rgba(46,184,114,0.16); border-color: var(--success); }
.map-building.moderate { background: rgba(242,201,76,0.24); border-color: var(--warning); }
.map-building.full { background: rgba(238,91,42,0.18); border-color: var(--full); }
.map-building strong { font-size: 1.05rem; }
.map-building .count { font-size: 2.1rem; font-weight: 900; }
.map-building .status { font-weight: 900; }


@media (max-width: 360px) {
  .app-tile-grid { grid-template-columns: 1fr; }
  .light-tile { grid-column: auto; }
}

@media (max-width: 360px) {
  .card-actions { grid-template-columns: 1fr; }
  .map-grid { grid-template-columns: 1fr; }
}

/* Desktop/tablet layout: usable on PC and still responsive on mobile */
@media (min-width: 900px) {
  body {
    padding: 32px;
    background: #e9e9e9;
  }

  .app-shell {
    width: min(1180px, calc(100vw - 64px));
    min-height: calc(100vh - 64px);
    border-radius: 30px;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.18);
  }

  .login-screen {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 56px 70px;
    background-position: center;
  }

  .login-screen::before {
    background:
      linear-gradient(90deg, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.62) 44%, rgba(255,255,255,0.16) 100%),
      radial-gradient(circle at 18% 20%, rgba(255,255,255,0.75), transparent 30%);
  }

  .brand-card {
    width: 420px;
    min-height: 170px;
    border-radius: 48px;
  }

  .brand-logo {
    max-width: 340px;
  }

  .welcome-block {
    max-width: 570px;
    text-align: left;
    margin-top: 76px;
  }

  .welcome-block h1 {
    font-size: clamp(2.2rem, 4vw, 3.8rem);
  }

  .welcome-text {
    margin-left: 0;
    max-width: 470px;
    font-size: 1.08rem;
  }

  .login-cta {
    width: 320px;
    margin-top: 56px;
    margin-bottom: 0;
  }

  .auth-page {
    width: min(900px, calc(100vw - 64px));
    min-height: calc(100vh - 64px);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.18);
  }

  .auth-card {
    min-height: calc(100vh - 64px);
    padding: 64px 88px 42px;
  }

  .app-page {
    padding: 36px 48px;
  }

  .topbar {
    margin-bottom: 44px;
  }

  .topbar-logo {
    width: 210px;
  }

  .logout-button {
    font-size: 0.92rem;
    padding: 11px 18px;
  }

  .menu-hero {
    margin-top: 50px;
  }

  .menu-hero p {
    font-size: 1.2rem;
  }

  .menu-hero h1,
  .page-title h1 {
    font-size: clamp(2.6rem, 4vw, 4rem);
  }

  .app-tile-grid {
    grid-template-columns: repeat(3, minmax(210px, 1fr));
    max-width: 920px;
  }

  .app-tile {
    min-height: 210px;
    aspect-ratio: 1 / 1;
    padding: 24px;
  }

  .light-tile {
    grid-column: auto;
  }

  .tile-icon {
    width: 58px;
    height: 58px;
    font-size: 1.8rem;
  }

  .app-tile strong {
    font-size: 1.28rem;
  }

  .app-tile small {
    font-size: 0.92rem;
  }

  .page-title {
    max-width: 820px;
  }

  .reservation-form,
  .survey-form {
    max-width: 720px;
  }

  .reservation-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .confirm-modal {
    position: fixed;
  }

  .legend {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
  }

  .map-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .map-building {
    min-height: 220px;
  }

  .map-building .count {
    font-size: 3rem;
  }
}

/* Touch-friendly survey controls */
.touch-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.touch-options label,
.wide-touch-option {
  position: relative;
  display: block;
}
.touch-options input,
.wide-touch-option input,
.rating-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.touch-options span,
.wide-touch-option span {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  background: #f9f9f9;
  font-weight: 900;
  cursor: pointer;
}
.touch-options input:checked + span,
.wide-touch-option input:checked + span {
  background: var(--inacap-red);
  color: #fff;
  border-color: var(--inacap-red);
  box-shadow: 0 10px 22px rgba(227, 6, 19, 0.22);
}
.wide-touch-option {
  margin-top: 10px;
}
.touch-grid-7 {
  margin-bottom: 0;
}

/* Selectable flow map */
.map-building {
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.map-building.selected {
  outline: 4px solid rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}
.building-selector-grid {
  grid-template-columns: 1fr;
}
.flow-detail {
  margin: 16px 0 18px;
}
.flow-detail-card {
  border-radius: 22px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid transparent;
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.flow-detail-card.available { background: rgba(46,184,114,0.14); border-color: var(--success); }
.flow-detail-card.moderate { background: rgba(242,201,76,0.22); border-color: var(--warning); }
.flow-detail-card.full { background: rgba(238,91,42,0.16); border-color: var(--full); }
.flow-detail-card p { margin: 0 0 4px; color: var(--muted); font-weight: 800; }
.flow-detail-card h2 { margin: 0; }
.flow-total { text-align: right; }
.flow-total strong { display: block; font-size: 2.2rem; line-height: 1; }
.flow-total span { font-weight: 900; }
.zone-flow-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}
.zone-flow-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.zone-flow-list strong { color: var(--inacap-red); }

@media (max-width: 380px) {
  .touch-options { grid-template-columns: 1fr; }
  .rating-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 900px) {
  .touch-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .building-selector-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-detail { max-width: 840px; }
}

.skip-survey {
  margin-bottom: 18px;
  background: #fff;
}
.reservation-form input[type="number"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

/* Mapa de necesidades */
.need-grid,
.recommendation-list {
  display: grid;
  gap: 14px;
}
.need-grid {
  grid-template-columns: 1fr 1fr;
}
.need-card,
.recommendation-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.08);
}
.need-card {
  min-height: 150px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: var(--dark);
}
.need-card span {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(227,6,19,0.10);
  font-size: 1.5rem;
}
.need-card strong {
  font-size: 1rem;
  line-height: 1.1;
}
.need-card small {
  color: var(--muted);
  font-weight: 800;
}
.recommendation-card {
  padding: 16px;
  display: grid;
  gap: 14px;
}
.recommendation-card h2 {
  margin: 4px 0 8px;
}
.recommendation-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}
.recommendation-building {
  color: var(--inacap-red) !important;
  font-weight: 900 !important;
}
.recommendation-status {
  display: inline-flex;
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
}
.recommendation-status.ok {
  background: rgba(46,184,114,0.14);
  color: #087943;
}
.recommendation-status.bad {
  background: rgba(227,6,19,0.10);
  color: #b10000;
}

@media (max-width: 360px) {
  .need-grid { grid-template-columns: 1fr; }
}

@media (min-width: 900px) {
  .need-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 950px;
  }
  .need-card { min-height: 190px; }
  .recommendation-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .recommendation-card {
    min-height: 310px;
    align-content: space-between;
  }
}
