
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg:          #0d0f14;
      --surface-1:   #131720;
      --surface-2:   #1a1f2e;
      --surface-3:   #212638;
      --border:      rgba(255,255,255,0.07);
      --border-med:  rgba(255,255,255,0.12);

      --text-1: #f0f2f8;
      --text-2: #8b93a8;
      --text-3: #55607a;

      --blue:    #38bdf8;
      --green:   #34d399;
      --red:     #f87171;
      --amber:   #fbbf24;
      --purple:  #818cf8;

      --blue-dim:  rgba(56,189,248,0.12);
      --green-dim: rgba(52,211,153,0.12);
      --red-dim:   rgba(248,113,113,0.12);
      --amber-dim: rgba(251,191,36,0.12);

      /* Cores auxiliares dependentes de tema (usadas em estilos inline) */
      --modal-bg:        rgba(0,0,0,0.7);
      --modal-surface:   #1a1f3a;
      --device-bar-bg:   rgba(0,0,0,0.25);
      --input-bg:        rgba(0,0,0,0.4);
      --input-border:    rgba(255,255,255,0.12);

      --radius-sm: 8px;
      --radius-md: 14px;
      --radius-lg: 20px;

      --sidebar-w: 260px;
      --log-w: 240px;
      --gap: 16px;
    }

    /* ════════════════════ TEMA CLARO ════════════════════ */
    /* Filosofia: slate-tinted (nao pure white/black), camadas sutis com
       sombras leves de profundidade em vez de bordas duras, acentos
       refinados ligeiramente menos saturados que no escuro. */
    :root[data-theme="light"] {
      /* Backgrounds em camada (cool slate, evita branco esteril) */
      --bg:          #f5f7fb;
      --surface-1:   #ffffff;
      --surface-2:   #f1f4fa;
      --surface-3:   #e4e9f2;
      --border:      rgba(15,23,42,0.06);
      --border-med:  rgba(15,23,42,0.10);

      /* Texto: slate-800/500/400 — legivel sem ser preto duro */
      --text-1: #1e293b;
      --text-2: #64748b;
      --text-3: #94a3b8;

      /* Acentos: tons modernos, vibrantes mas refinados */
      --blue:    #2563eb;
      --green:   #10b981;
      --red:     #ef4444;
      --amber:   #f59e0b;
      --purple:  #8b5cf6;

      --blue-dim:  rgba(37,99,235,0.08);
      --green-dim: rgba(16,185,129,0.08);
      --red-dim:   rgba(239,68,68,0.08);
      --amber-dim: rgba(245,158,11,0.08);

      --modal-bg:        rgba(15,23,42,0.45);
      --modal-surface:   #ffffff;
      --device-bar-bg:   #eef2f8;
      --input-bg:        #ffffff;
      --input-border:    rgba(15,23,42,0.10);
    }

    /* Transicao suave ao trocar de tema */
    html, body, .sidebar, .panel, .icon-btn, #topbar, .modal-box,
    input, select, textarea, button {
      transition: background-color .25s ease, color .25s ease,
                  border-color .25s ease, box-shadow .25s ease;
    }

    /* === Elevacao por sombras (so no tema claro) ===
       No escuro, o contraste de superficies + bordas ja da hierarquia.
       No claro, sombras sutis dao profundidade sem deixar tudo achatado. */
    :root[data-theme="light"] #topbar {
      background: rgba(255,255,255,0.85);
      backdrop-filter: blur(14px) saturate(180%);
      -webkit-backdrop-filter: blur(14px) saturate(180%);
      box-shadow: 0 1px 0 rgba(15,23,42,0.04), 0 4px 20px rgba(15,23,42,0.04);
      border-bottom: 1px solid transparent;
    }
    :root[data-theme="light"] .sidebar {
      box-shadow: 0 1px 2px rgba(15,23,42,0.03);
      border-color: var(--border);
    }
    :root[data-theme="light"] .panel,
    :root[data-theme="light"] .telem-cell {
      box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 2px 8px rgba(15,23,42,0.03);
    }
    :root[data-theme="light"] .panel:hover {
      box-shadow: 0 2px 4px rgba(15,23,42,0.06), 0 8px 24px rgba(15,23,42,0.06);
    }
    :root[data-theme="light"] #users-modal > div {
      box-shadow: 0 24px 48px rgba(15,23,42,0.18),
                  0 8px 16px rgba(15,23,42,0.10) !important;
    }
    :root[data-theme="light"] #device-bar {
      box-shadow: inset 0 -1px 0 rgba(15,23,42,0.05);
      border-bottom-color: transparent !important;
    }
    /* Botoes icone: limpinhos, sem fundo no claro */
    :root[data-theme="light"] .icon-btn {
      background: transparent;
      border-color: transparent;
      color: var(--text-2);
    }
    :root[data-theme="light"] .icon-btn:hover {
      background: var(--surface-2);
      color: var(--text-1);
    }
    :root[data-theme="light"] .icon-btn.status-ok { color: var(--amber); }
    :root[data-theme="light"] .icon-btn.status-mqtts { color: var(--green); }
    :root[data-theme="light"] .icon-btn.status-err { color: var(--red); }
    /* Brand dot com glow sutil de marca */
    :root[data-theme="light"] .brand-dot {
      box-shadow: 0 4px 12px rgba(37,99,235,0.25);
    }
    /* Scrollbars discretas no claro */
    :root[data-theme="light"] .sidebar::-webkit-scrollbar-thumb,
    :root[data-theme="light"] #main-area::-webkit-scrollbar-thumb {
      background: rgba(15,23,42,0.12);
    }
    :root[data-theme="light"] .sidebar::-webkit-scrollbar-thumb:hover,
    :root[data-theme="light"] #main-area::-webkit-scrollbar-thumb:hover {
      background: rgba(15,23,42,0.20);
    }
    /* Inputs com micro-sombra interna em vez de borda dura */
    :root[data-theme="light"] input,
    :root[data-theme="light"] select,
    :root[data-theme="light"] textarea {
      box-shadow: 0 1px 2px rgba(15,23,42,0.04);
    }
    :root[data-theme="light"] input:focus,
    :root[data-theme="light"] select:focus,
    :root[data-theme="light"] textarea:focus {
      outline: none;
      border-color: var(--blue) !important;
      box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    }

    html, body {
      height: 100%;
      font-family: 'DM Sans', sans-serif;
      background: var(--bg);
      color: var(--text-1);
      font-size: 14px;
      line-height: 1.5;
      overflow-x: hidden;
    }

    /* ── PANIC ── */
    .panic-active #topbar { background: #4a0606 !important; border-bottom-color: var(--red) !important; }
    .panic-active #topbar-title { color: var(--red) !important; animation: blink 1s infinite; }
    @keyframes blink { 50% { opacity: 0.4; } }

    /* ── TOPBAR ── */
    #topbar {
      position: sticky; top: 0; z-index: 100;
      display: flex; align-items: center; gap: 12px;
      padding: 0 20px; height: 56px;
      background: var(--surface-1);
      border-bottom: 1px solid var(--border);
      backdrop-filter: blur(12px);
    }
    #topbar-brand { display: flex; align-items: center; gap: 10px; }
    .brand-dot {
      width: 28px; height: 28px; border-radius: 8px;
      background: linear-gradient(135deg, var(--blue), var(--green));
      display: flex; align-items: center; justify-content: center;
    }
    .brand-dot span { font-size: 14px; color: #fff; }
    #topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
    #topbar-version { font-size: 10px; color: var(--text-3); font-family: 'DM Mono', monospace; margin-left: 2px; }
    .topbar-spacer { flex: 1; }
    .topbar-actions { display: flex; align-items: center; gap: 8px; }

    .icon-btn {
      width: 36px; height: 36px; border-radius: var(--radius-sm);
      background: var(--surface-2); border: 1px solid var(--border);
      color: var(--text-2); display: flex; align-items: center; justify-content: center;
      cursor: pointer; transition: all 0.18s; font-family: inherit;
    }
    .icon-btn span { font-size: 18px; }
    .icon-btn:hover { background: var(--surface-3); color: var(--text-1); border-color: var(--border-med); }
    .icon-btn.status-ok { color: var(--amber); }
    .icon-btn.status-mqtts { color: var(--green); }
    .icon-btn.status-err { color: var(--red); }

    /* ── LAYOUT ── */
    #app-shell {
      display: flex; height: calc(100vh - 56px);
      overflow: hidden;
    }

    /* ── SIDEBARS ── */
    .sidebar {
      display: flex; flex-direction: column;
      background: var(--surface-1);
      border-right: 1px solid var(--border);
      overflow-y: auto; overflow-x: hidden;
      flex-shrink: 0;
    }
    .sidebar:last-child { border-right: none; border-left: 1px solid var(--border); }
    #sidebar-left  { width: var(--sidebar-w); }
    #sidebar-right { width: var(--log-w); }

    .sidebar::-webkit-scrollbar { width: 4px; }
    .sidebar::-webkit-scrollbar-track { background: transparent; }
    .sidebar::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

    .s-section { padding: 16px 16px 0; }
    .s-section:last-child { padding-bottom: 16px; }
    .s-label {
      font-size: 10px; font-weight: 700; letter-spacing: 1px;
      text-transform: uppercase; color: var(--blue);
      margin-bottom: 10px; padding-bottom: 6px;
      border-bottom: 1px solid rgba(56,189,248,0.2);
      display: flex; align-items: center; gap: 6px;
    }
    .s-label::before {
      content: '';
      display: inline-block; width: 3px; height: 10px;
      background: var(--blue); border-radius: 2px; flex-shrink: 0;
    }

    /* ── MAIN CONTENT ── */
    #main-area {
      flex: 1; overflow-y: auto; overflow-x: hidden;
      background: var(--bg);
    }
    #main-area::-webkit-scrollbar { width: 5px; }
    #main-area::-webkit-scrollbar-track { background: transparent; }
    #main-area::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

    .main-inner {
      padding: 20px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: var(--gap);
      max-width: 1400px;
      margin: 0 auto;
      width: 100%;
    }
    .col-full { grid-column: 1 / -1; }

    /* ── CARDS ── */
    .card {
      background: linear-gradient(165deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.008) 32%, rgba(0,0,0,0.10) 100%), var(--surface-1);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 20px;
      padding: 20px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 8px 26px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.05);
    }
    .card-sm {
      background: linear-gradient(160deg, rgba(255,255,255,0.035) 0%, rgba(0,0,0,0.06) 100%), var(--surface-2);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 14px;
      padding: 14px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    }
    .card-title {
      font-size: 11px; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.8px;
      color: var(--text-2); margin-bottom: 14px;
      display: flex; align-items: center; gap: 6px;
    }
    .card-title::before {
      content: '';
      display: inline-block; width: 3px; height: 11px;
      background: var(--blue); border-radius: 2px; flex-shrink: 0;
    }

    /* ── CLOCK ── */
    .clock-wrap { text-align: center; padding: 4px 0 10px; }
    .clock-time { font-size: 32px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text-1); letter-spacing: -1px; line-height: 1; }
    .clock-date { font-size: 11px; color: var(--text-2); margin-top: 4px; text-transform: capitalize; }
    .clock-tz   { font-size: 10px; color: var(--text-3); margin-top: 2px; font-family: 'DM Mono', monospace; }

    /* ── WEATHER ── */
    .weather-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
    .weather-loc { font-size: 11px; color: var(--text-2); margin-bottom: 4px; }
    .weather-temp { font-size: 30px; font-weight: 700; color: var(--text-1); line-height: 1; }
    .weather-feels { font-size: 11px; color: var(--text-3); margin-top: 3px; }
    .weather-icon-wrap span { font-size: 36px; }
    .weather-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .weather-stat {
      background: var(--surface-3); border-radius: var(--radius-sm);
      padding: 8px 10px; text-align: center;
    }
    .weather-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
    .weather-stat-val { font-size: 16px; font-weight: 600; color: var(--blue); margin-top: 2px; }
    .weekly-header { display: grid; grid-template-columns: 40px 24px 1fr 36px 32px 32px; gap: 0 4px; padding: 0 4px; margin-bottom: 6px; }
    .weekly-header span { font-size: 9px; color: var(--text-3); text-transform: uppercase; }
    .weekly-row {
      display: grid; grid-template-columns: 40px 24px 1fr 36px 32px 32px;
      align-items: center; gap: 0 4px;
      padding: 6px 4px; border-radius: var(--radius-sm);
      transition: background 0.15s;
    }
    .weekly-row:hover { background: var(--surface-3); }
    .weekly-day { font-size: 11px; color: var(--text-2); }
    .weekly-icon { font-size: 14px !important; }
    .weekly-rain { font-size: 11px; color: var(--blue); text-align: right; }
    .weekly-max  { font-size: 12px; font-weight: 600; color: var(--text-1); text-align: right; }
    .weekly-min  { font-size: 11px; color: var(--text-3); text-align: right; }
    .weekly-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0 8px; }

    /* ── OPERATION WINDOW ── */
    .row-between { display: flex; justify-content: space-between; align-items: center; }
    .time-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
    .time-group label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 5px; }
    .time-input {
      width: 100%; padding: 9px 10px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: var(--surface-3);
      color: var(--text-1); font-family: 'DM Mono', monospace;
      font-size: 15px; text-align: center; outline: none; transition: border-color 0.18s;
    }
    .time-input:focus { border-color: var(--blue); }
    .days-row { display: flex; justify-content: space-between; margin-top: 12px; gap: 4px; }
    .day-chk { display: none; }
    .day-lbl {
      width: 33px; height: 33px; border-radius: 50%;
      border: 1px solid var(--border); background: var(--surface-3);
      display: flex; align-items: center; justify-content: center;
      font-size: 11px; font-weight: 600; color: var(--text-3);
      cursor: pointer; transition: all 0.18s; user-select: none;
    }
    .day-chk:checked + .day-lbl {
      background: var(--blue); color: #0d1117;
      border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,189,248,0.18);
    }
    .window-warn {
      margin-top: 12px; padding: 8px 10px; border-radius: var(--radius-sm);
      background: var(--amber-dim); border: 1px solid rgba(251,191,36,0.2);
      font-size: 11px; color: var(--amber); line-height: 1.4;
    }

    /* ── TOGGLE SWITCH ── */
    .toggle-wrap { display: inline-flex; align-items: center; gap: 8px; }
    .toggle-label { font-size: 12px; color: var(--text-2); }
    .switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
    .switch input { opacity: 0; width: 0; height: 0; }
    .slider {
      position: absolute; inset: 0; background: var(--surface-3);
      border: 1px solid var(--border-med); border-radius: 34px;
      cursor: pointer; transition: 0.25s;
    }
    .slider::before {
      content: ''; position: absolute;
      width: 16px; height: 16px; left: 2px; bottom: 2px;
      background: var(--text-3); border-radius: 50%; transition: 0.25s;
    }
    input:checked + .slider { background: var(--blue); border-color: var(--blue); }
    input:checked + .slider::before { transform: translateX(16px); background: #fff; }
    .switch.amber input:checked + .slider { background: var(--amber); border-color: var(--amber); }
    .switch.green  input:checked + .slider { background: var(--green); border-color: var(--green); }

    /* ── RESET ALARM BTN ── */
    .alarm-btn {
      width: 100%; padding: 10px; border-radius: var(--radius-md);
      border: 1px solid rgba(251,191,36,0.3);
      background: var(--amber-dim); color: var(--amber);
      font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
      letter-spacing: 0.3px; cursor: pointer; display: flex; align-items: center;
      justify-content: center; gap: 6px; transition: all 0.18s;
    }
    .alarm-btn:hover { background: rgba(251,191,36,0.22); }

    /* ── SUSTAINABILITY ── */
    .meta-card {
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius-md); padding: 12px 14px; margin-top: 10px;
    }
    .meta-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
    .meta-title { font-size: 12px; font-weight: 600; color: var(--green); }
    .meta-row { display: flex; gap: 8px; margin-top: 0; align-items: center; flex-wrap: nowrap; min-width: 0; }
    .meta-input {
      padding: 9px 10px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: var(--surface-3);
      color: var(--text-1); font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none;
      min-width: 0;
    }
    .meta-input:focus { border-color: var(--green); }
    .meta-input::placeholder { color: var(--text-3); }
    .meta-input-litros { width: 72px; flex-shrink: 0; }
    .meta-input-msg { flex: 1; min-width: 0; width: 0; }

    .sidebar-brand {
      min-height: 132px;
      margin: auto 10px 4px;
      padding: 22px 14px 18px;
      border-top: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      color: var(--text-2);
    }
    .sidebar-brand img {
      width: 78px;
      height: 58px;
      object-fit: contain;
      filter: drop-shadow(0 0 14px rgba(32, 189, 246, .22));
    }
    .sidebar-brand strong {
      margin-top: 2px;
      color: #eaf7ff;
      font-size: 19px;
      font-weight: 750;
      letter-spacing: .2px;
    }
    .sidebar-brand small { margin-top: 4px; color: var(--text-3); font-size: 9px; letter-spacing: .6px; text-transform: uppercase; }
    .sidebar-brand-version { margin-top: 9px; color: var(--blue); font: 600 10px 'DM Mono', monospace; }

    /* ── TANK CARD ── */
    .tank-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
    .tank-label { font-size: 13px; font-weight: 600; color: var(--text-1); }
    .tank-val { font-size: 28px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text-1); line-height: 1; }
    .tank-unit { font-size: 13px; color: var(--text-3); font-weight: 400; }

    .tank-wrapper {
      width: 100%;
    }
    .tank-main { width: 100%; }
    .tank-visual {
      position: relative; width: 100%; height: 180px;
      border-radius: 18px;
      background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.18) 100%), var(--surface-3);
      overflow: hidden;
      border: 1px solid rgba(255,255,255,0.07);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 24px rgba(0,0,0,0.35);
    }
    .tank-fill {
      position: absolute; bottom: 0; left: 0; width: 100%;
      background: linear-gradient(to top, var(--green), var(--blue));
      transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1);
      opacity: 0.92;
      box-shadow: 0 -1px 16px var(--glow, rgba(45,212,191,0.30));
    }
    .tank-fill::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 26px; z-index: 2;
      background: radial-gradient(75% 100% at 50% 0%, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0.14) 42%, rgba(255,255,255,0) 78%);
    }
    .tank-fill::after {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0) 42%);
    }
    /* Grade interna do tanque */
    .tank-grid-line {
      position: absolute; left: 0; right: 0; height: 1px;
      background: rgba(255,255,255,0.08); z-index: 1;
    }
    .tank-grid-label {
      position: absolute; right: 6px;
      font-size: 9px; font-family: 'DM Mono', monospace;
      color: rgba(255,255,255,0.35); z-index: 3;
      line-height: 1;
    }
    .tank-pct-badge {
      position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
      font-family: 'DM Mono', monospace; font-size: 16px; font-weight: 600;
      color: rgba(255,255,255,0.95); text-shadow: 0 1px 6px rgba(0,0,0,0.8);
      pointer-events: none; z-index: 4; white-space: nowrap;
    }

    @keyframes flowUp   { to { background-position: 0 -40px; } }
    @keyframes flowDown { to { background-position: 0  40px; } }
    /* Listras animadas sobrepostas via ::after — NÃO substituem a cor/gradiente de fundo */
    .active-flow-up::after,
    .active-flow-down::after {
      content: '';
      position: absolute;
      inset: 0;
      background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.10) 0px, rgba(255,255,255,0.10) 10px, transparent 10px, transparent 20px);
      background-size: 40px 40px;
      pointer-events: none;
      z-index: 1;
    }
    .active-flow-up::after   { animation: flowUp   1.2s linear infinite; }
    .active-flow-down::after { animation: flowDown 1.2s linear infinite; }

    /* Sensor dots */
    .sensor-row { display: flex; gap: 6px; margin-top: 10px; justify-content: center; }
    .sensor-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); transition: 0.3s; }
    .sensor-active { background: var(--green); border-color: var(--green); box-shadow: 0 0 6px var(--green); }

    /* ── PUMP TELEMETRY ── */
    .pump-telemetry {
      display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
      margin-top: 14px;
    }
    .telem-cell {
      background: linear-gradient(160deg, rgba(255,255,255,0.035) 0%, rgba(0,0,0,0.06) 100%), var(--surface-3);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 12px; padding: 10px 12px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    }
    .telem-label {
      font-size: 9px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.7px; color: var(--text-3); margin-bottom: 4px;
      display: flex; align-items: center; gap: 5px;
    }
    .telem-ico {
      display: inline-block; width: 14px; height: 14px;
      flex-shrink: 0; font-style: normal; font-size: 12px; line-height: 14px;
      text-align: center; text-transform: none; letter-spacing: 0;
      font-weight: normal; font-family: sans-serif;
    }
    .telem-val {
      font-family: 'DM Mono', monospace; font-size: 18px; font-weight: 600;
      color: var(--text-1); line-height: 1;
    }
    .telem-unit { font-size: 10px; color: var(--text-3); font-weight: 400; margin-left: 2px; }
    .telem-cell.active .telem-val { color: var(--green); }
    .telem-cell.warn   .telem-val { color: var(--amber); }

    /* runtime timer */
    .runtime-bar {
      width: 100%; height: 6px; background: var(--surface-2);
      border-radius: 3px; margin-top: 10px; overflow: hidden;
    }
    .runtime-fill {
      height: 100%; width: 0%; background: var(--green);
      border-radius: 2px; transition: width 1s linear;
    }

    /* ── PUMP CARD ── */
    .pump-status-row { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
    .pump-icon {
      width: 48px; height: 48px; border-radius: var(--radius-md);
      background: var(--surface-3); border: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      color: var(--text-3); transition: all 0.3s; flex-shrink: 0;
    }
    .pump-icon span { font-size: 22px; }
    .pump-icon.on { background: var(--green-dim); border-color: rgba(52,211,153,0.3); color: var(--green); }
    .pump-icon.maint { background: var(--amber-dim); border-color: rgba(251,191,36,0.3); color: var(--amber); }
    .pump-icon.alarm { background: var(--red-dim); border-color: rgba(248,113,113,0.3); color: var(--red); }
    .spin { animation: spin 2s linear infinite; }
    @keyframes spin { to { transform: rotate(360deg); } }
    .pump-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
    .pump-sub  { font-size: 11px; color: var(--text-3); margin-top: 2px; }
    .mode-badge {
      margin-left: auto; padding: 4px 10px; border-radius: 20px;
      font-size: 10px; font-weight: 600; letter-spacing: 0.5px;
      background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,189,248,0.2);
    }
    .mode-badge.manual { background: var(--amber-dim); color: var(--amber); border-color: rgba(251,191,36,0.2); }

    .pump-action-btn {
      width: 100%; padding: 11px; border-radius: 12px;
      border: none; font-family: 'DM Sans', sans-serif;
      font-size: 13px; font-weight: 600; cursor: pointer;
      display: flex; align-items: center; justify-content: center; gap: 6px;
      transition: all 0.18s; letter-spacing: 0.2px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
    }
    .pump-action-btn.ligar  { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,189,248,0.25); }
    .pump-action-btn.ligar:hover { background: rgba(56,189,248,0.22); }
    .pump-action-btn.desligar { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }
    .pump-action-btn.desligar:hover { background: rgba(248,113,113,0.22); }
    .pump-action-btn.blocked { background: linear-gradient(160deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.08) 100%), var(--surface-3); color: var(--text-3); border: 1px solid rgba(255,255,255,0.07); cursor: not-allowed; }

    /* ── CISTERNA ── */
    .cisterna-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
    /* Litros da cisterna: mesma familia do %, um degrau menor para o % seguir dominante.
       margin-right:auto empurra o badge de alerta para a direita, preservando o layout antigo. */
    .cisterna-litros { font-size: 15px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text-2); margin-right: auto; }
    /* Linha de 3 campos no admin (bloco da cisterna). Classe propria, nao style inline,
       porque o breakpoint mobile precisa conseguir sobrescrever para 1 coluna. */
    .admin-field-trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    /* (V10.79) Trio da geometria: os dois primeiros rotulos ganharam a segunda linha
       "= DIAMETRO / 2" e empurravam seus inputs para baixo, deixando o terceiro desalinhado.
       align-items:end encosta as celulas na BASE da linha do grid, entao os inputs ficam
       alinhados independente de quantas linhas cada rotulo ocupar -- nao depende de contar
       linhas nem de altura fixa, e continua certo se o texto quebrar em telas estreitas. */
    #cfg-geo-trio { align-items: end; }
    /* --- Calibracao guiada de fluxo (firmware V11.7.24-fix) --- */
    .calib-box { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: rgba(127,127,127,.06); }
    .calib-head { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; color: var(--text-1); margin-bottom: 8px; }
    .calib-msg { font-size: 12.5px; line-height: 1.5; color: var(--text-2); margin-bottom: 10px; }
    .calib-progress { height: 6px; border-radius: 3px; background: rgba(127,127,127,.25); overflow: hidden; margin-bottom: 10px; }
    .calib-bar { height: 100%; width: 0%; border-radius: 3px; background: var(--blue); transition: width .4s linear; }
    .calib-actions { display: flex; gap: 8px; flex-wrap: wrap; }
    .calib-btn { padding: 9px 16px; border: none; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 700; font-size: 12.5px; cursor: pointer; }
    .calib-btn:disabled { opacity: .5; cursor: not-allowed; }
    .calib-btn.cancel { background: #e74c3c; }
    /* Alvo em litros: escolhido por calibracao, ao lado do botao. Some enquanto roda,
       junto com o proprio botao Iniciar -- o alvo ja' foi congelado no firmware. */
    .calib-alvo-lbl { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
    .calib-alvo-lbl input { width: 72px; }
    .calib-ask { margin-top: 12px; }
    /* O input cresce e o botao fica no tamanho do texto; em telas estreitas o botao desce. */
    .calib-ask-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
    .calib-ask-row .admin-field { flex: 1 1 140px; }
    .field-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
    .cisterna-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
    .cisterna-val { font-size: 18px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text-1); }
    .cisterna-alert-badge {
      font-size: 10px; color: var(--red); font-weight: 600;
      background: var(--red-dim); border: 1px solid rgba(248,113,113,0.25);
      padding: 2px 6px; border-radius: 4px;
    }
    .cisterna-bar-wrap {
      width: 100%; height: 80px; min-height: 80px; flex-grow: 1;
      border-radius: 18px;
      background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.18) 100%), var(--surface-3);
      border: 1px solid rgba(255,255,255,0.07);
      overflow: hidden; position: relative;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 20px rgba(0,0,0,0.35);
    }
    .cisterna-fill {
      position: absolute; bottom: 0; left: 0; width: 100%;
      background: linear-gradient(to top, var(--green), var(--blue));
      transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1);
      opacity: 0.92;
      box-shadow: 0 -1px 14px var(--glow, rgba(45,212,191,0.30));
    }
    .cisterna-fill::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 20px;
      background: radial-gradient(75% 100% at 50% 0%, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0.14) 42%, rgba(255,255,255,0) 78%);
    }
    .cisterna-fill::after {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0) 42%);
    }

    /* ── CHART ── */
    .tabs-row { display: flex; gap: 2px; background: var(--surface-3); border-radius: var(--radius-sm); padding: 3px; }
    .tab-btn {
      flex: 1; padding: 5px 8px; border-radius: 6px; border: none;
      background: transparent; color: var(--text-3);
      font-family: 'DM Sans', sans-serif; font-size: 11px; font-weight: 600;
      cursor: pointer; transition: all 0.18s; letter-spacing: 0.3px;
    }
    .tab-btn.active { background: linear-gradient(160deg, rgba(56,189,248,0.18) 0%, rgba(56,189,248,0.05) 100%); color: var(--blue); box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px rgba(56,189,248,0.28); }
    .chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
    .chart-canvas-wrap { position: relative; height: 200px; }
    .chart-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
    .legend-item { background: linear-gradient(160deg, rgba(255,255,255,0.035) 0%, rgba(0,0,0,0.06) 100%), var(--surface-2); border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; padding: 10px 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
    .legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
    .legend-item-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; margin-bottom: 5px; }
    .legend-item-val { font-size: 20px; font-weight: 700; font-family: 'DM Mono', monospace; }
    .legend-item-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; }

    /* ── SIDEBAR RIGHT: LOGS ── */
    .logs-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
    .logs-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-3); }
    .logs-refresh-btn {
      background: var(--surface-2); border: 1px solid var(--border);
      color: var(--text-2); border-radius: var(--radius-sm); padding: 4px 8px;
      font-size: 10px; font-family: 'DM Mono', monospace; cursor: pointer;
      display: flex; align-items: center; gap: 4px; transition: all 0.18s;
    }
    .logs-refresh-btn:hover { color: var(--text-1); background: var(--surface-3); }
    .log-area {
      flex: 1; overflow-y: auto; padding: 12px 14px;
      font-family: 'DM Mono', monospace; font-size: 10.5px;
      color: var(--green); white-space: pre-wrap; line-height: 1.6;
      min-height: 0;
    }
    .log-area::-webkit-scrollbar { width: 3px; }
    .log-area::-webkit-scrollbar-thumb { background: var(--surface-3); }

    /* ── MODALS ── */
    .modal-backdrop {
      position: fixed; inset: 0; z-index: 500;
      background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
      display: flex; align-items: center; justify-content: center;
    }
    .modal-box {
      background: linear-gradient(165deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.12) 100%), var(--surface-1);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
      width: 90%; max-width: 360px; padding: 28px;
      display: flex; flex-direction: column; gap: 14px;
    }
    .modal-title { font-size: 16px; font-weight: 700; }
    .modal-sub { font-size: 12px; color: var(--text-3); margin-top: -8px; }
    .pass-field {
      width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
      border: 1px solid var(--border-med); background: var(--surface-3);
      color: var(--text-1); font-size: 16px; text-align: center;
      font-family: 'DM Mono', monospace; outline: none;
      transition: border-color 0.18s;
    }
    .pass-field:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,189,248,0.18); }
    /* glow de foco em TODOS os campos do site (aditivo, baixo risco) */
    input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(56,189,248,0.16); }
    .pass-field.error { border-color: var(--red) !important; animation: shake 0.3s; }
    @keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
    .btn-primary {
      width: 100%; padding: 12px; border-radius: var(--radius-md); border: none;
      background: linear-gradient(90deg, #22d3ee, #0ea5e9); color: #06121f; font-family: 'DM Sans', sans-serif;
      font-size: 13px; font-weight: 700; cursor: pointer; transition: 0.18s;
      box-shadow: 0 6px 18px rgba(14,165,233,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
    }
    .btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 24px rgba(14,165,233,0.5), inset 0 1px 0 rgba(255,255,255,0.4); }
    .btn-ghost {
      width: 100%; padding: 10px; border-radius: var(--radius-md);
      border: 1px solid var(--border); background: transparent;
      color: var(--text-3); font-family: 'DM Sans', sans-serif;
      font-size: 12px; cursor: pointer; transition: 0.18s;
    }
    .btn-ghost:hover { background: var(--surface-2); color: var(--text-2); }

    /* LOGS MODAL */
    .modal-log-box {
      background: var(--surface-1); border: 1px solid var(--border-med);
      border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(0,0,0,0.6);
      width: 90%; max-width: 700px; max-height: 80vh;
      display: flex; flex-direction: column; overflow: hidden;
    }
    .modal-log-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
    .modal-log-title { font-size: 13px; font-weight: 600; font-family: 'DM Mono', monospace; color: var(--green); }
    .modal-log-content {
      flex: 1; overflow-y: auto; padding: 14px 18px;
      font-family: 'DM Mono', monospace; font-size: 11px; color: var(--green);
      white-space: pre-wrap; line-height: 1.6; background: #050a0a;
    }

    /* ADMIN PANEL */
    #view-admin { display: none; flex-direction: column; gap: 16px; padding: 20px; max-width: 700px; margin: 0 auto; width: 100%; }

    /* ── ABAS DO PAINEL ADMIN ── */
    #admin-tabs {
      display: flex; gap: 2px; flex-wrap: wrap;
      position: sticky; top: 0; z-index: 10;
      padding: 6px; margin-bottom: 4px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius-md);
    }
    .admin-tab {
      flex: 1 1 auto; min-width: 84px;
      padding: 8px 12px; border-radius: var(--radius-sm); border: none;
      background: transparent; color: var(--text-3);
      font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
      letter-spacing: 0.3px; cursor: pointer; transition: all 0.18s; white-space: nowrap;
      display: flex; align-items: center; justify-content: center; gap: 6px;
    }
    .admin-tab:hover:not(.active) { background: var(--surface-3); color: var(--text-2); }
    .admin-tab.active { background: var(--surface-1); color: var(--blue); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
    .admin-tab .material-icons-round { font-size: 15px; }
    /* Seções escondidas quando não pertencem à aba ativa (controlado por JS) */
    .admin-sec[hidden] { display: none !important; }
    .admin-section-title {
      font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
      color: var(--text-3); margin-bottom: 10px;
    }
    .admin-row {
      display: flex; justify-content: space-between; align-items: center;
      padding: 12px 14px; background: var(--surface-2);
      border-radius: var(--radius-md); border: 1px solid var(--border);
      margin-bottom: 8px;
    }
    .admin-row-label { font-size: 13px; font-weight: 500; }
    .admin-row-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
    .admin-row.maint-row { border-color: rgba(251,191,36,0.2); background: var(--amber-dim); }
    .admin-field {
      width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: var(--surface-3);
      color: var(--text-1); font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none;
    }
    .admin-field:focus { border-color: var(--blue); }
    .admin-field-pair { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; }
    .field-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
    .admin-alert-row {
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 8px;
    }
    .admin-alert-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .admin-action-btn {
      width: 100%; padding: 10px 14px; border-radius: var(--radius-md);
      font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600;
      cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
      margin-bottom: 8px; transition: all 0.18s;
    }
    .admin-action-btn.purple { background: rgba(129,140,248,0.12); color: var(--purple); border: 1px solid rgba(129,140,248,0.25); }
    .admin-action-btn.purple:hover { background: rgba(129,140,248,0.22); }
    .admin-action-btn.green-a { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
    .admin-action-btn.green-a:hover { background: rgba(52,211,153,0.22); }
    .admin-back-row { display: flex; gap: 10px; margin-top: 6px; }

    /* ── GUIDE MODAL ── */
    .guide-box {
      background: linear-gradient(165deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.12) 100%), var(--surface-1);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
      width: 92%; max-width: 640px; max-height: 88vh;
      display: flex; flex-direction: column; overflow: hidden;
    }
    .guide-header {
      display: flex; justify-content: space-between; align-items: center;
      padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .guide-header-left { display: flex; align-items: center; gap: 10px; }
    .guide-header-icon {
      width: 36px; height: 36px; border-radius: var(--radius-sm);
      background: var(--blue-dim); border: 1px solid rgba(56,189,248,0.2);
      display: flex; align-items: center; justify-content: center;
      color: var(--blue);
    }
    .guide-title { font-size: 16px; font-weight: 700; }
    .guide-subtitle { font-size: 11px; color: var(--text-3); margin-top: 2px; }

    /* Nav tabs */
    .guide-tabs {
      display: flex; gap: 2px; padding: 12px 16px;
      border-bottom: 1px solid var(--border); flex-shrink: 0;
      overflow-x: auto; background: var(--surface-1);
    }
    .guide-tab {
      padding: 6px 14px; border-radius: var(--radius-sm); border: none;
      background: transparent; color: var(--text-3);
      font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
      cursor: pointer; transition: all 0.18s; white-space: nowrap;
    }
    .guide-tab.active {
      background: var(--surface-3); color: var(--blue);
      border: 1px solid rgba(56,189,248,0.15);
    }
    .guide-tab:hover:not(.active) { background: var(--surface-2); color: var(--text-2); }

    /* Content */
    .guide-body {
      flex: 1; overflow-y: auto; padding: 20px 24px;
    }
    .guide-body::-webkit-scrollbar { width: 4px; }
    .guide-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

    .guide-page { display: none; }
    .guide-page.active { display: block; }

    .guide-section { margin-bottom: 24px; }
    .guide-section-title {
      font-size: 13px; font-weight: 700; color: var(--text-1);
      margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
    }
    .guide-section-title .gs-icon {
      width: 28px; height: 28px; border-radius: var(--radius-sm);
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; flex-shrink: 0; line-height: 1;
      font-style: normal; font-family: sans-serif;
    }
    .guide-section-title .gs-icon.blue   { background: var(--blue-dim); }
    .guide-section-title .gs-icon.green  { background: var(--green-dim); }
    .guide-section-title .gs-icon.amber  { background: var(--amber-dim); }
    .guide-section-title .gs-icon.red    { background: var(--red-dim); }
    .guide-section-title .gs-icon.purple { background: rgba(129,140,248,0.12); }

    .guide-p {
      font-size: 12px; color: var(--text-2); line-height: 1.7;
      margin-bottom: 8px;
    }
    .guide-list {
      display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
    }
    .guide-list-item {
      display: flex; gap: 10px; align-items: flex-start;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius-sm); padding: 10px 12px;
    }
    .gli-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
    .gli-content { flex: 1; min-width: 0; }
    .gli-title { font-size: 12px; font-weight: 600; color: var(--text-1); }
    .gli-desc  { font-size: 11px; color: var(--text-3); margin-top: 2px; line-height: 1.5; }

    .guide-badge {
      display: inline-block; padding: 2px 8px; border-radius: 20px;
      font-size: 10px; font-weight: 600; margin-right: 4px;
    }
    .badge-blue   { background: var(--blue-dim);  color: var(--blue); }
    .badge-green  { background: var(--green-dim); color: var(--green); }
    .badge-amber  { background: var(--amber-dim); color: var(--amber); }
    .badge-red    { background: var(--red-dim);   color: var(--red); }
    .badge-purple { background: rgba(129,140,248,0.12); color: var(--purple); }

    .guide-callout {
      background: var(--amber-dim); border: 1px solid rgba(251,191,36,0.2);
      border-radius: var(--radius-sm); padding: 10px 14px;
      font-size: 12px; color: var(--amber); line-height: 1.6;
      margin-top: 10px;
    }
    .guide-callout.info {
      background: var(--blue-dim); border-color: rgba(56,189,248,0.2); color: var(--blue);
    }
    .guide-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
    .guide-footer {
      padding: 14px 24px; border-top: 1px solid var(--border);
      display: flex; justify-content: space-between; align-items: center;
      flex-shrink: 0; background: var(--surface-1);
    }
    .guide-footer-version { font-size: 10px; color: var(--text-3); font-family: 'DM Mono', monospace; }

    /* ── MAC DISPLAY ── */
    .mac-display {
      font-family: 'DM Mono', monospace; font-size: 10px;
      color: var(--text-3); text-align: right; letter-spacing: 0.5px; margin-top: 8px;
    }

    /* ── TOAST ── */
    #toast {
      position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
      background: var(--surface-2); border: 1px solid var(--border-med);
      color: var(--text-1); padding: 10px 20px; border-radius: var(--radius-md);
      font-size: 12px; font-weight: 500; z-index: 9999;
      box-shadow: 0 8px 24px rgba(0,0,0,0.4);
      opacity: 0; transition: opacity 0.25s; pointer-events: none;
    }
    #toast.show { opacity: 1; }

    .hidden { display: none !important; }

    /* ── NET BADGE ── */
    .net-badge {
      display: none; align-items: center; gap: 5px;
      padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 600;
      background: var(--amber-dim); color: var(--amber);
      border: 1px solid rgba(251,191,36,0.2); cursor: help;
    }

    /* ── FOOTER ── */
    .footer-note {
      font-size: 10px; color: var(--text-3); text-align: center;
      padding: 12px 0 4px; font-family: 'DM Mono', monospace;
    }

    /* Responsive (#7 V10.34): em telas estreitas EMPILHA as 3 colunas (nao esconde nada) ->
       controles, dashboard E logs ficam todos acessiveis no celular, com rolagem da pagina.
       Antes o CSS ESCONDIA as sidebars (#sidebar-left/right: display:none) -> no celular sumiam
       os controles/config (causa do "nao mostra as configuracoes"). */
    @media (max-width: 900px) {
      #app-shell { flex-direction: column; height: auto; min-height: calc(100vh - 56px); overflow: visible; align-items: stretch; }
      html, body { height: auto; overflow-y: auto; }
      #topbar { flex-wrap: wrap; height: auto; padding-top: 6px; padding-bottom: 6px; }
      .main-inner { grid-template-columns: 1fr; max-width: 100%; }
      .col-full { grid-column: 1; }

      /* CELULAR: "achata" as 3 colunas (display:contents) p/ INTERCALAR pecas de containers
         diferentes numa unica coluna. Ordem pedida: tanques -> resetar alarme -> janela ->
         logs -> bomba -> grafico -> relogio -> clima -> meta. */
      #sidebar-left, #sidebar-right, #main-area, .main-inner { display: contents; }
      #view-dashboard:not(.hidden) { display: contents; }
      #tank-card         { order: 1; }
      #reset-section     { order: 2; }
      #janela-section    { order: 3; }
      #sidebar-right > * { order: 4; }
      #pump-card         { order: 5; }
      #chart-card        { order: 6; }
      #clock-section     { order: 7; }
      #weather-section   { order: 8; }
      #meta-section      { order: 9; }
      #sidebar-brand     { order: 10; margin: 0 10px 12px; min-height: 118px; }
      #view-multiboard, #view-admin { order: 0; }
      /* logs precisam de altura fixa no celular (flex:1 sem altura do pai vira 0) */
      #inline-log-content, .log-area { flex: none; height: 300px; min-height: 300px; }
      /* respiro lateral/vertical (as secoes perderam o fundo das sidebars) */
      #tank-card, #pump-card, #chart-card, #clock-section, #weather-section,
      #janela-section, #reset-section, #meta-section, #sidebar-right > * { margin: 0 10px 12px; }
    }
    @media (max-width: 640px) {
      .admin-field-pair, .admin-field-trio { grid-template-columns: 1fr; }
      .weather-grid, .chart-legend { grid-template-columns: 1fr; }
      .time-pair { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; }   /* horários SEMPRE lado a lado no celular (minmax(0,..) impede empilhar/estourar no iOS) */
      .time-group { min-width: 0; }
      .time-input { font-size: 13px; padding: 7px 4px; min-width: 0; }
      .time-group label { font-size: 9px; }
      #view-admin { padding: 14px 12px; }
      #topbar { gap: 8px; }
      #topbar-title { font-size: 13px; }
      /* multi-placa SEMPRE 1 coluna no celular (o !important vence a coluna inline do JS);
         tanques mais baixos p/ caber sem rolar demais */
      #mb-grid { grid-template-columns: 1fr !important; --mb-tank-h: 150px !important; }
    }
    /* ════════════════════ MODO MULTI-PLACA (GRID DE MINIATURAS) ════════════════════ */
    #view-multiboard { display: none; padding: 20px; }
    .mb-header {
      display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
      flex-wrap: wrap;
    }
    .mb-header-title { font-size: 18px; font-weight: 700; color: var(--text-1); }
    .mb-header-hint {
      font-size: 11px; color: var(--text-3); background: var(--surface-2);
      border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px;
    }
    .mb-grid {
      /* Grid ADAPTATIVO: o nº de colunas e a ALTURA dos tanques (--mb-tank-h) sao
         definidos por ajustarGridMultiBoard() conforme a QUANTIDADE de placas. Poucas
         placas = cards grandes e tanques altos; muitas = mais colunas e tanques mais
         baixos (cabe mais na tela, menos rolagem). Teto de 620px por coluna + justify
         center evitam cards largos demais e mantem a proporcao. */
      display: grid;
      grid-template-columns: repeat(2, minmax(240px, 620px));
      justify-content: center;
      align-items: start;
      gap: 16px;
    }
    .mb-empty {
      width: 100%; text-align: center; color: var(--text-3);
      padding: 60px 20px; font-size: 14px;
    }
    .mb-card {
      /* largura vem da COLUNA do grid (.mb-grid + ajustarGridMultiBoard) */
      background: linear-gradient(165deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.01) 30%, rgba(0,0,0,0.12) 100%), var(--surface-1);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 22px; padding: 18px;
      cursor: pointer; transition: all 0.2s; user-select: none;
      position: relative; overflow: hidden;
      box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
    }
    .mb-card:hover { border-color: rgba(255,255,255,0.16); transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08); }
    .mb-card.focused { border-color: rgba(56,189,248,0.55); box-shadow: 0 0 0 1px rgba(56,189,248,0.4), 0 0 34px rgba(56,189,248,0.18), inset 0 1px 0 rgba(255,255,255,0.08); }
    .mb-card.alarm { border-color: var(--red); box-shadow: 0 0 0 2px rgba(248,113,113,0.22); }
    .mb-card.offline { opacity: 0.55; }
    .mb-card.offline::after {
      content: 'OFFLINE'; position: absolute; top: 10px; right: 10px;
      font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
      color: var(--red); background: var(--red-dim);
      border: 1px solid rgba(248,113,113,0.3); border-radius: 4px; padding: 2px 6px;
    }
    .mb-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
    .mb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
    .mb-dot.online { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
    .mb-dot.online.mqtts { background: var(--green); box-shadow: 0 0 7px var(--green); }
    .mb-dot.off    { background: var(--red); }
    .mb-name {
      font-size: 13px; font-weight: 700; color: var(--text-1);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
    }
    .mb-mode {
      font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
      padding: 3px 8px; border-radius: 20px; flex-shrink: 0;
      background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,189,248,0.2);
    }
    .mb-mode.manual { background: var(--amber-dim); color: var(--amber); border-color: rgba(251,191,36,0.2); }

    .mb-tanks { display: flex; gap: 10px; margin-bottom: 14px; }
    .mb-tank { flex: 1; }
    .mb-tank-cap { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 4px; }
    /* ── Tanque estilo "vidro/água" (glossy): container arredondado com gradiente sutil no
          vazio, e a água com linha de superfície BRILHANTE + glow (cor via --glow inline). ── */
    .mb-tank-visual {
      position: relative; width: 100%; height: var(--mb-tank-h, 240px); transition: height 0.2s;
      background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.18) 100%), var(--surface-3);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 18px; overflow: hidden;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 24px rgba(0,0,0,0.35);
    }
    .mb-tank-fill {
      position: absolute; bottom: 0; left: 0; width: 100%;
      background: linear-gradient(to top, var(--green), var(--blue));
      transition: height 0.6s cubic-bezier(.4,0,.2,1); opacity: 0.92;
      box-shadow: 0 -1px 16px var(--glow, rgba(45,212,191,0.30));
      border-radius: 0 0 17px 17px;
    }
    /* superfície da água: brilho concentrado NO MEIO, apagando p/ as laterais (reflexo elíptico) */
    .mb-tank-fill::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 26px;
      background: radial-gradient(75% 100% at 50% 0%, rgba(255,255,255,0.70) 0%, rgba(255,255,255,0.15) 42%, rgba(255,255,255,0) 78%);
    }
    /* reflexo suave de vidro sobre a água */
    .mb-tank-fill::after {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 42%);
    }
    .mb-tank-pct {
      position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
      font-family: 'DM Mono', monospace; font-size: 20px; font-weight: 600;
      color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,0.6); z-index: 2; letter-spacing: 0.5px;
    }
    .mb-tank-sub { font-size: 10px; color: var(--text-3); text-align: center; margin-top: 3px; font-family: 'DM Mono', monospace; }

    .mb-chips { display: flex; gap: 6px; flex-wrap: wrap; }
    .mb-chip {
      display: inline-flex; align-items: center; gap: 4px;
      font-size: 10px; font-weight: 600; padding: 4px 9px; border-radius: 20px;
      border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
    }
    .mb-chip .mb-chip-ico { font-size: 11px; line-height: 1; }
    .mb-chip.on    { background: var(--green-dim); color: var(--green); border-color: rgba(52,211,153,0.25); }
    .mb-chip.maint { background: var(--amber-dim); color: var(--amber); border-color: rgba(251,191,36,0.25); }
    .mb-chip.alarm { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.3); }
    .mb-chip-spin { animation: spin 2s linear infinite; }

    /* Indicador de placa-alvo (confirma para qual placa vão comandos/config) */
    .target-badge {
      display: inline-flex; align-items: center; gap: 5px;
      font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
      padding: 3px 9px; border-radius: 20px; margin-left: 8px;
      background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,189,248,0.28);
      vertical-align: middle;
    }
    .target-badge .tb-ico { font-size: 11px; line-height: 1; }

    /* Botao toggle ativo (no modo grid) */
    #btn-multiboard.active { background: var(--blue); color: #06121f; border-color: var(--blue); }

