/* =========================================================================
   NMC EXPLORER — DESIGN SYSTEM
   Matches the official Namecoin logo: Namecoin blue, clean sans type,
   light-first, soft but defined. Theme via [data-theme] on <html>.
   ========================================================================= */

/* ---------- tokens ---------- */
/* LIGHT is the default state. */
:root, html[data-theme="light"] {
  --c-bg: #ffffff;
  --c-bg-soft: #f4f6fa;
  --c-panel: #ffffff;
  --c-panel-2: #eef2f8;
  --c-ink: #1a2332;
  --c-ink-2: #43506a;
  --c-muted: #6b7688;
  --c-line: #e1e6ef;
  --c-line-strong: #c9d2e0;
  --c-accent: #3a6ea5;          /* Namecoin blue */
  --c-accent-2: #235a8f;
  --c-accent-soft: #dbe7f4;
  --c-chrome: #ffffff;
  --c-hover: #eef2f8;
  --shadow: 0 1px 2px rgba(26,35,50,.06), 0 4px 12px rgba(26,35,50,.05);
  --shadow-hover: 0 2px 6px rgba(26,35,50,.12), 0 8px 24px rgba(26,35,50,.08);
  --c-red: #c0392b;
  --c-green: #1e8449;
  --c-yellow: #b7791f;
  --c-purple: #6c23c9;
  --c-cyan: #0a7a73;
  --c-blue: #3a6ea5;
  --c-gray: #6b7688;
}

