:root {
  --bg: #14161c;
  --panel: #1c1f27;
  --panel-alt: #181a21;
  --sidebar-bg: #10121a;
  --border: #33384a;
  --text: #e9eefb;
  --muted: #9aa0b4;
  --accent: #00d1b2;
  --accent-2: #4258ff;
  --success: #48c78e;
  --danger: #f14668;
  --warning: #ffdd57;
  --radius: 10px;
  --sidebar-width: 254px;
  --sidebar-collapsed-width: 72px;
  --header-height: 90px;
}

/* ===== Top banner (adapted from nimiq-dashboard-api's header-3col) ===== */
.header-3col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-3col .header-left { min-width: 0; }
.header-3col .header-center { min-width: 0; overflow: hidden; }
.header-3col .header-right { min-width: 0; }
.header-left.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.header-left.brand > div { min-width: 0; }
.header-left .logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex-shrink: 0; }
#header-name.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(.85rem, 1.4vw, 1.15rem); line-height: 1.1; margin: 0 0 2px; letter-spacing: .01em; }
#header-address { margin: 0; font-size: .68rem; line-height: 1.25; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: normal; word-break: break-all; overflow: visible; }
.header-center { text-align: center; padding: 0 .5rem; }
.header-center .description.one-line {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: clamp(10px, 1.1vw, 13px);
  line-height: 1.25;
  color: var(--muted);
  font-weight: 500;
}
.header-right.params { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.header-right #fee-label { white-space: nowrap; font-size: 13px; color: var(--muted); }
.header-right #header-fee { color: var(--text); }
.header-right .sidebar-lang { margin-top: 0; padding-top: 0; border-top: none; position: relative; }
.header-right .lang-current { width: auto; }
.header-right .lang-menu { top: calc(100% + 6px); bottom: auto; left: auto; right: 0; min-width: 180px; }
@media (max-width: 900px) {
  .header-3col { grid-template-columns: auto 1fr auto; padding: 0 10px; gap: 8px; }
  .header-center { display: none; }
}
@media (max-width: 640px) {
  /* Not enough width for left (logo+title+full address) and right
     (API badge + fee + lang) side by side -- they overlapped. Stack
     into a single column instead, matching nimiq-dashboard-api's
     mobile header pattern. */
  .header-3col {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 8px;
    padding: 10px 12px;
    position: relative;
    top: auto;
  }
  .header-left.brand { flex-direction: column; text-align: center; }
  .header-right.params { flex-wrap: wrap; justify-content: center; }
  .header-right .lang-menu { left: 50%; right: auto; transform: translateX(-50%); }
  /* The header no longer has a fixed height once stacked -- decouple the
     drawer/toolbar sticky offsets from --header-height, same fix as
     nimiq-dashboard-api uses for its own mobile header. */
  .mobile-toolbar { top: 0; }
  .dashboard-sidebar { top: 0; height: 100dvh; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== Sidebar / app shell (adapted from the nimiq-dashboard-api pattern) ===== */
.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns .2s ease;
}

.dashboard-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 14px 10px;
  background: var(--sidebar-bg);
  color: var(--text);
  border-right: 1px solid var(--border);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-collapse, .mobile-menu-button, .lang-current {
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: inherit;
  border-radius: 9px;
  cursor: pointer;
}

.sidebar-collapse { width: 32px; height: 32px; font-size: 20px; line-height: 1; }

.sidebar-nav { display: grid; gap: 5px; }

.nav-item {
  display: grid;
  grid-template-columns: 32px minmax(0,1fr) auto;
  align-items: center;
  min-height: 42px;
  padding: 4px 9px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-item.active {
  color: #04211c;
  background: var(--accent);
}
.nav-icon { display: grid; place-items: center; width: 26px; height: 26px; font-size: 17px; }

.sidebar-lang {
  position: relative;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.lang-current {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 600;
}
.lang-flag { width: 20px; height: 14px; border-radius: 2px; overflow: hidden; display: inline-block; flex: 0 0 auto; }
.lang-flag svg { width: 100%; height: 100%; display: block; }
.lang-menu {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 40;
}
.lang-menu[hidden] { display: none; }
.lang-menu li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.lang-menu li:hover, .lang-menu li.active { background: rgba(255,255,255,.08); }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 8px 0;
  padding: 12px 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(72,199,142,.15);
  flex: 0 0 auto;
}

body.sidebar-collapsed .dashboard-shell { grid-template-columns: var(--sidebar-collapsed-width) minmax(0,1fr); }
body.sidebar-collapsed .sidebar-title, body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .sidebar-heading { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar-collapse { transform: rotate(180deg); }
body.sidebar-collapsed .nav-item { grid-template-columns: 1fr; padding-left: 8px; padding-right: 8px; }
body.sidebar-collapsed .nav-icon { margin: auto; }
body.sidebar-collapsed .sidebar-status { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .lang-current .nav-label { display: none; }

.dashboard-column { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.dashboard-column main { width: 100%; max-width: 1100px; margin: 0 auto; flex: 1; padding: 20px 24px 40px; }

.mobile-toolbar { display: none; }
.sidebar-backdrop { display: none; }

.page-header {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}
.brand { display: block; color: inherit; text-decoration: none; }
.brand:hover h1 { color: var(--accent); }
.brand h1 { margin: 0; font-size: 20px; transition: color .15s; }
.header-status { display: flex; align-items: center; gap: 10px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.badge-ok { color: var(--success); border-color: var(--success); }
.badge-error { color: var(--danger); border-color: var(--danger); }
.badge-unknown { color: var(--muted); }

h2 { font-size: 16px; margin: 0 0 12px 0; color: var(--text); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Overview: live banner */
.overview-live-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 13px;
}
.overview-live-banner > div { display: flex; flex-direction: column; gap: 2px; }
.overview-live-banner > div span:first-child { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.overview-live-primary { flex-direction: row !important; align-items: center; gap: 8px !important; }
.overview-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(72,199,142,.15); }
.overview-live-stale .overview-live-dot { background: var(--warning); box-shadow: 0 0 0 4px rgba(255,221,87,.15); }
.overview-live-unavailable .overview-live-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(241,70,104,.15); }

/* Overview: status cards */
.overview-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.overview-status-card { border-left: 3px solid var(--success); }
.overview-status-card.state-warning { border-left-color: var(--warning); }
.overview-facts { margin: 8px 0 0; display: grid; gap: 5px; }
.overview-facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.overview-facts dt { color: var(--muted); }
.overview-facts dd { margin: 0; font-weight: 600; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; background: var(--panel-alt); }
tr:last-child td { border-bottom: none; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.status-online { color: var(--success); font-weight: 600; }
.status-offline { color: var(--danger); font-weight: 600; }

.search-form { display: flex; gap: 8px; margin-bottom: 16px; max-width: 520px; }
.search-form input {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.search-form button {
  background: var(--accent);
  border: none;
  color: #04211c;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.search-form button:hover { opacity: .9; }

.empty-state { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* News */
.news-card { display: flex; flex-direction: column; gap: 6px; }
.news-title { font-size: 15px; line-height: 1.3; }
.news-summary { line-height: 1.4; }
.news-link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 700; margin-top: 4px; }
.news-link:hover { text-decoration: underline; }

/* Roadmap */
.roadmap-group { margin-bottom: 20px; }
.roadmap-section-title { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }
.roadmap-card .value { font-size: 15px; }

/* Finances chart */
.chart-wrap { padding: 16px; overflow-x: auto; }
.chart-title { margin: 0 0 8px; }
.finances-svg { width: 100%; height: auto; min-width: 560px; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 10px; }
.chart-line { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--accent); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend-col { flex-direction: column; gap: 8px; }

.finances-donut-layout { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.finances-donut { width: 180px; height: 180px; flex: 0 0 auto; }

/* Status */
.status-level { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status-level-ok { color: var(--success); background: rgba(72,199,142,.12); }
.status-level-warning { color: var(--warning); background: rgba(255,221,87,.12); }
.status-level-critical { color: var(--danger); background: rgba(241,70,104,.12); }
.status-level-unknown { color: var(--muted); background: rgba(154,160,180,.12); }

/* Wallet-signature login + export */
.login-box {
  max-width: 560px;
  margin-top: 24px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-box h3 { margin: 0 0 6px; font-size: 14px; }
.login-box .search-form { max-width: none; }
.login-message {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0 12px;
}
.login-success { color: var(--success); font-weight: 600; margin: 4px 0 10px; }
.login-export-link {
  display: inline-block;
  background: var(--accent);
  color: #04211c;
  padding: 9px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}
.login-export-link:hover { opacity: .9; }

.card .value .fig[title] { border-bottom: 1px dotted currentColor; cursor: help; }

.dashboard-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .45rem;
  min-height: 64px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.footer-heart { color: #e11d48; }
.footer-separator { color: #11507a; font-weight: 900; }
.footer-author-and { color: #11507a; font-weight: 900; margin: 0 -.1em; }
.footer-author-claude { display: inline-flex; align-items: center; gap: .28em; font-weight: 900; color: #D97757; }
.footer-claude-logo { display: block; width: 14px; height: 14px; max-width: 14px; max-height: 14px; flex: 0 0 auto; transform-origin: 50% 50%; animation: footer-claude-pulse 1.6s ease-in-out infinite !important; }
@keyframes footer-claude-pulse { 0%,100% { transform: scale(0.82); } 50% { transform: scale(1.18); } }
.footer-author-fr {
  display: inline-block;
  font-weight: 900;
  letter-spacing: .015em;
  background: linear-gradient(90deg, #0055a4 0 33.333%, #ffffff 33.333% 66.666%, #ef4135 66.666% 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 1px rgba(12,18,38,.72));
}
.footer-discord-link { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 38px; padding: 5px; border: 0; border-radius: 8px; color: inherit; background: transparent; text-decoration: none; box-shadow: none; transition: transform .15s ease, opacity .15s ease; }
.footer-discord-link:hover { transform: translateY(-1px) scale(1.04); opacity: .88; box-shadow: none; }
.footer-discord-link img { display: block; width: 28px; height: 28px; max-width: 28px; object-fit: contain; }
.footer-discord-fallback { font-weight: 800; letter-spacing: .01em; }

@media (max-width: 900px) {
  .dashboard-footer { flex-direction: column; gap: .3rem; padding: 18px 12px; }
  .footer-separator { display: none; }
  .footer-discord-link { min-height: 44px; padding: 8px 14px; }
  .footer-discord-link img { width: 30px; height: 30px; max-width: 30px; }
}

@media (max-width: 900px) {
  .dashboard-shell { display: block; min-height: 100vh; }
  .dashboard-sidebar {
    position: fixed;
    top: var(--header-height); left: 0;
    height: calc(100dvh - var(--header-height));
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 12px 0 30px rgba(0,0,0,.4);
    z-index: 50;
  }
  body.sidebar-mobile-open .dashboard-sidebar { transform: translateX(0); }
  .sidebar-collapse { display: none; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 45;
    width: 100%; height: 100%; border: 0;
    background: rgba(0,0,0,.48);
  }
  body.sidebar-mobile-open .sidebar-backdrop { display: block; }
  .mobile-toolbar {
    position: sticky; top: var(--header-height); z-index: 20;
    display: grid;
    grid-template-columns: 44px minmax(0,1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .mobile-menu-button { width: 40px; height: 40px; font-size: 18px; }
  .mobile-live { display: flex; align-items: center; gap: 8px; color: var(--success); font-size: 12px; font-weight: 700; }
  body.sidebar-collapsed .sidebar-title, body.sidebar-collapsed .nav-label { display: initial; }
  body.sidebar-collapsed .nav-item { grid-template-columns: 32px minmax(0,1fr) auto; }
  .page-header { display: none; }
  .dashboard-column main { padding: 16px; }
}

@media (max-width: 640px) {
  .card { padding: 12px; }
  .table-wrap table { min-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
