/* Identidade W3Vision: menu e cartões em azul-ardósia, ação em azul, destaque em verde-água. */
:root {
  --bg: #f1f5f9; --surface: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --slate: #1e293b; --slate-2: #334155; --slate-text: #cbd5e1; --slate-muted: #94a3b8;
  --accent: #30d0a0; --accent-dark: #16a37f;
  --primary: #3b82f6; --primary-dark: #2563eb;
  --danger: #b42318; --danger-bg: #fef3f2; --ok: #067647; --ok-bg: #ecfdf3; --warn: #93370d; --warn-bg: #fffaeb;
  --radius: 8px; --radius-lg: 1rem; --sidebar-w: 248px;
}
* { box-sizing: border-box; }
html { font-size: 14.5px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; line-height: 1.45; }
a { color: var(--primary-dark); }
h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: .95rem; font-weight: 700; margin: 16px 0 8px; }

/* Estrutura: menu lateral + área de conteúdo */
.nav-toggle { position: fixed; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--slate); color: var(--slate-text); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 24px; }
.logo { display: block; padding: 4px 8px 18px; }
.logo img { height: 32px; width: auto; display: block; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-muted); padding: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--slate-text); text-decoration: none; font-size: .93rem; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(48,208,160,.14); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-item.sub { padding-left: 40px; font-size: .88rem; }
.nav-item.disabled { opacity: .5; cursor: default; }
.nav-item.disabled:hover { background: none; color: var(--slate-text); }
.nav-item em { margin-left: auto; font-style: normal; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; background: rgba(255,255,255,.1); border-radius: 999px; padding: 1px 7px; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 8; }
.crumb { flex: 1; font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.who form { margin: 0; }
.tenant-name { font-weight: 600; color: var(--text); padding-right: 12px; border-right: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--slate); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; }
.icon-btn { display: none; cursor: pointer; padding: 6px; border-radius: 6px; }
.icon-btn .ic { width: 22px; height: 22px; }
.nav-scrim { display: none; }
main { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; padding-bottom: 96px; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .nav-toggle:checked ~ .shell .sidebar { transform: none; }
  .nav-toggle:checked ~ .shell .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 20; }
  .icon-btn { display: inline-flex; }
  .uname, .tenant-name { display: none; }
  main { padding: 16px 12px 96px; }
}

