/* AeroPublic v3.2 — cross-page layout stabilization.
   Intentionally additive: preserves existing visual brand and component JS IDs. */
:root {
  --ap-layout-gap: clamp(14px, 1.6vw, 22px);
  --ap-layout-radius: 18px;
  --ap-layout-outline: var(--border, #dce8e3);
  --ap-layout-muted: var(--text-secondary, #637a72);
  --ap-layout-ink: var(--text, #19392e);
}
html[data-theme="dark"] {
  --ap-layout-outline: var(--border, #30443f);
  --ap-layout-muted: var(--text-secondary, #b1c4bd);
  --ap-layout-ink: var(--text, #eef7f2);
}
html { scroll-behavior:smooth; }
*, *::before, *::after { box-sizing:border-box; }
body { overflow-x:clip; }
body :is(h1,h2,h3,h4,p,small,span) { overflow-wrap:break-word; }
body :is(img,video,svg,canvas) { max-width:100%; }
body :is(input,textarea,select,button) { font:inherit; }
body :is(input,textarea,select) { min-width:0; max-width:100%; }
body :is(button,a,[role="button"]) { touch-action:manipulation; }
body :is(button,input,textarea,select,a):focus-visible { outline:3px solid #047857; outline-offset:3px; }
body :is(button,[role="button"]) { cursor:pointer; }
body :is(button:disabled,[aria-disabled="true"]) { cursor:not-allowed; opacity:.62; }
body :is(.card,.stat-card,.settings-card,.device-card,.notif-item,.table-card,.chart-card,.fan-monitor-panel,.fan-alert-panel,.recap-card) { min-width:0; }
body :is(.card-header,.page-header,.section-header,.settings-card-header,.notif-header,.dashboard-header) { min-width:0; }
body :is(.btn,.btn-notif,.btn-filter,.btn-primary,.btn-secondary) { display:inline-flex; align-items:center; justify-content:center; gap:8px; line-height:1.35; min-height:38px; max-width:100%; text-decoration:none; }
body :is(.btn,.btn-notif,.btn-filter,.btn-primary,.btn-secondary) i { flex:0 0 auto; }
body :is(.table-card,.table-section,.card) .data-table-wrapper { overflow-x:auto; overscroll-behavior-inline:contain; -webkit-overflow-scrolling:touch; width:100%; max-width:100%; }
body .data-table-wrapper table { width:100%; border-collapse:separate; border-spacing:0; }
body .data-table-wrapper :is(td,th) { vertical-align:middle; }
body .data-table-wrapper thead th { position:relative; text-align:left; line-height:1.45; }
body .data-table-wrapper tbody td { font-variant-numeric:tabular-nums; }
body .data-table-wrapper tbody tr:hover { background:rgba(16,185,129,.035); }
body :is(.empty-state,.state-wrapper) { text-align:center; padding:clamp(22px,3vw,42px) 16px; max-width:100%; }
body :is(.empty-state,.state-wrapper) p { max-width:62ch; margin-inline:auto; }
/* Protect controls and overlays from clipping/overlap. */
body :is(.modal,.modal-content,[role="dialog"]) { max-width:min(94vw,740px); max-height:90dvh; }
body :is(.modal-body,.modal-content) { overflow-y:auto; overscroll-behavior:contain; }
body [hidden] { display:none!important; }
/* Public navigation and content hierarchy */
body.public-page #mainContent { width:100%; max-width:1600px; margin-inline:auto; }
body.public-page #mainContent > section { min-width:0; scroll-margin-top:100px; }
body.public-page .navbar { gap:clamp(8px,1.4vw,22px); flex-wrap:nowrap; min-width:0; }
body.public-page .nav-brand { flex:0 0 auto; min-width:0; }
body.public-page .nav-actions { flex:0 1 auto; min-width:0; }
body.public-page #publicSearchInput { min-width:0; max-width:100%; }
body.public-page .public-search-wrapper { min-width:0; max-width:240px; }
body.public-page .nav-menu { min-width:0; }
body.public-page .nav-menu a { white-space:nowrap; }
body.public-page .hero-scada { isolation:isolate; }
body.public-page .dashboard-middle,
body.public-page .dashboard-bottom,
body.public-page .parameter-grid,
body.public-page .recap-strip,
body.public-page .public-device-section,
body.public-page .content-grid { min-width:0; }
body.public-page .recap-strip > *,body.public-page .dashboard-middle > *,body.public-page .dashboard-bottom > * { min-width:0; }
body.public-page :is(.parameter-card,.recap-card,.param-chart-card) { overflow-wrap:anywhere; }
body.public-page :is(.parameter-card,.recap-card) .value { font-variant-numeric:tabular-nums; }
body.public-page .chart-card :is(canvas,.chart-container),
body.public-page .param-chart-card :is(canvas,.chart-container) { max-width:100%; }
/* Fan status remains telemetry-only and is not inferred from thresholds. */
body.public-page #fan-public-section .fan-monitor-heading { align-items:center; }
body.public-page #fan-public-section .fan-monitor-toolbar { border-top:1px solid var(--ap-layout-outline); padding-top:16px; }
body.public-page #fan-public-section .fan-monitor-stat,
body.public-page #fan-public-section .fan-monitor-explanation { min-width:0; overflow-wrap:anywhere; }
body.public-page #fan-public-section .fan-stat-value { font-variant-numeric:tabular-nums; }
body.public-page #fan-alert-section #alertFeedList { max-height:480px; overflow-y:auto; padding-right:3px!important; overscroll-behavior:contain; }
body.public-page #fan-alert-section #alertFeedList .alert-item { min-width:0; }
body.public-page #fan-alert-section #alertFeedList .alert-msg { overflow-wrap:anywhere; }
body.public-page #fan-alert-section #alertFeedList .alert-meta { display:flex; flex-wrap:wrap; gap:4px 10px; }
body.public-page .public-device-section .data-table-wrapper { max-width:100%; overflow-x:auto; }
/* Admin page-shell and readable spacing */
body.dashboard-layout { min-width:0; }
body.dashboard-layout #mainContent { min-width:0; max-width:none; }
body.dashboard-layout #mainContent > * { min-width:0; }
body.dashboard-layout :is(.page-header,.dashboard-header,.devices-header,.report-header,.settings-header,.notif-header) {
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:14px 20px;
  margin-bottom:var(--ap-layout-gap);
}
body.dashboard-layout :is(.page-header,.dashboard-header,.settings-header,.notif-header) :is(h1,h2) { margin-block:0 5px; line-height:1.25; overflow-wrap:anywhere; }
body.dashboard-layout :is(.header-actions,.notif-actions,.filter-actions,.toolbar-actions) { display:flex; flex-wrap:wrap; align-items:center; gap:10px; max-width:100%; }
body.dashboard-layout :is(.stats-grid,.summary-grid,.settings-grid,.devices-grid,.content-grid,.charts-grid) { gap:var(--ap-layout-gap); min-width:0; }
body.dashboard-layout :is(.stats-grid,.summary-grid,.settings-grid,.devices-grid,.charts-grid) > * { min-width:0; }
body.dashboard-layout :is(.card,.settings-card,.stat-card,.device-card,.notif-item) { border-radius:var(--ap-layout-radius); }
body.dashboard-layout :is(.card-header,.settings-card-header) { gap:12px; flex-wrap:wrap; }
body.dashboard-layout .card-header > :first-child { min-width:0; }
body.dashboard-layout :is(.card-body,.settings-card-body,.device-card-body) { min-width:0; }
body.dashboard-layout :is(.form-grid,.form-row,.filter-grid) { min-width:0; gap:12px; }
body.dashboard-layout .settings-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
body.dashboard-layout .settings-card :is(.setting-item,.setting-label,.setting-description,.setting-input) { min-width:0; max-width:100%; }
body.dashboard-layout .settings-card :is(.setting-label,.setting-description,.info-box-text) { overflow-wrap:anywhere; }
body.dashboard-layout .settings-card .settings-card-body { padding:clamp(16px,2vw,22px); }
body.dashboard-layout :is(.notif-list,.device-list) { min-width:0; }
body.dashboard-layout .notif-item { display:flex; gap:12px; padding:16px; align-items:flex-start; }
body.dashboard-layout .notif-item :is(.notif-content,.notif-title,.notif-message,.notif-meta) { min-width:0; overflow-wrap:anywhere; }
body.dashboard-layout .notif-item .notif-content { flex:1 1 auto; }
body.dashboard-layout .notif-item .notif-meta { display:flex; flex-wrap:wrap; gap:6px 14px; }
body.dashboard-layout .filter-chips { gap:8px; max-width:100%; }
body.dashboard-layout .filter-chip { white-space:normal; text-align:center; line-height:1.4; }
body.dashboard-layout .devices-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)); }
body.dashboard-layout .device-card { overflow:hidden; }
body.dashboard-layout .device-card :is(.device-card-header,.device-card-body,.device-card-footer) { min-width:0; }
body.dashboard-layout .device-card :is(button,.btn) { white-space:normal; }
body.dashboard-layout :is(.pagination,.pagination-container,#paginationContainer) { max-width:100%; display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:10px; }
body.dashboard-layout #paginationContainer .info { flex:1 1 100%; text-align:center; line-height:1.5; }
body.dashboard-layout .chart-container { min-width:0; width:100%; }
body.dashboard-layout #historyChart { display:block; max-width:100%; }
/* Inline chart/status fallback when libraries fail to load. */
.aero-report-notice { padding:12px 16px; margin:14px 0; border-radius:13px; border:1px solid #e8cf91; background:#fffaeb; color:#765514; font-size:13px; line-height:1.6; }
html[data-theme="dark"] .aero-report-notice { background:#382e17; color:#f6d68f; border-color:#756334; }
/* Mobile: avoid the broad min-width rules from legacy page-specific CSS. */
@media(max-width:1100px) {
  body.public-page .public-search-wrapper { display:none; }
  body.dashboard-layout .settings-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:900px) {
  body.dashboard-layout .settings-grid { grid-template-columns:1fr; }
  body.dashboard-layout :is(.stats-grid,.summary-grid,.charts-grid) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.public-page #mainContent { padding-left:clamp(12px,3vw,24px); padding-right:clamp(12px,3vw,24px); }
  body.public-page #fan-public-section .fan-monitor-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:650px) {
  body.dashboard-layout .main-content { padding-left:14px!important; padding-right:14px!important; }
  body.dashboard-layout :is(.page-header,.dashboard-header,.notif-header,.settings-header,.devices-header,.report-header) { align-items:stretch; }
  body.dashboard-layout :is(.stats-grid,.summary-grid,.charts-grid,.settings-grid) { grid-template-columns:1fr; }
  body.dashboard-layout :is(.header-actions,.notif-actions,.filter-actions) { width:100%; }
  body.dashboard-layout :is(.header-actions,.notif-actions) :is(button,.btn) { min-height:42px; }
  body.dashboard-layout :is(.stat-card,.settings-card,.device-card,.card) { max-width:100%; }
  body.dashboard-layout .filter-chip { padding:9px 11px; }
  body.public-page .navbar { padding:10px 14px!important; }
  body.public-page #mainContent { padding-left:12px; padding-right:12px; }
  body.public-page .nav-brand .logo-tagline { display:none; }
  body.public-page #fan-public-section .fan-monitor-grid { grid-template-columns:1fr; }
  body.public-page #fan-public-section .fan-monitor-heading { align-items:flex-start; }
  body.public-page #fan-public-section .fan-monitor-rule { padding:13px; }
  body.public-page .fan-monitor-toolbar { align-items:stretch; }
  body.public-page #fan-public-section .fan-device-filter { flex:1 1 100%; }
  body.public-page #fan-alert-section #alertFeedList { max-height:440px; }
}
@media(max-width:420px) {
  body.public-page .nav-actions { gap:6px; }
  body.public-page .nav-actions :is(.admin-login-btn,.theme-toggle-btn,.nav-toggle-btn) { flex-shrink:0; }
  body.public-page .nav-brand .logo-text { font-size:17px; }
  body.public-page #connectionStatus { display:none; }
  body.dashboard-layout .main-content { padding-left:10px!important; padding-right:10px!important; }
  body.dashboard-layout :is(.card-body,.settings-card-body) { padding:14px; }
  body.dashboard-layout :is(.notif-actions,.filter-actions) :is(.btn,.btn-notif) { flex:1 1 auto; }
}
@media(prefers-reduced-motion:reduce) {
  html { scroll-behavior:auto; }
  body :is(.reveal,.hero-reveal,[data-load-rise],[data-load-line]) { animation-duration:.01ms!important; transition-duration:.01ms!important; }
}

/* Login: keep the split layout balanced while preserving the existing visual theme. */
body.login-page .login-page-container { min-width:0; }
body.login-page .login-form-panel { min-width:0; }
body.login-page .login-form-card { width:min(100%,470px); padding:clamp(20px,3vw,38px); overflow-wrap:anywhere; }
body.login-page .form-label { color:var(--ap-layout-ink); }
body.login-page .input-wrapper { position:relative; min-width:0; width:100%; }
body.login-page .form-input { display:block; width:100%; min-width:0; max-width:100%; }
body.login-page .btn-login { width:100%; min-height:46px; justify-content:center; }
body.login-page .form-options { display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px 14px; }
@media(max-width:900px) {
  body.login-page .login-page-container { grid-template-columns:minmax(0,1fr); }
  body.login-page .login-form-panel { min-height:100dvh; padding:28px 16px; }
}
@media(max-width:420px) {
  body.login-page .login-form-card { padding:20px 16px; }
}
