:root {
  /* Identidade SIS-AE (baseada na tela de login) */
  --primary: #398296;
  --primary-hover: #2C697A;
  --dark: #1E4D6B;
  --surface: #FFFFFF;
  --bg: #F4F7F9;
  --border: #D1D9E0;

  /* Escala primária (azul petróleo) — mantém nomes teal para herança automática */
  --teal-50: #eaf4f7;
  --teal-100: #d5e9ee;
  --teal-200: #a8d1dc;
  --teal-500: #4fa3b8;
  --teal-600: #398296;
  --teal-700: #398296;
  --teal-800: #2C697A;
  --teal-900: #1E4D6B;
  --blue-600: #0284c7;
  --blue-50: #f0f9ff;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --green-600: #059669;
  --green-50: #ecfdf5;
  --slate-50: #F4F7F9;
  --slate-100: #e9eef3;
  --slate-200: #D1D9E0;
  --slate-300: #b8c5d0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(30, 77, 107, .06);
  --shadow: 0 8px 24px rgba(30, 77, 107, .08);
  --shadow-lg: 0 24px 60px rgba(30, 77, 107, .18);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--slate-800);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--dark); }
h1 { font-size: 22px; letter-spacing: -.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
small { font-size: 12px; }
.muted { color: var(--slate-500); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 16px; }

/* ---------- Login (SIAE) ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background: var(--bg);
}
.login-card-wrap {
  width: 100%; max-width: 1100px; min-height: 700px;
  display: flex; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 24px 60px rgba(30, 77, 107, .14), 0 4px 14px rgba(30, 77, 107, .06);
}
.login-art {
  width: 39%; flex-shrink: 0;
  background: #7fa9bb url("/img/login-hero.jpg") center / cover no-repeat;
}
.login-side {
  flex: 1; padding: 36px clamp(32px, 7vw, 76px) 32px;
  display: flex; flex-direction: column;
  color: var(--dark);
}
.login-brand { margin-bottom: 36px; }
.login-logo { display: flex; align-items: center; gap: clamp(12px, 2vw, 22px); }
.login-logo-ico { width: clamp(64px, 9vw, 104px); height: auto; aspect-ratio: 1; color: var(--primary); flex-shrink: 0; }
.login-logo-text {
  font-size: clamp(56px, 8.6vw, 96px); line-height: 1; font-weight: 800;
  letter-spacing: -.01em; color: var(--dark);
}
.login-logo-sub { margin-top: 10px; font-size: clamp(20px, 2.6vw, 29px); color: var(--dark); letter-spacing: .005em; }
.login-form-area { flex: 1; }
.login-form-area h1 { font-size: clamp(24px, 2.6vw, 30px); font-weight: 700; color: var(--dark); margin: 0 0 4px; letter-spacing: -.01em; }
.login-form-area .login-sub { font-size: 18px; color: #1f2937; margin: 0 0 28px; }
.login-input { position: relative; margin-bottom: 18px; }
.login-input > svg {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: #4b5563; pointer-events: none;
}
.login-input input {
  width: 100%; height: 54px; padding: 0 52px 0 48px; font-size: 17px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: #111827;
  transition: box-shadow .15s, border-color .15s, background-color .15s;
}
.login-input input::placeholder { color: #4b5563; }
.login-input input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(57, 130, 150, .2); }
.login-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; background: none; color: #1f2937; cursor: pointer; border-radius: 6px;
}
.login-eye:hover { color: #000; }
.login-eye:focus-visible { outline: 2px solid var(--primary); }
.login-eye svg { width: 22px; height: 22px; }
.login-eye .eye-on { display: none; }
.login-eye.on .eye-on { display: block; }
.login-eye.on .eye-off { display: none; }
.login-options {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 17px; color: #111827; margin: 4px 0 30px;
}
.login-remember { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.login-remember input { accent-color: var(--primary); width: 19px; height: 19px; margin: 0; }
.login-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: #111827; text-decoration: underline; text-underline-offset: 3px; }
.login-link:hover { color: var(--primary-hover); }
.login-submit {
  width: 100%; height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 8px; cursor: pointer;
  background: var(--dark); color: #fff; font-family: inherit; font-size: 17px; font-weight: 600;
  box-shadow: 0 2px 6px rgba(30, 77, 107, .25); transition: background-color .15s;
}
.login-submit:hover { background: #163a52; }
.login-submit:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); }
.login-submit:disabled { opacity: .75; cursor: wait; }
.login-legal { font-size: 13px; color: #111827; margin-top: 40px; }
.login-legal p { margin: 0 0 22px; }
.login-legal-links { display: flex; justify-content: center; gap: 24px; }
.login-legal a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.login-legal a:hover { color: var(--primary-hover); }
.login-error { display: none; margin-bottom: 14px; }
.login-error.show { display: block; }
.alert.login-error.info { background: var(--blue-50); border-color: #bae6fd; color: #075985; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--dark), #173d56 70%, #132f42);
  color: #d7e7ef;
  padding: 18px 14px 14px;
  z-index: 30;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.sidebar .brand .logo {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: rgba(57, 130, 150, .24); border: 1px solid rgba(111, 195, 212, .38); color: #7dd3e4;
}
.sidebar .brand .brand-logo-ico { width: 25px; height: 25px; display: block; }
.sidebar .brand strong { display: block; color: #fff; font-size: 16px; font-weight: 800; letter-spacing: .04em; line-height: 1.1; }
.sidebar .brand span { display: block; font-size: 10.5px; color: #b6d4e3; line-height: 1.25; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-bottom: 10px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #8fb3c6; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  color: #d7e7ef; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a .ico {
  width: 30px; height: 30px; display: inline-grid; place-items: center; flex: none;
  font-size: 20px; line-height: 1; border-radius: 8px;
  background: rgba(255,255,255,.06);
}
.nav a .ico svg { width: 17px; height: 17px; display: block; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a:hover .ico { background: rgba(255,255,255,.14); }
.nav a.active { background: rgba(57, 130, 150, .28); color: #fff; box-shadow: inset 3px 0 0 var(--primary); font-weight: 600; }
.nav a.active .ico { background: rgba(57, 130, 150, .38); box-shadow: 0 0 0 1px rgba(79,163,184,.3) inset; }
.nav a .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(57, 130, 150, .28); color: #fff; font-weight: 700; font-size: 13px;
}
.user-chip strong { display: block; font-size: 12.5px; color: #fff; }
.user-chip span { font-size: 11px; color: #b6d0de; }
.user-chip button { margin-left: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 26px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--slate-200);
}
.topbar .crumbs { font-size: 12.5px; color: var(--slate-500); }
.topbar .crumbs strong { color: var(--slate-700); }
.topbar .spacer { flex: 1; }
.topbar { flex-wrap: wrap; }
.user-box {
  flex-basis: 100%; display: grid; gap: 4px 22px;
  grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1.6fr);
  align-items: center; padding: 10px 16px; border-radius: 10px;
  background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(57, 130, 150, .25);
}
.user-box:empty { display: none; }
.user-box .ub-item { min-width: 0; }
.user-box .ub-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-100); }
.user-box .ub-value { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .ub-cnes .ub-value { font-family: ui-monospace, Consolas, monospace; font-size: 15px; }
@media (max-width: 860px) { .user-box { grid-template-columns: 1fr 1fr; } }
.menu-btn { display: none; }
.view { padding: 24px 26px 40px; max-width: 1500px; width: 100%; flex: 1; }
.app-footer {
  margin-top: auto; padding: 12px 26px 16px; text-align: right;
  font-size: 12px; color: var(--slate-500); border-top: 1px solid var(--slate-200);
}
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--slate-500); margin-top: 5px; font-size: 13px; max-width: 760px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards / KPIs ---------- */
.card {
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--slate-100); }
.card-head h3 { font-size: 14px; }
.card-head .right { margin-left: auto; }
.card-body { padding: 16px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-500); font-weight: 600; }
.kpi .value { font-size: 27px; font-weight: 750; letter-spacing: -.03em; margin: 6px 0 2px; color: var(--slate-900); }
.kpi .hint { font-size: 12px; color: var(--slate-500); }
.kpi .ico {
  position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  background: var(--teal-50); color: var(--teal-700);
}
.kpi.blue .ico { background: var(--blue-50); color: var(--blue-600); }
.kpi.amber .ico { background: var(--amber-50); color: var(--amber-600); }
.kpi.red .ico { background: var(--red-50); color: var(--red-600); }
.kpi.green .ico { background: var(--green-50); color: var(--green-600); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--slate-300); background: #fff; color: var(--slate-700);
  border-radius: 9px; padding: 8px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  font-family: inherit; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--slate-50); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn.primary:hover { background: var(--teal-800); }
