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

:root {
  --bg: #f4f7f8;
  --bg-soft: #eef5f4;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --primary-ink: #fff;
  --primary-soft: #ecfdf5;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
  --radius: 12px;
  --space-x: 0.45rem;
  --space-y: 0.35rem;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 420px at 12% -10%, rgba(15, 118, 110, 0.10), transparent 60%),
    radial-gradient(900px 360px at 88% 0%, rgba(14, 165, 233, 0.08), transparent 55%),
    linear-gradient(180deg, #f8fbfb 0%, var(--bg) 42%, #eef2f5 100%);
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.2rem var(--space-x) 0.15rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.shell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
  padding: 0;
  min-height: 2rem;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(248, 251, 251, 0.96) 0%, rgba(244, 247, 248, 0.92) 100%);
  backdrop-filter: blur(8px);
}

.shell-head__brand {
  min-width: 0;
  flex: 0 1 auto;
}

.shell-head h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.shell-head p[hidden] {
  display: none !important;
}

.shell-head__nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  margin-left: auto;
  min-width: 0;
}

.shell-head__nav .hub-tabs {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.shell-head__nav .btn {
  flex-shrink: 0;
  white-space: nowrap;
  height: 1.75rem;
  padding: 0 0.55rem;
  font-size: 0.74rem;
  border-radius: 7px;
  gap: 0.25rem;
}

.shell-head__nav .btn i {
  font-size: 0.78rem;
}

.shell-head__actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 0.42rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn-sm {
  padding: 0.22rem 0.48rem;
  font-size: 0.74rem;
  border-radius: 7px;
  height: 1.75rem;
  line-height: 1;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary:hover {
  background: #0d9488;
}

.btn-outline:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.auth-gate {
  max-width: 380px;
  margin: 3rem auto 1.5rem;
  padding: 1.15rem 1.1rem 1rem;
  text-align: center;
}

.auth-gate__brand {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
}

.auth-gate__icon {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.auth-gate h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-gate p {
  color: var(--muted);
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.4;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.auth-form--pin {
  grid-template-columns: 1fr;
}

.auth-form input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  letter-spacing: 0.32em;
  text-align: center;
  font-size: 1.2rem;
  background: #fff;
}

.auth-form--pin .btn {
  width: 100%;
  padding: 0.65rem 0.9rem;
}

.auth-form.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.auth-error {
  margin: 0.55rem 0 0;
  color: #b91c1c;
  font-size: 0.84rem;
}

code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.08rem 0.3rem;
  border-radius: 5px;
  font-size: 0.84em;
}

/* Sticky narrow footer — flush to bottom with minimal margin */
.portal-footer {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.14rem var(--space-x) 0.16rem;
  text-align: center;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
}

.portal-footer p {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #64748b;
  line-height: 1.15;
}

.portal-footer a {
  color: inherit;
  text-decoration: none;
}

.portal-footer a:hover {
  color: var(--primary);
}

@media (max-width: 720px) {
  :root {
    --space-x: 0.35rem;
  }

  .shell {
    padding-top: 0.18rem;
  }

  .shell-head__nav {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.2rem;
  }

  .shell-head h1 {
    font-size: 0.95rem;
  }

  .auth-gate {
    margin-top: 1.5rem;
  }
}

/* Short viewports: keep header reachable and allow full vertical slide to footer */
@media (max-height: 640px) {
  html, body {
    height: auto;
    max-height: none;
    overflow-y: auto;
  }

  body {
    min-height: 100dvh;
  }

  .shell {
    flex: 1 0 auto;
    min-height: calc(100dvh - 2.2rem);
    overflow: visible;
  }

  .wa-app {
    min-height: 58vh;
    overflow: visible;
  }

  .hub-view {
    overflow: visible;
    height: auto;
  }

  .wa-chat,
  .tpl-layout {
    min-height: 52vh;
  }
}
