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

  html, body {
    height: 100%;
    overflow: hidden;
    background: #0d1117;
    color: #e6edf3;
    font-family: 'Segoe UI', Tahoma, sans-serif;
  }

  /* ── Login ── */
  #login-screen {
    position: fixed; inset: 0; background: #0d1117;
    display: flex; align-items: center; justify-content: center; z-index: 9999;
  }
  .login-box {
    background: #161b22; border: 1px solid #30363d; border-radius: 12px;
    padding: 40px; width: 320px; text-align: center;
  }
  .login-box h1 { font-size: 1.4rem; margin-bottom: 6px; color: #58a6ff; }
  .login-box p  { font-size: 0.85rem; color: #8b949e; margin-bottom: 28px; }
  .login-box input {
    width: 100%; padding: 10px 14px; margin-bottom: 12px;
    background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
    color: #e6edf3; font-size: 0.9rem; box-sizing: border-box;
  }
  .login-box input:focus { outline: none; border-color: #58a6ff; }
  .login-box button {
    width: 100%; padding: 10px; background: #238636; border: none;
    border-radius: 6px; color: #fff; font-size: 0.95rem; cursor: pointer;
  }
  .login-box button:hover { background: #2ea043; }
  #login-error { color: #f85149; font-size: 0.85rem; margin-top: 10px; min-height: 18px; }

  /* ── Dashboard shell ── */
  #dashboard {
    display: none;
    flex-direction: column;
    height: 100%;
  }

  /* ── Header ── */
  header {
    flex: 0 0 auto;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  header h1 { font-size: 1rem; color: #58a6ff; letter-spacing: 0.02em; }
  #header-time { font-size: 0.82rem; color: #8b949e; font-variant-numeric: tabular-nums; min-width: 160px; text-align: center; }
  #ws-status {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.75rem; color: #8b949e;
  }
  #ws-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #484f58;
    transition: background 0.3s;
  }
  #ws-dot.live        { background: #3fb950; }
  #ws-dot.reconnecting { background: #f85149; animation: pulse 1s infinite; }
  @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

  /* ── Main content area ── */
  #content {
    flex: 1 1 0;
    display: flex;
    overflow: hidden;
  }

  /* ── Map panel (left 2/3) ── */
  #map-panel {
    flex: 2;
    position: relative;
    border-left: 1px solid #30363d;
  }
  #map-container {
    position: absolute;
    inset: 0;
  }

  /* ── Feed panel (right 1/3) ── */
  #feed-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d1117;
  }

  .feed-header {
    flex: 0 0 auto;
    padding: 10px 14px 8px;
    border-bottom: 1px solid #21262d;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .feed-header span:first-child { font-size: 0.78rem; color: #8b949e; text-transform: uppercase; letter-spacing: 0.06em; }
  #feed-status { font-size: 0.70rem; color: #484f58; }

  /* scrollable table wrapper */
  #feed-scroll {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: auto;
  }
  #feed-scroll::-webkit-scrollbar { width: 4px; }
  #feed-scroll::-webkit-scrollbar-track { background: transparent; }
  #feed-scroll::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

  .feed-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
  }
  .feed-table th {
    position: sticky;
    top: 0;
    background: #161b22;
    color: #8b949e;
    padding: 5px 6px;
    text-align: right;
    font-weight: 500;
    border-bottom: 1px solid #30363d;
    white-space: nowrap;
  }
  .feed-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #161b22;
    white-space: nowrap;
  }
  .feed-table tbody tr { cursor: pointer; }
  .feed-table tbody tr:hover td { background: #1c2128; }
  .feed-table tr.has-threats td { border-right: 3px solid #f85149; }

  .badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.70rem;
    font-weight: 600;
  }
  .badge-red   { background: #3d1414; color: #f85149; }
  .badge-green { background: #122320; color: #3fb950; }

  /* ── Incident markers ── */
  .start-marker, .start-marker-drone, .start-marker-event {
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    text-align: center;
    line-height: 1.1;
  }
  .start-marker       { background: #22c55e; }
  .start-marker-drone { background: #9333ea; }
  .start-marker-event { background: #f97316; font-size: 8px; }

  /* ── Leaflet popup override ── */
  .leaflet-popup-content-wrapper {
    background: #161b22;
    color: #e6edf3;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 0.82rem;
    direction: rtl;
  }
  .leaflet-popup-tip { background: #161b22; }
  .popup-id   { font-size: 1rem; font-weight: 700; color: #58a6ff; margin-bottom: 6px; }
  .popup-row  { margin: 3px 0; }
  .popup-threat { padding: 2px 0; border-bottom: 1px solid #21262d; font-size: 0.78rem; }

  /* ── Location markers ── */
  .loc-icon-wrapper {
    background: transparent !important;
    border: none !important;
  }
  .loc-marker {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1;
    border-radius: 50%;
    background: rgba(13,17,23,0.65);
    box-shadow: 0 0 4px rgba(0,0,0,0.6);
  }
  .loc-military { color: #f85149; }
  .loc-oil      { color: #c9d1d9; }
  .loc-infra    { color: #58a6ff; }
  .loc-default  { color: #8b949e; }

  /* pulsing threat ring */
  @keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0   rgba(248,81,73,0.8); }
    70%  { box-shadow: 0 0 0 10px rgba(248,81,73,0); }
    100% { box-shadow: 0 0 0 0   rgba(248,81,73,0); }
  }
  .loc-threatened {
    border-radius: 50%;
    animation: pulse-ring 1.4s ease-out infinite;
    outline: 2px solid #f85149;
    outline-offset: 2px;
  }

  /* ── Location tooltip ── */
  .loc-tooltip.leaflet-tooltip {
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
    font-size: 0.78rem;
    direction: rtl;
    text-align: right;
    border-radius: 5px;
    padding: 4px 8px;
  }
  .loc-tooltip.leaflet-tooltip::before { border-top-color: #30363d; }

  /* ── Toggle button ── */
  #toggle-locations {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 7px 13px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    direction: rtl;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  }
  #toggle-locations:hover { background: #21262d; }
