/* TX Portaria — APP do Condômino (Mobile-First PWA, Identidade Visual TX Oficial) */
:root {
  --tx-navy: #10243a;
  --tx-navy-2: #173454;
  --tx-blue: #245eea;
  --tx-blue-hover: #1d4ed8;
  --tx-dark: #1b2026;
  --tx-bg: #f1f5f9;
  --tx-card: #ffffff;
  --tx-border: #e2e8f0;
  --tx-text: #0f172a;
  --tx-muted: #64748b;
  --tx-ok: #15803d;
  --tx-ok-bg: #dcfce7;
  --tx-warn: #b45309;
  --tx-warn-bg: #fef3c7;
  --tx-danger: #b91c1c;
  --tx-danger-bg: #fee2e2;
  --tx-info: #1d4ed8;
  --tx-info-bg: #dbeafe;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--tx-bg); color: var(--tx-text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* Login Mobile-First */
.m-login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: linear-gradient(155deg, var(--tx-navy) 0%, #1d3f68 55%, #0f172a 100%);
}
.m-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--tx-card);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
}
.m-login-head {
  background: var(--tx-dark);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.m-login-head img { height: 30px; }
.m-login-body { padding: 22px; }
.m-login-body h1 { margin: 0 0 6px; font-size: 21px; }
.m-login-body p { margin: 0 0 16px; font-size: 13px; color: var(--tx-muted); line-height: 1.45; }

/* App Shell */
.m-app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--tx-bg);
  display: flex;
  flex-direction: column;
  padding-bottom: 78px;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.08);
}

.m-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, var(--tx-navy), var(--tx-navy-2));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.m-header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-header-brand img { height: 28px; width: 28px; flex-shrink: 0; }
.m-site-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.m-unit-tag { font-size: 11px; color: #bfdbfe; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.m-mod-chip {
  background: rgba(250, 204, 21, 0.22);
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

.m-main { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* Cards & Controls */
.m-card {
  background: var(--tx-card);
  border: 1px solid var(--tx-border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.m-card h2 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m-card h3 { margin: 0 0 6px; font-size: 14px; }
.m-muted { color: var(--tx-muted); font-size: 12px; line-height: 1.45; }

.m-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.m-field label { font-size: 12px; font-weight: 600; color: var(--tx-text); }
.m-field input, .m-field select, .m-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--tx-text);
}
.m-field input:focus, .m-field select:focus, .m-field textarea:focus {
  outline: none;
  border-color: var(--tx-blue);
  box-shadow: 0 0 0 3px rgba(36, 94, 234, 0.14);
}
.m-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--tx-border);
  background: #fff;
  color: var(--tx-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.m-btn:hover { background: #f8fafc; }
.m-btn-primary { background: var(--tx-blue); border-color: var(--tx-blue); color: #fff; }
.m-btn-primary:hover { background: var(--tx-blue-hover); }
.m-btn-ok { background: #16a34a; border-color: #16a34a; color: #fff; }
.m-btn-ok:hover { background: #15803d; }
.m-btn-danger { background: var(--tx-danger-bg); border-color: #fecaca; color: var(--tx-danger); }
.m-btn-ghost-light { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.25); color: #fff; padding: 6px 10px; font-size: 12px; }
.m-btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.m-btn-block { width: 100%; }

.m-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.m-pill-ok { background: var(--tx-ok-bg); color: var(--tx-ok); }
.m-pill-warn { background: var(--tx-warn-bg); color: var(--tx-warn); }
.m-pill-danger { background: var(--tx-danger-bg); color: var(--tx-danger); }
.m-pill-info { background: var(--tx-info-bg); color: var(--tx-info); }
.m-pill-muted { background: #e2e8f0; color: #475569; }

.m-alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  background: var(--tx-info-bg);
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  margin-bottom: 10px;
}
.m-alert-danger { background: var(--tx-danger-bg); color: var(--tx-danger); border-color: #fecaca; }
.m-alert-warn { background: var(--tx-warn-bg); color: var(--tx-warn); border-color: #fde68a; }
.m-alert-ok { background: var(--tx-ok-bg); color: var(--tx-ok); border-color: #bbf7d0; }

/* Cartão de Acesso & Facial */
.m-id-hero {
  background: linear-gradient(135deg, #10243a 0%, #1e3a5f 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.m-id-top { display: flex; align-items: center; gap: 12px; }
.m-avatar {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(96, 165, 250, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.m-avatar img { width: 100%; height: 100%; object-fit: cover; }
.m-qr-box {
  background: #fff;
  color: var(--tx-text);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.m-qr-svg { width: 106px; height: 106px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.m-qr-svg svg { width: 100%; height: 100%; display: block; }

.m-kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.m-kpi {
  background: var(--tx-card);
  border: 1px solid var(--tx-border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.m-kpi strong { display: block; font-size: 20px; color: var(--tx-navy); }
.m-kpi span { font-size: 11px; color: var(--tx-muted); }

/* Lista de itens */
.m-item {
  border: 1px solid var(--tx-border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.m-item + .m-item { margin-top: 8px; }
.m-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.m-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Câmera Facial */
.m-cam-preview { width: 100%; max-height: 220px; border-radius: 12px; background: #0f172a; object-fit: cover; margin-bottom: 8px; }

/* Código de Retirada */
.m-pickup-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
  background: var(--tx-navy);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-block;
}

/* Chat Interno */
.m-channels { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.m-ch-btn {
  border: 1px solid var(--tx-border);
  background: #fff;
  color: var(--tx-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.m-ch-btn.active { background: var(--tx-navy); border-color: var(--tx-navy); color: #fff; }

.m-chat-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 410px;
  overflow-y: auto;
  padding: 4px 2px;
}
.m-msg {
  border: 1px solid var(--tx-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.m-msg.mine { background: #eff6ff; border-color: #bfdbfe; }
.m-msg.removed { background: #f8fafc; border-style: dashed; color: var(--tx-muted); font-style: italic; }
.m-msg-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--tx-muted); margin-bottom: 4px; flex-wrap: wrap; }
.m-msg-body { font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

.m-chat-form { display: flex; gap: 8px; margin-top: 10px; }
.m-chat-form input { flex: 1; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 14px; }

/* Bottom Navigation */
.m-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-top: 1px solid var(--tx-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px 8px;
  z-index: 40;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
}
.m-nav-btn {
  background: transparent;
  border: none;
  color: var(--tx-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  position: relative;
}
.m-nav-btn.active { color: var(--tx-blue); }
.m-nav-btn svg { width: 20px; height: 20px; }
.m-nav-badge {
  position: absolute;
  top: 0;
  right: 14px;
  background: var(--tx-danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
}

/* Modal QR */
.m-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.m-modal {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.m-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tx-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 80;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  max-width: 92vw;
}
.m-toast.error { background: var(--tx-danger); }

.m-demo-box {
  margin-top: 14px;
  padding: 11px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--tx-border);
  font-size: 12px;
  color: var(--tx-muted);
  line-height: 1.5;
}
.m-demo-box code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; color: var(--tx-text); }
