@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --teal: #0f5c5b; --teal2: #147877; --teal3: #1c9c94;
  --navy: #0b2340; --navy2: #123258;
  --ambar: #d68910; --ambar2: #f0a92c;
  --bg: #eef2f3; --bg2: #f7f9fa;
  --texto: #2c3a3f; --texto2: #6b7c82;
  --linha: #e2e8ea;
  --danger: #d64545; --success: #1e9e6b; --warning: #d68910; --info: #2b83c4;
  --sombra: 0 2px 14px rgba(11,35,64,.08); --sombra2: 0 10px 34px rgba(11,35,64,.16);
  --raio: 12px; --raio2: 8px;
}
* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--texto); font-size: 15px; min-height: 100vh; }
a { color: inherit; }

/* LOGIN */
.login-wrap { min-height: 100vh; background: radial-gradient(circle at 20% 20%, var(--teal2), var(--navy) 65%); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border-radius: 20px; padding: 46px 42px; width: 100%; max-width: 420px; box-shadow: var(--sombra2); animation: subir .4s ease; }
@keyframes subir { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .marca { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--teal2), var(--teal3)); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: #fff; }
.login-logo .logo-empresa { max-width: 220px; max-height: 90px; object-fit: contain; margin: 0 auto 16px; display: block; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--navy); }
.login-logo p { color: var(--texto2); font-size: .85rem; margin-top: 4px; }