/* Páginas e cartões */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--primary); }
.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-ic { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: .8rem; background: #e0ecff; color: var(--primary); margin-bottom: 10px; }
.stat-ic .ic { width: 22px; height: 22px; }
a.stat:hover .stat-ic { background: var(--primary); color: #fff; }
.stat .value { font-size: 2rem; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.stat .hint { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.stat.accent { background: var(--slate); border-color: var(--slate); color: #fff; }
.stat.accent .label, .stat.accent .hint { color: var(--slate-muted); }
.stat.accent .value { color: var(--accent); }
.panels { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-size: .78rem; color: var(--muted); }
.bar span.fill { width: 100%; max-width: 46px; background: linear-gradient(var(--accent), var(--accent-dark)); border-radius: 6px 6px 0 0; min-height: 3px; }
.bar b { color: var(--text); font-weight: 700; }
.hbar { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; margin: 8px 0; font-size: .9rem; }
.hbar .track { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.alert-list li:last-child { border-bottom: 0; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 10px; }

/* Formulários */
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 10px; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.w2 { grid-column: span 2; } .w3 { grid-column: span 3; } .w4 { grid-column: span 4; } .w6 { grid-column: span 6; } .w8 { grid-column: span 8; } .w9 { grid-column: span 9; } .w12 { grid-column: span 12; }
@media (max-width: 760px) { .w2, .w3, .w4, .w6, .w8, .w9 { grid-column: span 12; } }
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > select { width: 130px; flex: none; }
.row > input { flex: 1 1 160px; }
.row > input.grow { flex: 3 1 220px; }
.row > input.short { flex: 0 1 80px; }
.row.addr > select:last-of-type { width: 80px; }
.row .msg { flex-basis: 100%; font-size: .85rem; }
.row.recv { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafc; }
.row.recv > select.grow-sel { flex: 2 1 220px; width: auto; }
.row.recv > input.short { flex: 1 1 110px; }
.row.recv > input.grow { flex: 2 1 200px; }
.mono { font-variant-numeric: tabular-nums; }
.row.has-error input, .has-error > input, .has-error > select { border-color: var(--danger); }
.error { color: var(--danger); font-size: .85rem; }
.ok-text { color: var(--ok); font-size: .85rem; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
button, .btn { font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 16px; border: 1px solid #cbd5e1; background: var(--surface); color: var(--text); text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .6; cursor: wait; }
button.link { border: 0; background: none; color: var(--primary-dark); padding: 4px 0; }
button.link.remove { color: var(--muted); font-size: .85rem; }
button.link.add { margin-top: 4px; }
.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; }
.check input { width: auto; min-height: 0; }
.check.small { font-size: .85rem; color: var(--muted); }
.roles { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 4px 0 8px; }
.role-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; }
.role-box[hidden] { display: none; }
#person-form, .form-stack { display: flex; flex-direction: column; gap: 16px; }
.savebar { position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; align-items: center; gap: 16px; padding: 10px 24px; z-index: 5; }
@media (max-width: 900px) { .savebar { left: 0; } }
.banner { padding: 10px 14px; border-radius: var(--radius); font-size: .92rem; border: 1px solid; }
.banner.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.filters { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.filters input { flex: 1 1 320px; width: auto; }
.filters select { width: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
table.list th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafc; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #f8fafc; }
td.more { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; background: var(--bg); border: 1px solid var(--line); margin-right: 4px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.off { background: var(--bg); color: var(--muted); }
.badge.bad { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.htmx-indicator { opacity: 0; color: var(--muted); font-size: .85rem; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
small.muted { margin-left: 6px; }
.checklist { list-style: none; padding: 0; margin: 0; columns: 2; font-size: .9rem; }
.checklist li { padding: 2px 0; }
.checklist li.done::before { content: '\2713  '; color: var(--ok); font-weight: 700; }
.checklist li.todo::before { content: '\2022  '; color: var(--danger); font-weight: 700; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.2rem; background: var(--slate); color: var(--accent); padding: 10px 14px; border-radius: 8px; display: inline-block; }

/* Login: página branca e cartão azul-ardósia, como nos outros sistemas W3Vision */
.login-page { background: #fff; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--slate); border-radius: var(--radius-lg); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.15); color: #fff; }
.login-box .login-logo { display: block; margin: 0 auto 8px; height: 40px; }
.login-box .muted { color: var(--slate-muted); margin: 0 0 20px; }
.login-box label { color: var(--slate-text); }
.login-box input { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: #fff; }
.login-box input:focus { background: rgba(255,255,255,.15); outline-color: rgba(255,255,255,.4); border-color: rgba(255,255,255,.3); }
.login-box .banner.danger { background: rgba(180,35,24,.25); color: #fecaca; border-color: rgba(254,202,202,.4); }
.login-box button.primary { width: 100%; padding: .6rem; }

/* Busca do item prescrito */
.sug-wrap { position: relative; min-width: 260px; }
.sug-wrap > input { width: 100%; }
.rx-sug { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: .75rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); }
.rx-sug[hidden] { display: none; }
.sug-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; background: transparent; color: #0f172a; border: 0; border-bottom: 1px solid #f1f5f9; border-radius: 0; padding: 9px 12px; cursor: pointer; font: inherit; }
.sug-item:last-child { border-bottom: 0; }
.sug-item:hover, .sug-item:focus { background: #eff6ff; outline: none; }
.sug-item small { color: #64748b; font-size: .78rem; }
.sug-empty { margin: 0; padding: 10px 12px; color: #64748b; font-size: .9rem; }
.rx-chip { margin-top: 4px; font-size: .82rem; color: #0f766e; }
.rx-chip[hidden] { display: none; }
