/* ── Reset & variáveis ────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:           var(--tg-theme-bg-color,            #ffffff);
  --text:         var(--tg-theme-text-color,           #000000);
  --hint:         var(--tg-theme-hint-color,           #999999);
  --link:         var(--tg-theme-link-color,           #2481cc);
  --btn-bg:       var(--tg-theme-button-color,         #2481cc);
  --btn-text:     var(--tg-theme-button-text-color,    #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color,   #f1f1f1);
  --tab-h:        58px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

/* ── Telas ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
}
.screen.active { display: flex; }

/* ── Tela: carregando ────────────────────────────────────────────────────── */
#screen-loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--btn-bg);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tela: erro ──────────────────────────────────────────────────────────── */
#screen-error {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
}
.error-icon { font-size: 52px; margin-bottom: 4px; }
#screen-error h2 { font-size: 18px; font-weight: 600; }

/* ── Tela: app principal ─────────────────────────────────────────────────── */
#screen-app {
  flex-direction: column;
}

/* ── Área de conteúdo ────────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
}

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

/* ── Cabeçalho da página ─────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
}
.page-header .hint {
  margin-top: 2px;
  font-size: 13px;
}

/* ── Card placeholder ────────────────────────────────────────────────────── */
.placeholder-card {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.placeholder-icon { font-size: 36px; }
.placeholder-card p { font-size: 14px; }

/* ── Texto de dica (cinza) ───────────────────────────────────────────────── */
.hint { color: var(--hint); font-size: 13px; }

/* ── Barra de abas ───────────────────────────────────────────────────────── */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--secondary-bg);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: stretch;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--hint);
  padding: 6px 4px;
  transition: color 0.15s ease;
}
.tab-btn.active  { color: var(--btn-bg); }
.tab-btn:active  { opacity: 0.7; }

.tab-icon  { font-size: 21px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