/* FORM */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .76rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-control { width: 100%; padding: 12px 14px; border: 1.5px solid var(--linha); border-radius: var(--raio2); font-family: inherit; font-size: .93rem; color: var(--texto); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.form-control:focus { border-color: var(--teal3); box-shadow: 0 0 0 3px rgba(28,156,148,.14); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { appearance: auto; }
.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 2fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
.form-hint { font-size: .76rem; color: var(--texto2); margin-top: 5px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 20px; border: none; border-radius: var(--raio2); font-family: inherit; font-size: .89rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--teal2), var(--teal3)); color: #fff; box-shadow: 0 4px 14px rgba(20,120,119,.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20,120,119,.36); }
.btn-navy { background: linear-gradient(135deg, var(--navy), var(--navy2)); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--teal3); color: var(--teal2); }
.btn-outline:hover { background: var(--teal3); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--texto); }
.btn-ghost:hover { background: var(--linha); }
.btn-whats { background: #25d366; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn-full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 258px; flex-shrink: 0; background: linear-gradient(180deg, var(--navy) 0%, var(--navy2) 100%); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; overflow-y: auto; box-shadow: 3px 0 18px rgba(0,0,0,.12); transition: transform .25s; }
.sb-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.sb-brand .ic { width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, var(--teal2), var(--teal3)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-bottom: 8px; }
.sb-logo-wrap { width: 100%; background: #fff; border-radius: var(--raio2); padding: 12px 14px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; }
.sb-brand .sb-logo { max-width: 100%; max-height: 64px; object-fit: contain; }
.sb-brand h2 { font-size: .98rem; font-weight: 700; line-height: 1.2; }
.sb-brand span { font-size: .7rem; opacity: .55; }
.sb-user { padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.sb-avatar { width: 36px; height: 36px; background: var(--ambar); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; color: #2c1a00; }
.sb-user .ui strong { font-size: .85rem; display: block; }
.sb-user .ui small { font-size: .7rem; opacity: .55; }
.sb-nav { padding: 12px 0; flex: 1; }
.sb-section { padding: 14px 20px 6px; font-size: .64rem; text-transform: uppercase; letter-spacing: 1px; opacity: .4; font-weight: 700; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,.72); text-decoration: none; font-size: .87rem; font-weight: 500; transition: all .15s; border-left: 3px solid transparent; }
.sb-item svg { width: 17px; height: 17px; }
.sb-item:hover, .sb-item.ativo { color: #fff; background: rgba(255,255,255,.07); border-left-color: var(--teal3); }
.sb-item .cnt { background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: .68rem; margin-left: auto; }
.sb-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); }

.main { margin-left: 258px; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--sombra); position: sticky; top: 0; z-index: 50; gap: 12px; }
.topbar h3 { font-size: 1.12rem; font-weight: 700; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page { padding: 26px; flex: 1; }

/* CARDS */
.card { background: #fff; border-radius: var(--raio); box-shadow: var(--sombra); padding: 22px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1.5px solid var(--bg); flex-wrap: wrap; gap: 10px; }
.card-header h4 { font-size: 1.02rem; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }

/* STATS */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: #fff; border-radius: var(--raio); padding: 18px 20px; box-shadow: var(--sombra); display: flex; align-items: center; gap: 14px; }
.stat-ico { width: 44px; height: 44px; border-radius: var(--raio2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-ico svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; }
.stat-ico.teal { background: linear-gradient(135deg, var(--teal2), var(--teal3)); }
.stat-ico.navy { background: linear-gradient(135deg, var(--navy), var(--navy2)); }
.stat-ico.ambar { background: linear-gradient(135deg, var(--ambar), var(--ambar2)); }
.stat-ico.green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.stat-body p { font-size: .7rem; color: var(--texto2); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.stat-body strong { font-size: 1.3rem; font-weight: 800; color: var(--navy); display: block; margin-top: 2px; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead th { padding: 10px 12px; text-align: left; font-size: .69rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--texto2); background: var(--bg2); }
tbody td { padding: 12px; border-bottom: 1px solid var(--bg); font-size: .87rem; vertical-align: middle; }
tbody tr:hover { background: #fafcfc; }
tbody tr:last-child td { border-bottom: none; }
.td-acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.vazio { text-align: center; padding: 40px 16px; color: var(--texto2); }
.vazio svg { width: 42px; height: 42px; opacity: .3; margin-bottom: 10px; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeef8; color: #0c4a6e; }
.badge-success { background: #dcfce7; color: #14532d; }
.badge-danger { background: #fde3e3; color: #7f1d1d; }
.badge-secondary { background: #eef1f2; color: #475569; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--raio2); margin-bottom: 16px; font-size: .87rem; font-weight: 500; display: flex; align-items: flex-start; gap: 8px; }
.alert-danger { background: #fde3e3; color: #7f1d1d; border-left: 4px solid var(--danger); }
.alert-success { background: #dcfce7; color: #14532d; border-left: 4px solid var(--success); }
.alert-info { background: #dbeef8; color: #0c4a6e; border-left: 4px solid var(--info); }
.alert-warning { background: #fef3c7; color: #78350f; border-left: 4px solid #d97706; }

/* MODAL */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(11,35,64,.55); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.aberto { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--sombra2); animation: modalIn .18s ease; max-height: 92vh; overflow-y: auto; }
.modal.modal-lg { max-width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.modal-head { padding: 20px 24px 14px; border-bottom: 1.5px solid var(--bg); display: flex; align-items: center; justify-content: space-between; }
.modal-head h5 { font-size: 1.03rem; font-weight: 700; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--texto2); line-height: 1; padding: 2px 6px; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 14px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* PAINEL PACIENTE (link enviado no popup) */
.paciente-mini { display: flex; align-items: center; gap: 12px; background: var(--bg2); border-radius: var(--raio2); padding: 14px; margin-bottom: 18px; }
.paciente-mini .av { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--teal2), var(--teal3)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.paciente-mini strong { display: block; font-size: .92rem; color: var(--navy); }
.paciente-mini small { color: var(--texto2); font-size: .78rem; }

.busca-quest { position: relative; margin-bottom: 12px; }
.busca-quest input { padding-left: 38px; }
.busca-quest svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--texto2); }
.lista-quest { max-height: 280px; overflow-y: auto; border: 1.5px solid var(--linha); border-radius: var(--raio2); }
.item-quest { padding: 12px 14px; border-bottom: 1px solid var(--bg); cursor: pointer; transition: background .12s; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-quest:last-child { border-bottom: none; }
.item-quest:hover { background: var(--bg2); }
.item-quest.selecionado { background: #e6f4f3; border-left: 3px solid var(--teal2); }
.item-quest strong { font-size: .88rem; color: var(--navy); display: block; }
.item-quest small { color: var(--texto2); font-size: .76rem; }

/* RADIO PILL */
.pill-toggle { display: inline-flex; background: var(--bg2); border-radius: 30px; padding: 4px; gap: 4px; }
.pill-toggle label { display: flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 24px; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--texto2); transition: all .15s; }
.pill-toggle input { display: none; }
.pill-toggle input:checked + span { color: inherit; }
.pill-toggle label:has(input:checked) { background: #fff; color: var(--teal2); box-shadow: var(--sombra); }

/* BUILDER DE PERGUNTAS (admin) */
.pergunta-card { border: 1.5px solid var(--linha); border-radius: var(--raio2); padding: 16px; margin-bottom: 14px; background: var(--bg2); }
.pergunta-card .ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.pergunta-card .ph strong { color: var(--navy); font-size: .82rem; text-transform: uppercase; letter-spacing: .4px; }
.opcao-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.opcao-row input { flex: 1; }

/* HAMBURGER */
.hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; background: none; border: none; }
.hamburger span { width: 22px; height: 2px; background: var(--navy); border-radius: 2px; display: block; }
.mob-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
.mob-overlay.ativo { display: block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-258px); }
  .sidebar.aberto { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .page { padding: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .login-card { padding: 32px 22px; }
}
@media (max-width: 500px) { .stats { grid-template-columns: 1fr; } }