.btn.blue { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn.danger { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--slate-600); }
.btn.ghost:hover { background: var(--slate-100); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 11px 18px; font-size: 14px; }
.btn.wide { width: 100%; justify-content: center; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 12px; font-weight: 650; color: var(--slate-600);
  line-height: 1.3; min-height: 16px;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field .req { color: var(--red-600); font-weight: 700; }
.field .help { font-size: 11.5px; color: var(--slate-500); line-height: 1.35; }
.field.has-error label { color: var(--red-700); }
.field.has-error input, .field.has-error select, .field.has-error textarea,
input.input-error, select.input-error, textarea.input-error {
  border-color: var(--red-500) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; color: var(--slate-800);
  background: #fff; border: 1px solid var(--slate-300); border-radius: 9px;
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field > input:not([type="checkbox"]):not([type="radio"]),
.field > select,
.field .esf-combo > input,
.input-like {
  min-height: 40px;
}
.input-like {
  display: flex; align-items: center;
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--slate-200); border-radius: 9px;
  background: var(--slate-50); color: var(--slate-700); font-size: 13.5px;
}
.field > input[readonly]:not(.pl-sc-fixo) {
  background: var(--slate-50); color: var(--slate-600); border-color: var(--slate-200);
}
input:focus, select:focus, textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(57, 130, 150, .18); }
input:disabled, select:disabled { background: var(--slate-100); color: var(--slate-500); }
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; align-items: start; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }

/* Configuração do estabelecimento: grid responsivo que quebra linha sem espremer campos */
.settings-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 16px;
  align-items: start;
}
.settings-grid .field { min-width: 0; }
.settings-grid .col-2,
.settings-grid .col-3,
.settings-grid .col-4,
.settings-grid .col-5,
.settings-grid .col-6,
.settings-grid .col-8,
.settings-grid .col-9,
.settings-grid .col-12 { grid-column: auto; }
.settings-grid .span-uf { min-width: 96px; }
.settings-grid .span-short { min-width: 150px; }
.settings-grid .span-code { min-width: 170px; }
.settings-grid .span-wide { grid-column: span 2; min-width: 280px; }
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .span-wide { grid-column: span 1; min-width: 0; }
}
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 16px; background: #fff; border: 1px solid var(--slate-200);
  border-radius: var(--radius); margin-bottom: 16px;
}
.filters .field { min-width: 150px; }
.filters .field.wide { min-width: 240px; flex: 1; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box input { padding-left: 34px; }
.search-box::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--slate-400); font-size: 17px; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--slate-200); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--slate-500); font-weight: 700; background: var(--slate-50);
  padding: 10px 12px; border-bottom: 1px solid var(--slate-200); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
tbody tr:hover { background: #fbfdfd; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 34px 20px; text-align: center; color: var(--slate-500); font-size: 13px; }
.empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .7; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--slate-100); font-size: 12px; color: var(--slate-500); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--slate-100); color: var(--slate-600); white-space: nowrap;
}
.badge.teal { background: var(--teal-50); color: var(--teal-700); }
.badge.blue { background: var(--blue-50); color: var(--blue-600); }
.badge.green { background: var(--green-50); color: var(--green-600); }
.badge.amber { background: var(--amber-50); color: var(--amber-600); }
.badge.red { background: var(--red-50); color: var(--red-600); }
.badge.slate { background: var(--slate-100); color: var(--slate-600); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--slate-200); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--slate-500); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--slate-800); }
.tabs button.active { color: var(--teal-700); border-bottom-color: var(--teal-600); }

