:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #2b2620;
  --muted: #746b5e;
  --border: #e8e0d3;
  --brand: #c1673b;
  --brand-dark: #a8532c;
  --brand-tint: #f6e6dc;
  --accent: #6f8f66;
  --accent-tint: #e7efe3;
  --danger: #b3432b;
  --danger-tint: #fbe8e3;
  --radius: 14px;
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }

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

/* ── login (modal) ── */
.modal-login {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.18);
  position: relative;
}
.modal-login h1 { font-size: 1.4rem; margin: 0 0 4px; }
.modal-login p.sub { color: var(--muted); margin: 0 0 20px; }
.modal-scrim[hidden] { display: none; }
.modal-scrim {
  position: fixed; inset: 0; background: rgba(43,38,32,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92rem; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 11px 18px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn.secundario { background: var(--accent-tint); color: var(--accent); }
.btn.perigo { background: var(--danger-tint); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.bloco { width: 100%; }
.erro { color: var(--danger); font-size: .9rem; margin-top: 8px; }
.demo-hint { margin-top: 18px; font-size: .82rem; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 12px; }

/* ── shell ── */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 240px; background: #2b2620; color: #f2ece2; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.side .brand { font-weight: 700; font-size: 1.05rem; padding: 6px 10px 18px; }
.side .brand small { display: block; font-weight: 400; opacity: .65; font-size: .78rem; }
.nav-item {
  display: block; padding: 10px 12px; border-radius: 10px; color: #f2ece2cc;
  text-decoration: none; margin-bottom: 2px; cursor: pointer;
}
.nav-item:hover { background: #ffffff14; }
.nav-item.ativo { background: var(--brand); color: #fff; }
.side .chip {
  margin-top: auto; padding: 12px; border-top: 1px solid #ffffff20; font-size: .85rem;
}
.side .chip .nome { font-weight: 600; }
.side .chip .cargo { opacity: .65; }
.side .chip button { margin-top: 8px; background: transparent; border: 1px solid #ffffff40; color: #f2ece2; padding: 6px 10px; border-radius: 8px; cursor: pointer; width: 100%; }

.main { flex: 1; padding: 28px 32px; max-width: 1000px; }
.main h2 { margin: 0 0 18px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 1.05rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.utente-card { cursor: pointer; }
.utente-card .quarto { color: var(--muted); font-size: .88rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge.on { background: var(--accent-tint); color: var(--accent); }
.badge.off { background: var(--danger-tint); color: var(--danger); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); cursor: pointer; }
.tab.ativo { background: var(--brand); color: #fff; border-color: var(--brand); }

.registo { border-bottom: 1px solid var(--border); padding: 10px 0; }
.registo:last-child { border-bottom: none; }
.registo .meta { color: var(--muted); font-size: .82rem; }
.tipo-pill { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--brand-dark); font-weight: 700; }

.chat { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: var(--brand-tint); }
.msg.minha { align-self: flex-end; background: var(--accent-tint); }
.msg .meta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }

.vazio { color: var(--muted); font-style: italic; padding: 12px 0; }
.consent-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.consent-row:last-child { border-bottom: none; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .15s; }
.slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.top-banner { background: var(--brand-tint); color: var(--brand-dark); padding: 10px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.status-dot.off { background: var(--danger); }

table.tabela-simples { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tabela-simples th, table.tabela-simples td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }

form.form-inline { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-top: 10px; }
form.form-inline .full { grid-column: 1 / -1; }

/* ── site público (landing) ── */
.site { max-width: 100%; overflow-x: hidden; }
.site-nav { position: sticky; top: 0; z-index: 40; background: rgba(250,246,240,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
.site-nav-inner { max-width: 1120px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 24px; }
.site-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.site-links { display: flex; gap: 22px; margin-left: auto; }
.site-links a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.site-links a:hover { color: var(--brand); }

.hero {
  max-width: 1120px; margin: 0 auto; padding: 56px 24px 40px; display: grid;
  grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center;
}
.hero h1 { font-size: 2.4rem; line-height: 1.15; margin: 0 0 16px; }
.hero-text p { color: var(--muted); font-size: 1.08rem; margin: 0 0 26px; max-width: 46ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-actions .btn.secundario { text-decoration: none; }
.hero-art svg { width: 100%; height: auto; display: block; }

.site-section { max-width: 1120px; margin: 0 auto; padding: 56px 24px; }
.site-section.alt { max-width: none; background: var(--card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.site-section.alt > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.site-section h2 { font-size: 1.7rem; margin: 0 0 18px; }
.site-lead { color: var(--muted); font-size: 1.05rem; max-width: 70ch; }

.stats-row { display: flex; gap: 40px; margin-top: 28px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 1.9rem; color: var(--brand-dark); }
.stat span { color: var(--muted); font-size: .88rem; }

.servicos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 24px; }
.servico-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.servico-card h3 { margin: 14px 0 6px; font-size: 1.05rem; }
.servico-card p { margin: 0; color: var(--muted); font-size: .92rem; }

.portal-promo { text-align: center; }
.portal-promo h2 { margin-bottom: 12px; }
.portal-promo .site-lead { margin: 0 auto 24px; }

.site-footer {
  max-width: 1120px; margin: 0 auto; padding: 32px 24px 48px; display: flex; flex-wrap: wrap;
  justify-content: space-between; gap: 12px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border);
}

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .side .brand { padding: 6px 10px; }
  .side .chip { display: none; }
  .main { padding: 18px; }

  .site-links { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 32px; }
  .hero-art { order: -1; max-width: 320px; margin: 0 auto; }
  .hero h1 { font-size: 1.8rem; }
}
