/* ====================== RESET & LAYOUT GERAL ====================== */
  :root{color-scheme:dark}
  body{margin:0;background:#0e1217;color:#fff;font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial; overflow: hidden;}
  #app{position:relative;width:100vw;height:100vh}

  /* ====================== UTILITÁRIOS ====================== */

  .flex-between { display: flex; justify-content: space-between; }
  .flex-grow { flex-grow: 1; }
  
  .popup-panel {
    position: absolute;
    background: rgba(14, 18, 23, 0.45);
    padding: 12px;
    border-radius: 16px;
    display: grid;
    gap: 12px;
    z-index: 10;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    resize: both;
    overflow: auto;
    min-width: 280px;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  #panel-asd-2d { top: 10px; left: 10px; width: fit-content; max-width: 95vw; display: none; }
  #panel-mooring { top: 10px; left: 450px; width: 300px; display: none; }
  #panel-maneuvers { top: 10px; left: 770px; width: 300px; display: none; }
  #panel-adjustments { top: 250px; left: 10px; width: 330px; display: none; }
  #panel-views { top: 280px; left: 450px; width: 300px; display: none; }
  #panel-environment { top: 280px; left: 770px; width: 300px; display: none; }
  #panel-editor { top: 550px; left: 770px; width: 300px; display: none; }
  #panel-buoys { top: 420px; left: 450px; width: 300px; display: none; }
  .winch-control { margin-top: 10px; }
  .tension-gauge { margin-top: 5px; }
  .section-title { text-align: center; font-weight: 500; font-size: 14px; margin-bottom: 10px; }
  .section-subtitle { text-align: center; font-size: 12px; opacity: 0.7; padding-top: 10px; border-top: 1px solid #333; margin-top: 5px; }
  .full-width { width: 100%; }

  .panel-header {
    background-color: rgba(42, 45, 52, 0.8);
    color: #fff;
    padding: 8px 12px;
    margin: -12px -12px 0 -12px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: move;
    -webkit-user-select: none;
    user-select: none;
    text-align: center;
    font-weight: bold;
    touch-action: none;
  }
  
  /* Sistema de Abas (Tabs) */
  .tabs { display: flex; border-bottom: 1px solid #444; margin: 10px -8px; }
  .tab-btn { flex: 1; background: #00000000; color: #aaa; border: none; padding: 10px; font-weight: bold; cursor: pointer; border-bottom: 2px solid transparent; font-size: 13px; outline: none; border-radius: 0; }
  .tab-btn:hover { background: #1f232b; color: #fff; }
  .tab-btn.active { color: #0d6efd; border-bottom: 2px solid #0d6efd; background: #161b22; }
  .tab-content { display: none; }
  .tab-content.active { display: block; }

  .row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

  /* ====================== TOP TELEMETRY BAR ====================== */
  #top-telemetry-bar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14, 18, 23, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 8px 30px;
    border-radius: 30px;
    display: flex;
    gap: 35px;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
  .telemetry-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .telemetry-item .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8a9eb2;
    margin-bottom: 2px;
  }
  .telemetry-item .value {
    font-family: ui-monospace, Consolas, Menlo;
    font-weight: bold;
    font-size: 16px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  }
  .telemetry-item.highlight .value {
    color: #34e7e4;
  }

  label{font-size:13px;opacity:.95; white-space: nowrap;}
  .val{font-family:ui-monospace,Consolas,Menlo;background:#151a22;padding:2px 6px;border-radius:6px}
  /* Estilização Customizada de Range Slider Navis/Industrial */
  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    padding: 5px 0;
  }
  input[type="range"]:focus {
    outline: none;
  }
  input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  }
  input[type="range"]::-webkit-slider-thumb {
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.5), inset 0px 1px 1px rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    height: 18px;
    width: 14px;
    border-radius: 6px;
    background: linear-gradient(145deg, #1e90ff, #0a58ca);
    cursor: grab;
    -webkit-appearance: none;
    margin-top: -7px;
    transition: transform 0.1s, background 0.2s;
  }
  input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
    background: linear-gradient(145deg, #3399ff, #0d6efd);
  }
  /* Estilo p/ Firefox */
  input[type="range"]::-moz-range-track {
    width: 100%; height: 6px; cursor: pointer; background: rgba(255, 255, 255, 0.1);
    border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.3);
  }
  input[type="range"]::-moz-range-thumb {
    border: 1px solid rgba(255,255,255,0.2); height: 18px; width: 14px;
    border-radius: 6px; background: linear-gradient(145deg, #1e90ff, #0a58ca); cursor: grab;
  }
  input[type="range"]::-moz-range-thumb:active { cursor: grabbing; transform: scale(1.15); }
  input[type="text"]{padding:6px; border-radius:6px; border:1px solid #3a3f47; background:#151a22; color:#fff; width: 100%; box-sizing: border-box;}
  button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 0;
    background: #0d6efd;
    color: #fff;
    cursor: pointer; 
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  }
  button:hover {
    background: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(13, 110, 253, 0.25);
  }
  button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  }
  button:disabled {
    background-color: #334155;
    opacity: 0.5;
    cursor: not-allowed;
  }
  .btn-sec{background:#334155}
  .btn-sec:hover{background:#475569}
  .btn-danger{background:#dc3545}
  .btn-danger:hover{background:#bb2d3b}
  .btn-success{background:#198754}
  .btn-success:hover{background:#157347}
  .btn-warn { background: #ffc107; color: #000; }
  .btn-warn:hover {
    background: #ffca2c;
  }
  .hint{font-size:12px;opacity:.8;text-align:center}
  .section{border-top:1px solid #333;padding-top:8px;margin-top:2px}
  .control-group { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .thruster-panel { padding: 10px; border: 1px solid #334155; border-radius: 8px; }
  .thruster-panel h4 { margin: 0 0 10px 0; text-align: center; font-weight: 500; }
  .view-buttons-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .view-buttons-grid .full-span { grid-column: 1 / -1; }
  
  .tension-bar-container { background: #222; border-radius: 4px; padding: 2px; border: 1px solid #555; }
  .tension-bar { height: 10px; width: 0%; background: #28a745; border-radius: 3px; transition: width 0.1s, background-color 0.2s; }

  #maneuver-list { list-style: none; padding: 0; margin: 0; max-height: 150px; overflow-y: auto; }
  #maneuver-list li { display: flex; justify-content: space-between; align-items: center; padding: 4px; border-bottom: 1px solid #333; }
  #maneuver-list span { flex-grow: 1; }
  #maneuver-list button { font-size: 10px; padding: 2px 6px; margin-left: 4px; }
  .btn-margin-top { margin-top: 5px; }

  /* == Industrial Winch Controls == */
  .winch-group { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
  .winch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .winch-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.05); color: #fff; font-weight: bold; cursor: pointer; transition: all 0.1s; user-select: none; touch-action: manipulation; line-height: 1.2; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
  .winch-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  
  .winch-btn.clutch { grid-column: 1 / -1; height: 54px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; border-width: 2px; }
  .winch-btn.clutch.off { background: #dc3545; border-color: #ff4d4d; box-shadow: 0 0 10px rgba(220,53,69,0.3); }
  .winch-btn.clutch.on { background: #198754; border-color: #28a745; box-shadow: 0 0 15px rgba(25,135,84,0.5); }
  
  .winch-btn.action { background: #2c3e50; height: 60px; font-size: 13px; }
  .winch-btn.action:active:not(:disabled) { background: #0d6efd; border-color: #3b82f6; transform: translateY(2px); box-shadow: 0 2px 3px rgba(0,0,0,0.4); }
  
  .winch-btn.release { grid-column: 1 / -1; background: #eab308; color: #111; border-color: #facc15; }
  .winch-btn.release:hover:not(:disabled) { background: #fde047; }
  .winch-btn.release:active:not(:disabled) { transform: translateY(2px); }

  #right-sidebar {
    position: fixed;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: rgba(14, 18, 23, 0.45);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  }
  .sidebar-btn {
    background-color: #334155;
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .sidebar-btn:hover {
    background-color: #475569;
  }
  .sidebar-btn.active {
    background-color: #0d6efd;
    box-shadow: 0 0 10px #0d6efd;
  }

  #panel-levels {
    top: 450px;
    left: 10px;
    position: absolute;
    display: none;
  }
  .level-buttons-grid {
    display: grid;
    gap: 8px;
  }
  #level-buttons {
    display: grid;
    gap: 8px;
  }
  .justify-end {
    justify-content: flex-end;
  }
  #construction-options {
    gap: 10px;
  }

  /* Estilos para o novo Controle ASD 2D */
  .asd-2d-container {
    display: flex;
    gap: 25px;
    align-items: center;
    padding: 10px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .control-wrapper {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      width: 200px;
  }
  .control-wrapper h3 {
      margin: 0; padding: 0; font-weight: 500; color:  #8a9eb2; text-transform: uppercase;
  }
  #panel-asd-2d canvas {
      background-color: #2c3e50; border-radius: 50%; cursor: pointer; box-shadow: 0 0 15px rgba(0,0,0,0.5) inset;
      width: 100%;
      height: auto;
      aspect-ratio: 1 / 1;
  }
  #info-panel {
      width: 420px;
      font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, 'Courier New', monospace;
      display: flex;
      gap: 20px;
  }
  .prop-section { margin-bottom: 15px; }
  .prop-section h4 { margin: 0 0 10px 0; font-weight: normal; color: #c1d7ee; border-bottom: 1px solid #2c3e50; padding-bottom: 5px; }
  .data-row { font-size: 1.1em; margin-bottom: 8px; }
  .data-label { color: #8a9eb2; }
  .data-value { color: #ffffff; font-weight: bold; float: right; }

  .indicator-wrapper {
      margin-bottom: 10px;
  }
  .indicator-label {
      font-size: 0.9em;
      color: #8a9eb2;
      margin-bottom: 4px;
      display: block;
  }
  .bar-container {
      width: 100%;
      height: 28px;
      background-color: #101822;
      border-radius: 5px;
      position: relative;
      overflow: hidden;
      border: 1px solid #2c3e50;
  }
  .bar-fill {
      height: 100%;
      width: 0%;
      transition: width 0.1s linear, left 0.1s linear;
      position: absolute;
      top: 0;
      bottom: 0;
  }
  .bar-fill.rpm {
      background: linear-gradient(90deg, #2ecc71 0%, #f1c40f 75%, #e74c3c 100%);
  }
  .bar-value {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      color: white;
      font-weight: bold;
      text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
  }
  .controls-row {
      display: flex;
      gap: 20px;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
  }

  @media (max-width: 768px) {
      .popup-panel {
          max-width: 95vw;
          max-height: 90vh;
          overflow-y: auto;
          min-width: 90vw;
      }
      #panel-asd-2d, #panel-adjustments, #panel-views, #panel-environment, #panel-levels, #panel-editor, #panel-buoys, #panel-maneuvers {
          top: 10px;
          left: 10px;
      }
      #info-panel {
          flex-direction: column;
          gap: 10px;
      }
      .prop-section {
          margin-bottom: 5px;
      }
      .control-wrapper {
          width: 140px;
      }
      .sidebar-btn {
          width: 40px;
          height: 40px;
          font-size: 20px;
      }
      #right-sidebar {
          right: 5px;
          padding: 5px;
          gap: 5px;
      }
      .view-buttons-grid {
          grid-template-columns: 1fr;
      }
      .control-group {
          grid-template-columns: 1fr;
      }
      .asd-2d-container {
          gap: 15px;
      }
  }

  /* ====================== HUD JOYSTICK OVERLAYS ====================== */
  .hud-joystick-panel {
      position: fixed;
      bottom: 20px;
      background: rgba(14, 18, 23, 0.45);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 20px;
      padding: 15px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 15px;
      z-index: 9999;
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
      transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .hud-joystick-panel.hidden {
      opacity: 0;
      pointer-events: none;
      transform: translateY(40px);
  }
  .hud-header {
      font-size: 13px;
      font-weight: 700;
      color: #8a9eb2;
      letter-spacing: 1px;
  }
  .hud-body {
      display: flex;
      gap: 20px;
      align-items: center;
  }
  .hud-joystick-panel canvas {
      background-color: rgba(26, 42, 58, 0.8);
      border-radius: 50%;
      cursor: pointer;
      box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
      touch-action: none;
      transition: opacity 0.3s;
  }
  input[type="range"].hud-vertical-slider {
      writing-mode: vertical-lr;
      direction: rtl;
      width: 20px;
      height: 120px;
      background: rgba(0, 0, 0, 0.4);
      border-radius: 10px;
      border: 1px solid rgba(255, 255, 255, 0.15);
      box-shadow: inset 0 4px 10px rgba(0,0,0,0.5);
      padding: 0;
      margin: 0;
      transition: opacity 0.3s;
      cursor: pointer;
  }
  input[type="range"].hud-vertical-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      height: 24px;
      width: 14px;
      border-radius: 6px;
      background: linear-gradient(145deg, #1e90ff, #0a58ca);
      cursor: grab;
      border: 1px solid rgba(255,255,255,0.4);
  }
  input[type="range"].hud-vertical-slider::-webkit-slider-thumb:active {
      background: #38bdf8;
  }
  .hud-clutch-btn {
      width: 100%;
      padding: 10px;
      font-size: 12px;
      font-weight: bold;
      border-radius: 10px;
      border: none;
      cursor: pointer;
      transition: all 0.2s;
      letter-spacing: 0.5px;
  }
  .hud-clutch-btn.off {
      background: #dc3545;
      color: #fff;
      box-shadow: 0 0 15px rgba(220,53,69,0.2) inset;
  }
  .hud-clutch-btn.off:hover { background: #e04b59; }
  .hud-clutch-btn.on {
      background: #198754;
      color: #fff;
      box-shadow: 0 0 15px rgba(25,135,84,0.4);
  }
  .hud-clutch-btn.on:hover { background: #1fa264; }
