﻿:root {
      --primary: #2563eb;
      --primary-hover: #1d4ed8;
      --success: #10b981;
      --warning: #f59e0b;
      --danger: #ef4444;
      --bg-page: #f8fafc;
      --bg-panel: rgba(255, 255, 255, 0.85);
      --text-main: #0f172a;
      --text-muted: #64748b;
      --border: rgba(0, 0, 0, 0.1);
      --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
      --glass: blur(12px) saturate(180%);
    }

    .dark {
      --primary: #3b82f6;
      --primary-hover: #60a5fa;
      --bg-page: #020617;
      --bg-panel: rgba(15, 23, 42, 0.75);
      --text-main: #f1f5f9;
      --text-muted: #94a3b8;
      --border: rgba(255, 255, 255, 0.1);
      --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      font-family: 'Bahnschrift', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      background: var(--bg-page);
      color: var(--text-main);
      transition: background 0.3s ease, color 0.3s ease;
    }

    ::-webkit-scrollbar {
      width: 6px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.15);
      border-radius: 10px;
    }

    ::-webkit-scrollbar-thumb:hover {
      background: rgba(0, 0, 0, 0.25);
    }

    .dark ::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.15);
    }

    .dark ::-webkit-scrollbar-thumb:hover {
      background: rgba(255, 255, 255, 0.25);
    }

    * {
      scrollbar-width: thin;
      scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
    }

    .dark * {
      scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }

    #app {
      position: relative;
      width: 100%;
      height: 100vh;
      overflow: hidden;
    }

    #map {
      width: 100%;
      height: 100%;
    }

    .panel {
      position: absolute;
      z-index: 1000;
      background: var(--bg-panel);
      border-radius: 10px;
      box-shadow: var(--shadow);
      border: 1px solid var(--border);
      backdrop-filter: var(--glass);
      -webkit-backdrop-filter: var(--glass);
      transition: background 0.3s ease, border 0.3s ease;
    }

    .title {
      margin: 0 0 8px 0;
      font-size: 18px;
      font-weight: 700;
      color: #111827;
    }

    .subtitle {
      font-size: 12px;
      color: #6b7280;
      margin-bottom: 12px;
      line-height: 1.4;
    }

    .ranking-box {
      top: 18px;
      right: 18px;
      width: 290px;
      padding: 16px;
      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .ranking-box.collapsed {
      width: 48px;
      height: 48px;
      padding: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      left: auto !important;
      cursor: pointer;
    }

    .ranking-box.collapsed:hover {
      border-color: var(--primary);
    }

    .ranking-box.collapsed>#rankingHeader {
      width: 100%;
      height: 100%;
      margin: 0;
      justify-content: center !important;
      align-items: center !important;
    }

    .ranking-box.collapsed #rankingTitleContainer,
    .ranking-box.collapsed #rankingList {
      display: none !important;
    }

    .ranking-box.collapsed #toggleProvidersBtn {
      padding: 0 !important;
      font-size: 24px;
      transform: rotate(180deg);
      pointer-events: none;
    }

    .ranking-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .provider-btn {
      width: 100%;
      border: 1px solid var(--border);
      background: transparent;
      border-radius: 6px;
      padding: 12px 14px;
      text-align: left;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      font-size: 14px;
      color: var(--text-main);
    }

    .provider-btn:hover {
      transform: scale(1.02);
      background: var(--primary);
      border-color: var(--primary);
      color: white;
    }

    .provider-btn:hover .provider-score,
    .provider-btn:hover .provider-score-text,
    .provider-btn:hover .provider-name {
      color: white;
    }

    .provider-btn.active {
      background: var(--primary);
      border-color: var(--primary);
      color: white;
    }

    .provider-btn.active .provider-score,
    .provider-btn.active .provider-score-text {
      color: white;
    }

    .provider-score-text {
      font-size: 10px;
      color: var(--text-muted);
      margin-top: 2px;
      transition: color 0.2s;
    }

    .provider-name {
      font-weight: 600;
    }

    .provider-score {
      font-size: 12px;
      color: var(--primary);
      font-weight: 700;
      white-space: nowrap;
    }

    .details-box {
      left: 18px;
      top: 18px;
      width: 420px;
      padding: 16px;
      max-height: calc(100vh - 36px);
      overflow-y: auto;
      transition: all 0.3s ease;
    }

    .placeholder {
      color: #6b7280;
      font-size: 14px;
      line-height: 1.5;
    }

    .provider-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 700;
      background: #ecfeff;
      color: #0f766e;
      border: 1px solid #99f6e4;
    }

    .metric-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin-top: 12px;
    }

    .metric-card {
      background: #f8fafc;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      padding: 12px;
    }

    .metric-label {
      font-size: 12px;
      color: #6b7280;
      margin-bottom: 6px;
    }

    .metric-value {
      font-size: 18px;
      font-weight: 700;
      color: #111827;
    }

    .section-title {
      margin-top: 16px;
      margin-bottom: 8px;
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #475569;
      font-weight: 700;
    }

    .list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .list-item {
      background: #f8fafc;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      padding: 10px 12px;
      font-size: 14px;
      display: flex;
      justify-content: space-between;
      gap: 10px;
    }

    .leaflet-popup-content {
      margin: 10px 12px;
      font-size: 13px;
      line-height: 1.45;
    }

    .legend {
      position: absolute;
      z-index: 1000;
      right: 70px;
      left: auto;
      bottom: 32px;
      padding: 12px 14px;
      width: 250px;
    }

    .legend-row {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      color: #374151;
      margin-top: 8px;
    }

    .dot {
      width: 12px;
      height: 12px;
      border-radius: 999px;
      border: 1px solid rgba(0, 0, 0, 0.15);
      flex-shrink: 0;
    }

    .dark-mode-toggle {
      width: 100%;
      height: 48px;
      border-radius: 6px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      backdrop-filter: var(--glass);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      transition: all 0.2s;
      font-size: 15px;
      font-weight: 600;
      color: var(--text-main);
    }

    .dark-mode-toggle span {
      font-size: 14px;
    }

    .dark-mode-toggle:hover {
      transform: scale(1.05);
      border-color: var(--primary);
    }

    /* Metrics Styles */
    .loader {
      width: 24px;
      height: 24px;
      border: 3px solid var(--border);
      border-bottom-color: var(--primary);
      border-radius: 50%;
      display: inline-block;
      animation: rotation 1s linear infinite;
    }

    @keyframes rotation {
      0% {
        transform: rotate(0deg);
      }

      100% {
        transform: rotate(360deg);
      }
    }

    .metric-card {
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px;
      transition: all 0.2s ease;
      position: relative;
      overflow: hidden;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .metric-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 4px;
      height: 100%;
      background: var(--status-color, var(--primary));
    }

    .metric-host {
      font-size: 11px;
      font-weight: 700;
      color: var(--primary);
      margin-bottom: 2px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .metric-row {
      display: flex;
      flex-direction: column;
      gap: 2px;
      font-size: 10px;
      color: var(--text-muted);
      margin-top: 6px;
      border-top: 1px solid var(--border);
      padding-top: 6px;
    }

    .metric-row div {
      display: flex;
      justify-content: space-between;
      white-space: nowrap;
    }

    .timestamp {
      font-size: 10px;
      color: var(--text-muted);
      margin-top: 20px;
      text-align: right;
      opacity: 0.7;
    }

    .error-msg {
      background: rgba(239, 68, 68, 0.1);
      padding: 16px;
      border-radius: 8px;
      text-align: center;
      margin-top: 10px;
      border: 1px solid rgba(239, 68, 68, 0.2);
      color: var(--danger);
      font-size: 14px;
    }

    .action-btn {
      flex: 1;
      height: 48px;
      border-radius: 6px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      backdrop-filter: var(--glass);
      cursor: pointer;
      font-weight: 700;
      font-size: 14px;
      color: var(--text-main);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: all 0.2s;
      text-decoration: none;
    }

    .action-btn:hover {
      border-color: var(--primary);
      transform: translateY(-2px);
    }

    .modal {
      display: none;
      position: fixed;
      z-index: 2000;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(4px);
    }

    .modal-content {
      background: var(--bg-page);
      margin: 10% auto;
      padding: 30px;
      border: 1px solid var(--border);
      width: 90%;
      max-width: 500px;
      border-radius: 10px;
      box-shadow: var(--shadow);
      color: var(--text-main);
      position: relative;
    }

    .close {
      position: absolute;
      right: 20px;
      top: 15px;
      font-size: 28px;
      font-weight: bold;
      cursor: pointer;
      color: var(--text-muted);
    }

    #detailsBox {
      display: none;
    }

    .legend {
      display: flex;
      gap: 8px;
      width: auto !important;
      min-width: 250px;
    }

    .secondary-btn {
      flex: 1;
      height: 48px;
      border-radius: 6px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      backdrop-filter: var(--glass);
      cursor: pointer;
      font-weight: 600;
      color: var(--text-main);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: all 0.2s;
    }

    .secondary-btn:hover {
      border-color: var(--primary);
    }

    .leaflet-container {
      background-color: var(--bg-page) !important;
    }

    .dark .leaflet-tile-pane {
      filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
    }

    .dark .leaflet-container {
      background: #111 !important;
    }

    #legendToggle {
      display: flex;
      justify-content: center;
      align-items: center;
      font-weight: bold;
      font-size: 18px;
      cursor: pointer;
      transition: transform 0.3s ease;
      width: 48px;
      flex: none;
    }

    .legend.collapsed {
      width: 66px !important;
      min-width: 66px !important;
      padding: 8px !important;
      gap: 0 !important;
    }

    .legend.collapsed> :not(#legendToggle) {
      display: none !important;
    }

    @media (max-width: 900px) {

      .details-box,
      .ranking-box {
        position: fixed;
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
      }

      .details-box {
        bottom: 74px;
        top: auto;
        max-height: calc(100vh - 160px);
      }

      .ranking-box {
        top: 12px;
        height: auto;
        max-height: 45vh;
        overflow-y: auto;
      }

      .legend {
        display: flex;
        flex-direction: row;
        bottom: 12px;
        top: auto;
        left: 12px;
        right: auto;
        width: calc(100% - 24px) !important;
        min-width: 0;
        padding: 8px;
        gap: 12px;
      }

      .legend .dark-mode-toggle {
        height: 40px;
        font-size: 16px;
        flex: 0 0 60px;
        width: auto;
      }

      .legend .action-btn,
      .legend .secondary-btn {
        height: 40px;
        flex: 1;
      }

      #legendToggle {
        width: 40px;
      }

      #legendToggle span {
        display: inline-block;
        transform: rotate(180deg);
      }

      .legend.collapsed {
        width: 56px !important;
        min-width: 56px !important;
      }
    }

