/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:     rgba(239, 5, 5, 1);
  --primary-dk:  rgba(200, 0, 0, 1);
  --primary-lt:  #fee2e2;
  --bg:          #f1f5f9;
  --card:        #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --muted:       #64748b;
  --red:         #ef4444;
  --red-lt:      #fee2e2;
  --red-dk:      #b91c1c;
  --yellow:      #f59e0b;
  --yellow-lt:   #fef3c7;
  --yellow-dk:   #92400e;
  --green:       #10b981;
  --green-lt:    #d1fae5;
  --green-dk:    #065f46;
  --radius:      10px;
  --shadow:      0 1px 6px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-md);
  animation: popIn .25s ease;
  width: 320px;
  min-width: 320px;
}

.loading-logo {
  width: 140px;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .7; transform: scale(.97); }
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #fecaca;
  border-top-color: rgba(239, 5, 5, 1);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  text-align: center;
  min-height: 1.4rem;
  width: 100%;
}

.loading-phrase {
  color: var(--primary);
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.2rem;
  width: 100%;
  animation: fadePhrase .5s ease;
}

@keyframes fadePhrase {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── LOGIN ── */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('../image/bg-body.jpg');
  background-repeat: repeat;
  background-size: auto;
}

.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  width: 100%;
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  animation: popIn .35s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.login-logo img {
  width: 180px;
  max-width: 100%;
}

.login-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #000000;
  margin-bottom: .25rem;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
  margin-bottom: 1.75rem;
}

.input-group {
  position: relative;
  margin-bottom: .875rem;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: #f8fafc;
  transition: border-color .2s, box-shadow .2s;
}

input:focus {
  outline: none;
  border-color: rgba(239, 5, 5, 1);
  box-shadow: 0 0 0 3px rgba(239, 5, 5, .15);
  background: white;
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: rgba(239, 5, 5, 1);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

button:hover:not(:disabled) { background: rgba(200, 0, 0, 1); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .6; cursor: not-allowed; }

.error {
  color: var(--red-dk);
  font-size: .875rem;
  text-align: center;
  margin-top: .75rem;
  padding: .75rem 1rem;
  background: var(--red-lt);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
}

.erro-suporte-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  background: #25d366;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: .82rem;
  text-decoration: none;
  transition: background .2s;
}

.erro-suporte-link:hover { background: #1ebe5d; }
.erro-suporte-link svg { width: 15px; height: 15px; }

.login-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  color: #ffffff;
  font-size: .8rem;
  text-align: center;
  background: #000000;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  z-index: 50;
}

/* ── LOGIN LINKS ── */
.login-links {
  text-align: center;
  margin-top: 1rem;
}

.login-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: .82rem;
  text-decoration: none;
  transition: color .2s;
}

.login-links a:hover { color: var(--primary); }
.login-links a svg { width: 14px; height: 14px; }

.link-esqueci-inline {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  color: var(--primary) !important;
  font-weight: 600;
  font-size: .82rem;
  text-decoration: none;
  transition: opacity .2s;
}

