/* required styles */

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
	position: absolute;
	left: 0;
	top: 0;
	}
.leaflet-container {
	overflow: hidden;
	}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
	-webkit-user-select: none;
	   -moz-user-select: none;
	        user-select: none;
	  -webkit-user-drag: none;
	}
/* Prevents IE11 from highlighting tiles in blue */
.leaflet-tile::selection {
	background: transparent;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
	image-rendering: -webkit-optimize-contrast;
	}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
	width: 1600px;
	height: 1600px;
	-webkit-transform-origin: 0 0;
	}
.leaflet-marker-icon,
.leaflet-marker-shadow {
	display: block;
	}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg {
	max-width: none !important;
	max-height: none !important;
	}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
	max-width: none !important;
	max-height: none !important;
	width: auto;
	padding: 0;
	}

.leaflet-container img.leaflet-tile {
	/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
	mix-blend-mode: plus-lighter;
}

.leaflet-container.leaflet-touch-zoom {
	-ms-touch-action: pan-x pan-y;
	touch-action: pan-x pan-y;
	}
.leaflet-container.leaflet-touch-drag {
	-ms-touch-action: pinch-zoom;
	/* Fallback for FF which doesn't support pinch-zoom */
	touch-action: none;
	touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
	-ms-touch-action: none;
	touch-action: none;
}
.leaflet-container {
	-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
	-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
	filter: inherit;
	visibility: hidden;
	}
.leaflet-tile-loaded {
	visibility: inherit;
	}
.leaflet-zoom-box {
	width: 0;
	height: 0;
	-moz-box-sizing: border-box;
	     box-sizing: border-box;
	z-index: 800;
	}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
	-moz-user-select: none;
	}

.leaflet-pane         { z-index: 400; }

.leaflet-tile-pane    { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane  { z-index: 500; }
.leaflet-marker-pane  { z-index: 600; }
.leaflet-tooltip-pane   { z-index: 650; }
.leaflet-popup-pane   { z-index: 700; }

.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg    { z-index: 200; }

.leaflet-vml-shape {
	width: 1px;
	height: 1px;
	}
.lvml {
	behavior: url(#default#VML);
	display: inline-block;
	position: absolute;
	}


/* control positioning */

.leaflet-control {
	position: relative;
	z-index: 800;
	pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
	pointer-events: auto;
	}
.leaflet-top,
.leaflet-bottom {
	position: absolute;
	z-index: 1000;
	pointer-events: none;
	}
.leaflet-top {
	top: 0;
	}
.leaflet-right {
	right: 0;
	}
.leaflet-bottom {
	bottom: 0;
	}
.leaflet-left {
	left: 0;
	}
.leaflet-control {
	float: left;
	clear: both;
	}
.leaflet-right .leaflet-control {
	float: right;
	}
.leaflet-top .leaflet-control {
	margin-top: 10px;
	}
.leaflet-bottom .leaflet-control {
	margin-bottom: 10px;
	}
.leaflet-left .leaflet-control {
	margin-left: 10px;
	}
.leaflet-right .leaflet-control {
	margin-right: 10px;
	}


/* zoom and fade animations */

.leaflet-fade-anim .leaflet-popup {
	opacity: 0;
	-webkit-transition: opacity 0.2s linear;
	   -moz-transition: opacity 0.2s linear;
	        transition: opacity 0.2s linear;
	}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
	opacity: 1;
	}
.leaflet-zoom-animated {
	-webkit-transform-origin: 0 0;
	    -ms-transform-origin: 0 0;
	        transform-origin: 0 0;
	}
svg.leaflet-zoom-animated {
	will-change: transform;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
	-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
	   -moz-transition:    -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
	        transition:         transform 0.25s cubic-bezier(0,0,0.25,1);
	}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
	-webkit-transition: none;
	   -moz-transition: none;
	        transition: none;
	}

.leaflet-zoom-anim .leaflet-zoom-hide {
	visibility: hidden;
	}


/* cursors */

.leaflet-interactive {
	cursor: pointer;
	}
.leaflet-grab {
	cursor: -webkit-grab;
	cursor:    -moz-grab;
	cursor:         grab;
	}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
	cursor: crosshair;
	}
.leaflet-popup-pane,
.leaflet-control {
	cursor: auto;
	}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
	cursor: move;
	cursor: -webkit-grabbing;
	cursor:    -moz-grabbing;
	cursor:         grabbing;
	}

/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
	pointer-events: none;
	}

.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
	pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
	pointer-events: auto;
	}

/* visual tweaks */

.leaflet-container {
	background: #ddd;
	outline-offset: 1px;
	}
.leaflet-container a {
	color: #0078A8;
	}
.leaflet-zoom-box {
	border: 2px dotted #38f;
	background: rgba(255,255,255,0.5);
	}


/* general typography */
.leaflet-container {
	font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-size: 0.75rem;
	line-height: 1.5;
	}


/* general toolbar styles */

.leaflet-bar {
	box-shadow: 0 1px 5px rgba(0,0,0,0.65);
	border-radius: 4px;
	}
.leaflet-bar a {
	background-color: #fff;
	border-bottom: 1px solid #ccc;
	width: 26px;
	height: 26px;
	line-height: 26px;
	display: block;
	text-align: center;
	text-decoration: none;
	color: black;
	}
.leaflet-bar a,
.leaflet-control-layers-toggle {
	background-position: 50% 50%;
	background-repeat: no-repeat;
	display: block;
	}
.leaflet-bar a:hover,
.leaflet-bar a:focus {
	background-color: #f4f4f4;
	}
.leaflet-bar a:first-child {
	border-top-left-radius: 4px;
	border-top-right-radius: 4px;
	}
.leaflet-bar a:last-child {
	border-bottom-left-radius: 4px;
	border-bottom-right-radius: 4px;
	border-bottom: none;
	}
.leaflet-bar a.leaflet-disabled {
	cursor: default;
	background-color: #f4f4f4;
	color: #bbb;
	}

.leaflet-touch .leaflet-bar a {
	width: 30px;
	height: 30px;
	line-height: 30px;
	}
.leaflet-touch .leaflet-bar a:first-child {
	border-top-left-radius: 2px;
	border-top-right-radius: 2px;
	}
.leaflet-touch .leaflet-bar a:last-child {
	border-bottom-left-radius: 2px;
	border-bottom-right-radius: 2px;
	}

/* zoom control */

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
	font: bold 18px 'Lucida Console', Monaco, monospace;
	text-indent: 1px;
	}

.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out  {
	font-size: 22px;
	}


/* layers control */

.leaflet-control-layers {
	box-shadow: 0 1px 5px rgba(0,0,0,0.4);
	background: #fff;
	border-radius: 5px;
	}
.leaflet-control-layers-toggle {
	background-image: url(images/layers.png);
	width: 36px;
	height: 36px;
	}
.leaflet-retina .leaflet-control-layers-toggle {
	background-image: url(images/layers-2x.png);
	background-size: 26px 26px;
	}
.leaflet-touch .leaflet-control-layers-toggle {
	width: 44px;
	height: 44px;
	}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
	display: none;
	}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
	display: block;
	position: relative;
	}
.leaflet-control-layers-expanded {
	padding: 6px 10px 6px 6px;
	color: #333;
	background: #fff;
	}
.leaflet-control-layers-scrollbar {
	overflow-y: scroll;
	overflow-x: hidden;
	padding-right: 5px;
	}
.leaflet-control-layers-selector {
	margin-top: 2px;
	position: relative;
	top: 1px;
	}
.leaflet-control-layers label {
	display: block;
	font-size: 13px;
	font-size: 1.08333em;
	}
.leaflet-control-layers-separator {
	height: 0;
	border-top: 1px solid #ddd;
	margin: 5px -10px 5px -6px;
	}

/* Default icon URLs */
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
	background-image: url(images/marker-icon.png);
	}


/* attribution and scale controls */

.leaflet-container .leaflet-control-attribution {
	background: #fff;
	background: rgba(255, 255, 255, 0.8);
	margin: 0;
	}
.leaflet-control-attribution,
.leaflet-control-scale-line {
	padding: 0 5px;
	color: #333;
	line-height: 1.4;
	}
.leaflet-control-attribution a {
	text-decoration: none;
	}
.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus {
	text-decoration: underline;
	}
.leaflet-attribution-flag {
	display: inline !important;
	vertical-align: baseline !important;
	width: 1em;
	height: 0.6669em;
	}
.leaflet-left .leaflet-control-scale {
	margin-left: 5px;
	}
.leaflet-bottom .leaflet-control-scale {
	margin-bottom: 5px;
	}
.leaflet-control-scale-line {
	border: 2px solid #777;
	border-top: none;
	line-height: 1.1;
	padding: 2px 5px 1px;
	white-space: nowrap;
	-moz-box-sizing: border-box;
	     box-sizing: border-box;
	background: rgba(255, 255, 255, 0.8);
	text-shadow: 1px 1px #fff;
	}
.leaflet-control-scale-line:not(:first-child) {
	border-top: 2px solid #777;
	border-bottom: none;
	margin-top: -2px;
	}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
	border-bottom: 2px solid #777;
	}

.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
	box-shadow: none;
	}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
	border: 2px solid rgba(0,0,0,0.2);
	background-clip: padding-box;
	}


/* popup */

.leaflet-popup {
	position: absolute;
	text-align: center;
	margin-bottom: 20px;
	}
.leaflet-popup-content-wrapper {
	padding: 1px;
	text-align: left;
	border-radius: 12px;
	}
.leaflet-popup-content {
	margin: 13px 24px 13px 20px;
	line-height: 1.3;
	font-size: 13px;
	font-size: 1.08333em;
	min-height: 1px;
	}
.leaflet-popup-content p {
	margin: 17px 0;
	margin: 1.3em 0;
	}
.leaflet-popup-tip-container {
	width: 40px;
	height: 20px;
	position: absolute;
	left: 50%;
	margin-top: -1px;
	margin-left: -20px;
	overflow: hidden;
	pointer-events: none;
	}
.leaflet-popup-tip {
	width: 17px;
	height: 17px;
	padding: 1px;

	margin: -10px auto 0;
	pointer-events: auto;

	-webkit-transform: rotate(45deg);
	   -moz-transform: rotate(45deg);
	    -ms-transform: rotate(45deg);
	        transform: rotate(45deg);
	}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
	background: white;
	color: #333;
	box-shadow: 0 3px 14px rgba(0,0,0,0.4);
	}
.leaflet-container a.leaflet-popup-close-button {
	position: absolute;
	top: 0;
	right: 0;
	border: none;
	text-align: center;
	width: 24px;
	height: 24px;
	font: 16px/24px Tahoma, Verdana, sans-serif;
	color: #757575;
	text-decoration: none;
	background: transparent;
	}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
	color: #585858;
	}
.leaflet-popup-scrolled {
	overflow: auto;
	}

.leaflet-oldie .leaflet-popup-content-wrapper {
	-ms-zoom: 1;
	}
.leaflet-oldie .leaflet-popup-tip {
	width: 24px;
	margin: 0 auto;

	-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
	filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
	}

.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
	border: 1px solid #999;
	}


/* div icon */

.leaflet-div-icon {
	background: #fff;
	border: 1px solid #666;
	}


/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
	position: absolute;
	padding: 6px;
	background-color: #fff;
	border: 1px solid #fff;
	border-radius: 3px;
	color: #222;
	white-space: nowrap;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
	box-shadow: 0 1px 3px rgba(0,0,0,0.4);
	}
.leaflet-tooltip.leaflet-interactive {
	cursor: pointer;
	pointer-events: auto;
	}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
	position: absolute;
	pointer-events: none;
	border: 6px solid transparent;
	background: transparent;
	content: "";
	}

/* Directions */

.leaflet-tooltip-bottom {
	margin-top: 6px;
}
.leaflet-tooltip-top {
	margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
	left: 50%;
	margin-left: -6px;
	}
.leaflet-tooltip-top:before {
	bottom: 0;
	margin-bottom: -12px;
	border-top-color: #fff;
	}
.leaflet-tooltip-bottom:before {
	top: 0;
	margin-top: -12px;
	margin-left: -6px;
	border-bottom-color: #fff;
	}
.leaflet-tooltip-left {
	margin-left: -6px;
}
.leaflet-tooltip-right {
	margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
	top: 50%;
	margin-top: -6px;
	}
.leaflet-tooltip-left:before {
	right: 0;
	margin-right: -12px;
	border-left-color: #fff;
	}
.leaflet-tooltip-right:before {
	left: 0;
	margin-left: -12px;
	border-right-color: #fff;
	}

/* Printing */

@media print {
	/* Prevent printers from removing background-images of controls. */
	.leaflet-control {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
		}
	}


