/* ============================================================================
   RateioSmart — Portal do Morador (/morador/)
   Alta legibilidade (publico geral e 55+), identidade #0B3C5D + #1CA7BC
   ============================================================================ */

:root {
  --navy-dark: #072840;
  --navy: #0B3C5D;
  --cyan: #1CA7BC;
  --cyan-dark: #138496;
  --bg: #F4F7FA;
  --card: #FFFFFF;
  --border: #DCE6EE;
  --text: #162938;
  --text-muted: #52677A;
  --success: #16794F;
  --success-bg: #E7F7EF;
  --danger: #B42318;
  --danger-bg: #FDECEC;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(11, 60, 93, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Header */
.topbar {
  background: var(--navy);
  color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(7, 40, 64, 0.22);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-logo {
  height: 40px;
  width: auto;
  background: #FFFFFF;
  padding: 4px 10px;
  border-radius: 8px;
  display: block;
}

.portal-badge {
  background: rgba(28, 167, 188, 0.24);
  border: 1px solid rgba(155, 231, 242, 0.55);
  color: #D9F7FC;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon-help {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-help:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Main */
.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 36px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.center-card {
  max-width: 560px;
  margin: 40px auto;
  padding: 36px 28px;
  text-align: center;
}

/* Login */
.login-wrapper {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.login-card {
  width: 100%;
  max-width: 540px;
  padding: 34px 30px;
}

.login-icon {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: #E6F6F9;
  color: var(--cyan-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: 1.85rem;
  color: var(--navy);
  text-align: center;
  line-height: 1.25;
}

.login-lead {
  margin: 0 0 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 1.05rem;
}

.field-label {
  display: block;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
  font-size: 1rem;
}

.field-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.15rem;
  border: 2px solid #C5D6E3;
  border-radius: 10px;
  color: var(--text);
  background: #FFFFFF;
}

.field-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(28, 167, 188, 0.2);
}

.field-hint {
  margin: 10px 0 18px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-dark);
}

.btn-cyan {
  background: var(--cyan);
  color: #FFFFFF;
}

.btn-cyan:hover:not(:disabled) {
  background: var(--cyan-dark);
}

.btn-outline {
  background: #FFFFFF;
  color: var(--navy);
  border-color: var(--navy);
}

.btn-outline-light {
  background: transparent;
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.6);
  min-height: 40px;
  padding: 6px 16px;
  font-size: 0.95rem;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-lg {
  padding: 15px 24px;
  font-size: 1.08rem;
}

.btn-block {
  width: 100%;
}

/* Alerts */
.alert {
  padding: 13px 16px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 16px;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #F7C7C5;
}

/* Unit Banner */
.unit-banner {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #FFFFFF;
  border-radius: var(--radius);
  padding: 24px 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.unit-brand {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #9BE7F2;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.unit-condo {
  margin: 0 0 4px;
  font-size: 1.65rem;
  line-height: 1.25;
}

.unit-ident {
  margin: 0;
  font-size: 1.1rem;
  color: #E2F4F8;
  font-weight: 600;
}

.unit-banner-controls {
  min-width: 260px;
}

.select-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #BFEBF2;
  margin-bottom: 6px;
}

.select-competencia {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  background: #FFFFFF;
  border: 2px solid #9BE7F2;
  border-radius: 10px;
  cursor: pointer;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  padding: 20px 22px;
  border-top: 5px solid var(--navy);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-cyan { border-top-color: var(--cyan); }
.kpi-navy { border-top-color: var(--navy); }
.kpi-pdf  { border-top-color: #16794F; }

.kpi-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.pdf-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* Details Grid */
.details-grid {
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 18px;
  margin-bottom: 20px;
}

.section-card {
  padding: 22px 24px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--navy);
}

.subsection-title {
  margin: 18px 0 10px;
  font-size: 1rem;
  color: var(--navy);
}

/* Meter readings + photos */
.leituras-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.leitura-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.leitura-chassi {
  font-weight: 800;
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.leitura-nums {
  font-size: 0.98rem;
  color: var(--text);
  margin-bottom: 10px;
}

.meter-photo-wrap {
  margin-top: 10px;
}

.meter-photo {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

.meter-photo-hint {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Breakdown */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
  font-size: 1.02rem;
}

.breakdown-row strong {
  font-weight: 700;
}

.value-discount {
  color: var(--success);
}

.breakdown-total {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--navy);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--navy);
  font-weight: 800;
  font-size: 1.12rem;
}

.breakdown-total strong {
  font-size: 1.55rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th, .data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--bg);
  color: var(--navy);
  font-weight: 700;
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 92px 1fr 195px;
  align-items: center;
  gap: 12px;
}

.history-month {
  font-weight: 800;
  color: var(--navy);
}

.history-bar-track {
  height: 18px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.history-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--cyan));
  border-radius: 999px;
}

.history-val {
  text-align: right;
  font-weight: 700;
  font-size: 0.96rem;
}

/* Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #D5E4EE;
  border-top-color: var(--cyan);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

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

.loading-text, .muted-text {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Footer */
.footer {
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  padding: 18px 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-link {
  color: var(--navy);
  font-weight: 700;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 40, 64, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-box {
  background: #FFFFFF;
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--navy);
  color: #FFFFFF;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.modal-body {
  padding: 20px 22px;
  font-size: 1rem;
}

.modal-body ol, .modal-body ul {
  padding-left: 20px;
}

.modal-footer {
  padding: 14px 22px 20px;
  display: flex;
  justify-content: flex-end;
}

.modal-photo-box {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  background: #071926;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
}

.modal-photo-box img {
  max-width: 86vw;
  max-height: 78vh;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.btn-close-photo {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 2rem;
}

.photo-zoom-caption {
  margin: 10px 0 0;
  color: #E2F4F8;
  font-size: 0.95rem;
}

/* Responsivo */
@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .unit-banner {
    padding: 20px 18px;
  }
  .unit-banner-controls {
    width: 100%;
    min-width: 0;
  }
  .history-row {
    grid-template-columns: 76px 1fr;
  }
  .history-val {
    grid-column: 1 / -1;
    text-align: left;
  }
  .login-card {
    padding: 26px 20px;
  }
}

/* Banner de instalacao PWA (Android 1 toque + iOS Safari) */
.pwa-banner {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 16px;
  z-index: 950;
  max-width: 500px;
  margin: 0 auto;
  background: var(--navy);
  color: #FFFFFF;
  border: 2px solid var(--cyan);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(7, 40, 64, 0.42);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-banner-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: #FFFFFF;
  padding: 4px;
  flex-shrink: 0;
}

.pwa-banner-title {
  margin: 0 0 3px;
  font-size: 1.05rem;
  font-weight: 800;
}

.pwa-banner-desc {
  margin: 0;
  font-size: 0.9rem;
  color: #D9F2F7;
  line-height: 1.35;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-pwa-main {
  flex: 1;
}
