:root {
  --teal-dark: #12343c;
  --emerald: #11695e;
  --accent: #fc9864;
  --accent-hover: #f0834b;
  --bg: #f2f5f3;
  --surface: #ffffff;
  --text: #16262a;
  --text-muted: #5a6d71;
  --border: #dce4e1;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 4px 18px rgba(18, 52, 60, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.hidden { display: none !important; }

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(74px + var(--safe-bottom));
}

.app-header {
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--emerald) 100%);
  color: #fff;
  padding: 16px 16px 18px;
  border-bottom-left-radius: 22px;
  border-bottom-right-radius: 22px;
  box-shadow: var(--shadow);
}

.header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  opacity: 0.85;
}

.status-pill {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-loading { background: rgba(255, 255, 255, 0.2); color: #fff; }
.status-active { background: rgba(16, 185, 129, 0.22); color: #d1fae5; border: 1px solid rgba(167, 243, 208, 0.45); }
.status-locked { background: rgba(252, 152, 100, 0.25); color: #ffedd5; border: 1px solid rgba(252, 152, 100, 0.6); }

.app-main {
  flex: 1;
  padding: 16px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.state-banner {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 14px;
}

.gate-card {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-icon { font-size: 28px; margin-bottom: 6px; }
.gate-title { margin: 0 0 6px; font-size: 17px; color: var(--teal-dark); }
.gate-text { margin: 0 0 14px; font-size: 14px; color: var(--text-muted); }

.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 520px) {
  .services-grid { grid-template-columns: 1fr 1fr; }
}

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  text-align: left;
}

.service-card:active { transform: scale(0.985); }
.service-card.is-soon { opacity: 0.72; cursor: default; }
.service-card.is-locked { border-style: dashed; }

.service-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.service-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}

.service-icon img { width: 100%; height: 100%; object-fit: cover; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.badge-ok { background: #e6f4f1; color: var(--emerald); }
.badge-sub { background: #fff0e6; color: #b84b14; }
.badge-soon { background: #e9eef0; color: #5a6d71; }

.service-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--teal-dark);
}

.service-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  flex: 1;
}

.service-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--emerald); color: #fff; }
.btn-accent { background: var(--accent); color: var(--teal-dark); }
.btn-secondary { background: var(--teal-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--teal-dark); border: 1.5px solid var(--border); }

.realtor-card, .help-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.realtor-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.realtor-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--emerald);
  background: var(--teal-dark);
}

.realtor-name { margin: 0; font-size: 18px; color: var(--teal-dark); }
.realtor-role { margin: 3px 0 0; font-size: 13.5px; color: var(--emerald); font-weight: 600; }
.realtor-bio { margin: 0 0 16px; font-size: 14.5px; color: var(--text); }
.realtor-actions { display: flex; flex-direction: column; gap: 10px; }

.help-status-card h3 { margin: 0 0 6px; color: var(--teal-dark); }
.help-status-text { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; }
.help-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.faq-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
}

.faq-item summary {
  font-weight: 600;
  color: var(--teal-dark);
  cursor: pointer;
}

.faq-item p {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  z-index: 50;
}

.tab-btn {
  background: none;
  border: none;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active { color: var(--emerald); }
.tab-icon { font-size: 20px; line-height: 1; }

.iframe-modal {
  position: fixed;
  inset: 0;
  background: var(--surface);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.iframe-bar {
  height: 50px;
  background: var(--teal-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 10px;
}

.iframe-back {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.iframe-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iframe-ext {
  color: var(--accent);
  text-decoration: none;
  font-size: 18px;
  padding: 4px 8px;
}

.service-frame {
  flex: 1;
  width: 100%;
  border: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--teal-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  z-index: 120;
  max-width: 90vw;
  text-align: center;
}
