﻿:root {
      --bg: #eef2f5;
      --panel: #ffffff;
      --line: #c9d3dc;
      --ink: #1f2d38;
      --muted: #667684;
      --blue: #1f8eea;
      --green: #29a65a;
      --red: #d84a4a;
      --amber: #f4a62a;
      --header-color: #263746;
      /* --header-color: #b91c1c; */
      /* --header-color: #2631d4; */
      /* --header-color: #006400; */
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: "Segoe UI", Arial, sans-serif;
      background: var(--bg);
      color: var(--ink);
    }

    .page {
      display: grid;
      grid-template-rows: auto auto auto;
    }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 12px 18px;
      background: var(--header-color);
      color: #fff;
      border-bottom: 4px solid var(--blue);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 14px;
      min-width: 0;
    }

    .brand-mark {
      width: 44px;
      height: 44px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      background: transparent;
      font-weight: 800;
      flex: 0 0 auto;
    }

    .brand-mark img {
      width: 44px;
      height: 44px;
      display: block;
      object-fit: contain;
    }

    .brand strong,
    .brand span {
      display: block;
      white-space: nowrap;
    }

    .brand span {
      color: #cbd7e2;
      font-size: 13px;
    }

    .status-chip {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.12);
      font-size: 14px;
      font-weight: 700;
    }

    .status-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--green);
      box-shadow: 0 0 0 4px rgba(41, 166, 90, 0.18);
    }

    .content {
      width: min(1360px, calc(100% - 28px));
      margin: 18px auto;
      display: grid;
      grid-template-columns: 1fr;
      align-items: start;
      gap: 16px;
    }

    .card {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 14px 34px rgba(33, 49, 65, 0.1);
    }

    .main-card {
      overflow: hidden;
    }

    .card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      background: #f8fafc;
    }

    h1 {
      margin: 0;
      font-size: 22px;
      letter-spacing: 0;
    }

    .subtitle {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: 13px;
    }

    .kpis {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .kpi {
      min-width: 94px;
      padding: 7px 10px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      text-align: right;
    }

    .kpi span {
      display: block;
      color: var(--muted);
      font-size: 11px;
      text-transform: uppercase;
    }

    .kpi strong {
      font-size: 18px;
    }

    .diagram-wrap {
      padding: 16px;
      background: #e8eef3;
    }

    .diagram {
      width: 100%;
      height: auto;
      display: block;
      border: 1px solid #b9c6d1;
      border-radius: 6px;
      background: #f7fafc;
    }

    .pipe {
      fill: none;
      stroke: #8ea0ad;
      stroke-width: 28;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .flow {
      fill: none;
      stroke: var(--blue);
      stroke-width: 11;
      stroke-linecap: round;
      stroke-dasharray: 20 18;
      animation: flow 1.2s linear infinite;
    }

    .flow.reverse {
      animation-name: reverse-flow;
    }

    .zone-meter-flow {
      animation: flow 1.2s linear infinite;
    }

    body.paused .flow,
    body.paused .zone-meter-flow,
    body.pump-off .flow,
    body.pump-off .zone-meter-flow,
    body.no-flow .flow,
    body.no-flow .zone-meter-flow {
      animation-play-state: paused;
      opacity: 0.25;
    }

    @keyframes flow {
      to { stroke-dashoffset: -76; }
    }

    @keyframes reverse-flow {
      to { stroke-dashoffset: 76; }
    }

    .fan {
      fill: var(--amber);
      transform-box: fill-box;
      transform-origin: center;
      animation: spin 0.9s linear infinite;
    }

    body.paused .fan,
    body.pump-off .fan {
      animation-play-state: paused;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .label {
      fill: #23313d;
      font-size: 19px;
      font-weight: 700;
    }

    .value {
      fill: #0f5f9e;
      font-size: 28px;
      font-weight: 800;
    }

    .small-value {
      fill: #465766;
      font-size: 15px;
      font-weight: 700;
    }

    .unit-label,
    .tank-scale {
      fill: #465766;
      font-size: 12px;
      font-weight: 800;
    }

    .unit-badge {
      fill: #eef4f8;
      stroke: #9fb0bd;
      stroke-width: 1;
    }

    .tank-scale {
      fill: #23313d;
    }

    .well-level-value {
      fill: #0f5f9e;
      font-size: 22px;
      font-weight: 800;
    }

    #tankWater,
    #wellWater,
    #wave {
      transition: y 0.45s ease, height 0.45s ease, transform 0.45s ease, fill 0.45s ease, opacity 0.45s ease;
    }

    .side-card {
      padding: 16px;
      display: grid;
      grid-template-columns: minmax(300px, 1.2fr) minmax(300px, 1fr) minmax(360px, 1.1fr);
      align-content: start;
      gap: 16px;
    }

    .side-card section {
      min-width: 0;
    }

    .section-title {
      margin: 0 0 8px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .control {
      display: grid;
      gap: 7px;
      padding-bottom: 14px;
      border-bottom: 1px solid #e7edf2;
    }

    .control-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    input[type="checkbox"] {
      width: 44px;
      height: 24px;
      accent-color: var(--green);
    }

    input[type="range"] {
      width: 100%;
      accent-color: var(--blue);
    }

    input:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }

    .button-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    button {
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      padding: 9px 12px;
      color: var(--ink);
      font-weight: 700;
      cursor: pointer;
    }

    button.primary {
      color: #fff;
      border-color: #1578c8;
      background: var(--blue);
    }

    .event-list {
      display: grid;
      gap: 8px;
    }

    .event {
      display: grid;
      grid-template-columns: 24px 50px 1fr;
      gap: 8px;
      align-items: center;
      padding: 8px;
      border-radius: 6px;
      background: #f8fafc;
      border-left: 4px solid var(--blue);
      font-size: 13px;
    }

    .side-card .event span {
      min-width: 0;
      line-height: 1.25;
    }

    .event.warn { border-left-color: var(--amber); }
    .event.ok { border-left-color: var(--green); }

    .fuxa-event-icon {
      width: 18px;
      height: 18px;
      object-fit: contain;
      padding: 3px;
      border-radius: 4px;
      background: #263746;
    }

    .trend {
      width: min(1360px, calc(100% - 28px));
      margin: 0 auto 18px;
      padding: 14px 16px;
    }

    .trend-head {
      display: flex;
      justify-content: space-between;
      gap: 14px;
      margin-bottom: 10px;
      color: var(--muted);
    }

    #levelChart {
      width: 100%;
      height: 170px;
      display: block;
      border: 1px solid #d8e1e8;
      border-radius: 6px;
      background: #fff;
    }

    @media (max-width: 900px) {
      .content {
        grid-template-columns: 1fr;
      }

      .side-card {
        grid-template-columns: 1fr;
      }

      .card-head,
      .topbar {
        align-items: flex-start;
        flex-direction: column;
      }

      .kpis {
        width: 100%;
      }

      .kpi {
        flex: 1;
      }
    }