.leaflet-control-layers-toggle{
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNiAyNiI+CiAgICA8cmVjdCB4PSI0IiB5PSI2IiB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHJ4PSIyIiBmaWxsPSIjMmU3ZDMyIiBvcGFjaXR5PSIwLjk1Ii8+CiAgICA8cmVjdCB4PSIxMCIgeT0iMTAiIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgcng9IjIiIGZpbGw9IiMxNTY1YzAiIG9wYWNpdHk9IjAuODUiLz4KICAgIDxyZWN0IHg9IjciIHk9IjQiIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgcng9IjIiIGZpbGw9IiNmZmZmZmYiIG9wYWNpdHk9IjAuODUiLz4KICAgIDwvc3ZnPg==");
    background-size: 20px 20px;
}

        /* Skip-to-content link (acessibilidade WCAG 2.1) */
        .skip-link {
            position: absolute;
            top: -100%;
            left: 0;
            background: var(--primary, #1565c0);
            color: #fff;
            padding: 8px 16px;
            z-index: 10000;
            font-size: 1rem;
            text-decoration: none;
            border-radius: 0 0 4px 0;
        }
        .skip-link:focus {
            top: 0;
        }

        :root {
            /* Tokens web (Trilha U): alinhar --primary/--accent com web/static/style.css quando possível */
            /* PALETA CLÍNICA PROFISSIONAL */
            --primary: #00796b;       /* Verde Petróleo SUS */
            --primary-dark: #004d40;
            --secondary: #0277bd;     /* Azul Institucional */
            --accent: #d84315;        /* Laranja Alerta */
            --bg-body: #f5f7fa;
            --bg-paper: #ffffff;
            --bg-card: #ffffff;
            --text-main: #263238;
            --text-muted: #546e7a;
            --border: #cfd8dc;
            --warning-bg: #fff8e1;
            --warning-text: #f57f17;
            --action-danger: #d32f2f;
            --action-danger-hover: #b71c1c;
            --action-print: #1976d2;
            --action-print-hover: #0d47a1;
            --action-card: #00897b;
            --action-card-hover: #00695c;
            --action-audit: #6f42c1;
            --action-audit-hover: #59359c;
            --shadow: 0 2px 8px rgba(0,0,0,0.08);
            --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.12);
            --radius: 6px;
            --radius-sm: 8px;
            --space-touch: 12px;
            --transition: 0.2s ease;
        }

        [data-theme="dark"] {
            --primary: #4db6ac;
            --primary-dark: #004d40;
            --secondary: #4fc3f7;
            --bg-body: #101010;
            --bg-paper: #1e1e1e;
            --bg-card: #252525;
            --text-main: #eceff1;
            --text-muted: #b0bec5;
            --border: #333;
            --warning-bg: #3e2723;
            --warning-text: #ffb74d;
            --action-danger: #e57373;
            --action-danger-hover: #ef5350;
            --action-print: #64b5f6;
            --action-print-hover: #42a5f5;
            --action-card: #4db6ac;
            --action-card-hover: #26a69a;
            --action-audit: #9575cd;
            --action-audit-hover: #7e57c2;
            --bg-missing: #3b1515;
            --border-error: #ef5350;
            --border-warn: #ffb74d;
            --border-success: #66bb6a;
            --border-info: #90a4ae;
            --border-ignored: #ba68c8;
            --border-diag-ns1: #ffb74d;
            --border-diag-igm: #7986cb;
        }
        /* Preferir classes a overrides por inline-style; mantemos os overrides legados como fallback. */
        .panel { background: var(--bg-paper); color: var(--text-main); border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); }
        .panel.pad { padding: 12px; }
        .panel.soft-success { background: rgba(46, 125, 50, 0.08); border-color: rgba(46, 125, 50, 0.25); }
        .panel.soft-muted { background: rgba(0,0,0,0.03); }
        [data-theme="dark"] .panel.soft-muted { background: rgba(255,255,255,0.04); }
        [data-theme="dark"] .panel { background: var(--bg-paper); color: var(--text-main); border-color: var(--border); }
        [data-theme="dark"] .panel.soft-success { background: rgba(46, 125, 50, 0.10); color: var(--text-main); }

        /* Fallback legado: corrigir trechos antigos ainda serializados com inline style. */
        [data-theme="dark"] [style*="background: white"],
        [data-theme="dark"] [style*="background: #fff"],
        [data-theme="dark"] [style*="background:#fff"],
        [data-theme="dark"] [style*="background: #f5f5f5"],
        [data-theme="dark"] [style*="background:#f5f5f5"] {
            background: var(--bg-paper) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #f1f8e9"],
        [data-theme="dark"] [style*="background:#f1f8e9"]{
            background: rgba(46, 125, 50, 0.10) !important;
            color: var(--text-main) !important;
        }
        /* Outros backgrounds claros que ficam "estourados" no tema escuro */
        [data-theme="dark"] [style*="background: #e3f2fd"],
        [data-theme="dark"] [style*="background:#e3f2fd"]{
            background: rgba(25, 118, 210, 0.16) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #fff3e1"],
        [data-theme="dark"] [style*="background:#fff3e1"]{
            background: rgba(255, 152, 0, 0.16) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #fff3cd"],
        [data-theme="dark"] [style*="background:#fff3cd"]{
            background: rgba(255, 193, 7, 0.16) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #e8f5e9"],
        [data-theme="dark"] [style*="background:#e8f5e9"]{
            background: rgba(46, 125, 50, 0.14) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #e0f2f1"],
        [data-theme="dark"] [style*="background:#e0f2f1"]{
            background: rgba(0, 150, 136, 0.14) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background:#eee"],
        [data-theme="dark"] [style*="background: #eee"]{
            background: rgba(255,255,255,0.06) !important;
            color: var(--text-main) !important;
            border-color: var(--border) !important;
        }
        [data-theme="dark"] [style*="color:#333"],
        [data-theme="dark"] [style*="color: #333"],
        [data-theme="dark"] [style*="color:#000"],
        [data-theme="dark"] [style*="color: #000"]{
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="color: #616161"],
        [data-theme="dark"] [style*="color:#616161"],
        [data-theme="dark"] [style*="color: #666"],
        [data-theme="dark"] [style*="color:#666"],
        [data-theme="dark"] [style*="color: #1b5e20"],
        [data-theme="dark"] [style*="color:#1b5e20"],
        [data-theme="dark"] [style*="color: #558b2f"],
        [data-theme="dark"] [style*="color:#558b2f"],
        [data-theme="dark"] [style*="color: #1565c0"],
        [data-theme="dark"] [style*="color:#1565c0"]{
            color: var(--text-main) !important;
        }
        /* R-UX01 fix: cores adicionais de texto/fundo que faltavam para dark theme */
        [data-theme="dark"] [style*="color: #856404"],
        [data-theme="dark"] [style*="color:#856404"]{
            color: var(--warning-text) !important;
        }
        [data-theme="dark"] [style*="color: #1976d2"],
        [data-theme="dark"] [style*="color:#1976d2"]{
            color: var(--secondary) !important;
        }
        /* v8.5: dark overrides adicionais para inline styles faltantes */
        [data-theme="dark"] [style*="background: #fff8e1"],
        [data-theme="dark"] [style*="background:#fff8e1"]{
            background: rgba(255,152,0,0.14) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: #ffebee"],
        [data-theme="dark"] [style*="background:#ffebee"]{
            background: rgba(198,40,40,0.12) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="color: #5d4037"],
        [data-theme="dark"] [style*="color:#5d4037"]{
            color: #bcaaa4 !important;
        }
        [data-theme="dark"] [style*="color: #6c757d"],
        [data-theme="dark"] [style*="color:#6c757d"]{
            color: var(--text-muted) !important;
        }
        [data-theme="dark"] [style*="color: #0d47a1"],
        [data-theme="dark"] [style*="color:#0d47a1"]{
            color: #90caf9 !important;
        }
        [data-theme="dark"] [style*="color: #2e7d32"],
        [data-theme="dark"] [style*="color:#2e7d32"]{
            color: #81c784 !important;
        }
        [data-theme="dark"] [style*="background: linear-gradient"]{
            background: var(--bg-paper) !important;
        }
        [data-theme="dark"] [style*="background: rgba(212, 67, 21"],
        [data-theme="dark"] [style*="background: rgba(212,67,21"],
        [data-theme="dark"] [style*="background:rgba(212"]{
            background: rgba(216, 67, 21, 0.14) !important;
            color: var(--text-main) !important;
        }
        [data-theme="dark"] [style*="background: rgba(46, 125, 50"],
        [data-theme="dark"] [style*="background:rgba(46"]{
            background: rgba(46, 125, 50, 0.12) !important;
            color: var(--text-main) !important;
        }
        /* Badges/Pills - manter contraste no escuro (sem fundos muito claros) */
        [data-theme="dark"] .manejo-badge.a{ background: rgba(46,125,50,0.16); border-color: rgba(46,125,50,0.35); color: var(--text-main); }
        [data-theme="dark"] .manejo-badge.b{ background: rgba(255,152,0,0.16); border-color: rgba(255,152,0,0.35); color: var(--text-main); }
        [data-theme="dark"] .manejo-badge.c{ background: rgba(216,67,21,0.16); border-color: rgba(216,67,21,0.35); color: var(--text-main); }
        [data-theme="dark"] .manejo-badge.d{ background: rgba(198,40,40,0.16); border-color: rgba(198,40,40,0.35); color: var(--text-main); }
        [data-theme="dark"] .diag-ns1 { background: rgba(255,152,0,0.14); color: var(--text-main); border-left-color: var(--border-diag-ns1); }
        [data-theme="dark"] .diag-igm { background: rgba(63,81,181,0.14); color: var(--text-main); border-left-color: var(--border-diag-igm); }
        [data-theme="dark"] .magic-warning { color: #ef9a9a; background: rgba(198,40,40,0.14); }
        [data-theme="dark"] .magic-validation { color: var(--text-muted); background: rgba(96,125,139,0.12); }
        [data-theme="dark"] .magic-validation.ok { color: #a5d6a7; background: rgba(46,125,50,0.14); }
        [data-theme="dark"] .magic-validation.warn { color: #ffcc80; background: rgba(239,108,0,0.14); }
        [data-theme="dark"] .magic-validation.err { color: #ef9a9a; background: rgba(198,40,40,0.14); }
        [data-theme="dark"] .ignored-warning { color: #ce93d8; background: rgba(142,36,170,0.14); }
        /* Interacoes/estados com backgrounds fixos (ajustar para o tema escuro) */
        [data-theme="dark"] .tab-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-main); }
        [data-theme="dark"] input:focus, [data-theme="dark"] select:focus, [data-theme="dark"] textarea:focus { background: var(--bg-paper); }
        [data-theme="dark"] input[readonly] { background: rgba(255,255,255,0.06); color: var(--text-muted); border-color: var(--border); }
        [data-theme="dark"] .check-btn.active { background: rgba(0,150,136,0.18); border-color: var(--primary); color: var(--text-main); }
        [data-theme="dark"] .check-btn.active-alarm { background: rgba(198,40,40,0.18); border-color: var(--accent); color: var(--text-main); }
        /* v8.5: dark mode — tab active, manejo, confirm, buttons, misc */
        [data-theme="dark"] .tab-btn.active { background: var(--bg-paper); color: var(--primary); }
        [data-theme="dark"] .tab-btn.vigilancia.active { background: var(--bg-paper); color: var(--secondary); }
        [data-theme="dark"] .manejo-panel { background: var(--bg-card); border-color: var(--border); }
        [data-theme="dark"] .manejo-badge { background: var(--bg-card); border-color: var(--border); color: var(--text-main); }
        [data-theme="dark"] .vd-confirm-actions .vd-btn-no { background: #424242; color: var(--text-main); }
        [data-theme="dark"] .vd-agravo-suggest button { background: #3e2723; color: #ffb74d; border-color: #ff9800; }
        [data-theme="dark"] .vd-viacep-chip button { background: #1a2332; color: #90caf9; border-color: #2196f3; }
        [data-theme="dark"] .vd-classif-suggest button { background: #1b2e1b; color: #81c784; border-color: #4caf50; }
        [data-theme="dark"] .vd-date-needs-fill { background: rgba(255,152,0,0.14) !important; border-color: #ff9800 !important; }
        [data-theme="dark"] .btn-cielo-ubv-remove { background: #333 !important; color: var(--text-main) !important; border-color: var(--border) !important; }
        [data-theme="dark"] .magic-counter { color: var(--text-muted); }
        [data-theme="dark"] .magic-counter.warn { color: #ffb74d; }
        [data-theme="dark"] .vd-critical-phase-alert { color: #ff8a65; }
        [data-theme="dark"] .vd-coh-invest { border-top-color: #555; }
        [data-theme="dark"] .vd-coh-invest summary::-webkit-details-marker { color: #bcaaa4; }

        /* RESET & BASE */
        * { box-sizing: border-box; outline: none; }
        html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
        body { font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif; background: var(--bg-body); color: var(--text-main); margin: 0; padding: 0; font-size: 13.5px; line-height: 1.5; transition: background 0.3s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
        @media(prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

        /* HEADER */
        header {
            background: linear-gradient(135deg, #004d40 0%, #00695c 50%, #00796b 100%);
            color: white; padding: 10px 14px;
            display: flex; justify-content: space-between; align-items: center; gap: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.18);
            position: sticky; top: 0; z-index: 1000;
            border-bottom: 2px solid rgba(255,255,255,0.2);
        }
        @media(max-width: 768px) {
            header { padding: 6px 8px; flex-wrap: wrap; gap: 6px; }
            .brand { gap: 6px; }
            .brand-icon { width: 22px; height: 22px; }
            .brand h1 { font-size: 0.92rem; }
            .brand span { font-size: 0.62rem; }
            .brand-meta-line { flex-wrap: nowrap; gap: 4px; }
            .brand-meta-line > span { display: none; }
            /* Mobile compacto com quebra de linha (mantém compatibilidade dos testes UX) */
            .actions {
                gap: 4px;
                flex-wrap: wrap;
                order: 3;
                width: 100%;
                margin-top: 4px;
                overflow-x: visible;
                overflow-y: visible;
                justify-content: center;
            }
            .actions:not(.is-open) .btn:not(.btn-actions-toggle):not(.btn-save):not(.btn-import){ display: none; }
            .actions .actions-mobile-hint{
                display: block;
                width: 100%;
                flex: 1 1 100%;
                font-size: 0.68rem;
                color: var(--text-dim);
                text-align: center;
                margin: 2px 0 0;
                line-height: 1.3;
            }
            .actions.is-open .actions-mobile-hint{ display: none; }
            .actions .btn-actions-toggle{ display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; max-width: none; }
            .actions .btn:not(.btn-theme) {
                width: auto;
                min-width: 82px;
                min-height: 36px;
                height: 36px;
                padding: 4px 6px;
                font-size: 0.7rem;
                flex: 1 1 auto;
                max-width: 130px;
                line-height: 1.05;
            }
            .actions .btn-theme {
                width: 36px;
                min-width: 36px;
                height: 36px;
                font-size: 0.92rem;
                flex: 0 0 auto;
            }
            .actions .btn-primary-action { order: -1; } /* Botões prioritários primeiro */
        }
        /* B1-fix: at 320px, buttons shrink further and quality score stays compact */
        @media(max-width: 380px) {
            .actions .btn:not(.btn-theme) {
                min-width: 70px;
                font-size: 0.65rem;
                padding: 3px 5px;
            }
            .quality-score { min-width: 80px; padding: 2px 6px; }
            .quality-score-label { font-size: 0.65rem; }
            .quality-score-value { font-size: 0.78rem; }
        }
        .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
        .brand-icon { width: 28px; height: 28px; fill: white; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25)); }
        .brand h1 { margin: 0; font-size: 1.2rem; font-weight: 600; letter-spacing: 0.3px; text-shadow: 0 1px 2px rgba(0,0,0,0.18); white-space: nowrap; }
        .brand span { font-size: 0.85rem; opacity: 0.95; font-weight: 400; display: block; margin-top: 2px; }
        .brand-meta-line {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 2px;
            flex-wrap: wrap;
            min-width: 0;
        }
        .brand-meta-line > span {
            font-size: 0.78rem;
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
            line-height: 1.15;
            max-width: 320px;
        }
        
        /* v6.9 - Manejo tempo real + Split layout + Profissional */
        
        /* Manejo Split Layout */
        .manejo-split {
            display: grid;
            grid-template-columns: 1.15fr 0.85fr;
            gap: 16px;
            align-items: start;
        }
        .manejo-right {
            position: sticky;
            top: calc(64px + 48px + 12px);
            max-height: calc(100vh - 140px);
            overflow-y: auto;
        }
        @media (max-width: 900px) {
            .manejo-split { grid-template-columns: 1fr; }
            .manejo-right { position: relative; top: auto; }
        }
        .actions-mobile-hint { display: none; }

        /* Quando servido em /tools/* o bridge injeta uma barra fixa no topo.
           O header sticky deve ceder espaço para ela não sobrepor o conteúdo. */
        body.vd-web-tool-active header {
            top: var(--vd-web-toolbar-h, 52px);
        }

        .actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            align-items: stretch;
            justify-content: flex-end;
            overflow: visible;
            flex: 1 1 560px;
            max-width: 720px;
            min-width: 0;
        }
        .actions-break{
            flex-basis: 100%;
            width: 0;
            height: 0;
            margin: 0;
            padding: 0;
        }
        .actions .btn:not(.btn-theme){
            width: 118px;
            min-width: 118px;
            min-height: 44px;
            height: 44px;
            padding: 6px 8px;
            font-size: 0.8rem;
            line-height: 1.08;
            justify-content: center;
            text-align: center;
            white-space: normal;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .actions .btn-theme{
            width: 36px;
            min-width: 36px;
            height: 44px;
            padding: 0;
            justify-content: center;
            font-size: 1rem;
        }
        .actions .btn-actions-toggle{ display: none; }
        @media(min-width: 1024px){
            .actions { flex-wrap: wrap; }
        }
        @media(max-width: 1280px){
            .actions .btn:not(.btn-theme){
                width: 112px;
                min-width: 112px;
                font-size: 0.71rem;
            }
        }
        @media(max-width: 768px){
            .actions-break{ display: none; }
        }

        /* SCORE DE QUALIDADE */
        .quality-score {
            position: relative;
            display: inline-flex;
            flex-direction: column;
            gap: 2px;
            padding: 4px 10px;
            border-radius: 12px;
            border: 1px solid rgba(255,255,255,0.35);
            background: rgba(255,255,255,0.18);
            min-width: 120px;
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
        }
        .quality-score-main {
            display: flex;
            align-items: baseline;
            gap: 6px;
        }
        .quality-score-label { font-weight: 700; font-size: 0.78rem; opacity: 0.95; }
        .quality-score-value { font-weight: 800; font-size: 0.95rem; letter-spacing: 0.4px; }
        .quality-score-sub {
            font-size: 0.68rem;
            opacity: 0.9;
            display: flex;
            align-items: center;
            gap: 4px;
        }
        .quality-score-sub .sep { opacity: 0.6; margin: 0 2px; }
        .quality-score-tooltip {
            position: absolute;
            top: 110%;
            left: 0;
            z-index: 5;
            display: none;
            width: 260px;
            max-width: calc(100vw - 24px);
            padding: 8px 10px;
            background: rgba(0,0,0,0.85);
            color: #fff;
            font-size: 0.72rem;
            border-radius: 6px;
            box-shadow: 0 6px 14px rgba(0,0,0,0.25);
        }
        .quality-score:hover .quality-score-tooltip,
        .quality-score:focus .quality-score-tooltip,
        .quality-score:focus-within .quality-score-tooltip { display: block; }
        @media(max-width: 768px) {
            .quality-score { min-width: 92px; padding: 3px 7px; border-radius: 10px; }
            .quality-score-label { font-size: 0.7rem; }
            .quality-score-value { font-size: 0.84rem; }
            .quality-score-sub { font-size: 0.62rem; }
            .quality-score-tooltip { width: 220px; }
        }

        /* TABS */
        .tabs {
            display: flex; background: var(--bg-card, #ffffff);
            border-bottom: 2px solid var(--border);
            padding: 0 30px; gap: 5px;
            box-shadow: 0 2px 12px rgba(0,0,0,0.08);
            position: static;
            top: auto;
            z-index: auto;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            align-items: center;
            min-height: 52px;
            backdrop-filter: none;
        }
        @media(max-width: 768px) {
            .tabs { padding: 0 15px; gap: 3px; top: auto; }
        }
        @media(max-width: 480px) {
            .tabs { gap: 0; }
        }
        .tab-btn {
            padding: 8px 12px; border: none; background: transparent;
            font-weight: 600; color: #888;
            cursor: pointer; border-bottom: 4px solid transparent;
            transition: all var(--transition, 0.2s ease);
            font-size: 0.8rem;
            display: flex; align-items: center; gap: 8px;
            position: relative;
            white-space: nowrap;
            min-height: 44px;
            line-height: 1.2;
            flex-shrink: 0;
            border-radius: 4px 4px 0 0;
        }
        @media(max-width: 768px) {
            .tab-btn { padding: 6px 10px; font-size: 0.7rem; gap: 4px; min-height: 44px; }
            .tab-btn svg { width: 14px; height: 14px; }
        }
        @media(max-width: 480px) {
            .tab-btn { padding: 6px 8px; font-size: 0.75rem; gap: 2px; }
            .tab-btn svg { display: none; }
        }
        .tab-btn svg { width: 18px; height: 18px; fill: currentColor; transition: transform 0.3s; }
        .tab-btn:hover { background: #f5f5f5; color: var(--primary); transform: translateY(-2px); }
        .tab-btn:hover svg { transform: scale(1.1); }
        /* R-UX05 fix: indicador visual de foco para navegação por teclado (setas) */
        .tab-btn:focus-visible { outline: 3px solid var(--primary, #1565c0); outline-offset: 2px; background: #e3f2fd; }
        [data-theme="dark"] .tab-btn:focus-visible { background: rgba(25, 118, 210, 0.15); }
        .tab-btn.active {
            color: var(--text-main); border-bottom-color: var(--primary);
            background: #ffffff;
            font-weight: 700;
        }
        .tab-btn.vigilancia.active {
            color: var(--secondary); border-bottom-color: var(--secondary);
            background: #ffffff;
        }

        /* Mobile shell (paridade ACE): abas inferiores + ações de campo fixas */
        .vd-mobile-actions { display: none; }
        @media(max-width: 768px) {
            :root {
                --vd-mobile-actions-h: 56px;
                --vd-mobile-tabbar-h: 52px;
                --vd-mobile-chrome-bottom: calc(
                    var(--vd-mobile-actions-h) + var(--vd-mobile-tabbar-h)
                    + env(safe-area-inset-bottom, 0px)
                );
                --vd-toast-bottom: calc(var(--vd-mobile-chrome-bottom) + 12px);
            }
            .tabs.vd-bottom-tabbar {
                position: fixed;
                left: 0;
                right: 0;
                bottom: calc(var(--vd-mobile-actions-h) + env(safe-area-inset-bottom, 0px));
                z-index: 1001;
                margin: 0;
                padding: 6px calc(12px + env(safe-area-inset-right, 0px)) 6px calc(12px + env(safe-area-inset-left, 0px));
                gap: 6px;
                min-height: var(--vd-mobile-tabbar-h);
                border-bottom: none;
                border-top: 1px solid var(--border);
                box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
                overflow-x: visible;
            }
            .tabs.vd-bottom-tabbar .tab-btn {
                flex: 1;
                justify-content: center;
                text-align: center;
                border-bottom: none;
                border-top: 3px solid transparent;
                border-radius: 8px 8px 0 0;
                min-height: 44px;
                font-size: 0.72rem;
                gap: 4px;
            }
            .tabs.vd-bottom-tabbar .tab-btn svg {
                display: block;
                width: 16px;
                height: 16px;
            }
            .tabs.vd-bottom-tabbar .tab-btn.active {
                border-top-color: var(--primary);
            }
            .tabs.vd-bottom-tabbar .tab-btn.vigilancia.active {
                border-top-color: var(--secondary);
            }
            .tabs.vd-bottom-tabbar .tab-btn:hover { transform: none; }
            .vd-mobile-actions {
                display: flex;
                position: fixed;
                left: 0;
                right: 0;
                bottom: 0;
                z-index: 1002;
                gap: 8px;
                padding: 8px calc(12px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
                background: var(--bg-card, #ffffff);
                border-top: 1px solid var(--border);
                box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.14);
            }
            .vd-mobile-actions .btn {
                flex: 1;
                min-height: 44px;
                font-size: 0.82rem;
                font-weight: 700;
                max-width: none;
                width: auto;
            }
            .actions .btn-save,
            .actions .btn-import { display: none !important; }
            .actions-mobile-hint { display: none !important; }
        }

        /* CONTAINER */
        .container { max-width: 1240px; margin: 30px auto; padding-bottom: 80px; padding-left: 20px; padding-right: 20px; }
        @media(max-width: 768px) {
            .container { margin: 15px auto; padding-bottom: calc(var(--vd-mobile-chrome-bottom, 108px) + 16px); padding-left: 12px; padding-right: 12px; }
        }
        @media(max-width: 480px) {
            .container { margin: 10px auto; padding-bottom: 50px; padding-left: 10px; padding-right: 10px; }
        }
        .tab-content { display: none !important; animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1); content-visibility: auto; }
        .tab-content.active { display: block !important; content-visibility: visible; }
        @keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
        @media(prefers-reduced-motion: reduce) {
            .tab-content { animation: none; }
            .card, .btn { transition: none !important; }
        }
        /* N-β: prefers-contrast: more (paridade ACE C) */
        @media (prefers-contrast: more) {
            :root { --border: #757575; }
            .card, .input-wrapper input, .input-wrapper select, .input-wrapper textarea, .btn, .tab-btn {
                border-width: 2px;
            }
            .vd-toast-container, .vd-confirm-overlay { forced-color-adjust: none; }
        }

        /* CARDS */
        .card {
            background: var(--bg-paper); border-radius: var(--radius);
            padding: 28px; margin-bottom: 24px;
            box-shadow: 0 3px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
            border-left: 5px solid var(--primary);
            position: relative;
            transition: box-shadow 0.3s, transform 0.3s;
            contain: layout style;
        }
        @media(max-width: 768px) {
            .card { padding: 18px; margin-bottom: 16px; }
        }
        @media(max-width: 480px) {
            .card { padding: 14px; margin-bottom: 12px; border-radius: 4px; }
        }
        .card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08); transform: translateY(-2px); }
        .card.vigilancia { border-left-color: var(--secondary); }
        .card.danger { border-left-color: var(--accent); box-shadow: 0 3px 12px rgba(198,40,40,0.12); }

        .card h2 {
            margin-top: 0; font-size: 1.15rem; color: var(--primary);
            border-bottom: 2px solid var(--border);
            padding-bottom: 14px; margin-bottom: 24px;
            display: flex; align-items: center; gap: 12px;
            font-weight: 600; letter-spacing: 0.3px;
        }
        .card.vigilancia h2 { color: var(--secondary); }
        .card.danger h2 { color: var(--accent); }

        /* COLLAPSIBLE (CHIKUNGUNYA) */
        details.chikungunya {
            border: 1px dashed var(--border);
            border-radius: 6px;
            padding: 10px 12px;
            background: rgba(2, 119, 189, 0.04);
        }
        details.chikungunya summary {
            cursor: pointer;
            font-weight: 600;
            color: var(--secondary);
            list-style: none;
        }
        details.chikungunya summary::-webkit-details-marker { display: none; }
        details.chikungunya[open] summary { margin-bottom: 10px; }

        /* GRID SYSTEM */
        .grid { 
            display: grid; 
            grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
            gap: 12px 16px; 
            width: 100%;
        }
        .grid.manejo-clinico { 
            grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
        }
        /* Para seções "densas" (menos rolagem): reduz o min-width das colunas */
        .grid.compact {
            grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
            gap: 10px 12px;
        }
        .col-2 { grid-column: span 2; }
        .col-3 { grid-column: span 3; }
        .col-full { grid-column: 1 / -1; }
        
        @media(max-width: 1400px) {
            .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
            .grid.manejo-clinico { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
            .grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
        }
        
        @media(max-width: 1024px) {
            .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
            .grid.manejo-clinico { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
            .grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
        }
        
        @media(max-width: 768px) { 
            .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
            .grid.manejo-clinico { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
            .grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
            .col-2, .col-3 { grid-column: span 1; }
        }
        /* UX-47: breakpoint intermediário para evitar 1-coluna em 481-600px */
        @media(min-width: 481px) and (max-width: 600px) {
            .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
            .grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); }
        }
        
        @media(max-width: 480px) {
            .grid { grid-template-columns: 1fr; }
            .grid.manejo-clinico { grid-template-columns: 1fr; }
            .grid.compact { grid-template-columns: 1fr; }
            .col-2, .col-3, .col-full { grid-column: span 1; }
        }
        /* FORM ELEMENTS */
        .input-wrapper { 
            position: relative; 
            margin-bottom: 4px; 
            min-width: 0;
            overflow: visible;
            word-break: break-word;
            overflow-wrap: break-word;
        }
        label {
            display: block; font-size: 0.78rem; font-weight: 600;
            color: var(--text-muted); margin-bottom: 5px;
            letter-spacing: 0.2px;
            word-break: break-word;
            overflow-wrap: break-word;
        }
        @media(max-width: 768px) {
            label { font-size: 0.75rem; margin-bottom: 4px; }
        }
        @media(max-width: 480px) {
            label { font-size: 0.76rem; margin-bottom: 3px; }
        }
        label span.num { color: var(--primary); font-weight: 700; margin-right: 6px; font-size: 0.88rem; }
        label span.req { color: var(--accent); margin-left: 3px; font-size: 1.1em; }

        input, select, textarea {
            width: 100%; padding: 9px 12px;
            border: 1.5px solid var(--border);
            border-radius: 6px;
            background: var(--bg-paper); color: var(--text-main);
            font-size: 0.95rem; font-family: inherit;
            word-break: break-word;
            overflow-wrap: break-word;
            white-space: normal;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        @media(max-width: 768px) {
            input, select, textarea { padding: 8px 10px; font-size: 0.9rem; }
        }
        @media(max-width: 480px) {
            input, select, textarea { padding: 7px 10px; font-size: 16px; }
            /* UX-48: prevent long select text overflow on narrow screens */
            select { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%; }
        }
        input:focus, select:focus, textarea:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0,105,92,0.12);
            background: #fafafa;
        }
        input[readonly] {
            background: #f5f5f5;
            cursor: not-allowed;
            font-weight: 600;
            color: #607d8b;
            border-style: dashed;
        }

        /* COMPACT (igual ao Manejo - itens menores) */
        .compact-fields label { font-size: 0.78rem; margin-bottom: 5px; }
        .compact-fields input,
        .compact-fields select,
        .compact-fields textarea { padding: 9px 12px; font-size: 0.9rem; }
        @media(max-width: 768px) {
            .compact-fields label { font-size: 0.75rem; margin-bottom: 4px; }
            .compact-fields input,
            .compact-fields select,
            .compact-fields textarea { padding: 8px 10px; font-size: 0.85rem; }
        }
        @media(max-width: 480px) {
            .compact-fields label { font-size: 0.7rem; margin-bottom: 3px; }
            .compact-fields input,
            .compact-fields select,
            .compact-fields textarea { padding: 7px 10px; font-size: 14px; }
        }
        .compact-fields .check-btn { padding: 8px; font-size: 0.85rem; }
        .compact-fields .card { padding: 22px; }
        .compact-fields .card h2 { font-size: 1.05rem; padding-bottom: 10px; margin-bottom: 18px; }

        /* POPUP DE ALERTA (Endereço/Telefone) */
        .popup-warning {
            position: absolute; bottom: 105%; left: 0; background: var(--warning-bg); color: var(--warning-text);
            padding: 8px 12px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; border: 1px solid #ffe0b2;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1); display: none; z-index: 10; width: 100%;
        }
        .input-wrapper:focus-within .popup-warning, .input-wrapper:hover .popup-warning { display: block; animation: fadeIn 0.2s; }

        /* CHECKBOXES */
        fieldset.check-fieldset {
            border: none; padding: 0; margin: 0; min-width: 0;
        }
        fieldset.check-fieldset > legend {
            font-weight: 700; font-size: 1rem; margin-bottom: 12px; padding: 0;
        }
        .check-group { 
            display: grid; 
            grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); 
            gap: 12px; 
            margin-top: 10px;
            align-items: center;
        }
        /* Campos 33 e 34: 3 colunas em PC, reduz tamanho da caixa */
        #checklist_campo33, #checklist_campo34 {
            grid-template-columns: repeat(3, 1fr);
        }
        #checklist_campo33 .check-btn, #checklist_campo34 .check-btn {
            padding: 6px 10px;
            font-size: 0.8rem;
        }
        @media(max-width: 1024px) {
            #checklist_campo33, #checklist_campo34 {
                grid-template-columns: repeat(2, 1fr);
            }
        }
        @media(max-width: 768px) {
            #checklist_campo33, #checklist_campo34 {
                grid-template-columns: repeat(2, 1fr);
            }
        }
        @media(max-width: 480px) {
            #checklist_campo33, #checklist_campo34 {
                grid-template-columns: 1fr;
            }
            .epi-two-col { grid-template-columns: 1fr !important; }
        }
        .check-btn {
            display: flex; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
            cursor: pointer; font-size: 0.85rem; transition: 0.2s; background: var(--bg-paper);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            /* UX-20: touch target mínimo 44px (WCAG 2.5.5) */
            min-height: 44px;
        }
        /* Para textos longos (ex.: viagem/epidemiologia): não truncar com reticências */
        .check-btn.wrap {
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
            align-items: flex-start;
        }
        .check-btn.wrap input { margin-top: 2px; }
        .check-btn:hover { background: rgba(0,0,0,0.02); border-color: var(--primary); }
        .check-btn input { width: auto; margin-right: 10px; transform: scale(1.1); cursor: pointer; }
        .check-btn.active { background: #e0f2f1; border-color: var(--primary); color: var(--primary); font-weight: 700; }
        .check-btn.active-alarm { background: #ffebee; border-color: var(--accent); color: #c62828; font-weight: 700; }
        /* Tri-state: not-informed (indeterminate) — campo não avaliado pelo profissional */
        .check-btn.not-informed { border-style: dashed; border-color: #9e9e9e; opacity: 0.65; }
        .check-btn.not-informed input[type="checkbox"] { opacity: 0.4; }

        /* Campos obrigatórios faltando (destacar antes de exportar código/TXT) */
        .input-wrapper.missing label { color: #b71c1c; }
        .input-wrapper.missing input,
        .input-wrapper.missing select,
        .input-wrapper.missing textarea {
            outline: 2px solid #d32f2f;
            background: var(--bg-missing, #fff5f5);
        }
        /* Fallback quando o campo não está dentro de .input-wrapper */
        .missing-field {
            outline: 2px solid #d32f2f !important;
            background: var(--bg-missing, #fff5f5) !important;
        }
        /* N-β: regra CSS para aria-invalid (paridade ACE B2) */
        input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
            outline: 2px solid #d32f2f;
            background: var(--bg-missing, #fff5f5);
        }
        [data-theme="dark"] input[aria-invalid="true"], [data-theme="dark"] select[aria-invalid="true"], [data-theme="dark"] textarea[aria-invalid="true"] {
            outline-color: #ef9a9a;
            background: rgba(198, 40, 40, 0.20);
        }
        /* Auditoria visual: obrigatorio (forte) e recomendado (suave). */
        .input-wrapper.audit-required label { color: #b71c1c; }
        .input-wrapper.audit-required input,
        .input-wrapper.audit-required select,
        .input-wrapper.audit-required textarea {
            border-color: #d32f2f;
            box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.18);
            background: #fff5f5;
        }
        .input-wrapper.audit-recommended label { color: #6a1b9a; }
        .input-wrapper.audit-recommended input,
        .input-wrapper.audit-recommended select,
        .input-wrapper.audit-recommended textarea {
            border-color: #8e24aa;
            box-shadow: 0 0 0 2px rgba(142, 36, 170, 0.12);
            background: #faf5ff;
        }
        .check-btn.audit-required, .check-group.audit-required {
            border-color: #d32f2f !important;
            box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.20);
            background: #fff5f5;
        }
        .check-btn.audit-recommended, .check-group.audit-recommended {
            border-color: #8e24aa !important;
            box-shadow: 0 0 0 2px rgba(142, 36, 170, 0.14);
            background: #faf5ff;
        }
        .audit-required-field {
            outline: 2px solid #d32f2f !important;
            background: #fff5f5 !important;
        }
        .audit-recommended-field {
            outline: 2px dashed #8e24aa !important;
            background: #faf5ff !important;
        }
        [data-theme="dark"] .input-wrapper.audit-required label { color: #ff8a80; }
        [data-theme="dark"] .input-wrapper.audit-required input,
        [data-theme="dark"] .input-wrapper.audit-required select,
        [data-theme="dark"] .input-wrapper.audit-required textarea {
            border-color: #ef9a9a;
            box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.32);
            background: rgba(198, 40, 40, 0.20);
        }
        [data-theme="dark"] .input-wrapper.audit-recommended label { color: #ce93d8; }
        [data-theme="dark"] .input-wrapper.audit-recommended input,
        [data-theme="dark"] .input-wrapper.audit-recommended select,
        [data-theme="dark"] .input-wrapper.audit-recommended textarea {
            border-color: #ce93d8;
            box-shadow: 0 0 0 2px rgba(186, 104, 200, 0.28);
            background: rgba(123, 31, 162, 0.22);
        }
        [data-theme="dark"] .check-btn.audit-required, [data-theme="dark"] .check-group.audit-required {
            border-color: #ef9a9a !important;
            box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.30);
            background: rgba(198, 40, 40, 0.18);
        }
        [data-theme="dark"] .check-btn.audit-recommended, [data-theme="dark"] .check-group.audit-recommended {
            border-color: #ce93d8 !important;
            box-shadow: 0 0 0 2px rgba(186, 104, 200, 0.24);
            background: rgba(123, 31, 162, 0.18);
        }
        [data-theme="dark"] .audit-required-field {
            outline-color: #ef9a9a !important;
            background: rgba(198, 40, 40, 0.20) !important;
        }
        [data-theme="dark"] .audit-recommended-field {
            outline-color: #ce93d8 !important;
            background: rgba(123, 31, 162, 0.20) !important;
        }

        /* Campos marcados como "Ignorado" */
        .ignored-field label { color: #8e24aa; }
        .ignored-field select {
            outline: 2px dashed #8e24aa;
            background: #f3e5f5;
        }
        .ignored-warning {
            margin-top: 6px;
            padding: 6px 8px;
            font-size: 0.75rem;
            border-left: 3px solid var(--border-ignored, #8e24aa);
            background: rgba(142, 36, 170, 0.08);
            color: #6a1b9a;
            border-radius: 4px;
        }

        /* DIAGNOSTIC BOX */
        .diag-box {
            padding: 15px; border-radius: 6px; margin-top: 5px; font-weight: bold; display: none; align-items: center; gap: 10px;
        }
        .diag-ns1 { background: #fff3e0; color: #e65100; border-left: 5px solid var(--border-diag-ns1, #ff9800); }
        .diag-igm { background: #e8eaf6; color: #283593; border-left: 5px solid var(--border-diag-igm, #3f51b5); }
        .vd-date-error { color: #c62828; font-size: 0.78rem; margin-top: 3px; }
        [data-theme="dark"] .vd-date-error { color: #ef9a9a; }
        /* v8.0.9: Date picker button — v8.1.2: sub-wrapper keeps icon centered on input */
        .vd-date-input-wrap { position: relative; }
        .vd-date-pick-btn {
            position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
            background: none; border: none; cursor: pointer; font-size: 1.1rem;
            padding: 8px 6px; opacity: 0.55; transition: opacity 0.2s;
            line-height: 1;
            min-width: 36px; min-height: 36px;
            display: flex; align-items: center; justify-content: center;
        }
        .vd-date-pick-btn:hover { opacity: 1; }
        .vd-date-pick-hidden { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; overflow: hidden; }

        /* UX-27: Auto-save indicator */
        .vd-autosave-badge {
            position: fixed; bottom: 12px; right: 12px; z-index: 9000;
            background: #388e3c; color: #fff; padding: 6px 14px; border-radius: 20px;
            font-size: 0.78rem; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
            opacity: 0; transition: opacity 0.3s ease;
            pointer-events: none;
        }
        .vd-autosave-badge.show { opacity: 1; }
        [data-theme="dark"] .vd-autosave-badge { background: #2e7d32; }

        /* BUTTONS */
        .btn {
            border: none; padding: 11px 22px; border-radius: 6px;
            font-weight: 600; cursor: pointer; color: white;
            display: inline-flex; align-items: center; gap: 8px;
            font-size: 0.92rem;
            white-space: nowrap;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 6px rgba(0,0,0,0.15);
        }
        .btn:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.2); filter: brightness(1.08); }
        .btn:active { box-shadow: 0 1px 3px rgba(0,0,0,0.2); filter: brightness(0.95); }
        .btn:focus-visible { outline: 3px solid var(--primary, #1565c0); outline-offset: 2px; }
        .btn-import { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); }
        .btn-import:hover { background: rgba(255,255,255,0.25); }
        .btn-save { background: var(--success, #2e7d32); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
        .btn-save:hover { background: #1b5e20; }
        .btn-magic { background: linear-gradient(135deg, #7b1fa2, #6a1b9a); }
        .btn-magic:hover { background: linear-gradient(135deg, #6a1b9a, #4a148c); }
        .btn-danger { background: var(--action-danger, #d32f2f); }
        .btn-danger:hover { background: var(--action-danger-hover, #b71c1c); }
        .btn-print-notif { background: var(--action-print, #1976d2); }
        .btn-print-notif:hover { background: var(--action-print-hover, #0d47a1); }
        .btn-print-card { background: var(--action-card, #00897b); }
        .btn-print-card:hover { background: var(--action-card-hover, #00695c); }
        .btn-audit-action { background: var(--action-audit, #6f42c1); }
        .btn-audit-action:hover { background: var(--action-audit-hover, #59359c); }
        .btn-theme { background: transparent; padding: 5px; font-size: 1.2rem; }

        /* v7.4: Modal de código profissional */
        .modal-code { max-width: 640px; padding: 0; overflow-y: auto; max-height: 90vh; }
        .modal-code-header {
            display: flex; align-items: center; gap: 12px;
            padding: 16px 20px; background: linear-gradient(135deg, #1a237e, #283593);
            color: white; position: relative;
        }
        .modal-code-icon { font-size: 1.6rem; }
        .modal-code-header h3 { color: white; }
        .modal-code-header p { color: rgba(255,255,255,0.75) !important; }
        .modal-close-x {
            position: absolute; right: 12px; top: 12px;
            background: rgba(255,255,255,0.15); border: none; color: white;
            width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
            font-size: 1rem; display: flex; align-items: center; justify-content: center;
            transition: background 0.2s;
        }
        .modal-close-x:hover { background: rgba(255,255,255,0.3); }
        .modal-code .whatsapp-contact { margin: 12px 20px 0 20px; }
        .magic-textarea-wrap { position: relative; margin: 12px 20px 0 20px; }
        .magic-textarea-wrap textarea {
            width: 100%; height: 120px; font-family: 'Courier New', monospace;
            padding: 12px;
            background: linear-gradient(135deg, #1a237e, #263238);
            color: #80cbc4; border-radius: 8px; border: 1px solid #37474f;
            font-size: 0.82rem; resize: vertical;
        }
        .magic-textarea-actions {
            display: flex; gap: 6px; justify-content: flex-end;
            margin-top: 6px;
        }
        .magic-inline-btn {
            background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
            color: #80cbc4; border-radius: 4px; padding: 3px 8px;
            font-size: 0.72rem; cursor: pointer; transition: background 0.2s;
        }
        .magic-inline-btn:hover { background: rgba(255,255,255,0.22); }
        .magic-inline-clear { color: #ef9a9a; border-color: rgba(239,154,154,0.3); }
        .magic-inline-clear:hover { background: rgba(239,154,154,0.18); }
        .modal-code .magic-meta { padding: 0 20px; margin-top: 4px; }
        .modal-code .magic-warning { margin: 8px 20px 0 20px; }
        .modal-code .magic-validation { margin: 8px 20px 0 20px; }
        .modal-code-actions {
            display: flex; justify-content: space-between; align-items: center;
            padding: 14px 20px; margin-top: 12px;
            border-top: 1px solid var(--border); background: var(--bg-body);
        }
        .modal-btn-secondary {
            background: transparent !important; color: var(--text-muted) !important;
            border: 1px solid var(--border) !important; box-shadow: none !important;
        }
        .modal-btn-secondary:hover { background: rgba(0,0,0,0.05) !important; }
        [data-theme="dark"] .modal-code-header { background: linear-gradient(135deg, #1a237e, #0d47a1); }
        [data-theme="dark"] .modal-btn-secondary { color: var(--text-main) !important; border-color: var(--border) !important; }
        [data-theme="dark"] .modal-btn-secondary:hover { background: rgba(255,255,255,0.08) !important; }
        @media(max-width: 640px) {
            .modal-code { max-width: 95%; }
            .modal-code-actions { flex-direction: column; gap: 8px; }
            .modal-code-actions > div { width: 100%; display: flex; justify-content: flex-end; }
        }

        /* QUICK NAV */
        .quick-nav-side, .quick-nav-vertical {
            position: fixed;
            z-index: 950;
        }
        .quick-nav-side.left {
            left: 8px;
            top: 52%;
            transform: translateY(-50%);
        }
        .quick-nav-side.right {
            right: 8px;
            top: 52%;
            transform: translateY(-50%);
        }
        .quick-nav-vertical {
            right: 8px;
            bottom: 12px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .quick-nav-btn {
            border: 1px solid #0b5d8d;
            background: #ffffff;
            color: #0b4f77;
            border-radius: 999px;
            padding: 7px 10px;
            font-size: 0.74rem;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(0,0,0,0.16);
            white-space: nowrap;
        }
        .quick-nav-btn:hover { background: #e9f5ff; }
        .quick-nav-btn:disabled,
        .quick-nav-btn.is-disabled {
            border-color: #cfd8dc;
            background: #eceff1;
            color: #90a4ae;
            box-shadow: none;
            cursor: not-allowed;
        }
        .quick-nav-btn:disabled:hover,
        .quick-nav-btn.is-disabled:hover { background: #eceff1; }
        .vd-coherence-btn {
            position: fixed;
            right: 8px;
            bottom: 112px;
            z-index: 960;
            border: 1px solid #f57c00;
            background: #fff3e0;
            color: #a84300;
            border-radius: 999px;
            padding: 8px 12px;
            font-size: 0.74rem;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(0,0,0,0.16);
            white-space: nowrap;
            display: none;
        }
        .vd-coherence-btn.show { display: inline-flex; align-items: center; gap: 6px; }
        .vd-coherence-btn:hover { background: #ffe0b2; }
        .vd-coherence-back-btn {
            bottom: 152px;
            border-color: #1565c0;
            background: #e3f2fd;
            color: #0d47a1;
        }
        .vd-coherence-back-btn:hover { background: #d6ecff; }
        [data-theme="dark"] .vd-coherence-btn {
            background: rgba(239,108,0,0.22);
            border-color: #ffb74d;
            color: #ffcc80;
        }
        [data-theme="dark"] .vd-coherence-back-btn {
            background: rgba(21,101,192,0.26);
            border-color: #64b5f6;
            color: #bbdefb;
        }
        .vd-coherence-list { margin: 8px 0 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
        .vd-coherence-item { border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; padding: 8px 10px; background: var(--bg-paper); }
        .vd-coherence-item.alta { border-left-color: #d32f2f; }
        .vd-coherence-item.media { border-left-color: #ef6c00; }
        .vd-coherence-item.baixa { border-left-color: #546e7a; }
        .vd-coherence-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
        .vd-coherence-title { font-weight: 700; font-size: 0.83rem; color: var(--text-main); }
        .vd-coherence-badge { font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 2px 7px; border: 1px solid transparent; }
        .vd-coherence-item.alta .vd-coherence-badge { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
        .vd-coherence-item.media .vd-coherence-badge { background: #fff3e0; border-color: #ffcc80; color: #a84300; }
        .vd-coherence-item.baixa .vd-coherence-badge { background: #eceff1; border-color: #b0bec5; color: #37474f; }
        .vd-coherence-detail { margin-top: 5px; font-size: 0.78rem; line-height: 1.45; color: var(--text-muted); }
        .vd-coherence-detail b { color: var(--text-main); }
        .vd-coherence-context { margin-top: 5px; font-size: 0.75rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
        .vd-coherence-field-btn {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--secondary);
            border-radius: 999px;
            padding: 2px 7px;
            font-size: 0.7rem;
            cursor: pointer;
            font-weight: 600;
        }
        .vd-coherence-field-btn:hover { background: rgba(2, 119, 189, 0.08); }
        .vd-coherence-actions { margin-top: 6px; }
        .vd-coherence-goto {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--secondary);
            border-radius: 999px;
            padding: 3px 8px;
            font-size: 0.72rem;
            cursor: pointer;
            font-weight: 700;
        }
        .vd-coherence-goto:hover { background: rgba(2, 119, 189, 0.08); }
        [data-theme="dark"] .vd-coherence-item { background: rgba(255,255,255,0.03); }
        [data-theme="dark"] .vd-coherence-item.alta .vd-coherence-badge { background: rgba(198,40,40,0.22); border-color: #ef9a9a; color: #ffb3b3; }
        [data-theme="dark"] .vd-coherence-item.media .vd-coherence-badge { background: rgba(239,108,0,0.22); border-color: #ffb74d; color: #ffd180; }
        [data-theme="dark"] .vd-coherence-item.baixa .vd-coherence-badge { background: rgba(96,125,139,0.25); border-color: #90a4ae; color: #cfd8dc; }
        [data-theme="dark"] .vd-coherence-field-btn { border-color: #607d8b; color: #90caf9; }
        /* UX-48: year auto-complete chip */
        .vd-year-chip {
            display: inline-block;
            margin-top: 3px;
            padding: 3px 10px;
            font-size: 0.74rem;
            font-weight: 700;
            border: 1px dashed #1565c0;
            background: #e3f2fd;
            color: #0d47a1;
            border-radius: 999px;
            cursor: pointer;
            animation: fadeIn 0.3s ease;
        }
        .vd-year-chip:hover { background: #bbdefb; }
        [data-theme="dark"] .vd-year-chip { background: rgba(21,101,192,0.22); border-color: #64b5f6; color: #bbdefb; }
        [data-theme="dark"] .vd-year-chip:hover { background: rgba(21,101,192,0.35); }
        /* UX-48: "Hoje" chip for data_notificacao */
        .vd-today-chip {
            padding: 4px 10px;
            font-size: 0.74rem;
            font-weight: 700;
            border: 1px solid #2e7d32;
            background: #e8f5e9;
            color: #1b5e20;
            border-radius: 999px;
            cursor: pointer;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .vd-today-chip:hover { background: #c8e6c9; }
        [data-theme="dark"] .vd-today-chip { background: rgba(46,125,50,0.22); border-color: #66bb6a; color: #a5d6a7; }
        [data-theme="dark"] .vd-today-chip:hover { background: rgba(46,125,50,0.35); }
        /* UX-49: agravo suggestion banner */
        .vd-agravo-suggest {
            margin-top: 6px;
            padding: 6px 10px;
            font-size: 0.78rem;
            border: 1px dashed #ef6c00;
            background: #fff3e0;
            color: #e65100;
            border-radius: 6px;
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .vd-agravo-suggest button {
            padding: 3px 10px;
            font-size: 0.72rem;
            font-weight: 700;
            border: 1px solid #ef6c00;
            background: #fff;
            color: #e65100;
            border-radius: 999px;
            cursor: pointer;
        }
        .vd-agravo-suggest button:hover { background: #ffe0b2; }
        [data-theme="dark"] .vd-agravo-suggest { background: rgba(239,108,0,0.16); border-color: #ffb74d; color: #ffe0b2; }
        .diag-diff-hint {
            margin-top: 10px;
            padding: 10px 12px;
            border-radius: 6px;
            border-left: 4px solid #ef6c00;
            background: #fff8e1;
            color: #5d4037;
            font-size: 0.83rem;
            line-height: 1.45;
            display: none;
        }
        .diag-diff-hint strong { color: #bf360c; }
        .diag-diff-hint .muted-note { display:block; margin-top:4px; font-size:0.77rem; color:#795548; }
        .diag-diff-hint.misto {
            border-left-color: #0277bd;
            background: #e3f2fd;
            color: #0d47a1;
        }
        .diag-diff-hint.misto strong { color: #01579b; }
        /* --- Novo motor de hipóteses: estilos por confiança --- */
        .diag-list { margin:8px 0 8px 0; padding:0; list-style:none; }
        .diag-item { margin:0 0 10px 0; padding:8px 10px; border-radius:5px; border-left:3px solid #bdbdbd; background:#fafafa; }
        .diag-item.conf-alta { border-left-color:#c62828; background:#ffebee; }
        .diag-item.conf-moderada { border-left-color:#f9a825; background:#fffde7; }
        .diag-item.conf-baixa { border-left-color:#1565c0; background:#e3f2fd; }
        .diag-item.conf-possivel { border-left-color:#9e9e9e; background:#f5f5f5; }
        .diag-header { margin-bottom:4px; }
        .diag-conf { font-size:0.78rem; color:#616161; font-weight:normal; }
        .urg-badge { display:inline-block; font-size:0.68rem; font-weight:700; padding:1px 6px; border-radius:3px; margin-left:6px; vertical-align:middle; }
        .urg-badge.urg-3 { background:#c62828; color:#fff; }
        .urg-badge.urg-2 { background:#e65100; color:#fff; }
        .diag-present, .diag-missing { font-size:0.79rem; margin:2px 0; line-height:1.5; }
        .sym-present { display:inline-block; background:#c8e6c9; color:#1b5e20; padding:1px 5px; border-radius:3px; margin:1px 2px; font-size:0.76rem; }
        .sym-missing-core { display:inline-block; background:#ffcdd2; color:#b71c1c; padding:1px 5px; border-radius:3px; margin:1px 2px; font-size:0.76rem; }
        .sym-missing-supp { display:inline-block; background:#fff9c4; color:#f57f17; padding:1px 5px; border-radius:3px; margin:1px 2px; font-size:0.76rem; }
        .diag-exams { font-size:0.77rem; margin:3px 0; color:#4e342e; }
        .diag-notes { font-size:0.77rem; margin:2px 0; color:#37474f; font-style:italic; }
        .diag-ref { font-size:0.7rem; color:#9e9e9e; margin-top:2px; }
        [data-theme="dark"] .diag-item { background:rgba(255,255,255,0.06); }
        [data-theme="dark"] .diag-item.conf-alta { border-left-color:#ef5350; background:rgba(198,40,40,0.15); }
        [data-theme="dark"] .diag-item.conf-moderada { border-left-color:#ffca28; background:rgba(249,168,37,0.12); }
        [data-theme="dark"] .diag-item.conf-baixa { border-left-color:#42a5f5; background:rgba(21,101,192,0.12); }
        [data-theme="dark"] .diag-item.conf-possivel { border-left-color:#757575; background:rgba(158,158,158,0.1); }
        [data-theme="dark"] .diag-conf { color:#bdbdbd; }
        [data-theme="dark"] .sym-present { background:rgba(76,175,80,0.25); color:#a5d6a7; }
        [data-theme="dark"] .sym-missing-core { background:rgba(244,67,54,0.2); color:#ef9a9a; }
        [data-theme="dark"] .sym-missing-supp { background:rgba(255,235,59,0.15); color:#fff176; }
        [data-theme="dark"] .diag-exams { color:#ffe0b2; }
        [data-theme="dark"] .diag-notes { color:#b0bec5; }
        [data-theme="dark"] .diag-ref { color:#757575; }
        [data-theme="dark"] .diag-diff-hint {
            background: rgba(239,108,0,0.16);
            border-left-color: #ffb74d;
            color: #ffe0b2;
        }
        [data-theme="dark"] .diag-diff-hint strong { color: #ffcc80; }
        [data-theme="dark"] .diag-diff-hint .muted-note { color: #ffcc80; opacity: 0.9; }
        [data-theme="dark"] .diag-diff-hint.misto {
            background: rgba(2,119,189,0.16);
            border-left-color: #4fc3f7;
            color: #bbdefb;
        }
        [data-theme="dark"] #card_diagnostico_diferencial {
            background: linear-gradient(135deg, rgba(239,108,0,0.08) 0%, rgba(30,30,30,1) 100%);
            border-left-color: #ffb74d;
        }
        [data-theme="dark"] #diagDiffDisclaimer { background:rgba(255,255,255,0.05); color:#bdbdbd; }
        /* --- Probabilidade dengue (Bayesiano) --- */
        .diag-dengue-prob { padding:10px; border-radius:6px; margin-bottom:8px; font-size:0.82rem; line-height:1.5; }
        .dengue-gauge { position:relative; height:22px; border-radius:11px; background:#e0e0e0; overflow:hidden; margin:6px 0 4px 0; }
        .dengue-gauge-fill { height:100%; border-radius:11px; transition: width 0.5s ease; }
        .dengue-gauge-label { position:absolute; top:0; left:0; right:0; height:100%; display:flex; align-items:center; justify-content:center; font-size:0.72rem; font-weight:700; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,0.4); }
        .dgp-alta { background:#c62828; }
        .dgp-moderada { background:#ef6c00; }
        .dgp-baixa { background:#1565c0; }
        .dgp-minima { background:#9e9e9e; }
        .diag-for-against { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:6px 0; font-size:0.76rem; }
        .diag-for { background:rgba(76,175,80,0.08); padding:6px 8px; border-radius:4px; border-left:3px solid #4caf50; }
        .diag-against { background:rgba(244,67,54,0.08); padding:6px 8px; border-radius:4px; border-left:3px solid #f44336; }
        .diag-investigate { background:rgba(33,150,243,0.08); padding:6px 8px; border-radius:4px; border-left:3px solid #2196f3; margin-top:4px; font-size:0.76rem; }
        .lr-chip { display:inline-block; padding:1px 5px; border-radius:3px; margin:1px 2px; font-size:0.73rem; }
        .lr-chip.lr-for { background:#c8e6c9; color:#1b5e20; }
        .lr-chip.lr-against { background:#ffcdd2; color:#b71c1c; }
        .lr-chip.lr-invest { background:#bbdefb; color:#0d47a1; }
        [data-theme="dark"] .diag-dengue-prob { background:rgba(239,108,0,0.12); }
        [data-theme="dark"] .dengue-gauge { background:rgba(255,255,255,0.1); }
        [data-theme="dark"] .diag-for { background:rgba(76,175,80,0.12); }
        [data-theme="dark"] .diag-against { background:rgba(244,67,54,0.12); }
        [data-theme="dark"] .diag-investigate { background:rgba(33,150,243,0.12); }
        [data-theme="dark"] .lr-chip.lr-for { background:rgba(76,175,80,0.25); color:#a5d6a7; }
        [data-theme="dark"] .lr-chip.lr-against { background:rgba(244,67,54,0.2); color:#ef9a9a; }
        [data-theme="dark"] .lr-chip.lr-invest { background:rgba(33,150,243,0.2); color:#90caf9; }
        @media(max-width: 900px){
            .diag-for-against { grid-template-columns:1fr; }
        }
        @media(max-width: 768px){
            .quick-nav-side { display: none; }
            .quick-nav-vertical { right: 6px; bottom: calc(var(--vd-mobile-chrome-bottom, 108px) + 8px); }
            .quick-nav-btn { font-size: 0.7rem; padding: 6px 8px; }
            .vd-coherence-btn { right: 6px; bottom: calc(var(--vd-mobile-chrome-bottom, 108px) + 58px); font-size: 0.69rem; padding: 7px 9px; }
        }
        /* B4-fix: collapse fixed buttons on very short viewports (landscape phones) */
        @media(max-height: 500px) {
            .quick-nav-vertical { gap: 3px; bottom: 4px; }
            .quick-nav-btn { padding: 4px 7px; font-size: 0.65rem; min-height: 28px; }
            .vd-coherence-btn { bottom: 50px; padding: 5px 8px; font-size: 0.64rem; }
            .vd-coherence-back-btn { bottom: 80px; }
        }

        /* FOOTER */
        footer { text-align: center; margin-top: 40px; padding: 20px; color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--border); }

        /* v7.4: Soft validation warning banner — B5-fix: sticky instead of fixed on mobile */
        .soft-validation-banner {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1800;
            background: linear-gradient(135deg, #fff3e0, #ffe0b2);
            border-bottom: 2px solid #ffb74d;
            border-radius: 0;
            padding: 10px 16px;
            font-size: 0.85rem;
            color: #e65100;
            display: none;
            align-items: center;
            gap: 8px;
            animation: slideDown 0.3s ease;
        }
        @media(max-width: 768px) {
            .soft-validation-banner {
                position: sticky;
                font-size: 0.78rem;
                padding: 8px 12px;
            }
        }
        .soft-validation-banner.visible { display: flex; }
        [data-theme="dark"] .soft-validation-banner {
            background: linear-gradient(135deg, rgba(230,81,0,0.18), rgba(255,152,0,0.12));
            border-color: #ff9800;
            color: #ffb74d;
        }
        @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

        /* v7.5: Spotlight overlay — destaca o botão Código com escurecimento do restante */
        .spotlight-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.72);
            z-index: 8000;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 18px;
            animation: spotlightFadeIn 0.4s ease;
            cursor: pointer;
        }
        .spotlight-overlay .spotlight-btn-clone {
            background: linear-gradient(135deg, #7b1fa2, #6a1b9a);
            color: #fff;
            border: 3px solid #fff;
            border-radius: 8px;
            padding: 14px 32px;
            font-size: 1.15rem;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 0 40px rgba(123,31,162,0.6), 0 0 80px rgba(123,31,162,0.3);
            animation: spotlightPulse 1.8s ease-in-out infinite;
            letter-spacing: 0.5px;
        }
        .spotlight-overlay .spotlight-msg {
            color: #fff;
            font-size: 1rem;
            font-weight: 600;
            text-align: center;
            max-width: 420px;
            line-height: 1.5;
            text-shadow: 0 1px 4px rgba(0,0,0,0.4);
        }
        .spotlight-overlay .spotlight-dismiss {
            color: rgba(255,255,255,0.7);
            font-size: 0.78rem;
            cursor: pointer;
            margin-top: 6px;
            text-decoration: underline;
        }
        .spotlight-overlay .spotlight-dismiss:hover { color: #fff; }
        @keyframes spotlightFadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes spotlightPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(123,31,162,0.6); } 50% { transform: scale(1.06); box-shadow: 0 0 60px rgba(123,31,162,0.8); } }

        /* v7.4: Flying mosquito Easter egg */
        .aedes-mosquito {
            position: fixed;
            z-index: 9999;
            pointer-events: none;
            font-size: 28px;
            opacity: 0;
            transition: none;
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
            user-select: none;
        }
        .aedes-mosquito.flying {
            animation: mosquitoFly var(--fly-duration, 8s) linear forwards;
            opacity: 1;
            pointer-events: auto;
            cursor: crosshair;
        }
        .aedes-mosquito.dead {
            pointer-events: none;
            animation: mosquitoDie 0.6s ease forwards;
        }
        @keyframes mosquitoFly {
            0%   { opacity: 0; }
            5%   { opacity: 1; }
            90%  { opacity: 1; }
            100% { opacity: 0; }
        }
        @keyframes mosquitoDie {
            0%   { opacity: 1; transform: scale(1) rotate(0deg); }
            30%  { opacity: 1; transform: scale(1.4) rotate(20deg); }
            100% { opacity: 0; transform: scale(0.3) rotate(180deg); }
        }
        .splat-effect {
            position: fixed;
            z-index: 10000;
            pointer-events: none;
            font-size: 36px;
            animation: splatAnim 1s ease-out forwards;
        }
        @keyframes splatAnim {
            0%   { opacity: 1; transform: scale(0.5); }
            30%  { opacity: 1; transform: scale(1.3); }
            100% { opacity: 0; transform: scale(1.6) translateY(-20px); }
        }

        /* v7.4: Map modal */
        .map-modal { display: none; position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(3px); align-items: center; justify-content: center; }
        .map-modal.open { display: flex; }
        .map-modal-content { background: var(--bg-paper); border-radius: 12px; width: 90%; max-width: 700px; max-height: 90vh; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
        .map-modal-header { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
        .map-modal-header h3 { margin: 0; font-size: 1.05rem; }
        #mapContainer { width: 100%; height: 400px; position: relative; }
        /* B6-fix: map modal adapts to small viewports */
        @media(max-width: 480px) {
            .map-modal-content { width: 98%; max-height: 95vh; }
            #mapContainer { height: 260px; }
            .map-modal-header { padding: 10px 12px; }
            .map-modal-header h3 { font-size: 0.9rem; }
            .map-modal-footer { padding: 8px 12px; font-size: 0.78rem; flex-wrap: wrap; }
        }
        @media(max-height: 500px) {
            #mapContainer { height: 200px; }
        }
        /* UX-44: spinner enquanto Leaflet carrega */
        #mapContainer.vd-map-loading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: vdSpin 0.8s linear infinite; z-index: 10; }
        @keyframes vdSpin { to { transform: rotate(360deg); } }
        /* UX-18: fallback manual de coordenadas quando offline */
        .vd-map-offline-hint { padding: 18px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
        .vd-map-offline-hint input { width: 110px; margin: 4px 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
        /* v8.0.1: destaque visual para campos de data quando sinais de alarme/gravidade marcados */
        @keyframes vdDatePulse { 0%,100% { box-shadow: 0 0 0 2px rgba(255,152,0,0.4); } 50% { box-shadow: 0 0 0 4px rgba(255,152,0,0.7); } }
        .vd-date-needs-fill { border-color: #ff9800 !important; background: #fff8e1 !important; animation: vdDatePulse 1.5s ease-in-out 3; }
        .map-modal-footer { padding: 10px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--border); font-size: 0.85rem; }

        /* MODAL */
        .modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); align-items: center; justify-content: center; }
        .modal-content { background: var(--bg-paper); padding: 25px; border-radius: 12px; width: 600px; max-width: 90%; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
        .modal-content h3 { display: flex; align-items: center; gap: 8px; }

        /* v7.4: WhatsApp contact in modal */
        .whatsapp-contact {
            display: flex; align-items: center; gap: 10px;
            background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
            border: 1px solid #66bb6a;
            border-radius: 8px;
            padding: 10px 14px;
            margin: 12px 0 8px 0;
            font-size: 0.85rem;
            color: #1b5e20;
        }
        .whatsapp-contact a {
            color: #2e7d32; font-weight: 700; text-decoration: none;
        }
        .whatsapp-contact a:hover { text-decoration: underline; }
        [data-theme="dark"] .whatsapp-contact {
            background: linear-gradient(135deg, rgba(46,125,50,0.18), rgba(56,142,60,0.12));
            border-color: #4caf50;
            color: #a5d6a7;
        }
        [data-theme="dark"] .whatsapp-contact a { color: #81c784; }
        #magicString { width: 100%; height: 120px; margin: 12px 0; font-family: 'Courier New', monospace; padding: 12px; background: linear-gradient(135deg, #1a237e, #263238); color: #80cbc4; border-radius: 8px; border: 1px solid #37474f; font-size: 0.82rem; resize: vertical; }
        .magic-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: -8px; }
        .magic-counter { font-size: 0.78rem; color: #4e4e4e; }
        .magic-counter.warn { color: #b26a00; font-weight: 700; }
        .magic-warning {
            margin-top: 8px;
            padding: 8px 10px;
            border-left: 3px solid var(--border-error, #c62828);
            background: rgba(198, 40, 40, 0.08);
            color: #7f0000;
            border-radius: 4px;
            font-size: 0.78rem;
        }
        .magic-validation {
            margin-top: 8px;
            padding: 8px 10px;
            border-radius: 4px;
            font-size: 0.78rem;
            border-left: 3px solid var(--border-info, #607d8b);
            background: rgba(96, 125, 139, 0.10);
            color: #37474f;
        }
        .magic-validation.ok {
            border-left-color: var(--border-success, #2e7d32);
            background: rgba(46, 125, 50, 0.10);
            color: #1b5e20;
        }
        .magic-validation.warn {
            border-left-color: var(--border-warn, #ef6c00);
            background: rgba(239, 108, 0, 0.10);
            color: #a34a00;
        }
        .magic-validation.err {
            border-left-color: var(--border-error, #c62828);
            background: rgba(198, 40, 40, 0.10);
            color: #7f0000;
        }

        /* MANEJO CLÍNICO (A/B/C/D) */
        .manejo-panel{
          border:1px solid #e5e5e5;
          border-radius:10px;
          padding:12px;
          background:#fafafa;
        }
        .manejo-head{
          display:flex;
          gap:12px;
          align-items:center;
          justify-content:space-between;
          flex-wrap:wrap;
          margin-bottom:10px;
        }
        .manejo-badge{
          font-weight:700;
          padding:6px 10px;
          border-radius:999px;
          border:1px solid #ddd;
          background:#fff;
        }
        .manejo-badge.a{ border-color:#b7d7b7; background:#f3fff3; color:#1b5e20; }
        .manejo-badge.b{ border-color:#ffe2a8; background:#fffaf0; color:#e65100; }
        .manejo-badge.c{ border-color:#ffd0a8; background:#fff5ef; color:#d84315; }
        .manejo-badge.d{ border-color:#ffb3b3; background:#fff0f0; color:#c62828; }

        .manejo-body ul{ margin:8px 0 0 18px; padding-left:0; }
        .manejo-body li{ margin:4px 0; }

        /* UX-34: CSS classes for manejo resumo sections (theme-aware, replaces inline styles) */
        .manejo-conduta-box{ margin-top:10px; padding:8px 10px; background:var(--bg-conduta, #f0f7ff); border-radius:6px; border:1px solid var(--border-conduta, #cce0ff); }
        .manejo-conduta-title{ font-weight:700; font-size:0.92rem; color:var(--text-conduta, #1565c0); margin-bottom:4px; }
        .manejo-conduta-text{ font-size:0.88rem; line-height:1.5; }
        .manejo-hemo-box{ margin-top:6px; padding:6px 10px; background:var(--bg-hemo, #fff8e1); border-radius:6px; border:1px solid var(--border-hemo, #ffe082); }
        .manejo-hemo-title{ font-weight:600; font-size:0.88rem; color:var(--text-hemo, #e65100); }
        .manejo-hemo-item{ font-size:0.84rem; margin-top:3px; }
        .manejo-hemo-sub{ font-size:0.82rem; color:var(--text-hemo-sub, #bf360c); padding-left:12px; font-style:italic; }
        .manejo-hydra-box{ margin-top:6px; padding:6px 10px; background:var(--bg-hydra, #f0fff4); border-radius:6px; border:1px solid var(--border-hydra, #c8e6c9); }
        .manejo-hydra-title{ font-weight:600; font-size:0.88rem; color:var(--text-hydra, #2e7d32); }
        .manejo-hydra-text{ font-size:0.86rem; }
        .manejo-hydra-peso{ font-size:0.78rem; color:var(--text-muted); margin-top:3px; opacity:0.8; }
        .manejo-hydra-missing{ font-size:0.78rem; color:var(--text-hemo, #d84315); margin-top:3px; }
        /* UX: destacar Peso (ajuda nos cálculos de hidratação) */
        .vd-calc-chip{
            display:inline-flex;
            align-items:center;
            gap:4px;
            margin-left:6px;
            padding:2px 8px;
            border-radius:999px;
            border:1px solid var(--primary);
            color: var(--primary);
            background: rgba(0,0,0,0.03);
            font-size:0.72rem;
            font-weight:700;
            line-height:1.1;
            vertical-align: middle;
        }
        [data-theme="dark"] .vd-calc-chip{ background: rgba(255,255,255,0.06); }
        .vd-weight-hint{
            margin-top:4px;
            font-size:0.78rem;
            font-weight:600;
            color: var(--primary);
            opacity:0.95;
        }
        .manejo-extra-header{ margin-bottom:8px; font-weight:600; font-size:0.88rem; color:var(--text-muted); }
        .manejo-extra-item{ margin-bottom:6px; padding:6px 10px 6px 14px; background:var(--bg-card, #f8f9fa); border-radius:4px; }
        .manejo-extra-title{ font-weight:600; font-size:0.9rem; }
        .manejo-extra-li{ font-size:0.88rem; }
        .manejo-proto-detail{ margin-top:6px; padding:6px 10px; background:var(--bg-card, #fafafa); border-radius:4px; }
        .manejo-proto-title{ font-weight:600; font-size:0.85rem; margin-bottom:3px; }
        .manejo-proto-text{ font-size:0.84rem; line-height:1.5; }
        .manejo-ul{ margin:6px 0 4px 0; padding-left:22px; list-style-position:outside; }
        .manejo-ul-sm{ margin:4px 0 0 0; padding-left:22px; list-style-position:outside; }
        [data-theme="dark"] .manejo-conduta-box{ --bg-conduta: #1a2332; --border-conduta: #2a4a6b; --text-conduta: #64b5f6; }
        [data-theme="dark"] .manejo-hemo-box{ --bg-hemo: #2a2210; --border-hemo: #6d5a1e; --text-hemo: #ffb74d; --text-hemo-sub: #ff8a65; }
        [data-theme="dark"] .manejo-hydra-box{ --bg-hydra: #1a2e1a; --border-hydra: #2e5d2e; --text-hydra: #81c784; }

        .muted { color: var(--text-muted); font-size: 0.9rem; }
        .inline { display:flex; }
        /* Controle Vetorial: evitar colisao entre linhas dinamicas de datas (data + remover). */
        .cielo-ubv-date-row {
            display: flex;
            gap: 8px;
            align-items: center;
            margin-top: 4px;
            flex-wrap: wrap;
        }
        .cielo-ubv-date-row .cielo-ubv-date {
            flex: 1 1 220px;
            min-width: 0;
        }
        .cielo-ubv-date-row .btn-cielo-ubv-remove {
            flex: 0 0 auto;
            background: #eee;
            color: #333;
            border: 1px solid #ccc;
            padding: 6px 10px;
        }

        /* IMPRESSÃO A4 PROFISSIONAL */
        @media print {
            @page { size: A4; margin: 8mm; }
            header, .tabs, .btn, footer, .popup-warning, .modal, .quick-nav-side, .quick-nav-vertical, .vd-toast-container { display: none !important; }
            body { background: white; color: black; font-size: 10.6px; line-height: 1.14; margin: 0; padding: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
            .container { max-width: 100%; margin: 0; padding: 0; }
            .tab-content { display: none !important; }
            .tab-content.active { display: block !important; }
            
            .card {
                box-shadow: none; border: 1px solid #000; margin-bottom: 5px; padding: 5px;
                border-radius: 0; border-left: 1px solid #000; page-break-inside: avoid;
            }
            .card h2 {
                color: black; border-bottom: 1px solid #000; margin-bottom: 3px; font-size: 11.9px;
                padding-bottom: 2px; text-transform: uppercase; background: #f5f5f5; padding: 2px 3px;
            }
            
            .grid { gap: 2px 5px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
            input, select, textarea {
                border: none; border-bottom: 1px dotted #999; padding: 2px 0; background: none;
                font-weight: bold; font-size: 10.2px; height: auto; min-height: 0;
            }
            label { font-weight: normal; margin-bottom: 0; font-size: 9.8px; color: #444; }
            label span.num { color: #000; }
            /* SINAN: mostrar número entre parênteses */
            label span.num::before { content: "("; }
            label span.num::after  { content: ") "; } /* espaço depois do ) */
            
            .check-btn { border: none; padding: 0; display: inline-block; width: auto; margin-right: 15px; font-size: 10px; }
            .check-btn input { display: none; }
            /* UX-51: font stack com fallback para fontes que suportam ☐/☒ em todos OS */
            .check-btn::before { content: "☐ "; font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", monospace; font-size: 11.5px; }
            .check-btn.active::before, .check-btn.active-alarm::before { content: "☒ "; font-weight: bold; }
            .ignored-warning { display: none !important; }
            /* UX-35/UX-49: nota visível apenas na impressão direta (Ctrl+P) orientando usuário */
            .vd-print-hint { display: block !important; text-align: center; font-size: 8px; color: #888;
                margin-top: 8px; border-top: 1px dotted #ccc; padding-top: 4px; }
        }

        /* ─── Toast notifications (substitui alert() bloqueante) ─── */
        .vd-toast-container {
            position: fixed;
            bottom: var(--vd-toast-bottom, 80px);
            left: 16px;
            right: auto;
            z-index: 3400;
            display: flex;
            flex-direction: column-reverse;
            gap: 8px;
            pointer-events: none;
            /* Reservar faixa à direita para botões fixos (quick-nav/coerência) */
            max-width: min(420px, calc(100vw - 32px - var(--vd-toast-right-reserved, 120px)));
        }
        .vd-toast {
            pointer-events: auto;
            padding: 12px 18px; border-radius: 8px;
            font-size: 14px; line-height: 1.4;
            color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.18);
            opacity: 0; transform: translateX(60px);
            animation: vdToastIn 0.3s ease forwards;
            cursor: pointer; word-break: break-word;
            white-space: pre-line;
            position: relative; overflow: hidden;
        }
        .vd-toast-progress {
            position: absolute;
            left: 0; right: 0; bottom: 0;
            height: 3px;
            pointer-events: none;
            background: linear-gradient(90deg, #66bb6a, #2e7d32);
            transform-origin: right center;
            animation: vdToastTimerShrink var(--vd-toast-ms, 4500ms) linear forwards;
        }
        .vd-toast.clickable {
            text-decoration: underline;
            text-underline-offset: 2px;
        }
        .vd-toast.info    { background: #1976d2; }
        .vd-toast.success { background: #2e7d32; }
        .vd-toast.warn    { background: #e65100; }
        .vd-toast.error   { background: #c62828; }
        .vd-toast.removing {
            animation: vdToastOut 0.25s ease forwards;
        }
        @keyframes vdToastIn  { to { opacity: 1; transform: translateX(0); } }
        @keyframes vdToastOut { to { opacity: 0; transform: translateX(60px); } }
        @keyframes vdToastTimerShrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

        /* ─── Confirm modal (substitui confirm() bloqueante) ─── */
        /* N6 — confirm unificado (paridade ACE) */
        .vd-confirm {
            position: fixed;
            inset: 0;
            display: none;
            z-index: 1000011;
            align-items: center;
            justify-content: center;
        }
        .vd-confirm--show { display: flex; }
        .vd-confirm-backdrop {
            position: absolute;
            inset: 0;
            background: rgba(0, 0, 0, 0.56);
            backdrop-filter: blur(4px);
        }
        .vd-confirm-dialog {
            position: relative;
            max-width: 440px;
            width: min(calc(100vw - 32px), 440px);
            margin: 16px;
            padding: 22px;
            background: var(--bg-card, #fff);
            border: 1px solid var(--border);
            border-radius: 12px;
            box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
            display: grid;
            gap: 14px;
        }
        .vd-confirm-title {
            font-size: 17px;
            font-weight: 800;
            color: var(--text-main);
            line-height: 1.3;
        }
        .vd-confirm-body {
            font-size: 14px;
            color: var(--text-muted);
            line-height: 1.55;
            white-space: pre-line;
        }
        .vd-confirm-actions {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            flex-wrap: wrap;
        }
        .vd-confirm-actions .btn {
            min-height: 40px;
            padding: 10px 18px;
        }
        .vd-confirm-actions .vd-confirm-danger {
            background: #c62828;
            color: #fff;
            border-color: #b71c1c;
        }
        [data-theme="dark"] .vd-confirm-dialog { background: var(--bg-card); }
        [data-theme="dark"] .vd-confirm-actions .vd-confirm-cancel {
            background: #424242;
            color: var(--text-main);
        }

        /* N-δ fase 1 — popup epidemiológico (sem cssText inline) */
        .vd-epi-popup-overlay {
            position: fixed;
            inset: 0;
            z-index: 1000008;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.45);
            animation: fadeIn 0.2s ease;
        }
        .vd-epi-popup-box {
            background: var(--bg-card, #fff);
            border-radius: 12px;
            padding: 28px 32px;
            max-width: 420px;
            width: 90%;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
            text-align: center;
        }
        .vd-epi-popup-icon { font-size: 2rem; margin-bottom: 12px; }
        .vd-epi-popup-title {
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 10px;
            color: var(--text-main);
        }
        .vd-epi-popup-body {
            font-size: 0.9rem;
            color: var(--text-muted);
            line-height: 1.5;
            white-space: pre-line;
            margin: 0 0 18px;
        }
        .vd-epi-popup-dismiss {
            background: var(--primary, #00897b);
            color: #fff;
            border: none;
            padding: 10px 28px;
            border-radius: 6px;
            font-size: 0.9rem;
            cursor: pointer;
            font-weight: 600;
        }
        .label-req-mark { color: #e53935; }

        .vd-confirm-overlay {
            position: fixed; inset: 0; z-index: 3600;
            background: rgba(0,0,0,0.5); display: flex;
            align-items: center; justify-content: center;
        }
        .vd-confirm-box {
            background: var(--bg-paper, #fff); color: var(--text-main, #212121);
            border-radius: 12px; padding: 24px 28px;
            max-width: min(420px, calc(100vw - 32px));
            box-shadow: 0 8px 32px rgba(0,0,0,0.25);
            text-align: center;
        }
        .vd-confirm-box p { margin: 0 0 20px; font-size: 0.95rem; line-height: 1.5; white-space: pre-line; }
        .vd-confirm-actions { display: flex; gap: 12px; justify-content: center; }
        .vd-confirm-actions button {
            padding: 10px 24px; border-radius: 8px; border: none;
            font-size: 0.9rem; font-weight: 600; cursor: pointer;
        }
        .vd-confirm-actions .vd-btn-yes { background: #c62828; color: #fff; }
        .vd-confirm-actions .vd-btn-no  { background: #e0e0e0; color: #333; }
        /* ─── v8.5: ViaCEP auto-fill chip ─── */
        .vd-viacep-chip {
            margin-top: 6px; padding: 6px 10px; background: #e3f2fd; border: 1px solid #90caf9;
            border-radius: 8px; font-size: 0.82rem; display: flex; align-items: center;
            gap: 6px; flex-wrap: wrap; animation: slideDown 0.2s ease;
        }
        .vd-viacep-chip span { flex: 1; min-width: 120px; color: #1565c0; }
        .vd-viacep-chip button {
            padding: 3px 10px; border: 1px solid #1565c0; border-radius: 6px;
            background: #fff; color: #1565c0; font-size: 0.78rem; font-weight: 600;
            cursor: pointer; white-space: nowrap;
        }
        .vd-viacep-chip button:hover { background: #1565c0; color: #fff; }
        [data-theme="dark"] .vd-viacep-chip { background: #1a2332; border-color: #2196f3; }
        [data-theme="dark"] .vd-viacep-chip span { color: #90caf9; }

        /* ─── v8.5: Critical phase alert banner ─── */
        .vd-critical-phase-alert {
            margin: 8px 0; padding: 10px 14px; background: linear-gradient(135deg, #fff3e0, #fbe9e7);
            border: 2px solid #ff6f00; border-radius: 8px; font-size: 0.85rem;
            color: #bf360c; display: flex; align-items: flex-start; gap: 8px;
            animation: slideDown 0.3s ease;
        }
        .vd-critical-phase-alert .vd-cpa-icon { font-size: 1.3rem; flex-shrink: 0; }
        .vd-critical-phase-alert .vd-cpa-text { flex: 1; line-height: 1.45; }
        .vd-critical-phase-alert .vd-cpa-title { font-weight: 700; margin-bottom: 2px; }
        .vd-critical-phase-alert .vd-cpa-detail { font-size: 0.8rem; color: #e65100; }
        [data-theme="dark"] .vd-critical-phase-alert { background: linear-gradient(135deg, #3e2723, #4e342e); border-color: #ff9800; }
        [data-theme="dark"] .vd-critical-phase-alert .vd-cpa-detail { color: #ffb74d; }

        /* ─── v8.5: Classification suggestion chip ─── */
        .vd-classif-suggest {
            margin-top: 8px; padding: 8px 12px; background: #e8f5e9; border: 1px solid #66bb6a;
            border-radius: 8px; font-size: 0.82rem; display: flex; align-items: center;
            gap: 8px; flex-wrap: wrap; animation: slideDown 0.2s ease;
        }
        .vd-classif-suggest button {
            padding: 3px 10px; border: 1px solid #2e7d32; border-radius: 6px;
            background: #fff; color: #2e7d32; font-size: 0.78rem; font-weight: 600;
            cursor: pointer; white-space: nowrap;
        }
        .vd-classif-suggest button:hover { background: #2e7d32; color: #fff; }
        [data-theme="dark"] .vd-classif-suggest { background: #1b2e1b; border-color: #4caf50; }

        /* ─── v8.5: Lab collection timing hint ─── */
        .vd-lab-hint {
            margin-top: 4px; padding: 4px 8px; background: rgba(0,121,107,0.08);
            border-radius: 4px; font-size: 0.76rem; color: #00695c;
            display: flex; align-items: center; gap: 4px;
        }
        [data-theme="dark"] .vd-lab-hint { background: rgba(0,150,136,0.15); color: #80cbc4; }

        /* ─── v8.5: One-click fix button in coherence plan ─── */
        .vd-coherence-fix-btn {
            padding: 2px 8px; border: 1px solid #e65100; border-radius: 4px;
            background: #fff3e0; color: #e65100; font-size: 0.72rem; font-weight: 600;
            cursor: pointer; margin-left: 4px;
        }
        .vd-coherence-fix-btn:hover { background: #e65100; color: #fff; }
        [data-theme="dark"] .vd-coherence-fix-btn { background: #3e2723; border-color: #ff9800; color: #ffb74d; }

        /* ─── v8.5: Coherence panel — notificação vs investigação sections ─── */
        .vd-coh-section { margin-bottom: 10px; }
        .vd-coh-section:last-child { margin-bottom: 0; }
        .vd-coh-invest {
            border-top: 1px dashed #bcaaa4; padding-top: 8px; margin-top: 8px;
        }
        .vd-coh-invest summary::-webkit-details-marker { color: #8d6e63; }
        .vd-coh-invest .vd-coherence-item { opacity: 0.85; }
        .vd-coh-invest .vd-coherence-item.alta { opacity: 0.92; }

        /* ─── v8.5: Smart field validation — dismissible inline alerts ─── */
        .vd-smart-alert {
            margin-top: 4px; padding: 6px 10px; border-radius: 6px;
            border-left: 3px solid #ff9800; background: #fff8e1;
            font-size: 0.8rem; display: flex; align-items: center;
            gap: 6px; flex-wrap: wrap; animation: slideDown 0.2s ease;
            color: #5d4037;
        }
        .vd-smart-alert .vd-sa-msg { flex: 1; min-width: 120px; line-height: 1.4; }
        .vd-smart-alert .vd-sa-actions { display: flex; gap: 4px; flex-shrink: 0; }
        .vd-smart-alert .vd-sa-btn {
            padding: 2px 8px; border-radius: 4px; font-size: 0.73rem;
            font-weight: 600; cursor: pointer; border: 1px solid; white-space: nowrap;
        }
        .vd-smart-alert .vd-sa-confirm { background: #e8f5e9; color: #2e7d32; border-color: #66bb6a; }
        .vd-smart-alert .vd-sa-confirm:hover { background: #2e7d32; color: #fff; }
        .vd-smart-alert .vd-sa-fix { background: #fff; color: #e65100; border-color: #ff9800; }
        .vd-smart-alert .vd-sa-fix:hover { background: #e65100; color: #fff; }
        .vd-smart-alert.vd-sa-critical { border-left-color: #d32f2f; background: #ffebee; color: #7f0000; }
        [data-theme="dark"] .vd-smart-alert { background: rgba(255,152,0,0.12); color: var(--text-main); border-left-color: #ff9800; }
        [data-theme="dark"] .vd-smart-alert.vd-sa-critical { background: rgba(198,40,40,0.12); border-left-color: #ef5350; }
        [data-theme="dark"] .vd-smart-alert .vd-sa-confirm { background: rgba(46,125,50,0.18); color: #81c784; border-color: #4caf50; }
        [data-theme="dark"] .vd-smart-alert .vd-sa-fix { background: var(--bg-card); color: #ffb74d; border-color: #ff9800; }

        @media (max-width: 768px) {
            .section, .card {
                padding: 12px !important;
                margin-bottom: 12px !important;
            }
            .form-group {
                margin-bottom: 10px !important;
            }
            .form-control, input, select, textarea {
                padding: 8px 10px !important;
                font-size: 14px !important;
            }
            details.vd-mobile-disclosure {
                border: 1px solid var(--border, #334155);
                border-radius: 8px;
                padding: 8px 12px;
                margin-bottom: 10px;
                background: var(--surface, #1e293b);
            }
            details.vd-mobile-disclosure > summary {
                font-weight: 600;
                cursor: pointer;
                list-style: none;
                display: flex;
                justify-content: space-between;
                align-items: center;
                color: var(--text-primary, #f8fafc);
            }
            details.vd-mobile-disclosure > summary::-webkit-details-marker {
                display: none;
            }
            details.vd-mobile-disclosure > summary::after {
                content: "+";
                font-size: 18px;
                font-weight: bold;
            }
            details.vd-mobile-disclosure[open] > summary::after {
                content: "−";
            }
        }
    