/* ── Base ── */
html, body { height: 100%; }
body { margin: 0; padding: 0; }
body.dark { filter: invert(1) hue-rotate(180deg) brightness(1.33); }
body.dark .dark-hidden { display: none; }
body:not(.dark) .dark-only { display: none; }

/* ── Header ── */
#header {
  background-color: #fff;
  box-shadow: 0 0 4px 0 rgb(0 0 0 / 40%);
  color: #333;
  display: flex;
  align-items: center;
  gap: 1em;
  font-family: "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.2;
  height: 40px;
  padding: 0 17px 0 15px;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 1000;
}
#header a { color: inherit; text-decoration: none; }
#header a:hover { opacity: 0.7; }
#header a img { display: block; }
#header div:nth-child(2) { flex-grow: 1; text-align: right; }

/* ── Map ── */
#map { position: absolute; top: 40px; bottom: 0; left: 0; right: 0; }

/* ── Tables ── */
table { border-collapse: collapse; }
table :is(th, td) { text-align: left; vertical-align: top; }
table :is(th, td):nth-child(n+2) { padding-left: 1em; }
.break { word-break: break-all; }
code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

/* ── Leaflet overrides ── */
.leaflet-tooltip, .leaflet-popup-content { font-family: "Inter", sans-serif; font-size: 12px; }
.leaflet-popup-content .title { font-size: 13px; font-weight: bold; margin-bottom: 3px; }
.leaflet-popup-content table { margin-top: 1em; }
.leaflet-right .leaflet-control-attribution { text-align: right; }
body.dark .leaflet-shadow-pane { display: none; }
body.dark :is(.leaflet-tooltip, .leaflet-popup-content-wrapper, .leaflet-popup-tip) {
  box-shadow: 0 0 4px 0 rgb(0 0 0 / 40%);
}
@media (hover: none) { .leaflet-tooltip-pane { display: none; } }

/* ── About Modal (Liam Cottle style) ── */
#aboutModal { display: none; position: fixed; z-index: 10000; inset: 0; }
#aboutModal-overlay { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.75); }
#aboutModal-content {
  position: relative; display: flex; width: 100%; height: 100%;
  overflow-y: auto; padding: 16px; box-sizing: border-box;
}
#aboutModal-card {
  margin: auto; width: 100%; max-width: 672px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 16px; position: relative;
  font-family: "Inter", sans-serif; font-size: 14px; color: #333;
  transform: translateY(40px); opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
#aboutModal.am-open #aboutModal-card { transform: translateY(0); opacity: 1; }
.am-close {
  position: absolute; top: 8px; right: 8px; cursor: pointer;
  background: #f3f4f6; border: none; border-radius: 50%;
  padding: 7px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; line-height: 1;
}
.am-close:hover { background: #e5e7eb; }
.am-close svg { width: 20px; height: 20px; display: block; }
.am-app-info { text-align: center; padding: 10px 40px 8px; }
.am-app-info img { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 6px; display: block; }
.am-app-info h1 { font-size: 18px; font-weight: bold; margin: 0 0 4px; }
.am-app-info p { font-size: 14px; margin: 0 0 10px; color: #555; }
.am-social-btns { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 4px; }
.am-social-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  color: #fff !important; transition: opacity 0.15s; text-decoration: none;
}
.am-social-btn:hover { opacity: 0.8; }
.am-section { margin-top: 12px; }
.am-section-title { font-weight: bold; margin-bottom: 6px; color: #111; }
.am-box {
  background: #f3f4f6; border: 1px solid #e5e7eb;
  border-radius: 6px; padding: 10px 12px; margin-bottom: 6px; line-height: 1.5;
}
.am-box-green { background: #dcfce7; border-color: #bbf7d0; }
.am-q { font-weight: 600; margin-bottom: 4px; }
.am-box ul { margin: 4px 0; padding-left: 20px; }
.am-box li { margin-bottom: 2px; }
#aboutModal a { color: #0a84ff; text-decoration: none; }
.am-dismiss { text-align: center; margin-top: 14px; }
.am-dismiss button {
  background: #e5e7eb; border: none; padding: 8px 28px; border-radius: 6px;
  font-family: "Inter", sans-serif; font-size: 14px; cursor: pointer;
  transition: background 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.am-dismiss button:hover { background: #d1d5db; }

/* ── Node Database Modal ── */
#nodeDbModal { display: none; position: fixed; z-index: 10001; inset: 0; }
#nodeDbModal-overlay { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.75); }
#nodeDbModal-content {
  position: relative; display: flex; width: 100%; height: 100%;
  overflow-y: auto; padding: 16px; box-sizing: border-box;
}
#nodeDbModal-card {
  margin: auto; width: 100%; max-width: 800px; max-height: 90vh;
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 16px; position: relative;
  font-family: "Inter", sans-serif; font-size: 14px; color: #333;
  transform: translateY(40px); opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
#nodeDbModal.nd-open #nodeDbModal-card { transform: translateY(0); opacity: 1; }
.nd-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-shrink: 0; padding-right: 36px; }
.nd-header h2 { margin: 0; font-size: 16px; font-weight: bold; }
.nd-search-box { flex: 1; position: relative; }
.nd-search-box input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-family: "Inter", sans-serif; outline: none; box-sizing: border-box;
}
.nd-search-box input:focus { border-color: #0a84ff; box-shadow: 0 0 0 2px rgba(10,132,255,0.15); }
.nd-search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.nd-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-shrink: 0; flex-wrap: wrap; align-items: center; }
.nd-filter-btn {
  padding: 4px 12px; border: 1px solid #d1d5db; border-radius: 16px;
  background: #fff; font-size: 12px; cursor: pointer;
  font-family: "Inter", sans-serif; transition: 0.15s;
}
.nd-filter-btn:hover { background: #f3f4f6; }
.nd-filter-btn.active { background: #0a84ff; color: #fff; border-color: #0a84ff; }
.nd-stats { font-size: 12px; color: #6b7280; margin-left: auto; }
.nd-list { flex: 1; overflow-y: auto; min-height: 0; }
.nd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.nd-table th {
  text-align: left; padding: 6px 8px; border-bottom: 2px solid #e5e7eb;
  font-weight: 600; color: #374151; position: sticky; top: 0; background: #fff; font-size: 12px;
}
.nd-table td { padding: 6px 8px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.nd-table tr:hover td { background: #f9fafb; }
.nd-table tr { cursor: pointer; }
.nd-badge { display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.nd-badge-on { background: #dcfce7; color: #166534; }
.nd-badge-off { background: #fee2e2; color: #991b1b; }
.nd-badge-dead { background: #e5e7eb; color: #111827; }
.nd-badge-nomap { background: #fef3c7; color: #92400e; }
.nd-load-more { text-align: center; padding: 10px; flex-shrink: 0; }
.nd-load-more button {
  padding: 6px 20px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; cursor: pointer; font-family: "Inter", sans-serif; font-size: 13px;
}
.nd-load-more button:hover { background: #f3f4f6; }

/* ── Responsive ── */
#meshnode-filter label { white-space: nowrap; }
@media (max-width: 600px) {
  .nd-hide-sm { display: none !important; }
  .nd-table { font-size: 12px; }
  .nd-table th, .nd-table td { padding: 5px 4px; }
}
@media (max-width: 500px) {
  #meshnode-filter { font-size: 11px !important; gap: 4px !important; }
}
@media (max-width: 480px) {
  .social-hide-sm { display: none !important; }
}
