@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Sora:wght@600;700&display=swap');

:root {
  --rj-ink: #0b1c2c;
  --rj-navy: #14324d;
  --rj-steel: #1f4b6e;
  --rj-mist: #e8eef4;
  --rj-cloud: #f3f6f9;
  --rj-amber: #e8a317;
  --rj-amber-deep: #c4840c;
  --rj-teal: #1aa6a0;
  --rj-text: #152433;
  --rj-muted: #5c6f82;
  --rj-border: rgba(20, 50, 77, 0.12);
  --rj-shadow: 0 10px 30px rgba(11, 28, 44, 0.12);
  --rj-radius: 1rem;
  --rj-font-display: "Sora", sans-serif;
  --rj-font-body: "Figtree", sans-serif;
  --nav-h: 64px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--rj-font-body);
  color: var(--rj-text);
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}

#gestor-shell[hidden],
#drive-shell[hidden],
#app[hidden] {
  display: none !important;
}

body.pwa-login-active {
  overflow: hidden;
  overscroll-behavior: none;
}

body.pwa-login-active #app {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

body.pwa-app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

body.pwa-app #app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pwa-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rj-border);
}

.pwa-header h1 {
  margin: 0;
  font-family: var(--rj-font-display);
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.pwa-header .back-btn {
  border: none;
  background: var(--rj-mist);
  color: var(--rj-navy);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.pwa-main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--tab-h) + var(--safe-b));
}

.pwa-main.no-tabs {
  padding-bottom: calc(1rem + var(--safe-b));
}

.pwa-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--rj-border);
  padding-bottom: var(--safe-b);
  height: calc(var(--tab-h) + var(--safe-b));
}

.pwa-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.4rem;
  border: none;
  background: none;
  color: var(--rj-muted);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.pwa-tab.active {
  color: var(--rj-steel);
}

.pwa-tab .icon { font-size: 1.25rem; line-height: 1; }

.pwa-tab .badge-dot {
  position: absolute;
  top: 6px;
  margin-left: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
}

.card {
  background: #fff;
  border-radius: var(--rj-radius);
  box-shadow: var(--rj-shadow);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card h2, .card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--rj-font-display);
  font-size: 1rem;
}

.muted { color: var(--rj-muted); font-size: 0.875rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border: none;
  border-radius: 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--rj-steel), var(--rj-navy));
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #1aa6a0, #148f8a);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, var(--rj-amber), var(--rj-amber-deep));
  color: #fff;
}

.btn-danger {
  background: #c0392b;
  color: #fff;
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--rj-border);
  color: var(--rj-navy);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field { margin-bottom: 0.85rem; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--rj-muted);
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--rj-border);
  border-radius: 0.65rem;
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
}

.field textarea { min-height: 72px; resize: vertical; }

.list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: none;
  background: #fff;
  border-radius: var(--rj-radius);
  box-shadow: var(--rj-shadow);
  margin-bottom: 0.5rem;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.list-item .row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.list-item .row2 {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--rj-muted);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-pendente { background: #fff3cd; color: #856404; }
.badge-aprovada { background: #d1ecf1; color: #0c5460; }
.badge-paga { background: #d4edda; color: #155724; }
.badge-recusada { background: #f8d7da; color: #721c24; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.alert-error { background: #fdecea; color: #c0392b; }
.alert-success { background: #e8f8f5; color: #117a65; }
.alert-info { background: #eaf4fb; color: #1f4b6e; }
.alert-warn { background: #fff8e6; color: #856404; }

.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
}

/* Login compacto — igual ao app Android */
.rj-login-wrap {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #EEF2F7;
}

.rj-login-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #0F2A4A 0%, #163A63 50%, #1E4A7A 100%);
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 22px;
}

.rj-login-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.rj-login-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #C9D7E8;
  line-height: 1.35;
}

.rj-login-card {
  flex: 1;
  min-height: 0;
  margin: -12px 0 0;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 16px rgba(11, 28, 44, 0.08);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rj-login-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0F2A4A;
}

.rj-login-card .d-field,
.rj-login-card .field {
  margin-top: 12px;
}

.rj-login-card input,
.rj-login-card select {
  font-size: 16px;
}

.rj-login-card .d-btn-primary,
.rj-login-card .btn-primary {
  margin-top: 16px;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand img {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  box-shadow: var(--rj-shadow);
}

.login-brand h1 {
  font-family: var(--rj-font-display);
  margin: 0.75rem 0 0.25rem;
  font-size: 1.5rem;
}

.pix-box {
  background: var(--rj-cloud);
  border: 1px dashed var(--rj-border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  word-break: break-all;
  font-size: 0.8rem;
  font-family: monospace;
  max-height: 120px;
  overflow-y: auto;
}

.qr-reader {
  width: 100%;
  border-radius: var(--rj-radius);
  overflow: hidden;
  margin: 0.5rem 0;
}

.filter-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
}

.filter-tabs button {
  flex-shrink: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--rj-border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--rj-muted);
}

.filter-tabs button.active {
  background: var(--rj-navy);
  color: #fff;
  border-color: var(--rj-navy);
}

.spinner {
  text-align: center;
  padding: 2rem;
  color: var(--rj-muted);
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--rj-muted);
}

.banner-qr {
  background: linear-gradient(135deg, #1aa6a0, #148f8a);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--rj-radius);
  margin-bottom: 0.75rem;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.install-hint {
  font-size: 0.8rem;
  color: var(--rj-muted);
  text-align: center;
  margin-top: 1rem;
  line-height: 1.4;
}

@media (min-width: 768px) {
  body.pwa-app {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
  }
}
