
/*
 * Aquantis Dashboard Premium
 * Camada exclusivamente visual. Mantem IDs, eventos e contratos do dashboard legado.
 */

:root {
  --bg: #020914;
  --surface-1: #06111f;
  --surface-2: #0a1728;
  --surface-3: #10223a;
  --border: rgba(119, 162, 205, .14);
  --border-med: rgba(119, 181, 235, .25);
  --text-1: #edf6ff;
  --text-2: #92a8c3;
  --text-3: #607896;
  --blue: #20bdf6;
  --green: #2bdba0;
  --red: #ff5d68;
  --amber: #ffc42d;
  --purple: #9d8cff;
  --blue-dim: rgba(32, 189, 246, .12);
  --green-dim: rgba(43, 219, 160, .11);
  --red-dim: rgba(255, 93, 104, .11);
  --amber-dim: rgba(255, 196, 45, .10);
  --sidebar-w: 266px;
  --log-w: 316px;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #edf4fb;
  --surface-1: #f8fbff;
  --surface-2: #edf4fb;
  --surface-3: #dfeaf5;
  --border: rgba(28, 70, 108, .10);
  --border-med: rgba(28, 96, 150, .20);
  --text-1: #10243a;
  --text-2: #506b87;
  --text-3: #7890a8;
  color-scheme: light;
}

html,
body {
  background:
    radial-gradient(circle at 54% -15%, rgba(21, 127, 190, .13), transparent 35%),
    radial-gradient(circle at 5% 95%, rgba(14, 98, 145, .09), transparent 32%),
    var(--bg);
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .16;
  background-image:
    linear-gradient(rgba(79, 155, 214, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 155, 214, .04) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, #000, transparent 86%);
}

/* Topbar preservada, com acabamento industrial premium. */
#topbar {
  height: 68px;
  padding: 0 24px;
  gap: 14px;
  background: rgba(3, 12, 23, .88);
  border-bottom: 1px solid rgba(89, 149, 204, .16);
  box-shadow: 0 12px 42px rgba(0, 0, 0, .22);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

#topbar-brand { gap: 12px; }
#topbar-brand .brand-dot { width: 30px; height: 30px; }
#topbar-title { font-size: 20px; letter-spacing: -.55px; }
#topbar-version { margin-left: 7px; color: #607591; }

.net-badge {
  padding: 5px 10px;
  background: rgba(255, 196, 45, .06);
  border-color: rgba(255, 196, 45, .28);
}

.topbar-actions { gap: 10px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(14, 29, 48, .9), rgba(5, 16, 29, .9));
  border-color: rgba(111, 154, 197, .20);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), 0 5px 14px rgba(0, 0, 0, .16);
}
.icon-btn:hover {
  color: #fff;
  border-color: rgba(32, 189, 246, .42);
  background: linear-gradient(180deg, rgba(21, 45, 71, .94), rgba(8, 24, 41, .94));
  transform: translateY(-1px);
}
#btn-multiboard.active {
  color: #00121e;
  background: linear-gradient(145deg, #41d0ff, #149ce3);
  box-shadow: 0 0 24px rgba(32, 189, 246, .28), inset 0 1px 0 rgba(255, 255, 255, .38);
}

#app-shell { height: calc(100vh - 68px); }

/* Laterais: mesmas funcoes e mesmos controles, nova hierarquia visual. */
.sidebar {
  background: linear-gradient(180deg, rgba(5, 16, 29, .96), rgba(3, 13, 25, .96));
  border-color: rgba(93, 146, 196, .16);
}
#sidebar-left { padding: 12px 10px 10px; }
#sidebar-right { padding-bottom: 12px; }
.s-section {
  margin: 0;
  padding: 18px 10px 0;
}
.s-section + .s-section {
  margin-top: 4px;
  border-top-color: rgba(109, 157, 199, .14) !important;
}
.s-label {
  margin-bottom: 12px;
  padding-bottom: 9px;
  font-size: 11px;
  letter-spacing: .55px;
  color: var(--blue);
  border-bottom-color: rgba(32, 189, 246, .20);
}
.s-label::before {
  content: "";
  display: block;
  width: 3px;
  height: 13px;
  border-radius: 4px;
  background: var(--blue);
  box-shadow: 0 0 10px rgba(32, 189, 246, .5);
}