html[data-theme="dark"] {
  --c-bg: #0f1622;
  --c-bg-soft: #141d2b;
  --c-panel: #16203a;
  --c-panel-2: #1c2940;
  --c-ink: #e6ecf5;
  --c-ink-2: #b8c4d8;
  --c-muted: #8b97ad;
  --c-line: #263349;
  --c-line-strong: #37486b;
  --c-accent: #7ba7d6;          /* lighter Namecoin blue for dark bg */
  --c-accent-strong: #9dc0e4;
  --c-accent-soft: #1e2e4a;
  --c-chrome: #16203a;
  --c-hover: #1e2b40;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.25);
  --shadow-hover: 0 2px 6px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  --c-red: #e0656a;
  --c-green: #43c27b;
  --c-yellow: #e0b04d;
  --c-purple: #b585ff;
  --c-cyan: #4dd6d0;
  --c-blue: #5ba1d6;
  --c-gray: #93a0b5;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3 { font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif; font-weight: 700; }
h2 { letter-spacing: .02em; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { color: var(--c-accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* soft, simple edges */
* { box-shadow: none; }
.panel,.stat,.btn,.search input,.filterbar select,.filterbar input,.value { border-radius: 8px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; border-right: 1px solid var(--c-line);
  background: var(--c-bg); padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display:flex; flex-direction:column;
}
.brand { display: block; margin: 4px 0 14px; padding: 0 6px; }
.brand .dot { color: var(--c-accent); }
.brand svg { height: 40px; width: auto; display: block; }
/* official Namecoin logo lockup */
.logo { display: block; }
.logo svg { width: 170px; height: auto; display: block; }
.logo-sub { font-size: 10px; color: var(--c-muted); letter-spacing: .04em; margin-top: 2px; }

.nav { display:flex; flex-direction:column; margin-top: 8px; }
.nav a {
  display: flex; align-items:center; gap: 12px; padding: 12px 12px;
  border-radius: 0; border-bottom: 1px solid var(--c-line);
  color: var(--c-ink-2); font-size: 14px; font-weight: 500;
  text-decoration:none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--c-hover); color: var(--c-ink); }
.nav a.active { background: var(--c-hover); color: var(--c-ink); font-weight: 700; border-left: 3px solid var(--c-accent); }
.nav-ico { flex-shrink: 0; color: var(--c-accent); opacity: .9; }
.nav a.active .nav-ico { color: var(--c-accent-2); }
.status-box { margin-top:auto; border-top: 1px solid var(--c-line); padding: 14px 8px 0; font-size: 11px; }
.status-box .row { display:flex; justify-content:space-between; gap:8px; padding:4px 0; }
.status-box .k { color: var(--c-muted); font-size: 11px; text-transform: uppercase; letter-spacing:.05em; align-self:center; }
.status-box .v { color: var(--c-ink-2); font-weight:600; font-family: var(--mono, ui-monospace, monospace); font-size: 11px; }

.main { flex:1; min-width:0; padding: 24px 28px 40px; }
.topbar { display:flex; align-items:baseline; gap:14px; flex-wrap:wrap; margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--c-line); min-width:0; }
.topbar h1 { margin:0; font-size: 28px; font-weight: 750; color: var(--c-ink); letter-spacing:-.01em; overflow-wrap: anywhere; word-break: break-word; min-width:0; max-width:100%; }
.topbar h1 .nav-ico { width: 22px; height: 22px; color: var(--c-accent); margin-right: 8px; vertical-align: -3px; opacity:.9; }
.topbar .crumb { color: var(--c-muted); font-size: 13px; }
.topbar a.crumb { color: var(--c-accent); }

/* search */
.search { position:relative; max-width: 480px; margin-bottom: 18px; }
.search input {
  width:100%; background: var(--c-panel); color:var(--c-ink);
  border: 1.5px solid var(--c-line-strong); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; outline:none; font-family:inherit;
  box-shadow: var(--shadow); transition: border-color .12s;
}
.search input:focus { border-color: var(--c-accent); }
.search-results { position:absolute; top:100%; left:0; right:0; margin-top:6px; background:var(--c-panel); border:1px solid var(--c-line); border-radius:8px; max-height:320px; overflow:auto; z-index:60; box-shadow: var(--shadow-hover); }
.search-results a { display:block; padding:8px 12px; color:var(--c-ink); border-bottom:1px solid var(--c-line); }
.search-results a:hover { background:var(--c-hover); text-decoration:none; }
.search-results .empty { color:var(--c-muted); padding:10px 12px; }

/* ---------- panels & grid ---------- */
.panel { background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 10px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); }
.stat { background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.stat .nav-ico { width: 20px; height: 20px; color: var(--c-accent); margin-bottom: 6px; opacity:.9; }
.stat .n { font-size: 26px; font-weight: 750; color: var(--c-accent); line-height:1.05; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--c-muted); text-transform: uppercase; letter-spacing:.06em; margin-top: 6px; text-align:left; }
.panel h2 .nav-ico { width: 15px; height: 15px; color: var(--c-accent); margin-right: 6px; vertical-align: -2px; opacity:.85; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; font-weight: 600; color: var(--c-muted); padding: 8px 10px; border-bottom: 1px solid var(--c-line-strong); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--c-line); }
tr:hover td { background: var(--c-hover); }
td.mono { font-size: 12px; }
th a { color: inherit; }

/* ---------- badges / pills ---------- */
.pill { display:inline-block; padding: 2px 9px; font-size: 10px; font-weight:650; letter-spacing:.04em; text-transform: uppercase; border-radius: 999px; border: 1px solid transparent; }
.pill.green { color: var(--c-green); background: color-mix(in srgb, var(--c-green) 12%, transparent); border-color: color-mix(in srgb, var(--c-green) 30%, transparent); }
.pill.red { color: var(--c-red); background: color-mix(in srgb, var(--c-red) 12%, transparent); border-color: color-mix(in srgb, var(--c-red) 30%, transparent); }
.pill.yellow { color: var(--c-yellow); background: color-mix(in srgb, var(--c-yellow) 12%, transparent); border-color: color-mix(in srgb, var(--c-yellow) 30%, transparent); }
.pill.purple { color: var(--c-purple); background: color-mix(in srgb, var(--c-purple) 12%, transparent); border-color: color-mix(in srgb, var(--c-purple) 30%, transparent); }
.pill.cyan { color: var(--c-cyan); background: color-mix(in srgb, var(--c-cyan) 12%, transparent); border-color: color-mix(in srgb, var(--c-cyan) 30%, transparent); }
.pill.blue { color: var(--c-accent); background: var(--c-accent-soft); border-color: color-mix(in srgb, var(--c-accent) 30%, transparent); }
.pill.gray { color: var(--c-muted); background: color-mix(in srgb, var(--c-muted) 12%, transparent); border-color: color-mix(in srgb, var(--c-muted) 30%, transparent); }

