:root {
  /* Overridden at runtime from tenant config */
  --brand-primary: #25292c;
  --brand-primary-dark: #000000;
  --brand-primary-light: #3a4045;
  --brand-secondary: #b5121b;
  --brand-secondary-dark: #8d0008;
  --brand-gradient-start: #000000;
  --brand-gradient-stop: #25292c;
  --tabbar-height: 58px;
  --header-height: 56px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

.app-body {
  margin: 0;
  background: #f4f5f7;
  color: #1f2329;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button { font-family: inherit; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-stop));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-header__back { color: #fff !important; font-size: 1.4rem; padding: .1rem .4rem; text-decoration: none; }
.app-header__logo { height: 30px; max-width: 160px; object-fit: contain; }
.app-header__title { font-weight: 600; font-size: 1.05rem; }

/* ---------- Main scroll area ---------- */
.app-main {
  min-height: calc(100vh - var(--tabbar-height));
  padding: 1rem;
  padding-bottom: calc(var(--tabbar-height) + 1.25rem + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.app-main--full { padding: 0; max-width: 100%; }

/* ---------- Bottom tab bar ---------- */
.app-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: #ffffff;
  border-top: 1px solid #e6e8eb;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.app-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #8a9099;
  font-size: .72rem;
  padding: 6px 0;
}
.app-tabbar__item i { font-size: 1.3rem; }
.app-tabbar__item.active { color: var(--brand-primary); }

/* ---------- Brand helpers ---------- */
.btn-brand {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); color: #fff; }
.btn-brand-outline { color: var(--brand-primary); border: 1px solid var(--brand-primary); background: transparent; }
.text-brand { color: var(--brand-primary) !important; }
.bg-brand { background: var(--brand-primary) !important; color: #fff; }
.bg-brand-gradient { background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-stop)) !important; color: #fff; }

a { color: var(--brand-primary); }

/* ---------- Cards / lists ---------- */
.tile {
  display: flex;
  align-items: center;
  gap: .9rem;
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  color: inherit;
  text-decoration: none;
}
.tile:active { transform: scale(.995); }
.tile__icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: rgba(0,0,0,.05);
  color: var(--brand-primary);
  font-size: 1.3rem;
  flex-shrink: 0;
}
.tile__body { flex: 1; min-width: 0; }
.tile__title { font-weight: 600; margin: 0; }
.tile__subtitle { color: #8a9099; font-size: .85rem; margin: 0; }
.tile__chev { color: #c2c7cd; }

/* ---------- Auth screens ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--brand-gradient-start), var(--brand-gradient-stop));
  color: #fff;
  padding: 2rem 1.5rem calc(2rem + env(safe-area-inset-bottom));
}
.auth-screen .auth-logo { max-height: 90px; max-width: 75%; margin: 1.5rem auto 1rem; display: block; }
.auth-card { background: #fff; color: #1f2329; border-radius: 18px; padding: 1.5rem; margin-top: auto; }
.auth-fsp { font-size: .72rem; opacity: .8; text-align: center; margin-top: 1rem; }

/* ---------- Panic ---------- */
.panic-btn {
  border: none;
  width: 100%;
  background: transparent;
  padding: 0;
  margin-bottom: .75rem;
}
.panic-btn img { width: 100%; border-radius: 16px; display: block; }
.panic-fallback {
  border-radius: 16px;
  padding: 1.4rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.panic-fallback--primary { background: var(--brand-secondary); }
.panic-fallback--assist { background: var(--brand-primary); }

.countdown-ring {
  width: 220px; height: 220px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 2rem auto;
  background: var(--brand-secondary);
  color: #fff;
  font-size: 4rem;
  font-weight: 800;
  box-shadow: 0 0 0 12px rgba(181,18,27,.2);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%{transform:scale(1)} 50%{transform:scale(1.04)} 100%{transform:scale(1)} }

/* ---------- Chat ---------- */
.chat-thread { display: flex; flex-direction: column; gap: .5rem; padding-bottom: 80px; }
.chat-bubble { max-width: 80%; padding: .6rem .85rem; border-radius: 14px; font-size: .92rem; word-wrap: break-word; }
.chat-bubble--in { align-self: flex-start; background: #fff; border: 1px solid #ececec; }
.chat-bubble--out { align-self: flex-end; background: var(--brand-primary); color: #fff; }
.chat-bubble img { max-width: 100%; border-radius: 10px; }
.chat-input-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; gap: .5rem; padding: .6rem;
  padding-bottom: calc(.6rem + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #e6e8eb;
}

/* ---------- Misc ---------- */
.app-busy {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4);
}
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #8a9099; margin: 1.25rem 0 .5rem; }
.home-hero { border-radius: 18px; overflow: hidden; margin-bottom: 1rem; position: relative; }
.home-hero img { width: 100%; display: block; }
.home-hero__caption { position: absolute; inset: auto 0 0 0; padding: 1rem; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-weight: 600; }
.empty-state { text-align: center; color: #8a9099; padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.avatar-lg { width: 86px; height: 86px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.html-content img { max-width: 100%; height: auto; }
.html-content { line-height: 1.5; }