/* ---------- Modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(860px, 100%); max-height: 92vh; overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop .14s ease-out;
}
.modal.sm { width: min(480px, 100%); }
.modal.lg { width: min(1080px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--slate-100); position: sticky; top: 0; background: #fff; z-index: 2; border-radius: 16px 16px 0 0; }
.modal-head h3 { font-size: 17px; }
.modal-head .sub { font-size: 12.5px; color: var(--slate-500); margin-top: 3px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--slate-100); position: sticky; bottom: 0; background: #fff; border-radius: 0 0 16px 16px; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 10px;
  background: var(--slate-900); color: #fff; font-size: 13px; box-shadow: var(--shadow-lg);
  display: flex; gap: 9px; align-items: flex-start; animation: slide .18s ease-out;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast.warn { background: #92400e; }
@keyframes slide { from { transform: translateX(14px); opacity: 0; } }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.55; border: 1px solid; }
.alert.info { background: var(--blue-50); border-color: #bae6fd; color: #075985; }
.alert.ok { background: var(--green-50); border-color: #a7f3d0; color: #065f46; }
.alert.warn { background: var(--amber-50); border-color: #fde68a; color: #92400e; }
.alert.err { background: var(--red-50); border-color: #fecaca; color: #991b1b; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.alert li { margin: 2px 0; }

/* ---------- Misc ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 10px 4px 0; }
.chart-bars > .chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bars > .chart-bar .bar { width: 100%; max-width: 46px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--teal-500), var(--teal-700)); min-height: 4px; }
.chart-bars > .chart-bar .lbl { font-size: 10.5px; color: var(--slate-500); }
.chart-bars > .chart-bar .val { font-size: 11px; font-weight: 700; color: var(--slate-700); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--slate-100); }
.list-item:last-child { border-bottom: 0; }
.list-item .rank { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--slate-100); font-size: 11px; font-weight: 700; color: var(--slate-600); }
.list-item .txt { min-width: 0; }
.list-item .txt strong { display: block; font-size: 12.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.list-item .txt span { font-size: 11.5px; color: var(--slate-500); }
.list-item .num { margin-left: auto; font-weight: 700; font-size: 13px; }
.split-2 { display: grid; grid-template-columns: 1.35fr .65fr; gap: 16px; align-items: start; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.detail { background: var(--slate-50); border: 1px solid var(--slate-100); border-radius: 9px; padding: 9px 11px; }
.detail .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-500); font-weight: 700; }
.detail .v { font-size: 13px; margin-top: 3px; font-weight: 600; color: var(--slate-800); word-break: break-word; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; font-size: 12.5px; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; color: var(--slate-600); }
.pager-size select { width: auto; padding: 3px 8px; font-size: 12.5px; }
.pager-nav { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: auto; }
.pager-gap { padding: 0 4px; color: var(--slate-500); }
.pill-note { display: inline-flex; gap: 6px; align-items: center; padding: 3px 9px; border-radius: 999px; background: var(--slate-100); font-size: 11.5px; color: var(--slate-600); }
.progress { height: 6px; border-radius: 99px; background: var(--slate-100); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--teal-500); }
.divider { height: 1px; background: var(--slate-200); margin: 16px 0; }
.code-box {
  background: var(--slate-900); color: #d1fae5; border-radius: 10px; padding: 12px 14px;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; line-height: 1.55;
  overflow: auto; max-height: 240px; white-space: pre;
}
.checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--slate-700); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--teal-700); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--slate-300); border-top-color: var(--teal-700); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; padding: 50px; color: var(--slate-500); gap: 10px; }
.loading-block .spinner { width: 24px; height: 24px; border-width: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .split-2 { grid-template-columns: 1fr; }
  .col-4, .col-5, .col-6, .col-8, .col-9 { grid-column: span 12; }
  .col-3 { grid-column: span 6; }
}
@media (max-width: 860px) {
  .login-art { display: none; }
  .login-card-wrap { min-height: 0; }
  .login-side { width: 100%; min-width: 0; padding: 28px 20px; }
  .login-form-area .login-sub { font-size: 16px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px;
    transform: translateX(-105%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .view { padding: 18px 16px 50px; }
  .topbar { padding: 10px 16px; }
  .col-2, .col-3 { grid-column: span 6; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 22px; }
  .col-2, .col-3, .col-4 { grid-column: span 12; }
  .filters .field, .filters .field.wide { min-width: 100%; }
  .page-head .actions { width: 100%; margin-left: 0; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .app-footer, .page-head .actions, .filters, .btn, .toast-wrap { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .view { padding: 0; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; }
}

/* ONDA 6 login/admin helpers */
.login-brand-logo{max-height:56px;max-width:220px;object-fit:contain;display:block}.login-logo-fallback{display:inline-flex;align-items:center;gap:10px}.auth-view.hidden{display:none !important}.login-error.show.info{border-color:#93c5fd;background:#eff6ff;color:#1e3a8a}.login-error.show.ok{border-color:#86efac;background:#f0fdf4;color:#166534}.stack{display:flex;flex-direction:column}

/* Fluxo de atendimento: procedimentos (autocomplete + destaque) */
.proc-pick { transition: background .12s, border-color .12s; border-left: 4px solid transparent; }
.proc-pick:hover { background: #f8fafc; }
.proc-pick.active { background: #eff6ff; border-left-color: #2563eb; }
.proc-pick.selected { background: #f0fdf4; border-left-color: #16a34a; }
.proc-pick.selected.active { background: #ecfeff; border-left-color: #0891b2; }
.proc-pick[disabled] { cursor: not-allowed; opacity: .62; }

/* ------------------------------------------------------------------ *
 * Fluxo de atendimento — CAPS (RAAS-PS) x Atenção Especializada (BPA-I)
 * ------------------------------------------------------------------ */
.avatar {
  width: 34px; height: 34px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--teal-50); color: var(--teal-700); font-weight: 700; font-size: 12px; flex: none;
}
.patient-banner { padding: 16px 18px; }
.patient-banner h2 { font-size: 19px; line-height: 1.2; }
.patient-banner .avatar { width: 46px; height: 46px; font-size: 15px; }
.patient-header-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 18px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--slate-100);
}
.patient-header-grid dt {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--slate-500); font-weight: 700;
}
.patient-header-grid dd { margin: 2px 0 0; font-size: 13px; color: var(--slate-800); }
.flow-section {
  background: var(--surface, #fff);
  border: 1px solid var(--slate-200); border-radius: 12px;
  padding: 16px 18px 18px; margin: 0 0 18px; min-width: 0;
  box-shadow: 0 1px 3px rgba(30, 77, 107, .04);
}
.flow-section legend {
  padding: 3px 10px; border-radius: 6px;
  background: var(--teal-50); border: 1px solid var(--teal-200);
  font-size: 12.5px; font-weight: 700; color: var(--dark); letter-spacing: .01em;
}
.flow-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.billing-off { opacity: .55; }
.proc-results {
  margin-top: 6px; max-height: 240px; overflow: auto;
  border: 1px solid var(--slate-200); border-radius: 8px; padding: 2px 8px; background: #fff;
}
.proc-results .list-item, .list-item[data-pick-patient] {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: transparent; border: 0; border-bottom: 1px solid var(--slate-100); padding: 8px 2px;
}
.proc-results .list-item:last-child { border-bottom: 0; }
.proc-results .list-item .txt strong { white-space: normal; max-width: 100%; }
.proc-selected { padding: 10px; min-height: 46px; font-size: 13px; }

/* Busca de procedimento em bloco de largura total */
.proc-block {
  margin-top: 12px; padding: 12px; border: 1px solid var(--slate-200);
  border-radius: 10px; background: var(--slate-50, #f8fafc);
}
.proc-block .proc-search { width: 100%; font-size: 15px; padding: 10px 12px; }
.proc-block .proc-results { max-height: 420px; }
.proc-block-title { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate-700); margin-bottom: 6px; }
.proc-pick { border-left: 3px solid transparent; }
.proc-pick.active { border-left-color: var(--teal-600); background: var(--teal-50); }
.proc-pick:hover { background: #f8fafc; }
/* Bloco de faturamento: executante, folha RAAS, caixas e linha única por procedimento */
.exec-card {
  display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline;
  padding: 12px 14px; margin: 10px 0 14px; border: 1px solid var(--slate-200);
  border-left: 4px solid var(--teal-600); border-radius: 9px; background: var(--slate-50, #f8fafc);
}
.exec-card > div:first-child { display: flex; flex-direction: column; }
.exec-card .muted { font-size: 12px; }
.sub-section {
  margin: 8px 0 16px; padding: 16px 18px;
  border: 1px solid var(--teal-200); border-radius: 11px;
  background: linear-gradient(180deg, rgba(234, 244, 247, .35), rgba(255, 255, 255, .98));
}
.sub-section h4, .proc-box h4 {
  margin: 0 0 12px; font-size: 13.5px; font-weight: 700; color: var(--dark);
  padding-bottom: 8px; border-bottom: 1px solid var(--slate-200);
}
.proc-box h4 .muted { font-weight: 400; font-size: 12px; margin-left: 6px; }
.proc-box { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50, #f8fafc); }
.proc-box .proc-search { width: 100%; font-size: 15px; padding: 10px 12px; }
.proc-box .proc-results { max-height: 360px; padding: 0; }
.proc-box[data-proc-box="itens"] .table-wrap, .proc-box[data-proc-box="itens"] table { background: #fff; }
.inline-checks {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  border: 1px solid var(--slate-200); border-radius: 9px; padding: 8px 12px; margin: 0;
  background: #fff; min-height: 40px;
}
/* `.field` e `.inline-checks` definem display:flex, que vence o atributo [hidden] (UA stylesheet).
   Escopo: só esses dois e o que estiver dentro da folha RAAS (nada de regra global solta). */
.field[hidden], .inline-checks[hidden], [data-flow-sub="folha-raas"] [hidden] { display: none !important; }
/* Auditoria: filtros e destaque de exclusões/reativações */
.aud-filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; margin-bottom: 8px; }
.aud-filtros .aud-q { grid-column: span 2; }
.aud-filtros .aud-acoes { display: flex; gap: 8px; }
.aud-atalhos { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; font-size: 12px; }
tr.aud-exclusao td { background: #fef2f2; }
tr.aud-exclusao td:first-child { box-shadow: inset 3px 0 0 var(--red-600, #dc2626); }
tr.aud-reativacao td { background: #f0fdf4; }
tr.aud-reativacao td:first-child { box-shadow: inset 3px 0 0 var(--green-600, #16a34a); }
tr.aud-destaque:not(.aud-exclusao):not(.aud-reativacao) td { background: #fffbeb; }
.aud-detalhe { max-width: 420px; overflow-wrap: anywhere; }
/* Cadastros a completar (aba de Pacientes) e selo no menu */
.nav a .nav-badge { margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px; background: #f59e0b; color: #1f2937; font-size: 11px; font-weight: 700; text-align: center; line-height: 1.5; }
.nav-badge[hidden], .badge[data-cad-count][hidden] { display: none !important; }
.cad-filtros { align-items: end; gap: 16px; }
.cad-resumo { font-size: 13px; padding-bottom: 8px; }
.cad-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.cad-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 6px 0 11px; border: 1px solid var(--slate-300, #cbd5e1); border-radius: 999px; background: #fff; color: var(--slate-700, #334155); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.cad-chip b { min-width: 22px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--slate-100, #f1f5f9); color: var(--slate-800, #1e293b); font-size: 11px; display: inline-grid; place-items: center; }
.cad-chip:hover { border-color: var(--amber-600, #d97706); }
.cad-chip:focus-visible { outline: 2px solid var(--primary, #398296); outline-offset: 2px; }
.cad-chip[aria-pressed="true"] { background: #fffbeb; border-color: var(--amber-600, #d97706); box-shadow: inset 0 0 0 1px var(--amber-600, #d97706); }
.cad-chip[aria-pressed="true"] b { background: #fff; }
.cad-todos[aria-pressed="true"] { background: var(--primary-soft, #e6f2f5); border-color: var(--primary, #398296); box-shadow: inset 0 0 0 1px var(--primary, #398296); }
.cad-limpar { all: unset; cursor: pointer; margin-left: 4px; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--primary, #398296); }
.cad-limpar:hover { background: var(--primary-soft, #e6f2f5); }
.cad-limpar:focus-visible { outline: 2px solid var(--primary, #398296); outline-offset: 2px; }
.cad-limpar[hidden] { display: none !important; }
.cad-pends { display: flex; flex-wrap: wrap; gap: 4px; }
.chip.pend { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; cursor: help; }
.chip.pend:focus-visible { outline: 2px solid var(--primary, #398296); outline-offset: 1px; }
.cad-vazio { padding: 36px 12px; }
.cad-vazio .big { color: #15803d; font-size: 34px; }
/* Faixa de pré-fechamento (não bloqueante) após salvar o atendimento */
.pre-fechamento .pf-nome { font-weight: 600; }
.pre-fechamento .pf-lista { margin: 6px 0 8px; padding-left: 18px; }
.pre-fechamento .pf-erro { color: #b91c1c; }
.pre-fechamento .pf-aviso { font-size: 12.5px; }
/* Nome do CID (só leitura, abaixo do campo). Em célula de tabela não alarga a coluna (largura 0 + min 100%). */
.cid-nome { display: block; margin-top: 3px; font-size: 11.5px; line-height: 1.25; color: var(--slate-600, #475569); white-space: normal; overflow-wrap: anywhere; font-weight: 500; }
.cid-nome:empty { display: none; }
td .cid-nome { width: 0; min-width: 100%; }
/* Aba CAPS: sugestão destacada do atendimento individual (0301080208) */
.sugestao-individual { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--amber-600, #d97706); border-left-width: 4px; border-radius: 9px; background: #fffbeb; }
.sugestao-individual .sugestao-titulo { margin-bottom: 2px; }
.sugestao-individual .proc-line.destaque { background: #fff; box-shadow: 0 0 0 1px #fcd34d inset; border-radius: 7px; }
tr.destaque td { background: #fffbeb; }
/* Administração: Excluir (vermelho discreto), Reativar e linhas inativas */
.btn.excluir { color: var(--red-600, #dc2626); }
.btn.excluir:hover:not([disabled]) { background: #fef2f2; color: #b91c1c; }
.btn.excluir[disabled] { color: var(--slate-400, #94a3b8); cursor: not-allowed; }
.btn.excluir svg, .btn.reativar svg { vertical-align: -2px; margin-right: 2px; }
.btn.reativar { color: var(--teal-700, #0f766e); }
tr.row-inativa td:not(.actions) { opacity: .55; }
tr.row-inativa td:not(.actions) .badge { opacity: 1; }
.admin-inativos { white-space: nowrap; }
.inline-checks legend { font-size: 12px; font-weight: 650; color: var(--slate-600); padding: 0 4px; }
/* Linha única SEMPRE: nada quebra (nem o hífen do código 03.02.05.002-7); nome longo com reticências
   e completo no title; em tela estreita o container rola na horizontal em vez de quebrar. */
.proc-results { overflow-x: auto; }
.proc-line {
  display: grid; align-items: center; gap: 8px; padding: 6px 8px; white-space: nowrap;
  grid-template-columns: 112px minmax(220px, 1fr) 64px 100px 86px 96px;
  min-width: 760px; border-bottom: 1px solid var(--slate-100);
}
.proc-line.with-local { grid-template-columns: 112px minmax(220px, 1fr) 64px 100px 86px 112px 96px; min-width: 880px; }
.proc-line:last-child { border-bottom: 0; }
.proc-line-head { position: sticky; top: 0; z-index: 1; background: var(--slate-100, #f1f5f9); font-size: 11.5px; font-weight: 700; color: var(--slate-600, #475569); text-transform: uppercase; letter-spacing: .02em; }
.proc-line .pl-code, td.pl-code-cell { white-space: nowrap; }
.proc-line .pl-name { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: 13px; line-height: 1.3; }
.pl-nome-txt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proc-line .pl-name .badge, td.it-nome .badge { flex: none; white-space: nowrap; }
.proc-line.blocked .pl-code, .proc-line.blocked .pl-nome-txt { opacity: .6; }
.proc-line.chosen { background: #f0fdf4; }
.proc-line input.input.sm, .proc-line select.input.sm,
td input.pl-qtd, td input.pl-sc, td input.pl-cid, td select.pl-local, td select.pl-sc { width: 100%; min-width: 0; padding: 4px 6px; font-size: 13px; }
td input.pl-qtd { max-width: 70px; } td input.pl-sc, td select.pl-sc { max-width: 104px; } td input.pl-cid { max-width: 90px; }
.pl-empty { padding: 10px; white-space: normal; }
/* Regras A-D (CNES): serv×class único = texto fixo; sem serviço habilitado = Adicionar travado */
input.pl-sc-fixo, input.pl-sc-fixo:focus { background: transparent; border-color: transparent; box-shadow: none; cursor: default; white-space: nowrap; }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
/* Folha RAAS: busca de unidade para o CNES da ESF */
.esf-combo { position: relative; }
.esf-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); max-height: 240px; overflow: auto; margin: 0; padding: 4px 0; list-style: none; background: var(--surface, #fff); border: 1px solid var(--border, #d4d4d8); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.esf-list li { padding: 6px 10px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.esf-list li.active, .esf-list li.esf-opt:hover { background: var(--primary-soft, #eef2ff); }
.esf-list li.esf-vazio { cursor: default; }
.esf-tipo { font-size: 12px; }
.help.err { color: #b91c1c; }
/* Importador SCNES */
details.scnes-svc summary { cursor: pointer; white-space: nowrap; }
details.scnes-svc ul { margin: 4px 0 6px 16px; padding: 0; font-size: 12px; }
details.scnes-svc .badge { margin-right: 4px; }
/* CID: formatado F32.1 (máx. 5 visíveis), sem quebrar a linha única; formato inválido = borda + aviso curto */
input.cid-input { white-space: nowrap; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.field input.cid-input { width: 100%; max-width: 100%; }
input.cid-input.cid-invalid, input.cid-input.cid-invalid:focus { border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, .18); }
.cid-warn { display: block; margin-top: 3px; font-size: 12px; color: #b91c1c; white-space: nowrap; }
/* Tabela "Itens do atendimento": uma linha por item, rolagem horizontal no .table-wrap */
.proc-box[data-proc-box="itens"] table { min-width: 760px; }
.proc-box[data-proc-box="itens"] td, .proc-box[data-proc-box="itens"] th { white-space: nowrap; }
td.it-nome { max-width: 1px; width: 100%; }
td.it-nome > .pl-nome-txt { display: inline-block; max-width: 100%; vertical-align: middle; }
td.it-nome.has-badge > .pl-nome-txt { max-width: calc(100% - 90px); }
/* Itens do atendimento: QTD, CID e LOCAL com largura própria (antes ficavam espremidos e cortavam o texto);
   o nome do procedimento pode quebrar linha para ceder espaço. Escopo só desta tabela. */
.proc-box[data-proc-box="itens"] td input.pl-qtd { width: 76px; min-width: 76px; max-width: none; }
.proc-box[data-proc-box="itens"] td input.pl-cid { width: 96px; min-width: 96px; max-width: none; }
.proc-box[data-proc-box="itens"] td select.pl-local { width: 140px; min-width: 140px; max-width: none; }
.proc-box[data-proc-box="itens"] td.it-nome { white-space: normal; max-width: none; min-width: 220px; }
.proc-box[data-proc-box="itens"] td.it-nome > .pl-nome-txt,
.proc-box[data-proc-box="itens"] td.it-nome.has-badge > .pl-nome-txt { display: inline; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
.proc-box[data-proc-box="itens"] td.it-nome .badge { margin-left: 6px; vertical-align: middle; }
.proc-box .only-cbo { display: inline-flex; gap: 6px; align-items: center; margin: 8px 0 2px; font-weight: 600; }
/* Serviços habilitados no CNES (Administração › Unidades) */
.cnes-servicos h4 { margin: 4px 0 6px; font-size: 13.5px; }
.cnes-servicos input[type=search] { width: 100%; margin-bottom: 6px; }
.cnes-list { max-height: 260px; overflow: auto; border: 1px solid var(--slate-200); border-radius: 8px; background: #fff; }
.cnes-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--slate-100); white-space: nowrap; cursor: pointer; }
.cnes-row:last-child { border-bottom: 0; }
.cnes-row .cnes-nome { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cnes-row .btn { flex: none; }
.cnes-dica { font-size: 12px; padding: 6px 8px; white-space: normal; }
/* Digitador: escolha do profissional executante no topo do faturamento */
.exec-picker { margin: 4px 0 10px; padding: 10px 12px 2px; border: 1px solid var(--primary); border-radius: 10px; background: var(--teal-50); }
/* Importação SIGTAP: alerta quando a maioria das linhas é ignorada */
.import-alerta { border-left: 5px solid var(--red-600, #dc2626); font-size: 13.5px; }
.import-alerta strong:first-child { display: block; font-size: 14.5px; margin-bottom: 4px; }
.import-alerta-count { font-size: 14px; margin: 4px 0; }
.import-alerta ul { margin: 4px 0 6px 18px; }
tr.row-added > td { background: #ecfdf5; }
tr.row-added { box-shadow: inset 3px 0 0 #10b981; }

/* Documentos assistenciais: botões destacados */
.doc-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.doc-btn {
  display: flex; align-items: center; gap: 12px; text-align: left; font: inherit; cursor: pointer;
  padding: 14px; border: 2px solid var(--teal-800); border-radius: 10px;
  background: var(--teal-800); color: #fff; box-shadow: 0 2px 6px rgba(30, 77, 107, .28);
  transition: background .15s, box-shadow .15s, transform .15s;
}
.doc-btn:hover:not(:disabled) { background: var(--dark); border-color: var(--dark); box-shadow: 0 4px 12px rgba(30, 77, 107, .38); transform: translateY(-1px); }
.doc-btn:focus-visible { outline: 3px solid var(--dark); outline-offset: 3px; }
.doc-ico { font-size: 24px; line-height: 1; }
.doc-txt { display: flex; flex-direction: column; gap: 2px; }
.doc-txt strong { color: #fff; font-size: 13.5px; }
.doc-txt span { font-size: 12px; color: #e6f2f5; }
/* Desabilitado (executante não habilitado): apagado, cinza, sem sombra; o motivo continua legível (AA). */
.doc-btn:disabled, .doc-btn[aria-disabled="true"] {
  cursor: not-allowed; opacity: .85; background: #e5e9ee; border: 2px dashed #94a3b8; box-shadow: none; transform: none;
}
.doc-btn:disabled .doc-ico, .doc-btn[aria-disabled="true"] .doc-ico { filter: grayscale(1); opacity: .6; }
.doc-btn:disabled .doc-txt strong, .doc-btn[aria-disabled="true"] .doc-txt strong { color: #475569; }
.doc-btn:disabled .doc-txt span, .doc-btn[aria-disabled="true"] .doc-txt span { color: #4b5563; }

@media (max-width: 760px) {
  .patient-header-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-section { padding: 10px; }
}

/* Classificação de risco (CAPS / RAAS) — cores na caixa de seleção e nas opções */
select.risk-select {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
select.risk-select[data-risk="baixo"] {
  background-color: #dcfce7;
  color: #166534;
  border-color: #86efac;
  font-weight: 600;
}
select.risk-select[data-risk="moderado"] {
  background-color: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
  font-weight: 600;
}
select.risk-select[data-risk="alto"] {
  background-color: #ffedd5;
  color: #9a3412;
  border-color: #fdba74;
  font-weight: 600;
}
select.risk-select[data-risk="critico"] {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
  font-weight: 700;
}
select.risk-select option {
  background-color: #ffffff;
  color: var(--ink, #0f172a);
  font-weight: 500;
}
select.risk-select option[value="baixo"],
select.risk-select option.risk-opt-baixo {
  background-color: #dcfce7;
  color: #166534;
  font-weight: 600;
}
select.risk-select option[value="moderado"],
select.risk-select option.risk-opt-moderado {
  background-color: #fef3c7;
  color: #92400e;
  font-weight: 600;
}
select.risk-select option[value="alto"],
select.risk-select option.risk-opt-alto {
  background-color: #ffedd5;
  color: #9a3412;
  font-weight: 600;
}
select.risk-select option[value="critico"],
select.risk-select option.risk-opt-critico {
  background-color: #fee2e2;
  color: #991b1b;
  font-weight: 700;
}

/* Destaque do local de erro no atendimento e bloqueio do botão Salvar até correção */
fieldset.flow-section.has-error,
.sub-section.has-error,
.proc-box.has-error,
.patient-banner.has-error {
  border-color: var(--red-600) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.14);
}
tr[data-item-row].has-error td {
  background: var(--red-50);
}
.fluxo-save-locked {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--red-50);
  border: 1px solid #fecaca;
  color: var(--red-600);
  font-size: 13px;
  font-weight: 500;
}
.fluxo-save-locked strong {
  font-weight: 700;
}

.doc-emissor { margin-bottom: 10px; }
.doc-emissor .field { margin: 0; }
.doc-emissor input[readonly] { width: 100%; font-weight: 600; }

/* Formulário estruturado de Receituário (escopo exclusivo .receita-form) */
.receita-form { display: flex; flex-direction: column; gap: 12px; }
.receita-form .rx-emissor-wrap input[readonly] { width: 100%; font-weight: 600; background: var(--slate-50); }
.receita-form .rx-live-alert[hidden] { display: none !important; }
.receita-form .rx-live-alert ul { margin: 6px 0 0 18px; padding: 0; }
.receita-form .rx-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 9px;
  position: sticky; top: 0; z-index: 2; /* Adicionar medicamento sempre à mão numa lista longa (até 20) */
}
.receita-form .rx-toolbar-info { display: flex; align-items: baseline; gap: 10px; }
.receita-form .rx-items { display: flex; flex-direction: column; gap: 10px; } /* sem rolagem própria: quem rola é o modal */
.receita-form fieldset.rx-item {
  margin: 0; padding: 12px 14px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--surface);
}
.receita-form .rx-item-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--slate-100);
}
.receita-form .rx-item-title { font-size: 13.5px; color: var(--dark); }
.receita-form .rx-item-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 12px; }
.receita-form .rx-col-3 { grid-column: span 3; }
.receita-form .rx-col-6 { grid-column: span 6; }
.receita-form .rx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.receita-form .rx-field > label { font-size: 12px; font-weight: 650; color: var(--slate-600); line-height: 1.3; }
.receita-form .rx-field .req { color: var(--red-600); font-weight: 700; }
.receita-form .rx-field input,
.receita-form .rx-field select,
.receita-form .rx-field textarea {
  width: 100%; border: 1px solid var(--slate-300); border-radius: 8px; padding: 7px 10px;
  font: inherit; font-size: 13.5px; color: var(--slate-800); background: #fff;
}
.receita-form .rx-field input:focus,
.receita-form .rx-field select:focus,
.receita-form .rx-field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(57, 130, 150, 0.18);
}
.receita-form .rx-field.rx-has-error > label { color: var(--red-600); }
.receita-form .rx-field input[aria-invalid="true"],
.receita-form .rx-field select[aria-invalid="true"],
.receita-form .rx-field textarea[aria-invalid="true"] {
  border-color: var(--red-600); background: var(--red-50);
}
.receita-form .rx-err { font-size: 11.5px; color: var(--red-600); min-height: 0; line-height: 1.3; }
.receita-form .rx-err:empty { display: none; }
.receita-form .rx-sncr-wrap { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); }
.receita-form .rx-preview-lbl { font-size: 12px; font-weight: 650; color: var(--slate-600); line-height: 1.3; }
.receita-form .rx-preview-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--slate-200); border-radius: 8px; background: #fff; font-size: 12px; min-height: 54px; }
.receita-form .rx-preview-emitente { flex: 1; color: var(--slate-700); line-height: 1.35; }
.receita-form .rx-preview-qr { flex: none; display: flex; align-items: center; justify-content: center; }
.receita-form .rx-preview-qr svg { display: block; border: 1px solid var(--slate-200); border-radius: 4px; }
.receita-form .rx-sncr-warn { margin: 0; font-size: 12.5px; }
.receita-form .rx-sncr-warn[hidden] { display: none !important; }
@media (max-width: 720px) {
  .receita-form .rx-col-3, .receita-form .rx-col-6 { grid-column: span 12; }
}

/* ------------------------------------------------------------------ *
 * Relatórios Gerenciais e Gráficos SVG (SIAE)
 * ------------------------------------------------------------------ */
.chart-svg { display: block; max-width: 100%; height: auto; }
.chart-row, .chart-col { cursor: default; transition: opacity .12s; }
.chart-row:hover .chart-bar, .chart-col:hover .chart-bar { filter: brightness(0.92); }
.chart-row:focus-visible, .chart-col:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.table-total-row { background: var(--slate-100); font-weight: 700; border-top: 2px solid var(--slate-300); }


/* ===== Analise Avancada (E2) — construtor de tabelas dinamicas ===== */
.pv-card { margin-top: 20px; padding: 0; overflow: hidden; background: #fff; }
.pv-summary { cursor: pointer; padding: 14px 18px; list-style: none; color: var(--dark); border-bottom: 1px solid transparent; }
.pv-summary::-webkit-details-marker { display: none; }
.pv-summary::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--primary); transition: transform .15s; }
.pv-card[open] > .pv-summary::before { transform: rotate(90deg); }
.pv-card[open] > .pv-summary { border-bottom-color: #e2e8f0; }
.pv-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pv-body { padding: 16px 18px 20px; display: grid; gap: 14px; }
.pv-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.pv-toolbar .field { display: grid; gap: 4px; }
.pv-toolbar label { font-size: 12px; font-weight: 600; color: #475569; }
.pv-toolbar input[type=text] { width: 110px; }
.pv-layout { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .pv-layout { grid-template-columns: 1fr; } }
.pv-lado { border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; padding: 10px; max-height: 420px; overflow: auto; }
.pv-catalogo { display: grid; gap: 10px; }
.pv-catalogo h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: #475569; margin: 4px 0; }
.pv-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pv-campo { display: flex; align-items: center; gap: 6px; padding: 5px 7px; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; cursor: grab; }
.pv-campo:active { cursor: grabbing; }
.pv-campo-ico { color: var(--primary); width: 14px; text-align: center; }
.pv-campo-nome { flex: 1; font-size: 13px; }
.pv-campo-add { font-size: 11px; max-width: 92px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; }
.pv-zonas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.pv-zona { border: 1.5px dashed #94a3b8; border-radius: 10px; padding: 8px 10px; background: #fff; min-height: 84px; transition: background .12s, border-color .12s; }
.pv-zona.pv-over { background: #e0f2fe; border-color: var(--primary); }
.pv-zona h4 { font-size: 12px; margin-bottom: 6px; color: var(--dark); }
.pv-zona-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pv-chip { display: flex; align-items: center; gap: 3px; background: #e6f1f4; border: 1px solid #b6d4dc; border-radius: 999px; padding: 2px 4px 2px 10px; cursor: grab; }
.pv-chip-nome { flex: 1; font-size: 12.5px; color: var(--dark); }
.pv-chip-btn { border: 0; background: transparent; cursor: pointer; font-size: 11px; padding: 0; border-radius: 6px; color: #334155; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: 0 0 24px; }
.pv-chip { max-width: 100%; min-width: 0; }
.pv-chip-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-chip-btn:hover:not([disabled]) { background: rgba(30,77,107,.12); }
.pv-chip-btn[disabled] { opacity: .35; cursor: default; }
.pv-chip-btn:focus-visible, .pv-toggle:focus-visible, .pv-fchip-abrir:focus-visible { outline: 2px solid var(--primary); }
.pv-vazio { list-style: none; padding: 6px 2px; }
.pv-fchips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pv-fchip { display: inline-flex; align-items: center; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 999px; padding: 1px 4px 1px 4px; font-size: 12px; max-width: 100%; }
.pv-fchip.aplicado { background: #e6f1f4; border-color: var(--primary); }
.pv-fchip-abrir { border: 0; background: transparent; cursor: pointer; padding: 3px 6px; text-align: left; font: inherit; color: #1e293b; }
.pv-filtro-painel { margin-top: 10px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px; background: #fff; }
.pv-filtro-topo { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pv-filtro-topo strong { flex: 1; color: var(--dark); }
.pv-filtro-lista { list-style: none; margin: 8px 0 0; padding: 0; max-height: 200px; overflow: auto; display: grid; gap: 2px; }
.pv-filtro-lista label { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.pv-erro { color: #991b1b; }
.pv-kpis { margin: 0; display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px }
.pv-kpi{background:#fff;border:1px solid var(--slate-200);border-radius:var(--radius);padding:16px;min-width:0}
.pv-kpi .label{font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;color:var(--slate-500);font-weight:600}
.pv-kpi .value{font-size:27px;font-weight:750;letter-spacing:-.03em;margin:6px 0 2px;color:var(--slate-900)}
.pv-kpi .hint{font-size:12px;color:var(--slate-500)}
.pv-grafico { margin: 0; }
.pv-grafico-topo { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pv-tabela-card { margin: 0; }
.pv-tabela-wrap { overflow: auto; max-height: 560px; }
.pv-tabela { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pv-tabela th, .pv-tabela td { border-bottom: 1px solid #e2e8f0; padding: 6px 9px; }
.pv-tabela thead th { position: sticky; top: 0; background: #eef4f6; color: var(--dark); z-index: 1; text-align: left; border-bottom: 2px solid #b6d4dc; }
.pv-tabela thead th.right { text-align: right; }
.pv-tabela thead th.pv-sub { font-weight: 500; font-size: 11px; top: 30px; }
.pv-tabela tbody tr:hover { background: #f8fafc; }
.pv-tabela tr.pv-subtotal { background: #f4f9fb; font-weight: 600; }
.pv-tabela .pv-total-col { background: #f1f7f9; }
.pv-tabela tfoot th, .pv-tabela tfoot td { background: #e6f1f4; border-top: 2px solid var(--dark); font-weight: 700; position: sticky; bottom: 0; text-align: left; }
.pv-tabela tfoot td { text-align: right; }
.pv-item { white-space: nowrap; }
.pv-toggle { border: 0; background: transparent; cursor: pointer; width: 22px; color: var(--primary); font-size: 11px; }
.pv-toggle-vazio { display: inline-block; width: 22px; }
.pv-na { color: #94a3b8; }
.pv-alert { margin: 0; }
/* Central de Inteligência — E3/E4 */
.rel-tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid #cbd5df;margin:0 0 18px}
.rel-tabs [role=tab]{border:0;border-bottom:3px solid transparent;background:transparent;color:var(--dark);padding:10px 16px;cursor:pointer;font-weight:650}
.rel-tabs [role=tab][aria-selected=true]{border-bottom-color:var(--primary);background:#edf6f8}
.rel-tabs [role=tab]:focus-visible,.pv-celula-btn:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.pv-modelos-bar,.pv-acoes,.pv-comparar-campos,.pv-pagina{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:10px 0}
.pv-modelos-bar select{min-width:200px;max-width:340px}
.pv-compartilhar{white-space:nowrap}
.pv-comparar{background:#f8fbfc;border:1px solid #d8e4e8;border-radius:8px;padding:14px;margin:12px 0}
.pv-comparar-campos label{display:grid;gap:3px;font-size:12px;color:var(--dark)}
.pv-comparar-campos input{width:95px}
.pv-comparativo-tabela th,.pv-comparativo-tabela td{white-space:nowrap}
.pv-alta{color:#166534}.pv-queda{color:#a13e35}
.pv-celula-btn{border:0;background:transparent;color:var(--dark);text-decoration:underline dotted;text-underline-offset:2px;cursor:pointer;font:inherit;padding:2px}
.pv-celula-btn:hover{color:var(--primary)}
.pv-detalhe{width:min(1100px,95vw);max-height:88vh;border:1px solid #b8cbd3;border-radius:10px;padding:18px;color:var(--dark)}
.pv-detalhe::backdrop{background:rgba(19,45,60,.55)}
.pv-detalhe-topo{display:flex;justify-content:space-between;align-items:center;gap:12px}
.pv-detalhe-tabela{font-size:12px}.pv-detalhe-tabela td,.pv-detalhe-tabela th{white-space:nowrap}
@media(max-width:700px){.rel-tabs [role=tab]{flex:1 1 100%;text-align:left}.pv-detalhe{width:96vw;padding:10px}}
.rel-fat-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px}
.rel-fat-card{background:#f1f7f9;border:1px solid #c8dce3;border-radius:8px;padding:14px}
.rel-fat-card .label{font-size:12px;color:#475569}.rel-fat-card .value{font-size:21px;font-weight:700;color:var(--dark)}
.pv-card,.pv-body,.pv-centro,#pv-resultado,.pv-tabela-card{min-width:0;max-width:100%}
.pv-layout{grid-template-columns:minmax(220px,280px) minmax(0,1fr)}
.pv-tabela-wrap,.pv-detalhe .table-wrap{max-width:100%;overflow-x:auto}
.pv-grafico svg{max-width:100%;height:auto}
@media screen {
  .rel-chart-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-items:start}
  .rel-chart-grid>.card,.pv-grafico{min-width:0;background:#fff}
  .rel-chart-grid .card-body{min-width:0;overflow:hidden}
  .chart-ranking-viewport{max-height:260px;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable}
  .chart-ranking-viewport svg{display:block}
  .chart-compact{display:block;max-width:100%;height:auto}
  .pv-grafico svg.chart-compact.chart-vertical,.pv-grafico svg.chart-compact.chart-line,.rel-chart-grid svg.chart-compact.chart-vertical,.rel-chart-grid svg.chart-compact.chart-line{height:220px}
  .chart-vertical.chart-compact .chart-bar:hover{fill:#2C697A}
  .chart-compact .chart-row:focus-visible,.chart-compact .chart-col:focus-visible{outline:2px solid #398296;outline-offset:-2px}
}
@media screen and (min-width:1100px){.rel-chart-grid{grid-template-columns:repeat(2,minmax(0,1fr));align-items:stretch}.rel-chart-grid>.card{display:flex;flex-direction:column;justify-content:center}}
@media screen and (max-width:560px){#rep-apply{width:100%;min-width:90px}.form-grid>.field.col-1:has(#rep-apply){grid-column:span 12}}
.chart-legend{display:flex;flex-wrap:wrap;gap:6px 14px;margin:4px 0 0;padding:0;list-style:none;min-width:0}
.chart-legend-item{display:inline-flex;align-items:center;gap:6px;max-width:100%;font-size:12px;line-height:1.3;color:#1F2A30}
.chart-legend-item>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:210px}
.chart-legend-swatch{width:10px;height:10px;flex:0 0 10px;border-radius:2px}
.chart-ranking-mobile{display:none}
@media screen and (max-width:599px){
  .rel-chart-grid>.card{padding:8px!important}
  .rel-chart-grid .card-body{padding:8px}
  .chart-ranking-viewport{max-height:none;overflow:visible;scrollbar-gutter:auto}
  .chart-ranking-viewport>svg.chart-compact{display:none}
  .chart-ranking-mobile{display:block;width:100%}
  .chart-ranking-mobile-row{display:grid;grid-template-columns:18px 8px minmax(0,1fr) auto;column-gap:7px;row-gap:5px;align-items:center;padding:6px 0;border-bottom:1px solid #EEF3F5;color:#1F2A30;font-size:12px;line-height:1.2}
  .chart-ranking-mobile-row:last-child{border-bottom:0}
  .chart-ranking-mobile-pos{color:#5B6B75;font-variant-numeric:tabular-nums}
  .chart-ranking-mobile-swatch{width:8px;height:8px;border-radius:2px}
  .chart-ranking-mobile-name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;min-width:0}
  .chart-ranking-mobile-value{font-size:12px;font-variant-numeric:tabular-nums;text-align:right}
  .chart-ranking-mobile-track{grid-column:3/5;height:8px;border-radius:4px;background:#EEF3F5;overflow:hidden}
  .chart-ranking-mobile-track>span{display:block;height:100%;border-radius:4px}
  .rel-chart-grid svg.chart-compact.chart-vertical,.rel-chart-grid svg.chart-compact.chart-line,.pv-grafico svg.chart-compact.chart-vertical,.pv-grafico svg.chart-compact.chart-line{height:200px}
}
.pv-modelos-bar input,.pv-modelos-bar select,.pv-comparar-campos input{max-width:100%}
@media(max-width:860px){.pv-layout{grid-template-columns:minmax(0,1fr)}}
@media(max-width:600px){.pv-zonas{grid-template-columns:minmax(0,1fr)}.pv-lado,.pv-centro,.pv-zona{min-width:0}.pv-body{padding:12px}.pv-toolbar .field{min-width:0}}
