/* ============================================================================
   monitor - estructura de la replica original (replicador-web-integral/monitor/replica-test)
   re-pintada con la paleta de Vector GPS
   ============================================================================ */
* { box-sizing: border-box; }
:root { font: 13px Roboto,Arial,sans-serif; color: #26313d; background: #ffffff; }
html, body, #monitorApp { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea, dialog, fieldset { border:1px solid #bfcbd6; border-radius: 0; background: #ffffff; }
button { min-height: 30px; padding: 4px 7px; cursor: pointer; }
button:hover, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline:2px solid #bfcbd6; outline-offset: 1px; }
button.selected, button[aria-selected="true"] { background: #bfcbd6; }
button:disabled { color: #bfcbd6; cursor: default; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.empty { margin: 8px; padding: 8px; border:1px solid #bfcbd6; text-align: center; }
.error { color: #dc3545; min-height: 18px; }
.button-row { display: flex; gap: 3px; }

#unitPane { position: absolute; inset: 0 auto 0 0; width: 25%; min-width: 250px; border-right:1px solid #bfcbd6; overflow: hidden; }
#monitorHeader { height: 42px; display: flex; justify-content: flex-end; align-items: center; gap: 0; padding: 4px; border-bottom:1px solid #bfcbd6; }
#monitorHeader button { min-width: 42px; min-height: 28px; padding: 2px 4px; }
#monitorHeader strong { margin-left: 3px; }
#connectionStatus { display: inline-grid; width: 34px; height: 28px; place-items: center; color: #315f31; font-size: 20px; }
#pendingMessages, #pendingNotifications { color: #315f31; }
#pendingAlerts { color: #dc3545; }
#unitFilters { height: 96px; padding: 0 4px 4px; border-bottom:1px solid #bfcbd6; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: 28px 29px 28px; gap: 1px 0; }
.status-filters { grid-column: 1 / -1; }
.status-filters button { flex: 1; min-width: 0; }
#unitSearchWrap { position: relative; min-width: 0; }
#unitSearch { width: 100%; height: 29px; padding: 5px; }
#unitSuggestions { position: absolute; z-index: 12; inset: 29px 0 auto 0; max-height: 180px; overflow: auto; list-style: none; margin: 0; padding: 0; border:1px solid #bfcbd6; background: #ffffff; }
#unitSuggestions li { padding: 5px; border-bottom:1px solid #cfd9e2; cursor: pointer; }
#unitSuggestions li[aria-selected="true"], #unitSuggestions li:hover { background: #cfd9e2; }
#groupFilter, #productFilter { width: 100%; min-width: 0; height: 29px; padding: 4px; }
.list-actions { grid-column: 1 / -1; justify-content: flex-end; }
.list-actions button { width: 34px; }
#unitGridRegion { height: calc(100% - 138px); position: relative; }
#unitGridScroll { width: 100%; height: calc(100% - 28px); overflow: auto; }
#unitGridFooter { height: 28px; padding: 6px 8px; border-top:1px solid #bfcbd6; background: #f4f7f9; text-align: right; }
#unitGridState { position: absolute; z-index: 8; inset: 0 0 28px; display: grid; place-items: center; padding: 12px; border:1px solid #bfcbd6; background: rgba(255,255,255,.92); text-align: center; }
table { border-collapse: collapse; width: 100%; }
th, td { border:1px solid #bfcbd6; padding: 5px; text-align: left; white-space: nowrap; }
th { background: #f4f7f9; position: sticky; top: 0; z-index: 2; }
#unitGrid { table-layout: fixed; width: max-content; min-width: 100%; }
#unitGrid th:first-child, #unitGrid td:first-child { position: sticky; left: 0; background: #ffffff; z-index: 1; }
#unitGrid th:first-child { z-index: 3; }
#unitGrid th:nth-child(2), #unitGrid td:nth-child(2) { position: sticky; left: 34px; background: #ffffff; z-index: 1; }
#unitGrid th:nth-child(2) { background: #f4f7f9; z-index: 3; }
.unit-row.selected td { background: #cfd9e2; }
.expand-row { width: 30px; padding: 2px; }
.detail-row td { background: #f4f7f9; padding: 8px; }
.detail-row table { min-width: 620px; }
.sort-button { display: block; border:0; background: transparent; width: calc(100% - 21px); height: 30px; min-height: 30px; padding: 5px 8px; text-align: left; }
.column-button { position: absolute; z-index: 4; right: 0; top: 0; width: 21px; height: 28px; min-height: 28px; padding: 0; border:0; }
.column-resizer { position: absolute; right: -2px; top: 0; width: 5px; height: 100%; cursor: col-resize; }
#unitGrid th { position: sticky; padding: 0; }
#unitGrid th.drag-over { outline:2px solid #bfcbd6; outline-offset: -2px; }
.unit-column-menu { position: fixed; z-index: 30; width: 162px; border:1px solid #bfcbd6; background: #ffffff; padding: 1px; }
.unit-column-menu > button { display: block; width: 100%; text-align: left; border-width: 0 0 1px; }
.unit-column-menu > button:last-child { border-bottom:0; }
.columns-submenu-trigger::after { content: ">"; float: right; }
.unit-columns-submenu { position: fixed; z-index: 31; width: 180px; max-height: min(555px, calc(100vh - 20px)); overflow: auto; border:1px solid #bfcbd6; background: #ffffff; padding: 2px; }
.unit-columns-submenu label { display: flex; gap: 6px; align-items: center; padding: 4px; }
.unit-columns-submenu label:hover { background: #f4f7f9; }
.unit-columns-submenu input[type="checkbox"] { accent-color: #607080; }

#quickView { position: absolute; inset: 0 0 0 max(25%, 250px); overflow: hidden; }
#mapRegion { position: absolute; inset: 0 0 40% 0; border-bottom:1px solid #bfcbd6; background: #f4f7f9; overflow: hidden; }
#monitorMap { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.road { fill: none; stroke: #bfcbd6; stroke-width: 11; stroke-dasharray: 5 8; opacity: .65; }
.road.minor { stroke-width: 6; opacity: .45; }
#mapWorld { transform-origin: 0 0; }
.unit-marker { cursor: pointer; stroke: #26313d; stroke-width: 2; vector-effect: non-scaling-stroke; }
.unit-marker.selected { stroke-width: 5; stroke-dasharray: 4 3; }
.marker-label { font-size: 16px; pointer-events: none; }
.cluster { fill: #bfcbd6; stroke: #26313d; stroke-width: 2; cursor: pointer; }
.cluster-label { font-size: 16px; text-anchor: middle; pointer-events: none; }
.georeference { fill-opacity: .12; stroke-width: 4; vector-effect: non-scaling-stroke; }
.traffic { fill: none; stroke: #607080; stroke-width: 7; stroke-dasharray: 14 8; }
.toll { fill: #ffffff; stroke: #26313d; stroke-width: 2; }
.trail { fill: none; stroke: #26313d; stroke-width: 3; stroke-dasharray: 5 4; }
.route-line { fill: none; stroke: #607080; stroke-width: 10; opacity: .35; vector-effect: non-scaling-stroke; }
.route-waypoint { fill: #ffffff; stroke: #26313d; stroke-width: 3; vector-effect: non-scaling-stroke; }
.georeference[role="button"] { cursor: pointer; }
#mapZoom { position: absolute; left: 8px; top: 8px; display: grid; }
#mapZoom button { width: 32px; font-size: 18px; }
#routingControl { position: absolute; z-index: 7; right: 8px; top: 8px; width: 48px; height: 32px; border:1px solid #bfcbd6; background: #ffffff; }
#routeExpand { width: 46px; height: 30px; min-height: 30px; border:0; font-size: 18px; }
#routingControl.open { width: 320px; height: auto; min-height: 192px; }
#routingControl.open #routeExpand { display: none; }
#routePanel { min-height: 190px; padding: 26px 6px 6px; position: relative; }
#routeWaypoints label { display: grid; grid-template-columns: 1fr 24px; margin: 4px 0; }
#routeWaypoints input { width: 100%; height: 26px; padding: 4px; }
#routeWaypoints label button, #addRouteWaypoint { width: 25px; min-height: 22px; padding: 0; }
#routeIntermediate label { margin-left: 12px; }
.route-footer { position: absolute; left: 6px; bottom: 4px; display: flex; }
.route-footer button { width: 24px; min-height: 22px; padding: 0; border:0; }
#routeAlternatives { margin: 5px 0 24px; padding: 5px; border:1px solid #bfcbd6; }
#layerControl { position: absolute; right: 8px; top: 50px; min-width: 48px; min-height: 48px; }
#routingControl.open + #layerControl { top: 202px; }
#layerToggle { width: 48px; height: 48px; min-height: 48px; font-size: 20px; }
#layerPanel { width: 190px; margin-top: 3px; padding: 7px; background: #ffffff; }
#layerPanel label, #layerPanel span { display: block; margin: 4px 0; }
#layerPanel span { font-weight: bold; border-top:1px solid #bfcbd6; padding-top: 5px; }
#geoFilterWrap { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 135px; padding: 5px; border:1px solid #bfcbd6; background: #ffffff; }
#geoFilterWrap select { width: 100%; }
#mapAttribution { position: absolute; right: 0; bottom: 0; padding: 2px 5px; background: #ffffff; border:1px solid #bfcbd6; font-size: 11px; }
#unitPopup { position: absolute; z-index: 8; width: min(372px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; border:1px solid #bfcbd6; background: #ffffff; padding: 8px; }
#geoPopup { position: absolute; z-index: 8; width: min(300px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; border:1px solid #bfcbd6; background: #ffffff; padding: 8px; }
#geoPopup p { margin: 5px 0; }
#closeGeoPopup { float: right; min-height: 24px; }
#closePopup { float: right; min-height: 24px; }
#unitPopupContent { line-height: 1.55; }
#popupActions { display: flex; flex-wrap: nowrap; gap: 2px; border-top:1px solid #bfcbd6; margin-top: 6px; padding-top: 6px; overflow-x: auto; overflow-y: hidden; }
#popupActions button { min-width: 0; width: 21px; padding: 4px 0; flex: 0 0 auto; }

#unitInfo { position: absolute; inset: 60% 0 0 0; overflow: hidden; }
#infoTabs { height: 36px; display: flex; overflow-x: auto; border-bottom:1px solid #bfcbd6; }
#infoTabs button { border-width: 0 1px 0 0; white-space: nowrap; }
#tabContent { height: calc(100% - 36px); overflow: auto; padding: 8px; }
.dashboard { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; min-width: 690px; height: 100%; }
.dashboard-column { border:1px solid #bfcbd6; padding: 8px; min-width: 0; }
.dashboard-bars { display: grid; grid-template-rows: repeat(3, 1fr); gap: 8px; }
.fleet-metric { min-height: 58px; display: grid; grid-template-rows: auto 30px; align-content: center; }
.fleet-metric-label, .battery-filter { border:0; min-height: 22px; padding: 0; font-weight: bold; text-align: left; background: transparent; }
.fleet-progress { position: relative; height: 30px; border:1px solid #bfcbd6; background: #cfd9e2; overflow: hidden; }
.fleet-progress-fill { position: absolute; inset: 0 auto 0 0; background: #bfcbd6; }
.fleet-progress-value { position: absolute; right: 6px; top: 6px; z-index: 1; color: #ffffff; font-size: 13px; }
.dashboard-column.battery { display: grid; grid-template-rows: auto 1fr; }
.battery-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.battery-filter:last-child { text-align: right; }
.battery-chart { width: 100%; height: 100%; min-height: 170px; }
.battery-chart .battery-optimal { fill: #607080; }
.battery-chart .battery-low { fill: #bfcbd6; stroke: #607080; stroke-width: 1; }
.tab-table { min-width: 760px; }
.message-toolbar { display: grid; grid-template-columns: auto minmax(180px,1fr) 34px 34px 34px; gap: 4px; align-items: center; margin-bottom: 6px; }
.message-toolbar input, .message-toolbar select { min-width: 160px; padding: 5px; }
.message-toolbar select[multiple] { height: 30px; }
.message-toolbar button { min-width: 32px; padding: 3px; }
.lower-grid-wrap { height: calc(100% - 2px); overflow: auto; border:1px solid #bfcbd6; position: relative; }
.message-toolbar + .lower-grid-wrap { height: calc(100% - 42px); }
.lower-grid { min-width: 760px; }
.lower-grid th { padding: 0; }
.lower-column-menu { float: right; min-height: 27px; border:0; padding: 2px 4px; }
.lower-sort { width: calc(100% - 25px); min-height: 27px; border:0; text-align: left; background: transparent; }
.lower-grid tbody tr:nth-child(even) td { background: #f4f7f9; }
.lower-grid-footer { position: sticky; left: 0; bottom: 0; padding: 5px; border-top:1px solid #bfcbd6; background: #f4f7f9; text-align: right; }
.message-status { display: inline-block; min-width: 25px; text-align: center; }

header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h1 { font-size: 17px; margin: 0; }
dialog { width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 10px; }
dialog::backdrop { background: rgba(0,0,0,.25); }
dialog table { margin-top: 8px; }
.subscreen-dialog { width: min(1180px, calc(100vw - 24px)); height: min(760px, calc(100vh - 24px)); }
.subscreen-dialog > header { border-bottom:1px solid #bfcbd6; padding-bottom: 7px; margin-bottom: 8px; }
.history-layout { display: grid; grid-template-columns: minmax(350px, 42%) minmax(500px, 58%); min-height: 640px; position: relative; }
.history-map { position: relative; min-height: 640px; border-right:1px solid #bfcbd6; background: #f4f7f9; overflow: hidden; }
.history-map svg { width: 100%; height: 100%; display: block; }
.history-map pattern path { fill: none; stroke: #bfcbd6; stroke-width: 1; }
.history-road { fill: none; stroke: #bfcbd6; stroke-width: 16; stroke-dasharray: 6 7; }
#historyMapWorld { transform-origin: center; }
#historyGeoLayer rect, #historyGeoLayer circle { fill: #bfcbd6; fill-opacity: .15; stroke: #607080; stroke-width: 3; stroke-dasharray: 7 4; }
#historyTrafficLayer path { fill: none; stroke: #607080; stroke-width: 10; stroke-dasharray: 16 8; }
#historyIncidentLayer path { fill: #ffffff; stroke: #26313d; stroke-width: 3; }
#historyGeoToggle { position: absolute; z-index: 3; left: 8px; top: 8px; min-width: 55px; }
.history-map-controls { position: absolute; z-index: 4; right: 8px; top: 8px; display: flex; gap: 10px; align-items: start; }
.history-map-controls > button { width: 34px; font-size: 18px; }
.history-zoom { display: flex; }
.history-zoom button { width: 34px; font-size: 19px; border-right:0; }
.history-zoom button:last-child { border-right:1px solid #bfcbd6; }
#historyLayerMenu { position: absolute; z-index: 6; right: 78px; top: 35px; width: 180px; border:1px solid #bfcbd6; background: #ffffff; padding: 4px; }
#historyLayerMenu strong, #historyLayerMenu button { display: block; width: 100%; padding: 6px; text-align: left; }
#historyLayerMenu strong { border-bottom:1px solid #bfcbd6; }
.history-attribution { position: absolute; left: 8px; bottom: 7px; max-width: 75%; }
.history-playback { display: flex; height: 100%; align-items: center; border-left:1px solid #bfcbd6; background: #ffffff; }
.history-playback button { width: 36px; height: 100%; min-height: 34px; border:0; border-right:1px solid #bfcbd6; padding: 2px; }
.history-playback output { min-width: 42px; padding: 5px; text-align: center; }
#historyScreenPoints .history-position-active { r: 14px; fill: #26313d; stroke: #ffffff; stroke-width: 4; }
#historyTripAlertPoint circle { fill: #ffffff; stroke: #26313d; stroke-width: 4; }
#historyTripAlertPoint path { fill: none; stroke: #26313d; stroke-width: 4; }
.history-controls { min-width: 0; overflow: hidden; }
.history-unit-header { min-height: 36px; padding: 5px 8px; display: flex; align-items: center; justify-content: center; position: relative; border-bottom:1px solid #bfcbd6; }
.history-unit-header strong { padding: 0 105px; text-align: center; }
#historyChangeUnit { position: absolute; right: 8px; top: 3px; }
.subtabs { display: flex; border-bottom:1px solid #bfcbd6; }
.subtabs button { border-width: 0 1px 0 0; min-width: 82px; }
.history-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin: 8px; }
.history-filter label { display: grid; grid-template-columns: auto 112px 65px; gap: 4px; align-items: center; }
.history-list-header { min-height: 36px; display: flex; align-items: center; justify-content: space-between; padding-left: 10px; border:1px solid #bfcbd6; background: #cfd9e2; }
.history-list-actions { display: flex; align-self: stretch; align-items: center; }
.history-alias-search { height: 100%; display: flex; align-items: center; border-left:1px solid #bfcbd6; background: #ffffff; }
#historyAliasSearch { width: 190px; height: 100%; padding: 5px 4px 5px 8px; border:0; }
.history-alias-search > span { padding: 0 7px; font-size: 17px; }
#historyDownload { width: 38px; border-width: 0 0 0 1px; font-size: 17px; }
#historyScreenContent { height: 470px; overflow: auto; border:1px solid #bfcbd6; border-top:0; }
#historyScreenContent table { width: max-content; min-width: 100%; margin: 0; }
.history-empty { margin: 55px auto; max-width: 430px; padding: 12px; text-align: center; border:1px solid #bfcbd6; }
.history-trip-toolbar { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 7px; border-bottom:1px solid #bfcbd6; }
.history-trip-sections { display: grid; grid-template-columns: repeat(2, minmax(160px,1fr)); gap: 5px; padding: 6px; }
.history-trip-sections section { border:1px solid #bfcbd6; min-height: 76px; padding: 8px; }
.history-unit-chooser { position: absolute; z-index: 20; left: 50%; top: 50%; width: min(330px, calc(100% - 30px)); transform: translate(-50%,-50%); border:1px solid #bfcbd6; background: #ffffff; padding: 10px; }
.history-unit-chooser::before { content: ""; position: fixed; z-index: -1; inset: -100vh -100vw; background: rgba(0,0,0,.18); }
.history-unit-chooser h2 { margin: 0; font-size: 16px; }
.history-unit-chooser label, .history-unit-chooser input, .history-unit-chooser select { display: block; width: 100%; margin: 7px 0; }
.history-unit-chooser input { height: 30px; padding: 5px; }
.history-unit-chooser select { height: 210px; }
.history-unit-chooser > button:last-child { float: right; }
#communicationScreen section { margin-top: 12px; }
#communicationScreen .communication-section-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#communicationScreen .communication-section-header h2 { margin: 0; }
#communicationScreen .communication-columns-toggle { min-height: 24px; min-width: 24px; padding: 0 6px; }
#communicationScreen table { min-width: 820px; }
.communication-columns-menu { position: fixed; z-index: 31; width: 200px; max-height: min(555px, calc(100vh - 20px)); overflow: auto; border:1px solid #bfcbd6; background: #ffffff; padding: 2px; }
.communication-columns-menu label { display: flex; gap: 6px; align-items: center; padding: 4px; }
.communication-columns-menu label:hover { background: #f4f7f9; }
#waybillScreen table { min-width: 520px; }
#externalMapCoordinates { display: block; border:1px solid #bfcbd6; padding: 8px; margin-top: 8px; }
.dialog-tabs { display: flex; margin: 8px 0; }
.dialog-tabs button { min-width: 130px; }
.alerts-table-wrap { height: 350px; overflow: auto; border:1px solid #bfcbd6; }
.alerts-table { min-width: 820px; }
.alerts-table th { top: 0; }
.alerts-table td:nth-child(1) { text-align: center; width: 48px; }
.alerts-table td:nth-child(4) { min-width: 135px; }
.alerts-table td:nth-child(5), .alerts-table td:nth-child(6) { max-width: 250px; white-space: normal; }
.alert-type-icon { display: inline-grid; width: 23px; height: 23px; place-items: center; border:1px solid #bfcbd6; }
.attend-button { min-height: 26px; }
#acknowledgeDialog { width: min(520px, calc(100vw - 24px)); }
#acknowledgeDialog label { display: block; margin: 12px 0 5px; }
#acknowledgeComment { width: 100%; min-height: 90px; resize: vertical; }
#acknowledgeDialog .button-row { justify-content: flex-end; margin-top: 8px; }
#sharedCreateView label { display: block; margin: 7px 0; }
#sharedCreateView input:not([type="checkbox"]), #sharedCreateView select { width: 100%; padding: 5px; }
.shared-email-editor { display: grid; grid-template-columns: minmax(0,1fr) 34px; gap: 4px; align-items: end; }
.shared-email-editor label { min-width: 0; }
#sharedEmailList { margin: 4px 0 8px; padding: 0; list-style: none; }
#sharedEmailList li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border:1px solid #bfcbd6; }
#sharedEmailList li + li { border-top:0; }
#sharedEmailList button { min-height: 24px; padding: 1px 6px; }
.legal { max-height: 150px; overflow: auto; border:1px solid #bfcbd6; padding: 6px; }
#commandsDialog label { display: block; margin: 7px 0; }
#commandsDialog select { width: 100%; padding: 5px; }
#commandSelection { margin: 6px 0; }
.command-send-row { justify-content: flex-end; margin-top: 6px; }
#multimediaDialog label, #macroDialog label { display: block; margin: 10px 0; }
#multimediaDialog select, #macroDialog select { width: 100%; padding: 5px; }
#lastCommand { border:1px solid #bfcbd6; padding: 6px; margin: 7px 0; }
#lastCommand p { margin: 3px; }
#toast { position: fixed; left: 10px; bottom: 10px; max-width: min(520px, calc(100vw - 20px)); border:1px solid #bfcbd6; background: #ffffff; padding: 8px; z-index: 20; }
#toast:empty { display: none; }

@media (max-width: 760px) {
  #unitPane { width: 42%; min-width: 0; }
  #quickView { left: 42%; }
  #monitorHeader { justify-content: flex-start; overflow-x: auto; }
  #connectionStatus { font-size: 0; }
  #connectionStatus span { font-size: 13px; }
  #unitFilters { height: 96px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-filters, .list-actions { grid-column: 1 / -1; }
  #unitGridRegion { height: calc(100% - 138px); }
  #mapRegion { bottom: 48%; }
  #unitInfo { top: 52%; }
  .dashboard { grid-template-columns: 1fr; min-width: 320px; }
  .dashboard { height: auto; }
  .dashboard-column { min-height: 250px; }
  .message-toolbar { grid-template-columns: 1fr repeat(3,34px); }
  .message-toolbar label { grid-column: 1 / -1; }
  .history-layout { grid-template-columns: minmax(300px, 40%) minmax(460px, 60%); overflow: auto; }
}

@media (max-width: 480px) {
  #unitPane { width: 46%; }
  #quickView { left: 46%; }
  #monitorHeader button { min-width: 34px; }
  #monitorHeader strong { display: none; }
  .status-filters { flex-wrap: nowrap; }
  .status-filters button { flex: 1; }
  #unitFilters { height: 96px; }
  #unitGridRegion { height: calc(100% - 138px); }
  #mapRegion { bottom: 52%; }
  #unitInfo { top: 48%; }
  .history-unit-header strong { padding: 0 90px 0 5px; text-align: left; }
}

/* ============================================================================
   Capa Vector GPS (colores, bordes y estados) - no altera el layout original
   Referencia: GUIA_ESTILOS_UI.md
   ============================================================================ */
:root {
  --v-primary: #0f8995; --v-primary-border: #0d7d88; --v-primary-dark: #0a6670;
  --v-primary-tint: #e6f4f5; --v-primary-ring: rgba(15, 137, 149, .18);
  --v-danger: #dc3545; --v-danger-dark: #bd2130; --v-success: #28a745; --v-success-dark: #1e8a37;
  --v-text: #26313d; --v-title: #1f2a35; --v-muted: #607080; --v-label: #485664;
  --v-border: #cfd9e2; --v-input-border: #bfcbd6; --v-th-bg: #f4f7f9; --v-input-bg: #f9fbfc;
  --v-shadow-pop: 0 12px 24px rgba(26, 36, 44, .22);
}

html, body { font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif; color: var(--v-text); }
a { color: var(--v-primary); }
h1, h2, h3 { color: var(--v-title); }

button {
  border-color: var(--v-input-border);
  border-radius: 6px;
  background-color: #fff;
  color: var(--v-label);
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover:not(:disabled) { color: var(--v-primary); border-color: var(--v-primary); background-color: var(--v-primary-tint); }
button:disabled { opacity: .5; color: #9aa6b2; background-color: #f4f7f9; border-color: #d8e0e6; cursor: not-allowed; }

button:is([id*="save" i],[id*="create" i],[id*="crear" i],[id*="guardar" i],[id*="accept" i],[id*="aceptar" i],[id*="apply" i],[id*="send" i],[id*="enviar" i],[id*="agregar" i],[id*="add" i],[id*="submit" i],[id*="filter" i]):not(:disabled) { color: #fff; background-color: var(--v-primary); border-color: var(--v-primary-border); }
button:is([id*="save" i],[id*="create" i],[id*="crear" i],[id*="guardar" i],[id*="accept" i],[id*="aceptar" i],[id*="apply" i],[id*="send" i],[id*="enviar" i],[id*="agregar" i],[id*="add" i],[id*="submit" i],[id*="filter" i]):hover:not(:disabled) { color: #fff; background-color: var(--v-primary-dark); border-color: var(--v-primary-dark); }

button:is([id*="edit" i],[id*="editar" i]):not(:disabled) { color: var(--v-primary); border-color: var(--v-primary); }

button:is([id*="delete" i],[id*="remove" i],[id*="borrar" i],[id*="eliminar" i]):not(:disabled) { color: var(--v-danger); border-color: #e3a0a8; background-color: #fff5f6; }
button:is([id*="delete" i],[id*="remove" i],[id*="borrar" i],[id*="eliminar" i]):hover:not(:disabled) { color: #fff; border-color: var(--v-danger); background-color: var(--v-danger); }

button:is([id*="excel" i],[id*="download" i],[id*="export" i],[id*="csv" i],[id*="descargar" i]):not(:disabled) { color: #fff; background-color: var(--v-success); border-color: var(--v-success); }
button:is([id*="excel" i],[id*="download" i],[id*="export" i],[id*="csv" i],[id*="descargar" i]):hover:not(:disabled) { color: #fff; background-color: var(--v-success-dark); border-color: var(--v-success-dark); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, [role="row"]:focus-visible {
  outline: 2px solid var(--v-primary);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea {
  border-color: var(--v-input-border);
  border-radius: 6px;
  background-color: var(--v-input-bg);
  color: var(--v-text);
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { border-color: var(--v-primary); box-shadow: 0 0 0 3px var(--v-primary-ring); }
input:disabled, select:disabled, textarea:disabled { color: #8a97a4; background-color: #f1f4f6; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--v-primary); }

fieldset { border-color: var(--v-border); border-radius: 8px; }
legend { color: var(--v-primary); font-weight: 700; }

th, [role="columnheader"] { background-color: var(--v-th-bg); color: #536171; font-weight: 700; }

tr[aria-selected="true"], [role="row"][aria-selected="true"], [role="option"][aria-selected="true"], tr.selected, [role="row"].selected,
[class*="row"].selected, [class*="item"].selected, [class*="row"][aria-selected="true"], [class*="item"][aria-selected="true"] {
  background-color: var(--v-primary-tint);
  box-shadow: inset 4px 0 0 var(--v-primary);
  outline: none;
}
tbody tr:hover, [role="grid"] [role="row"]:hover { background-color: rgba(15, 137, 149, .07); }
tr[aria-selected="true"]:hover, tr.selected:hover, [role="row"][aria-selected="true"]:hover { background-color: var(--v-primary-tint); }

dialog {
  border: 1px solid var(--v-border);
  border-top: 4px solid var(--v-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--v-text);
  box-shadow: var(--v-shadow-pop);
}
dialog:not([open]) { display: none !important; }
dialog::backdrop { background: rgba(26, 36, 44, .5); }

/* Botones dentro de encabezados de tabla: sin caja */
th button, [role="columnheader"] button { background-color: transparent; border-color: transparent; box-shadow: none; color: inherit; }
th button:hover:not(:disabled), [role="columnheader"] button:hover:not(:disabled) { background-color: rgba(15, 137, 149, .10); border-color: transparent; color: var(--v-primary); }
/* Estado activo / seleccionado en botones (pestañas, filtros, categorías) */
button[aria-pressed="true"]:not(:disabled), button[aria-selected="true"]:not(:disabled), button.active:not(:disabled), button.selected:not(:disabled) {
  color: var(--v-primary-dark); background-color: var(--v-primary-tint); border-color: var(--v-primary); box-shadow: none;
}

/* v2: dialogos al nivel de Alertas */
html, body { background: #eef2f5; }
/* Diálogos con encabezado */
dialog { padding: 0 0 14px !important; overflow: auto; }
dialog > :not(header):not(h1:first-child):not(h2:first-child) { margin-left: 16px; margin-right: 16px; }
dialog > header, dialog > h1:first-child, dialog > h2:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px !important;
  padding: 9px 14px !important;
  font: 700 13px/1.45 Roboto, Arial, sans-serif !important;
  color: #fff !important;
  background: #343a40 !important;
  border: 0 !important;
  border-bottom: 3px solid var(--v-primary) !important;
}
dialog > header h2, dialog > header h1 { margin: 0 !important; padding: 0 !important; font: 700 13px/1.45 Roboto, Arial, sans-serif !important; color: #fff !important; background: transparent !important; border: 0 !important; }
dialog > header button { min-height: 26px; padding: 0 9px; color: #fff; background: transparent; border-color: rgba(255, 255, 255, .4); }
dialog > header button:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, .16); border-color: #fff; }
dialog[id*="confirm" i] { border-top-color: var(--v-danger); }
dialog[id*="confirm" i] > h1:first-child, dialog[id*="confirm" i] > h2:first-child, dialog[id*="confirm" i] > header { border-bottom-color: var(--v-danger); }

/* v3: tablas a ancho completo del contenedor */
table { width: 100%; }