.link-esqueci-inline:hover { opacity: .75; }
.link-esqueci-inline svg { width: 14px; height: 14px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 1.75rem 1.75rem 2rem;
  width: 100%;
  max-width: 420px;
  animation: popIn .25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.modal-title svg { width: 20px; height: 20px; color: var(--primary); }

.modal-fechar {
  width: auto;
  padding: 5px;
  background: none;
  border: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-fechar:hover { background: #f1f5f9; color: var(--text); }
.modal-fechar svg { width: 18px; height: 18px; }

.modal-desc {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.modal-feedback {
  font-size: .82rem;
  padding: .6rem .8rem;
  border-radius: 6px;
  margin-bottom: .75rem;
}

.modal-feedback-erro {
  background: var(--red-lt);
  color: var(--red-dk);
}

.modal-success {
  text-align: center;
  padding: .5rem 0 .25rem;
}

.modal-success-icon {
  background: var(--green-lt);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .875rem;
}
.modal-success-icon svg { width: 28px; height: 28px; color: var(--green); }

.modal-success-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .5rem;
}

.modal-success-desc {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.6;
  margin: 0 0 .75rem;
}

.modal-email-enviado {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}
.modal-email-enviado svg { width: 15px; height: 15px; color: var(--primary); }

/* ── BOTÃO VOLTAR (reset-senha.html) ── */
.btn-voltar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s;
  margin-top: 1rem;
}

.btn-voltar:hover { background: var(--primary-dk); }
.btn-voltar-green { background: var(--green); }
.btn-voltar-green:hover { background: #0a9e6e; }

/* ── DASH HEADER ── */
.dash-header {
  background: var(--primary);
  color: white;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.header-logo {
  height: 36px;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.header-cliente {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-nome {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-doc {
  font-size: .78rem;
  opacity: .8;
}

.btn-sair {
  width: auto;
  padding: 6px 14px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  gap: 5px;
  flex-shrink: 0;
}

.btn-sair:hover:not(:disabled) { background: rgba(255,255,255,.35); }
.btn-sair svg { width: 15px; height: 15px; }

/* ── NAV TABS ── */
.dash-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  position: sticky;
  top: 57px;
  z-index: 99;
  scrollbar-width: none;
}

.dash-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  width: auto;
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: .75rem .5rem;
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  position: relative;
}

.nav-tab svg { width: 20px; height: 20px; }
.nav-tab:hover:not(:disabled) { color: #475569 !important; background: #f1f5f9 !important; }

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 20px);
  background: var(--red);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── MAIN CONTENT ── */
.dash-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dash-section {
  animation: fadeUp .3s ease both;
  padding-top: .25rem;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: none;
}

/* ── CARDS GRID ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .875rem;
}

.data-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: box-shadow .2s;
}

.data-card:hover { box-shadow: var(--shadow-md); }

.card-headline {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
}

.card-row span:last-child { color: var(--text); font-weight: 500; }

.card-desc {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .25rem;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
}

.badge-green  { background: var(--green-lt);  color: var(--green-dk); }
.badge-red    { background: var(--red-lt);    color: var(--red-dk); }
.badge-yellow { background: var(--yellow-lt); color: var(--yellow-dk); }
.badge-gray   { background: #f1f5f9;          color: #475569; }
.badge-ativo  { background: #dcfce7;          color: #15803d; }
.badge-inativo{ background: #f1f5f9;          color: #64748b; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.hidden { display: none; }

/* ── BOLETOS ── */
.boleto-grupo { margin-bottom: 1.25rem; }

.grupo-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .88rem;
  font-weight: 700;
  padding: .45rem .85rem;
  border-radius: 6px;
  margin-bottom: .75rem;
}

.grupo-label svg { width: 16px; height: 16px; }
.grupo-label.atrasado   { background: var(--red-lt);    color: var(--red-dk); }
.grupo-label.aberto     { background: var(--yellow-lt); color: var(--yellow-dk); }
.grupo-label.pago       { background: var(--green-lt);  color: var(--green-dk); }
.grupo-label.grupo-verde { background: var(--green-lt);  color: var(--green-dk); }
.grupo-label.grupo-cinza { background: #f1f5f9;          color: #475569; }

.grupo-count {
  background: rgba(0,0,0,.12);
  border-radius: 12px;
  padding: 1px 7px;
  font-size: .72rem;
}

.grupo-toggle {
  cursor: pointer;
  user-select: none;
}

.grupo-chevron {
  margin-left: auto;
  width: 16px !important;
  height: 16px !important;
  transition: transform .25s ease;
  flex-shrink: 0;
}

.grupo-toggle.open .grupo-chevron {
  transform: rotate(180deg);
}

.grupo-body {
  overflow: hidden;
  transition: max-height .3s ease, opacity .3s ease, margin .3s ease;
  max-height: 2000px;
  opacity: 1;
  margin-bottom: .75rem;
}

.grupo-body.collapsed {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

/* boleto card */
.boleto-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.boleto-card.atrasado { border-left: 4px solid var(--red); }
.boleto-card.aberto   { border-left: 4px solid var(--yellow); }
.boleto-card.pago     { border-left: 4px solid var(--green); }

.boleto-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
}

.boleto-valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.boleto-meta {
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.linha-digitavel {
  font-size: .75rem;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .4rem .6rem;
  word-break: break-all;
  font-family: monospace;
}

.boleto-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .25rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  width: auto;
}

.btn-action svg { width: 14px; height: 14px; }

.btn-primary-action {
  background: var(--primary);
  color: white;
  border: none;
}
.btn-primary-action:hover:not(:disabled) { background: var(--primary-dk); }

.btn-outline-action {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline-action:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 2rem;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.empty-state svg { width: 32px; height: 32px; opacity: .4; }

.empty-grupo {
  color: var(--muted);
  font-size: .85rem;
  font-style: italic;
  padding: .25rem .5rem;
}

/* ── FOOTER ── */
.dash-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: .65rem 1rem;
  font-size: .8rem;
  color: #ffffff;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  z-index: 50;
}

.footer-serenas-link {
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .2s;
}

.footer-serenas-link:hover { opacity: .75; }

.dash-main { padding-bottom: 4rem; }

/* ── MOBILE ── */
@media (max-width: 600px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .sair-label { display: none; }

  /* nav fixo no topo no mobile */
  .dash-nav {
    position: fixed;
    top: var(--header-h, 58px);
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 98;
    border-top: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
  }

  /* compensa nav fixo — ajustado pelo JS */
  .dash-main {
    padding-top: 60px;
  }

  /* espaço para o nav fixo na parte inferior */
  .dash-main {
    padding-bottom: 7rem;
  }

  .btn-action span { display: none; }
  .btn-action { padding: 8px; }
  .boleto-actions { gap: .35rem; }

  .loading-box { padding: 2rem 1.5rem; margin: 1rem; min-width: unset; width: 90%; }

  /* footer uma linha no mobile */
  .dash-footer,
  .login-footer {
    font-size: .62rem;
    padding: .45rem .5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    justify-content: center;
    gap: 0;
  }
}

@media (max-width: 360px) {
  .nav-tab span { display: none; }
  .nav-tab { min-width: 56px; }
}