.clock-wrap { padding: 4px 4px 8px; }
.clock-time {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(34px, 3vw, 42px);
  font-weight: 700;
  letter-spacing: -1.8px;
  color: #f5f9ff;
  text-shadow: 0 3px 24px rgba(32, 189, 246, .12);
}
.clock-date { margin-top: 1px; color: #a3b5ca; }
.clock-tz { color: #657b96; }

.weather-top { align-items: center; }
.weather-loc { color: #b9c7d8; }
.weather-temp { font-size: 31px; font-weight: 700; letter-spacing: -1px; }
.weather-icon-wrap {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(255, 196, 45, .12), transparent 70%);
}
.weather-grid { gap: 10px; }
.weather-stat {
  padding: 6px 8px;
  border: 1px solid rgba(91, 145, 195, .12);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(15, 35, 58, .85), rgba(8, 25, 43, .8));
}
.weather-stat-label { line-height: 1.2; }
.weather-stat-val { color: var(--blue); font-size: 19px; line-height: 1.2; }
.weekly-row { border-color: rgba(105, 148, 190, .10); }

.time-input,
.meta-input,
#log-filter {
  background: rgba(3, 13, 25, .68) !important;
  border-color: rgba(101, 153, 202, .18) !important;
}
.time-input { min-height: 48px; border-radius: 10px; }
.day-lbl {
  border-color: rgba(97, 150, 198, .20);
  background: rgba(6, 20, 35, .74);
}
.day-chk:checked + .day-lbl {
  color: #02131f;
  background: linear-gradient(145deg, #40d0ff, #1aa6e9);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(32, 189, 246, .25);
}
.window-warn {
  border: 1px solid rgba(255, 196, 45, .14);
  background: rgba(255, 196, 45, .045);
}

/* Area central. */
#main-area {
  background:
    radial-gradient(circle at 50% 0, rgba(20, 116, 175, .07), transparent 32%),
    rgba(1, 8, 16, .36);
}
#view-multiboard { padding: 26px 24px 30px; }
.mb-header {
  min-height: 40px;
  margin-bottom: 18px;
  gap: 12px;
}
.mb-header-title { font-size: 25px; letter-spacing: -.65px; }
.mb-header-hint {
  padding: 5px 13px;
  color: #758ba6;
  background: rgba(8, 23, 39, .72);
  border-color: rgba(87, 139, 187, .16);
}
.aq-mb-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.aq-view-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(95, 151, 201, .18);
  border-radius: 10px;
  background: rgba(3, 13, 25, .72);
}
.aq-view-btn {
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: #6f86a1;
  background: transparent;
  cursor: pointer;
}
.aq-view-btn.active {
  color: #031521;
  background: var(--blue);
}
.aq-sort {
  min-width: 168px;
  height: 38px;
  padding: 0 34px 0 12px;
  color: var(--text-2);
  background: rgba(6, 20, 35, .84);
  border: 1px solid rgba(95, 151, 201, .18);
  border-radius: 9px;
  font-family: inherit;
  font-size: 12px;
}

.mb-grid { gap: 18px; }
.mb-card {
  min-width: 0;
  padding: 16px 17px 15px;
  border-radius: 17px;
  border-color: rgba(100, 156, 207, .22);
  background:
    radial-gradient(circle at 82% 0, rgba(38, 145, 207, .07), transparent 37%),
    linear-gradient(150deg, rgba(10, 27, 46, .98), rgba(4, 16, 29, .98));
  box-shadow:
    0 16px 36px rgba(0, 0, 0, .27),
    inset 0 1px 0 rgba(255, 255, 255, .035);
}
.mb-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(118deg, rgba(255, 255, 255, .025), transparent 29%);
}
.mb-card:hover {
  transform: translateY(-2px);
  border-color: rgba(32, 189, 246, .58);
  box-shadow: 0 20px 46px rgba(0, 0, 0, .35), 0 0 28px rgba(32, 189, 246, .08);
}
.mb-card.focused {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(32, 189, 246, .24), 0 0 32px rgba(32, 189, 246, .12);
}
.mb-card.alarm { border-color: rgba(255, 93, 104, .72); }
.mb-card.offline { opacity: .64; filter: saturate(.68); }
.mb-card-head { margin-bottom: 13px; }
.mb-dot { width: 10px; height: 10px; }
.mb-dot.online { box-shadow: 0 0 12px rgba(255, 196, 45, .85); }
.mb-dot.online.mqtts { box-shadow: 0 0 12px rgba(43, 219, 160, .8); }
.mb-name { font-size: 16px; letter-spacing: -.2px; }
.mb-mode { padding: 5px 10px; }
/* fix: o selo "OFFLINE" (::after) fica no canto sup. direito, mesmo lugar do badge de modo
   (AUTO/MANUAL, último item flex do cabeçalho). Numa placa offline o modo é dado velho/enganoso,
   então some com ele e deixa só o "OFFLINE" limpo — sem os dois sobrepostos. */
