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

  :root {
    --blue: #2563EB;
    --blue-light: #3b82f6;
    --blue-glow: rgba(37, 99, 235, 0.22);
    --marker-scale: 1;
    --glass-blur: blur(24px);
  }

  /* ── Light Theme (DEFAULT) ── */
  [data-theme="light"] {
    --bg: #e8eaef;
    --surface: rgba(255, 255, 255, 0.55);
    --surface-solid: #ffffff;
    --surface-2: rgba(255, 255, 255, 0.35);
    --border: rgba(0,0,0,0.08);
    --border-solid: #d0d3dc;
    --text: #1a1c2e;
    --text-dim: #6e7187;
    --accent: var(--blue);
    --accent-hover: var(--blue-light);
    --accent-glow: var(--blue-glow);
    --green: #16a34a;
    --orange: #ea580c;
    --pink: #db2777;
    --lavender: #7c3aed;
    --red: #dc2626;
    --yellow: #ca8a04;
    --map-bg: #dfe1e8;
    --map-opacity: 1;
    --marker-border: rgba(0,0,0,0.2);
    --panel-shadow: rgba(0,0,0,0.06);
    --glass-border: rgba(0,0,0,0.08);
    --glass-highlight: rgba(255,255,255,0.6);
    --img-filter: brightness(1.03) contrast(1.01);
  }

  /* ── Dark Theme ── */
  [data-theme="dark"] {
    --bg: #0c0e14;
    --surface: rgba(14, 16, 24, 0.55);
    --surface-solid: #14161e;
    --surface-2: rgba(28, 31, 42, 0.4);
    --border: rgba(255,255,255,0.07);
    --border-solid: #272b38;
    --text: #e2e4ee;
    --text-dim: #7d8196;
    --accent: var(--blue);
    --accent-hover: var(--blue-light);
    --accent-glow: var(--blue-glow);
    --green: #34d399;
    --orange: #fb923c;
    --pink: #f472b6;
    --lavender: #a78bfa;
    --red: #ef4444;
    --yellow: #facc15;
    --map-bg: #0a0c11;
    --map-opacity: 0.92;
    --marker-border: rgba(255,255,255,0.25);
    --panel-shadow: rgba(0,0,0,0.4);
    --glass-border: rgba(255,255,255,0.08);
    --glass-highlight: rgba(255,255,255,0.04);
    --img-filter: none;
  }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
  }

  /* ── Keyboard Focus Ring (Accessibility) ── */
  button:focus-visible,
  select:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  /* Override for inputs that already show focus via border-color */
  .field-input:focus-visible,
  .field-select:focus-visible,
  .field-textarea:focus-visible,
  .modal input:focus-visible,
  .modal select:focus-visible,
  .search-input:focus-visible {
    outline: none;
  }

  /* ── SVG Icon System ── */
  .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: middle;
  }
  .icon-sm { width: 14px; height: 14px; }
  .icon-lg { width: 18px; height: 18px; }
  .icon-xl { width: 20px; height: 20px; }

  /* ── Top Bar ── */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    z-index: 100;
    position: relative;
    transition: background 0.3s, border-color 0.3s;
  }
  .topbar-left { display: flex; align-items: center; gap: 12px; }
  .logo {
    height: 24px;
    flex-shrink: 0;
    display: flex; align-items: center;
  }
  .logo .logo-full { height: 24px; display: block; }
  .logo .logo-mini { height: 24px; display: none; }

  [data-theme="dark"] .logo .logo-full,
  [data-theme="dark"] .logo .logo-mini { filter: invert(1); }

  /* School Site Dropdown */
  .site-selector {
    position: relative;
    display: flex;
    align-items: center;
  }
  .site-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    color: var(--text);
  }
  .site-selector-btn:hover {
    background: var(--surface-2);
    border-color: var(--border);
  }
  .site-selector-btn .site-name {
    font-weight: 600;
    font-size: 14px;
  }
  .site-selector-btn .chevron {
    font-size: 10px;
    color: var(--text-dim);
    transition: transform 0.2s;
  }
  .site-selector-btn.open .chevron {
    transform: rotate(180deg);
  }

  .site-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 260px;
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--panel-shadow);
    z-index: 200;
    padding: 4px;
    animation: dropIn 0.15s ease;
  }
  .site-dropdown.open { display: block; }

  @keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .site-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: var(--text);
  }
  .site-dropdown-item:hover { background: var(--surface-2); }
  .site-dropdown-item.active {
    background: var(--accent-glow);
  }
  .site-dropdown-item .site-item-icon {
    width: 24px; height: 24px;
    background: var(--surface-2);
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
  }
  .site-dropdown-item.active .site-item-icon {
    background: var(--accent);
    color: #fff;
  }
  .site-dropdown-item .site-item-name {
    font-weight: 600;
    font-size: 13px;
  }
  .site-dropdown-item .site-item-detail {
    font-size: 11px;
    color: var(--text-dim);
  }
  .site-dropdown-item .site-check {
    margin-left: auto;
    color: var(--accent);
    font-size: 16px;
    opacity: 0;
  }
  .site-dropdown-item.active .site-check { opacity: 1; }

  .topbar-right { display: flex; align-items: center; gap: 10px; }
  .topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 500;
    font-size: 13px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    pointer-events: none;
    white-space: nowrap;
  }

  /* ── Search Bar ── */
  .search-container {
    position: relative;
    display: none;  /* Hidden until logged in */
  }
  .search-container.visible { display: block; }
  .search-input {
    width: 240px;
    padding: 6px 10px 6px 32px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s, width 0.2s;
  }
  .search-input:focus { border-color: var(--accent); width: 300px; outline: none; }
  .search-input::placeholder { color: var(--text-dim); }
  .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    display: flex;
    align-items: center;
  }
  .search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 380px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 200;
  }
  .search-dropdown.open { display: block; }
  .search-group-label {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    background: var(--surface-2);
    position: sticky;
    top: 0;
  }
  .search-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
  }
  .search-result:hover { background: var(--surface-2); }
  .search-result:last-child { border-radius: 0 0 8px 8px; }
  .search-result-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .search-result-icon img { width: 16px; height: 16px; }
  .search-result-info { flex: 1; min-width: 0; }
  .search-result-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-result-type { font-size: 11px; color: var(--text-dim); }
  .search-no-results { padding: 16px 14px; font-size: 13px; color: var(--text-dim); text-align: center; }

  /* Theme Toggle */
  .theme-toggle {
    width: 36px; height: 36px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    color: var(--text);
  }
  .theme-toggle:hover { background: var(--border); }

  /* Auth button */
  .auth-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: filter 0.15s;
    box-shadow: 0 0 12px var(--accent-glow);
  }
  .auth-btn:hover { filter: brightness(1.2); }
  .auth-btn.logged-in { background: var(--green); }
  [data-theme="dark"] .auth-btn.logged-in { color: #1a1a2e; }

  /* ── Main Layout ── */
  .main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
  }

  /* ── Sidebar ── */
  .sidebar {
    width: 250px;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: background 0.3s, border-color 0.3s;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
  }
  .sidebar-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-section h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    margin-bottom: 10px;
    font-weight: 600;
  }
  .toggle-group { display: flex; flex-direction: column; gap: 2px; }

  /* ── Collapsible Section Headers ── */
  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
  }
  .section-header:hover { opacity: 0.8; }
  .section-arrow {
    font-size: 10px;
    color: var(--text-dim);
    transition: transform 0.2s;
    margin-left: 6px;
  }
  .section-header.open .section-arrow { transform: rotate(90deg); }
  .section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .section-body.open { max-height: 600px; }
  .toggle-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
  }
  .toggle-item:hover { background: var(--surface-2); }
  .toggle-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .toggle-label { font-size: 13px; flex: 1; font-weight: 500; }
  .toggle-count {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-dim);
    background: var(--surface-2);
    padding: 2px 7px;
    border-radius: 4px;
  }
  .toggle-switch {
    width: 36px; height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
  }
  .toggle-switch.active { background: var(--accent); }
  .toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
  }
  .toggle-switch.active::after { transform: translateX(16px); }

  .master-toggle {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
  }
  .master-toggle:hover { text-decoration: underline; }

  /* Add Device Button */
  .add-device-btn {
    width: 100%;
    padding: 8px 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: filter 0.15s;
    box-shadow: 0 0 16px var(--accent-glow);
  }
  .add-device-btn:hover { filter: brightness(1.2); }
  .add-device-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: none;
  }

  /* Device Type Picker */
  .device-type-picker {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
  }
  .device-type-picker.visible { display: flex; }
  .type-pick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
  }
  .type-pick-btn:hover { border-color: var(--accent); }
  .type-pick-btn .pick-dot { width: 8px; height: 8px; border-radius: 50%; }

  .add-instructions {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(37,99,235,0.25);
    border-radius: 6px;
    font-size: 11px;
    color: var(--accent);
    line-height: 1.5;
    display: none;
  }
  .add-instructions.visible { display: block; }

  .cancel-add-btn {
    margin-top: 4px;
    width: 100%;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    display: none;
  }
  .cancel-add-btn.visible { display: block; }
  .cancel-add-btn:hover { background: var(--surface-2); }

  /* Cable Drawing Button */
  .draw-cable-btn {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 4px;
    transition: background 0.15s;
  }
  .draw-cable-btn:hover { background: var(--accent-glow); }
  .draw-cable-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }

  /* Cable Type Picker */
  .cable-type-picker {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
  }
  .cable-type-picker.visible { display: flex; }
  .cable-pick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
  }
  .cable-pick-btn:hover { border-color: var(--accent); }
  .cable-pick-btn .cable-line {
    width: 20px; height: 3px; border-radius: 2px; flex-shrink: 0;
  }

  .cable-instructions {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(37,99,235,0.25);
    border-radius: 6px;
    font-size: 11px;
    color: var(--accent);
    line-height: 1.5;
    display: none;
  }
  .cable-instructions.visible { display: block; }

  .cancel-cable-btn {
    margin-top: 4px;
    width: 100%;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    display: none;
  }
  .cancel-cable-btn.visible { display: block; }
  .cancel-cable-btn:hover { background: var(--surface-2); }

  /* ── Map Container ── */
  .map-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--map-bg);
    transition: background 0.3s;
  }
  .map-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: auto;
    cursor: none;
    scrollbar-width: none;           /* Firefox */
    -ms-overflow-style: none;        /* IE/Edge */
  }
  .map-wrapper::-webkit-scrollbar { display: none; } /* Chrome/Safari */

  /* ── Custom Map Cursor (DOM element, always crisp) ── */
  .map-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 999;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    display: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
  }
  .map-cursor.visible { display: block; }
  .map-viewport {
    display: inline-block;
    padding: 0;
    transform-origin: 0 0;
  }
  .map-inner {
    position: relative;
    display: inline-block;
    margin: 50vh 50vw;
  }
  .map-inner img {
    display: block;
    height: calc(100vh - 48px);
    width: auto;
    border-radius: 4px;
    border: 1px solid var(--border);
    opacity: var(--map-opacity);
    filter: var(--img-filter);
    transition: opacity 0.3s, filter 0.3s, border-color 0.3s;
    user-select: none;
    -webkit-user-drag: none;
  }
  .map-inner.placing-mode { cursor: crosshair; }

  /* ── SVG Cable Layer ── */
  .cable-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
  }
  .cable-svg.drawing { pointer-events: all; cursor: crosshair; }
  .cable-svg line, .cable-svg polyline {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Cable colors */
  .cable-cat5e { stroke: #EF4444; }
  .cable-cat6 { stroke: #22C55E; }
  .cable-cat6a { stroke: #3B82F6; }
  .cable-fiber-sm { stroke: #F97316; }
  .cable-fiber-mm { stroke: #14B8A6; }

  .cable-segment {
    stroke-width: 3;
    cursor: pointer;
    pointer-events: stroke;
    transition: stroke-width 0.1s, filter 0.1s;
  }
  .cable-group:hover .cable-segment {
    stroke-width: 5;
    filter: brightness(1.3);
  }
  .cable-node {
    fill: #fff;
    stroke-width: 2;
    cursor: pointer;
    pointer-events: all;
    r: 4;
  }
  .cable-group:hover .cable-node {
    r: 6;
  }
  .cable-preview-line {
    stroke-dasharray: 6 4;
    stroke-width: 2;
    opacity: 0.6;
    pointer-events: none;
  }

  /* ── Device Markers ── */
  .marker {
    position: absolute;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.15s;
    z-index: 10;
    transform: translate(-50%, -50%) scale(var(--marker-scale, 1));
  }
  .marker::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    z-index: -1;
    background: var(--mc, transparent);
    box-shadow: 0 0 12px var(--mc-glow, transparent);
  }
  .marker:hover { transform: translate(-50%, -50%) scale(calc(var(--marker-scale, 1) * 1.3)); z-index: 20; }
  .marker.ap::before  { background: #EAB308; box-shadow: 0 0 12px rgba(234,179,8,0.4); }
  .marker.cam::before { background: #22C55E; box-shadow: 0 0 12px rgba(34,197,94,0.4); }
  .marker.pa::before  { background: #3B82F6; box-shadow: 0 0 12px rgba(59,130,246,0.4); }
  .marker.cp::before  { background: #F97316; box-shadow: 0 0 12px rgba(249,115,22,0.4); }
  .marker.sw::before  { background: #8B5E3C; box-shadow: 0 0 12px rgba(139,94,60,0.4); }
  .marker.idf::before { background: #7C3AED; box-shadow: 0 0 12px rgba(124,58,237,0.4); }
  .marker.mdf-active::before { border: 3px solid #EF4444; box-shadow: 0 0 14px rgba(239,68,68,0.5); }
  .marker .marker-icon {
    width: 20px; height: 20px;
    pointer-events: none;
    position: relative;
    z-index: 1;
    background: #fff;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
  }
  .marker.hidden { display: none; }

  .marker-pulse {
    position: absolute;
    width: 100%; height: 100%;
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    pointer-events: none;
  }
  .marker.ap  .marker-pulse { background: #EAB308; }
  .marker.cam .marker-pulse { background: #22C55E; }
  .marker.pa  .marker-pulse { background: #3B82F6; }
  .marker.cp  .marker-pulse { background: #F97316; }
  .marker.sw  .marker-pulse { background: #8B5E3C; }
  .marker.idf .marker-pulse { background: #7C3AED; }

  @keyframes pulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(2.5); opacity: 0; }
  }

  /* ── Detail Panel ── */
  .detail-panel {
    position: absolute;
    top: 0; right: -380px;
    width: 360px;
    height: 100%;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--glass-border);
    z-index: 50;
    transition: right 0.3s ease, background 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px var(--panel-shadow);
  }
  .detail-panel.open { right: 0; }
  .detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .detail-header h2 { font-size: 15px; font-weight: 600; }
  .close-btn {
    width: 28px; height: 28px;
    background: var(--surface-2);
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .close-btn:hover { background: var(--border); }
  .detail-body { padding: 16px; overflow-y: auto; flex: 1; }
  .detail-type-badge {
    display: inline-flex;
    align-items: center; gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  .detail-type-badge.ap  { background: rgba(234,179,8,0.15); color: #EAB308; }
  .detail-type-badge.cam { background: rgba(34,197,94,0.15); color: #22C55E; }
  .detail-type-badge.pa  { background: rgba(59,130,246,0.15); color: #3B82F6; }
  .detail-type-badge.cp  { background: rgba(249,115,22,0.15); color: #F97316; }
  .detail-type-badge.sw  { background: rgba(139,94,60,0.15); color: #8B5E3C; }
  .detail-type-badge.idf { background: rgba(124,58,237,0.15); color: #7C3AED; }

  .field-group { margin-bottom: 14px; }
  .field-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    margin-bottom: 4px;
    font-weight: 500;
  }
  .field-value {
    font-size: 14px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: 6px;
    border: 1px solid transparent;
    font-family: 'JetBrains Mono', monospace;
    transition: background 0.3s;
  }
  .field-value.editable {
    border: 1px solid var(--border);
    cursor: text;
  }
  .field-value.editable:hover { border-color: var(--accent); }

  /* ── Typed Field Styles ── */
  .field-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    appearance: auto;
    cursor: pointer;
  }
  .field-select:focus { border-color: var(--accent); outline: none; }

  .field-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    resize: vertical;
  }
  .field-textarea:focus { border-color: var(--accent); outline: none; }

  .field-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
  }
  .field-input:focus { border-color: var(--accent); outline: none; }

  .checkbox-group { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
  .checkbox-group label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer;
    padding: 4px 0;
  }
  .checkbox-group input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
  }
  .checkbox-group .other-input {
    margin-left: 24px; margin-top: 2px;
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    width: 160px;
  }

  .yn-toggle {
    display: flex; gap: 0; border-radius: 6px; overflow: hidden; border: 1px solid var(--border);
  }
  .yn-toggle button {
    flex: 1; padding: 6px 16px; border: none;
    background: var(--surface-2); color: var(--text-dim);
    font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .yn-toggle button.active-yes { background: var(--green); color: #fff; }
  .yn-toggle button.active-no { background: var(--red); color: #fff; }

  /* ── IDF Switch Builder ── */
  .idf-switch-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 6px;
  }
  .idf-switch-card .sw-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
  }
  .idf-switch-card .sw-header span {
    font-size: 13px; font-weight: 600;
  }
  .idf-switch-card .sw-remove {
    background: none; border: none; color: var(--red);
    font-size: 14px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
  }
  .idf-switch-card .sw-remove:hover { background: rgba(220,38,38,0.1); }
  .idf-switch-card .field-group { margin-bottom: 8px; }
  .idf-switch-card .field-group:last-child { margin-bottom: 0; }

  .add-switch-btn {
    width: 100%; padding: 8px;
    background: var(--surface-2); border: 2px dashed var(--border);
    border-radius: 6px; color: var(--accent);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; margin-top: 4px;
  }
  .add-switch-btn:hover { border-color: var(--accent); }

  .edit-notice {
    margin-top: 20px;
    padding: 12px;
    background: var(--accent-glow);
    border: 1px solid rgba(37,99,235,0.25);
    border-radius: 6px;
    font-size: 12px;
    color: var(--accent);
    line-height: 1.5;
  }

  .delete-device-btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--red);
    border-radius: 6px;
    color: var(--red);
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
  }
  .delete-device-btn:hover { background: rgba(220,38,38,0.08); }

  /* ── Zoom Controls ── */
  .zoom-controls {
    position: absolute;
    bottom: 20px; right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 30;
  }
  .zoom-btn {
    width: 34px; height: 34px;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, border-color 0.3s;
  }
  .zoom-btn:hover { background: var(--surface-2); }

  /* ── Login Modal ── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.visible { display: flex; }
  .modal {
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 24px;
    width: 380px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  }
  .modal h2 {
    margin-bottom: 6px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .modal p { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }
  .modal label:not(.ss-upload-btn) {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .modal input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 14px;
    outline: none;
    transition: border-color 0.2s;
  }
  .modal input:focus { border-color: var(--accent); }
  .modal-actions { display: flex; gap: 10px; margin-top: 6px; }
  .modal-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: filter 0.15s;
  }
  .modal-actions .primary-btn {
    background: var(--accent);
    color: #fff;
    border: none;
  }
  .modal-actions .primary-btn:hover { filter: brightness(1.2); }
  .modal-actions .secondary-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
  }
  .modal-actions .secondary-btn:hover { background: var(--surface-2); }
  .login-error {
    color: var(--red);
    font-size: 12px;
    margin-bottom: 10px;
    display: none;
  }
  .login-error.visible { display: block; }

  /* ── Modal Sizing Variants ── */
  .modal-sm  { width: 420px; }
  .modal-md  { width: 460px; }
  .modal-lg  { width: 560px; }
  .modal-xl  { width: 600px; }
  .modal-scrollable {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
  }
  .modal-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 18px;
  }

  /* ── Reusable Section Label (uppercase dimmed heading) ── */
  .section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* ── Picker Headers (lighter weight, no uppercase) ── */
  .picker-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
  }

  /* ── Admin Tool Buttons (secondary-styled sidebar buttons) ── */
  .admin-tool-btn {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 4px;
    transition: background 0.15s, border-color 0.15s;
  }
  .admin-tool-btn:hover { background: var(--border); }

  /* ── Export Scope Toggle Buttons ── */
  .export-scope-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }
  .export-scope-btn.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
  }

  /* ── Tab Buttons (e.g. Custom Types modal) ── */
  .tab-btn {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
  }
  .tab-btn:hover { border-color: var(--accent); color: var(--accent); }
  .tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  /* ── Full-Width Action Button (for modals/forms) ── */
  .full-width-action {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--accent);
    color: #fff;
    transition: filter 0.15s;
  }
  .full-width-action:hover { filter: brightness(1.2); }

  /* ── Color Picker Input ── */
  .modal .color-input {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    margin-bottom: 0;
  }

  /* ── Custom Types Form ── */
  .ct-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }
  .ct-color-row label { margin-bottom: 0; }
  .ct-row-spacer { width: 8px; }
  .ct-icon-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .ct-icon-upload:hover { border-color: var(--accent); background: var(--surface-3, var(--surface-2)); }
  .ct-icon-filename {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: 4px;
  }

  /* ── Form Divider (border-top section separator) ── */
  .form-divider {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 8px;
  }

  /* ── Picker Icon (type/cable picker thumbnails) ── */
  .picker-icon { width: 16px; height: 16px; }

  /* ── Site Settings Modal ── */
  #ss-main-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .ss-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
  }
  .ss-header h2 { margin-bottom: 4px; }
  .ss-header p { margin-bottom: 0; }
  .ss-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    padding-top: 2px;
  }
  .ss-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
  }
  .ss-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
  .ss-new-site-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s;
  }
  .ss-new-site-btn:hover { filter: brightness(1.2); }

  .modal select {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: auto;
  }
  .modal select:focus { border-color: var(--accent); }

  .ss-map-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
  }
  .ss-map-filename {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ss-upload-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: filter 0.15s;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
  }
  .ss-upload-btn:hover { filter: brightness(1.2); }

  .ss-bottom-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }
  .ss-delete-btn {
    padding: 8px 14px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s;
  }
  .ss-delete-btn:hover { filter: brightness(1.15); }
  .ss-bottom-actions .modal-actions { flex: 1; justify-content: flex-end; }

  /* SSID management */
  .ss-ssid-hint {
    font-size: 12px;
    color: var(--muted);
    margin: -4px 0 8px;
  }
  .ss-ssid-add-row {
    display: flex;
    gap: 8px;
  }
  .ss-ssid-add-row input { flex: 1; }
  .ss-ssid-add-btn {
    padding: 8px 14px;
    font-size: 13px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s;
  }
  .ss-ssid-add-btn:hover { filter: brightness(1.2); }
  .ss-ssid-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: 8px;
    margin-bottom: 4px;
  }
  .ss-ssid-name { flex: 1; font-size: 14px; }
  .ss-ssid-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
  }
  .ss-ssid-remove:hover { color: var(--red); }
  .ss-ssid-empty {
    color: var(--muted);
    font-size: 13px;
    padding: 6px;
  }

  /* Reorder list */
  .ss-reorder-list {
    max-height: 360px;
    overflow-y: auto;
    margin-top: 4px;
  }
  .ss-reorder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: grab;
    user-select: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  }
  .ss-reorder-item:active { cursor: grabbing; }
  .ss-reorder-item.ss-drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
  }
  .ss-reorder-item.ss-dragging {
    opacity: 0.5;
    background: var(--surface);
  }
  .ss-reorder-grip {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1;
    letter-spacing: 1px;
  }

  /* ── Edit Button ── */
  .edit-toggle-btn {
    display: inline-flex;
    align-items: center; gap: 6px;
    padding: 6px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
  }
  .edit-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
  .edit-toggle-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
  }

  /* ── Draggable Markers ── */
  .marker.draggable { cursor: grab; }
  .marker.draggable:active { cursor: grabbing; }
  .marker.dragging {
    z-index: 100 !important;
    transform: translate(-50%, -50%) scale(calc(var(--marker-scale, 1) * 1.4));
    opacity: 0.85;
    cursor: grabbing;
  }

  /* ── Placement Ghost Cursor ── */
  .placement-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    box-shadow: 0 0 16px rgba(0,0,0,0.3);
  }

  /* ── User List ── */
  .user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    margin-bottom: 4px;
  }
  .user-row .user-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
    flex-shrink: 0;
  }
  .user-row .user-info { flex: 1; }
  .user-row .user-info .uname { font-size: 12px; font-weight: 600; }
  .user-row .user-info .urole { font-size: 10px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
  .user-row .user-delete {
    width: 24px; height: 24px;
    border: none; background: none;
    color: var(--red); cursor: pointer;
    font-size: 14px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
  }
  .user-row .user-delete:hover { background: rgba(220,38,38,0.1); }
  .user-row .user-reset {
    width: 24px; height: 24px;
    border: none; background: none;
    color: var(--orange); cursor: pointer;
    font-size: 14px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
  }
  .user-row .user-reset:hover { background: rgba(234,88,12,0.1); }

  /* ── Audit Info ── */
  .audit-info {
    margin-top: 16px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.7;
  }
  .audit-info span { font-family: 'JetBrains Mono', monospace; }

  /* ── Device History ── */
  .history-section { margin-top: 16px; }
  .history-latest {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
  }
  .history-latest:hover { background: var(--border); }
  .history-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
  }
  .history-arrow.open { transform: rotate(90deg); }
  .history-icon { flex-shrink: 0; }
  .history-text { flex: 1; line-height: 1.4; }
  .history-text strong { color: var(--text); font-weight: 600; }
  .history-date { font-family: 'JetBrains Mono', monospace; font-size: 11px; white-space: nowrap; }
  .history-list {
    display: none;
    margin-top: 4px;
    border-left: 2px solid var(--border);
    margin-left: 16px;
    padding-left: 12px;
  }
  .history-list.open { display: block; }
  .history-entry {
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--surface-2);
    line-height: 1.5;
  }
  .history-entry:last-child { border-bottom: none; }
  .history-entry strong { color: var(--text); font-weight: 600; }
  /* ── Sidebar Toggle (hamburger) — hidden on desktop ── */
  .sidebar-toggle {
    display: none;
    width: 32px; height: 32px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px;
    flex-shrink: 0;
  }
  .sidebar-toggle span {
    display: block;
    width: 18px; height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .sidebar-toggle:hover { background: var(--border); }

  /* Backdrop for mobile sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 59;
  }
  .sidebar-backdrop.visible { display: block; }

  /* Mobile auth in sidebar — hidden on desktop */
  .sidebar-auth-mobile { display: none; }

  /* ═══════════════════════════════════════════════════
     MOBILE RESPONSIVE — max-width: 768px
     ═══════════════════════════════════════════════════ */
  @media (max-width: 768px) {
    /* ── Topbar ── */
    .topbar { height: 44px; padding: 0 10px; }
    .topbar-left { gap: 8px; }
    .sidebar-toggle { display: flex; }
    .logo { width: 24px; height: 24px; }
    .logo .logo-full { display: none; }
    .logo .logo-mini { display: block; }
    .site-selector-btn { padding: 4px 8px; }
    .site-name { font-size: 12px; }
    .chevron { font-size: 10px; }
    .site-dropdown {
      left: -40px; right: auto;
      min-width: 240px;
    }
    .topbar-center { display: none; }
    .topbar-right { gap: 6px; }
    .search-input { width: 140px; font-size: 12px; padding: 6px 10px 6px 30px; }
    .search-input:focus { width: 180px; }
    .search-dropdown { width: 300px; right: 0; left: auto; }
    .theme-toggle { width: 34px; height: 34px; }
    /* Hide topbar auth button on mobile — it's in the sidebar now */
    .topbar-right .auth-btn { display: none; }
    /* Show sidebar auth */
    .sidebar-auth-mobile { display: block; }

    /* ── Sidebar as overlay ── */
    .sidebar {
      position: fixed;
      top: 44px;
      left: 0;
      bottom: 0;
      width: 250px;
      z-index: 60;
      transform: translateX(-100%);
      transition: transform 0.3s ease;
      box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }
    .sidebar.mobile-open {
      transform: translateX(0);
    }

    /* ── Map fills the screen ── */

    /* ── Detail panel full-width ── */
    .detail-panel {
      width: 100%;
      right: -100%;
    }
    .detail-panel.open { right: 0; }

    /* ── Zoom controls ── */
    .zoom-controls {
      bottom: 16px;
      right: 12px;
    }
    .zoom-btn {
      width: 40px; height: 40px;
      font-size: 20px;
    }

    /* ── Modals ── */
    .modal { width: calc(100vw - 32px); max-width: 380px; padding: 20px; }
    .modal.modal-sm  { max-width: 420px; }
    .modal.modal-md  { max-width: 460px; }
    .modal.modal-lg  { max-width: 560px; }
    .modal.modal-xl  { max-width: 600px; }
    .ss-header { flex-wrap: wrap; }
    .ss-header-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
    .ss-bottom-actions { flex-wrap: wrap; }
    .ss-bottom-actions .modal-actions { width: 100%; margin-top: 8px; }

    /* ── Markers — slightly larger tap targets ── */
    .marker {
      width: 36px; height: 36px;
    }
    .marker .marker-icon { width: 20px; height: 20px; }
  }

  /* ═══════════════════════════════════════════════════
     SMALL MOBILE — max-width: 480px
     ═══════════════════════════════════════════════════ */
  @media (max-width: 480px) {
    .topbar { height: 40px; padding: 0 8px; }
    .logo { width: 22px; height: 22px; }
    .logo .logo-mini { height: 22px; }
    .sidebar { width: 240px; top: 40px; }
    .site-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .search-input { width: 100px; }
    .search-input:focus { width: 140px; }
    .search-dropdown { width: calc(100vw - 20px); right: -50px; }
    .detail-body { padding: 12px; }
  }

  /* ═══════════════════════════════════════════════════
     LOGIN PAGE — .login-page body class
     ═══════════════════════════════════════════════════ */
  .login-page {
    font-family: 'DM Sans', sans-serif;
    background: #0f1117;
    color: #e4e6f0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Animated background ── */
  .login-page .bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
  }
  .login-page .bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.12;
    animation: orbFloat 20s ease-in-out infinite;
  }
  .login-page .bg-orb:nth-child(1) {
    width: 500px; height: 500px;
    background: var(--blue);
    top: -10%; left: -5%;
    animation-duration: 22s;
  }
  .login-page .bg-orb:nth-child(2) {
    width: 400px; height: 400px;
    background: #3b82f6;
    bottom: -15%; right: -10%;
    animation-duration: 18s;
    animation-delay: -5s;
  }
  .login-page .bg-orb:nth-child(3) {
    width: 300px; height: 300px;
    background: #a78bfa;
    top: 50%; left: 60%;
    animation-duration: 25s;
    animation-delay: -10s;
  }
  @keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
  }

  /* ── Login container ── */
  .login-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateY(-5vh);
    width: 100%;
    max-width: 380px;
    padding: 0 24px;
  }

  /* ── Logo ── */
  .login-logo {
    margin-bottom: 20px;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: fadeInDown 0.7s ease forwards;
  }
  .login-logo img {
    height: 100px;
    display: block;
    filter: invert(1);
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* ── Org Name ── */
  .login-org-name {
    font-size: 13px;
    letter-spacing: 0.5px;
    color: #8b8fa3;
    text-align: center;
    margin-bottom: 32px;
    min-height: 20px;
    opacity: 0;
    animation: fadeInUp 0.5s ease 0.2s forwards;
  }

  /* ── Form ── */
  .login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    animation: fadeInUp 0.6s ease 0.3s forwards;
  }
  .login-page .input-group { position: relative; }
  .login-page .input-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b8fa3;
    margin-bottom: 6px;
    font-weight: 600;
  }
  .login-page .input-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #e4e6f0;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  }
  .login-page .input-group input:focus {
    border-color: var(--blue-light);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px var(--blue-glow);
  }
  .login-page .input-group input::placeholder { color: #555770; }

  .sign-in-btn {
    width: 100%;
    padding: 14px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    margin-top: 4px;
    letter-spacing: 0.3px;
  }
  .sign-in-btn:hover { filter: brightness(1.15); }
  .sign-in-btn:active { transform: scale(0.98); }
  .sign-in-btn:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }

  .login-error {
    color: #ef4444;
    font-size: 13px;
    text-align: center;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .login-error.visible { opacity: 1; }

  /* ── Dissolve particles ── */
  .login-page .particle {
    position: fixed;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--blue-light);
    pointer-events: none;
    z-index: 100;
    opacity: 0;
  }
  .login-page.dissolving .bg-orb {
    transition: opacity 1s ease;
    opacity: 0;
  }
  .login-page.dissolving .login-form {
    opacity: 0;
    transform: translateY(20px);
  }
  .login-page.dissolving .login-org-name {
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  /* ── Entrance animations ── */
  @keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
  }

  /* ── Login mobile ── */
  @media (max-width: 480px) {
    .login-logo img { height: 72px; }
    .login-container { transform: translateY(-3vh); }
  }