/* ---------- misc ---------- */
.value { background: var(--c-bg-soft); border: 1px solid var(--c-line); border-radius: 8px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--c-ink); max-height: 320px; overflow: auto; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 20px; font-size: 13px; }
.dl dt { color: var(--c-muted); text-transform: uppercase; font-size: 10.5px; letter-spacing:.04em; white-space: nowrap; align-self:center; }
.dl dd { margin: 0; word-break: break-all; }
.timeline { border-left: 2px solid var(--c-line-strong); margin-left: 6px; padding-left: 18px; }
.tl-item { position: relative; padding: 9px 0; }
.tl-item::before { content:''; position:absolute; left:-26px; top:17px; width:9px; height:9px; border-radius:50%; background: var(--c-accent); }
.tl-item .tl-meta { font-size: 11.5px; color: var(--c-muted); }
.error { background: color-mix(in srgb, var(--c-red) 8%, transparent); border: 1px solid color-mix(in srgb, var(--c-red) 40%, transparent); color: var(--c-red); padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; font-weight:560; }
.pager { display:flex; gap: 12px; margin-top: 14px; align-items:center; font-size: 13px; }
.btn { background: var(--c-accent); color: #fff; border: 1px solid var(--c-accent-strong, var(--c-accent)); border-radius: 8px; padding: 7px 14px; font-size: 12px; font-weight:600; cursor: pointer; transition: background .12s; }
.btn:hover { background: var(--c-accent-2); color: #fff; }
.filterbar { display:flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filterbar select, .filterbar input { background: var(--c-panel); color: var(--c-ink); border: 1.5px solid var(--c-line-strong); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; font-family: inherit; }
footer { text-align: center; color: var(--c-muted); font-size: 11.5px; padding: 22px 0 10px; border-top: 1px solid var(--c-line); margin-top: 36px; }
.empty { padding: 34px; text-align: center; color: var(--c-muted); }
.muted { color: var(--c-muted); }
.dim { color: var(--c-muted); }

/* theme toggle (mobile app bar uses .mh-btn; desktop float if used) */
.theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 100; }
.theme-toggle button, .theme-toggle .mh-btn {
  background: var(--c-panel); color: var(--c-accent); border: 1px solid var(--c-line-strong); border-radius: 8px;
  box-shadow: var(--shadow); width: 44px; height: 44px; font-size: 18px; cursor:pointer;
}
.theme-toggle button:hover { border-color: var(--c-accent); }

/* =========================================================================
   MOBILE / RESPONSIVE
   ========================================================================= */
/* mobile hamburger (hidden on desktop) */
.mobile-toggle { display: none; }

/* =========================================================================
   MOBILE APP BAR (top header) — mobile only
   A standard mobile app-header: full-width bar, left menu btn, centered
   title, right theme btn, all integrated in one element. + default close X.
   ========================================================================= */
.mobile-header {
  display: none;  /* hidden on desktop */
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 200;
  background: var(--c-bg);
  border-bottom: 2px solid var(--c-line);
  align-items: center;
  padding: 0 6px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.mobile-header .mh-btn {
  flex: 0 0 auto; width: 44px; height: 44px;
  background: transparent; color: var(--c-ink); border: 0;
  font-size: 24px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mobile-header .mh-btn:hover { background: var(--c-hover); }
.mobile-header .mh-title {
  flex: 1; text-align: center;
  display: flex; align-items: center; justify-content: center;
  margin: 0 4px; min-width: 0; overflow: hidden; text-decoration: none;
}
.mobile-header .mh-title .logo { align-items: center; }
.mobile-header .mh-title .logo svg { width: 150px; height: auto; }
.mobile-header .mh-title .logo-sub { font-size: 8px; margin-top: 1px; letter-spacing: .1em; }
.mobile-header .mh-title:hover { background: none; }

/* hide the old floating theme toggle on mobile (now inside app bar) */
.theme-toggle { display: none; }

/* drawer close button - desktop hidden, shown in mobile drawer */
.drawer-close { display: none; }
.drawer-close button {
  width: 40px; height: 40px; background: transparent; color: var(--c-ink);
  border: 2px solid var(--c-line); font-size: 18px; cursor: pointer;
}
.drawer-close button:hover { background: var(--c-hover); }

/* under 900px: collapsible drawer + app bar */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .shell { display: block; max-width: 100vw; overflow: hidden; }
  /* app bar + hide floating legacy buttons */
  .mobile-header { display: flex; }
  .main { padding: 60px 14px 40px; max-width: 100%; overflow: hidden; }
  /* drawer sidebar - fills the full viewport (no inner scroll) */
  .sidebar {
    position: fixed; inset: 0; width: 100%; z-index: 300;
    transform: translateX(-100%); transition: transform .2s ease;
    background: var(--c-bg);
    padding: 56px 16px 20px;   /* top padding clears the 52px app bar */
    display: flex; flex-direction: column;
    overflow-y: auto;          /* full-viewport drawer can still scroll if content is long */
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display:none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 290; }
  .sidebar-backdrop.show { display: block; }
  /* drawer close X at top-left of the drawer */
  .drawer-close { display:flex; justify-content:flex-end; margin-bottom: 6px; }

  /* drawer content: clean native nav list */
  .sidebar .brand {
    font-size: 20px; display: block; box-shadow: none; border: 0;
    background: transparent; padding: 0; margin: 4px 0 2px;
  }
  .sidebar .nav { gap: 2px; }
  .sidebar .nav a {
    border: 0; border-bottom: 1px solid var(--c-line);
    margin: 0; padding: 13px 6px; font-size: 14px; width: 100%;
    border-radius: 0; color: var(--c-ink-2);
  }
  .sidebar .nav a.active {
    background: var(--c-hover); box-shadow: none; font-weight: 700; color: var(--c-ink);
  }
  .sidebar .nav a:hover { background: var(--c-hover); }
  .sidebar .status-box {
    margin-top: auto; border: 0; border-top: 1px solid var(--c-line);
    background: transparent; box-shadow: none; padding: 8px 0 0;
  }

  /* tables scroll horizontally inside their wrap */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  table { min-width: 480px; }
  /* keep the detail dl quiet - never overflow */
  .dl { grid-template-columns: 1fr; gap: 3px 0; min-width: 0; }
  .dl dd { overflow-wrap: anywhere; word-break: break-word; }
  .dl dt { text-transform: uppercase; margin-top: 6px; }
  /* grid children must not force overflow */
  .grid { grid-template-columns: 1fr !important; }
  .grid > * { min-width: 0; }
  .panel { max-width: 100%; overflow-wrap: anywhere; }
  .stat { max-width: 100%; min-width: 0; }
  .stat .n { font-size: 22px; overflow-wrap: anywhere; }
  .topbar { gap: 6px; }
  .topbar h1 { font-size: 22px; }
  .brand { font-size: 18px; }
}

/* very small phones */
@media (max-width: 480px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar .crumb { display: none; }
  .search { max-width: 100%; }
  body { font-size: 12px; }
}

/* =========================================================================
   GLOBAL OVERFLOW GUARD & TABLE SCROLL (all sizes)
   Prevents wide tables/panels from spilling the viewport at ANY width.
   ========================================================================= */
html, body { overflow-x: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
/* prevent grid/panel children from forcing overflow anywhere */
.grid, .grid > * { min-width: 0; }
.panel { max-width: 100%; overflow-wrap: anywhere; }
.dl { overflow-wrap: anywhere; }