* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4A90D9;
  --primary-light: #87CEEB;
  --primary-dark: #2B6CB0;
  --danger: #D32F2F;
  --warning: #F57C00;
  --success: #388E3C;
  --bg: #F0F4F8;
  --card: #FFFFFF;
  --text: #212121;
  --text-secondary: #6B8BA4;
  --border: #D4E2ED;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(74, 144, 217, 0.12);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.install-area {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.install-area .link {
  font-size: 13px;
  color: #4A90D9;
}

/* App Bar */
.app-bar {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-bar .btn-icon {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.app-bar .btn-icon:hover { background: rgba(255,255,255,0.1); }

.app-bar .title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
}

.app-bar .actions {
  display: flex;
  gap: 4px;
}

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
  width: 100%;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) { background: rgba(74, 144, 217, 0.05); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* Form fields */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.form-input:focus { border-color: var(--primary); }

.form-input.error { border-color: var(--danger); }

.input-icon {
  position: relative;
}

.input-icon .form-input { padding-left: 44px; }

.input-icon .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 20px;
}

/* Toggle visibilidade de senha */
.password-wrapper {
  position: relative;
}

.password-wrapper .form-input {
  padding-right: 44px;
}

.btn-toggle-senha {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.btn-toggle-senha:hover { color: var(--primary); }

/* Alert messages */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #FFEBEE;
  color: var(--danger);
  border: 1px solid #FFCDD2;
}

.alert-success {
  background: #E8F5E9;
  color: var(--success);
  border: 1px solid #C8E6C9;
}

/* Login screen */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 24px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo {
  width: 100px;
  height: auto;
  object-fit: contain;
  margin-bottom: 16px;
}

.login-header h1 {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
}

.login-header p {
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  margin-top: 4px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-card .link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  width: 100%;
  text-align: center;
  padding: 8px;
}

.login-card .link:hover { color: var(--primary-dark); }

/* Home Screen */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  min-height: calc(100vh - 56px);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.home-logo {
  width: 140px;
  height: auto;
  object-fit: contain;
  margin-bottom: 16px;
}

.home-welcome {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.home-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
}

.home-menu {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-menu-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 24px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 16px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.home-menu-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(74, 144, 217, 0.2);
}

.home-menu-btn:active {
  transform: scale(0.98);
}

.home-menu-btn .icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.home-menu-btn .menu-text {
  flex: 1;
}

.home-menu-btn .menu-text .title {
  font-size: 16px;
  font-weight: 600;
  display: block;
}

.home-menu-btn .menu-text .desc {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.home-menu-btn .arrow {
  font-size: 20px;
  color: var(--text-secondary);
}

.home-footer {
  margin-top: auto;
  padding: 24px 16px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
  max-width: 400px;
  line-height: 1.4;
}

/* Dashboard */
.cliente-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cliente-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  flex-shrink: 0;
}

.cliente-info h2 {
  font-size: 18px;
  font-weight: 600;
}

.cliente-info p {
  font-size: 14px;
  color: var(--text-secondary);
}

.resumo-card {
  text-align: center;
  padding: 24px;
}

.resumo-card .label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.resumo-card .valor {
  font-size: 36px;
  font-weight: 700;
}

.resumo-card .valor.danger { color: var(--warning); }
.resumo-card .valor.success { color: var(--success); }
.resumo-card .subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.proximo-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.proximo-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #E3F2FD;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  font-size: 24px;
  flex-shrink: 0;
}

.proximo-info h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.proximo-info .data {
  font-size: 18px;
  font-weight: 600;
}

.proximo-info .valor-small {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Mensalidades list */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  margin-bottom: 8px;
}

.filter-chip {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.mensalidade-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}

.mensalidade-item:active { transform: scale(0.99); }

.mensalidade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mensalidade-titulo {
  font-size: 16px;
  font-weight: 600;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.pago { background: #E8F5E9; color: var(--success); }
.status-badge.pendente { background: #FFF3E0; color: var(--warning); }
.status-badge.vencida { background: #FFEBEE; color: var(--danger); }

.mensalidade-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.mensalidade-info strong {
  color: var(--text);
}

/* Boleto screen */
.boleto-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.boleto-info-row:last-child { border-bottom: none; }

.boleto-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.boleto-value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.barcode-container {
  display: flex;
  justify-content: center;
  padding: 24px 0;
  background: #fff;
  border-radius: 8px;
  margin: 16px 0;
}

.linha-digitavel {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  background: #F5F5F5;
  border-radius: 8px;
  border: 1px solid var(--border);
  word-break: break-all;
  margin-bottom: 16px;
  user-select: all;
}

/* Spinner */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Falecidos list */
.falecido-item {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.1s;
}

.falecido-item:active { transform: scale(0.99); }

.falecido-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  font-size: 24px;
  flex-shrink: 0;
}

.falecido-info h3 {
  font-size: 16px;
  font-weight: 600;
}

.falecido-info p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Detail rows */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

/* Toast / Snackbar */
.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: snackbarIn 0.3s ease;
  max-width: 90%;
}

@keyframes snackbarIn {
  from { transform: translateX(-50%) translateY(40px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Print styles */
@media print {
  .app-bar, .btn, .no-print { display: none !important; }
  .main-content { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Admin */
.admin-cliente-card {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.admin-cliente-card:hover {
  box-shadow: 0 4px 16px rgba(74, 144, 217, 0.2);
  border-color: var(--primary);
}

.admin-cliente-card:active {
  transform: scale(0.99);
}

.admin-cliente-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.admin-search-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Responsive */
@media (max-width: 480px) {
  .main-content { padding: 12px; }
  .login-card { padding: 20px; }
  .resumo-card .valor { font-size: 28px; }
  .home-logo { width: 110px; }
  .home-menu-btn { padding: 16px 20px; }
}