.mb-card.offline .mb-mode { visibility: hidden; }

.mb-tanks {
  gap: 18px;
  align-items: end;
  margin: 0 -2px 13px;
  padding: 0 2px;
}
.mb-tank { min-width: 0; }
.mb-tank-cap {
  margin: 0 0 8px;
  color: #8397af;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}
.mb-tank-visual {
  width: min(100%, 190px);
  height: clamp(126px, var(--mb-tank-h, 170px), 188px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(174, 201, 222, .35);
  border-radius: 48% / 12%;
  background:
    linear-gradient(90deg, rgba(255,255,255,.06), transparent 15%, transparent 83%, rgba(255,255,255,.045)),
    linear-gradient(180deg, rgba(189, 216, 235, .06), rgba(4, 10, 17, .45));
  box-shadow:
    inset 12px 0 24px rgba(255, 255, 255, .025),
    inset -14px 0 26px rgba(0, 0, 0, .34),
    inset 0 -14px 24px rgba(0, 0, 0, .35),
    0 13px 18px rgba(0, 0, 0, .25);
}
.mb-tank-visual::before {
  content: "";
  position: absolute;
  z-index: 4;
  inset: -1px 2px auto;
  height: 20px;
  border: 2px solid rgba(184, 211, 230, .42);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(211, 231, 244, .07), rgba(4, 12, 20, .48) 72%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .16);
}
.mb-tank-visual::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 9px 14% 8px;
  pointer-events: none;
  border-left: 1px solid rgba(206, 228, 242, .18);
  border-right: 1px solid rgba(206, 228, 242, .12);
  background: linear-gradient(90deg, rgba(255,255,255,.07), transparent 25%, transparent 72%, rgba(255,255,255,.03));
}
.mb-tank-fill {
  left: 3%;
  width: 94%;
  min-height: 7px;
  opacity: .78;
  border-radius: 48% 48% 42% 42% / 12% 12% 8% 8%;
  box-shadow: 0 -2px 22px var(--glow, rgba(45, 212, 191, .3)), inset 0 7px 16px rgba(255,255,255,.10);
}
.mb-tank-fill::before {
  top: -7px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,.42), rgba(255,255,255,.09) 42%, transparent 72%);
}
.mb-tank-fill::after {
  background: linear-gradient(90deg, rgba(255,255,255,.12), transparent 25%, transparent 75%, rgba(0,0,0,.14));
}
.mb-tank-pct {
  align-items: center;
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(20px, 2.1vw, 27px);
  font-weight: 700;
  text-shadow: 0 2px 10px #000;
}
.mb-tank-pct::before {
  content: "";
  position: absolute;
  width: 64px;
  height: 38px;
  z-index: -1;
  border-radius: 9px;
  background: rgba(1, 8, 15, .58);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .24);
  backdrop-filter: blur(5px);
}
.mb-tank-sub { margin-top: 7px; color: #8498af; }
.mb-chips {
  padding-top: 9px;
  border-top: 1px solid rgba(100, 151, 198, .11);
}
.mb-chip { padding: 5px 10px; background: rgba(12, 29, 48, .72); }

.mb-grid.aq-list-mode { grid-template-columns: 1fr !important; }
.mb-grid.aq-list-mode .mb-card {
  display: grid;
  grid-template-columns: minmax(170px, .7fr) minmax(320px, 1.6fr) minmax(160px, .6fr);
  align-items: center;
  gap: 18px;
}
.mb-grid.aq-list-mode .mb-card-head,
.mb-grid.aq-list-mode .mb-tanks,
.mb-grid.aq-list-mode .mb-chips { margin: 0; }
.mb-grid.aq-list-mode .mb-tank-visual { height: 105px; }

/* Logs com leitura por evento, sem alterar o payload bruto. */
.logs-header {
  min-height: 61px;
  padding: 16px 18px 12px;
  border-color: rgba(95, 147, 194, .15);
}
.logs-title { color: #8fa5be; letter-spacing: .4px; }
.logs-refresh-btn {
  padding: 6px 10px;
  background: rgba(10, 27, 46, .78);
  border-color: rgba(103, 157, 205, .18);
}
#sidebar-right > div:nth-child(2) { padding: 9px 12px !important; }
#log-filter { height: 34px; border-radius: 8px !important; }
.log-area {
  margin: 0 10px;
  padding: 5px 10px 12px;
  color: #8da2ba;
  white-space: normal;
  background: rgba(2, 10, 19, .18);
  border-top: 1px solid rgba(91, 146, 195, .10);
}
.aq-log-line {
  position: relative;
  display: block;
  padding: 12px 6px 12px 20px;
  color: #94a7bd;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-bottom: 1px solid rgba(93, 145, 191, .12);
}
.aq-log-line::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 17px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6e849d;
  box-shadow: 0 0 8px currentColor;
}
.aq-log-line.is-ok { color: #35dca1; }
.aq-log-line.is-info { color: #43bff2; }
.aq-log-line.is-warn { color: #ffc447; }
.aq-log-line.is-error { color: #ff6973; }
.aq-logs-all {
  margin: 10px 18px 0;
  min-height: 42px;
  border: 1px solid rgba(107, 158, 204, .26);
  border-radius: 10px;
  color: #9ab0c8;
  background: rgba(6, 20, 35, .58);
  font: 500 12px 'DM Sans', sans-serif;
  cursor: pointer;
}
.aq-logs-all:hover { color: var(--blue); border-color: rgba(32, 189, 246, .48); }

/* Demais cards do foco detalhado recebem a mesma linguagem sem tocar na logica. */
.card,
.panel,
.card-sm,
.telem-cell {
  border-color: rgba(100, 155, 205, .17);
  background: linear-gradient(150deg, rgba(10, 27, 46, .94), rgba(5, 17, 30, .96));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .20), inset 0 1px 0 rgba(255, 255, 255, .025);
}

/* Desktop compacto/tablet: preserva as laterais e impede que os canvases 3D sejam recortados. */
@media (max-width: 1500px) and (min-width: 901px) {
  :root { --sidebar-w: 226px; --log-w: 264px; }
  .main-inner { padding: 16px; gap: 12px; }
  #view-multiboard { padding: 20px 16px; }
  #mb-grid { grid-template-columns: 1fr !important; }
  .mb-tank-visual { height: 142px; }
  .aq-mb-toolbar { width: 100%; margin-left: 0; }
}

/* Mobile: blocos inteiros empilhados, sem esconder funcoes e sem overflow horizontal. */
@media (max-width: 900px) {
  html,
  body { width: 100%; overflow-x: hidden; }
  #topbar {
    min-height: 62px;
    height: auto;
    padding: 9px 12px;
  }
  #topbar-title { font-size: 17px; }
  .topbar-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .icon-btn { width: 38px; height: 38px; flex: 0 0 38px; }
  #app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  #main-area {
    display: block;
    order: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
  }
  #sidebar-left { display: flex; order: 2; width: 100%; overflow: visible; }
  #sidebar-right { display: flex; order: 3; width: 100%; min-height: 520px; overflow: visible; }
  #view-dashboard:not(.hidden) {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .main-inner {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  #tank-card,
  #pump-card,
  #chart-card {
    min-width: 0;
    max-width: calc(100% - 20px);
    box-sizing: border-box;
  }
  #chart-card .chart-canvas-wrap {
    min-width: 0;
    overflow: hidden;
  }
  #unifiedChart {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
  }
  @media (max-width: 340px) {
    #chart-card .chart-header {
      align-items: stretch;
      flex-direction: column;
      gap: 8px;
    }
    #chart-card .tabs-row {
      width: 100%;
    }
    #chart-card .tab-btn {
      min-width: 0;
    }
  }
  #view-multiboard { padding: 18px 12px 24px; }
  .mb-header-title { font-size: 21px; }
  .aq-mb-toolbar { width: 100%; margin-left: 0; }
  .aq-sort { flex: 1; min-width: 0; }
  #mb-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
  .mb-card { padding: 14px; }
  .mb-tanks { gap: 10px; }
  .mb-tank-visual { height: 138px !important; }
  .mb-grid.aq-list-mode .mb-card { display: block; }
  .mb-grid.aq-list-mode .mb-card-head { margin-bottom: 13px; }
  .mb-grid.aq-list-mode .mb-tanks { margin-bottom: 13px; }
  #clock-section,
  #weather-section,
  #janela-section,
  #reset-section,
  #meta-section,
  #sidebar-right > * { margin-left: 8px; margin-right: 8px; }
  #inline-log-content.log-area { height: 320px; min-height: 320px; }
}

@media (max-width: 480px) {
  .mb-header-hint { width: 100%; }
  .mb-name { font-size: 14px; }
  .mb-tank-cap { font-size: 10px; }
  .mb-tank-visual { height: 124px !important; }
  .mb-tank-pct { font-size: 20px; }
  .mb-chip { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

  