/* ===== PORTAO TUYA (site V10.83) ===== */
    /* ── SIDEBAR RIGHT: PORTÃO (V10.83) ── */
    /* Mora ACIMA do bloco de logs, na mesma coluna. Comeca hidden: quem o revela e' o
       atualizarCardPortao(), pelo portao_on da placa selecionada. */
    .portao-card { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
    /* Sem esta linha o card aparece em TODA placa: o atributo `hidden` do HTML vale por uma
       regra [hidden]{display:none} do navegador, que perde em especificidade para o
       .portao-card{display:flex} acima. Pego em produção — a placa sem portão mostrava o card. */
    .portao-card[hidden] { display: none; }
    .portao-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
    /* Título FIXO da função (“PORTÃO”), igual ao “System Logs” logo abaixo. O nome do
       aparelho virou subtítulo: assim nada precisa ser truncado nesta coluna estreita. */
    .portao-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
    .portao-title svg { width: 13px; height: 13px; flex-shrink: 0; }
    .portao-sub { font-size: 11px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: -4px; }

    /* ── Animação do portão (SVG inline) ──
       SVG e não ícone de fonte de propósito: a fonte servida em produção é um SUBCONJUNTO e um
       glifo ausente vira o texto da ligadura na tela (foi o que quebrou o título no V10.84). */
    .portao-anim { background: rgba(0,0,0,0.18); border: 1px solid rgba(255,255,255,0.05); border-radius: 9px; padding: 6px 8px; }
    .portao-anim svg { display: block; width: 100%; height: auto; }
    .pa-chao  { stroke: var(--text-3); stroke-width: 1.4; opacity: 0.35; }
    .pa-pilar { fill: var(--text-3); opacity: 0.5; }
    .pa-folha { fill: currentColor; transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1); }
    .portao-anim            { color: var(--text-3); }
    .portao-anim.fechado    { color: var(--blue); }
    .portao-anim.aberto     { color: var(--green); }
    .portao-anim.erro       { color: var(--red); }
    .portao-anim.aberto .pa-folha { transform: translateX(-97px); }
    /* Em movimento não dá para saber a posição (num portão de pulso o toque tanto abre quanto
       pára), então a folha vai e volta devagar em vez de fingir um destino. */
    .portao-anim.movendo    { color: var(--amber); }
    .portao-anim.movendo .pa-folha { animation: pa-vaivem 2.6s ease-in-out infinite alternate; }
    .portao-anim.desconhecido .pa-folha { opacity: 0.45; transform: translateX(-48px); }
    @keyframes pa-vaivem { from { transform: translateX(-6px); } to { transform: translateX(-70px); } }
    @media (prefers-reduced-motion: reduce) {
      .pa-folha { transition: none; }
      .portao-anim.movendo .pa-folha { animation: none; opacity: 0.6; }
    }
    .portao-estado { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text-1); }
    .portao-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
    .portao-dot.aberto  { background: var(--green); box-shadow: 0 0 8px rgba(74,222,128,0.55); }
    .portao-dot.fechado { background: var(--blue);  box-shadow: 0 0 8px rgba(56,189,248,0.55); }
    .portao-dot.erro    { background: var(--red);   box-shadow: 0 0 8px rgba(248,113,113,0.55); }
    .portao-idade { margin-left: auto; font: 400 10px 'DM Mono', monospace; color: var(--text-3); }
    .portao-botoes { display: flex; gap: 8px; }
    /* text-align junto do justify-content: o rótulo fica centrado mesmo se algum dia voltar
       a haver ícone dentro do botão. */
    .portao-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
      padding: 10px 6px; border-radius: 9px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
      text-align: center; cursor: pointer; transition: all 0.18s; }
    .portao-btn.abrir  { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74,222,128,0.25); }
    .portao-btn.abrir:hover:not(:disabled)  { background: rgba(74,222,128,0.22); }
    .portao-btn.fechar { background: var(--blue-dim);  color: var(--blue);  border: 1px solid rgba(56,189,248,0.25); }
    .portao-btn.fechar:hover:not(:disabled) { background: rgba(56,189,248,0.22); }
    .portao-btn.acionar { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(251,191,36,0.28); }
    .portao-btn.acionar:hover:not(:disabled) { background: rgba(251,191,36,0.22); }
    .portao-btn:disabled { opacity: 0.5; cursor: progress; }
    /* Mesmo tropeco do card no V10.83: o `hidden` do HTML perde para o display:flex do
       .portao-btn, e o botão do modo que NÃO está em uso continuaria na tela. */
    .portao-btn[hidden] { display: none; }
    .portao-dica { font-size: 10px; line-height: 1.4; color: var(--text-3); }
    .portao-msg { font-size: 10px; line-height: 1.45; color: var(--red); display: none; }
    /* (V10.89) Retorno visível do Atualizar. Com o portão parado a leitura nova é igual à anterior,
       e sem isto o clique não mudava nada na tela — parecia que o botão não funcionava. */
    #btn-portao-atualizar.girando .material-icons-round { display: inline-block; animation: portao-gira 0.8s linear infinite; }
    #btn-portao-atualizar:disabled { opacity: 0.75; cursor: progress; }
    .portao-estado { border-radius: 6px; padding: 3px 4px; margin: 0 -4px; }
    .portao-estado.flash { animation: portao-flash 1.4s ease-out; }
    @keyframes portao-gira { to { transform: rotate(360deg); } }
    @keyframes portao-flash { 0% { background: rgba(56,189,248,0.30); } 100% { background: transparent; } }
    @media (prefers-reduced-motion: reduce) {
      #btn-portao-atualizar.girando .material-icons-round, .portao-estado.flash { animation: none; }
    }

