/* -- Top nav ---------------------------------------------------------------- */
.topnav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-lg);
  color: var(--color-text);
}
.topnav .brand .mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--color-accent);
  display: inline-block;
}
.topnav .brand:hover { text-decoration: none; color: var(--color-text); }
.nav-links { display: flex; gap: var(--space-1); align-items: center; }
.nav-links a {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.nav-links a:hover { background: var(--color-surface-alt); text-decoration: none; }
.nav-links a.active { color: var(--color-accent); background: var(--color-accent-soft); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: var(--space-2); }
.nav-toggle svg { width: 22px; height: 22px; stroke: var(--color-text); }
.nav-right { display: flex; align-items: center; gap: var(--space-3); }
.nav-role-badge { font-size: var(--fs-xs); }

/* -- Admin role switcher (admin-only; lets one admin account view consumer/provider dashboards) -- */
.role-switcher { display: flex; gap: 2px; padding: 2px; background: var(--color-surface-alt); border-radius: var(--radius-sm); }
.role-switcher a { font-size: var(--fs-xs); font-weight: 600; color: var(--color-text-muted); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.role-switcher a:hover { text-decoration: none; color: var(--color-text); }
.role-switcher a.active { background: var(--color-surface); color: var(--color-accent); box-shadow: var(--shadow-card); }

/* -- Release notes timeline (admin) ------------------------------------------ */
.release-timeline { display: flex; flex-direction: column; }
.timeline-entry {
  display: grid;
  grid-template-columns: 96px 24px 1fr;
  column-gap: var(--space-3);
}
.timeline-entry:not(:last-child) { padding-bottom: var(--space-6); }
.timeline-date { text-align: right; padding-top: 3px; }
.timeline-rail { position: relative; display: flex; justify-content: center; }
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent);
  margin-top: 5px;
  z-index: 1;
}
.timeline-entry:not(:last-child) .timeline-rail::after {
  content: '';
  position: absolute;
  top: 15px;
  bottom: calc(-1 * var(--space-6));
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--color-border);
}

/* -- Notification bell + dropdown --------------------------------------------- */
.notif-bell { position: relative; }
.notif-bell-btn {
  position: relative;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.notif-bell-btn:hover { background: var(--color-surface); }
.notif-bell-btn svg { width: 18px; height: 18px; stroke: var(--color-text-muted); }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 8px;
  background: var(--color-danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-badge[hidden] { display: none; }
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  z-index: 60;
}
.notif-dropdown[hidden] { display: none; }
.notif-dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.notif-item { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item.is-unread { background: var(--color-accent-soft); }
.notif-item-title { font-size: var(--fs-sm); font-weight: 600; }
.notif-item-body { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.notif-item-time { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }

/* -- Agent downloads (provider Devices page header) --------------------------- */
.agent-downloads-panel { position: relative; }
.agent-downloads-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: 380px; max-height: 480px; overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  z-index: 60;
}
.agent-downloads-dropdown[hidden] { display: none; }
.agent-downloads-dropdown-header { padding: var(--space-3) var(--space-3) 0; }

/* -- Profile icon + dropdown ------------------------------------------------- */
.profile-menu { position: relative; }
.profile-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.profile-icon:hover { filter: brightness(1.08); }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: var(--space-2);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.profile-dropdown[hidden] { display: none; }
.profile-dropdown-header {
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-break: break-all;
}
.profile-dropdown a {
  color: var(--color-text);
  font-size: var(--fs-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.profile-dropdown a:hover { background: var(--color-surface-alt); text-decoration: none; }

@media (max-width: 767px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-2) var(--space-4) var(--space-4);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: var(--space-3); }
}

/* -- Dashboard grid layouts --------------------------------------------------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 768px) {
  .dash-grid-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
  .dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .dash-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.stat-tile .stat-label { font-size: var(--fs-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .stat-value { font-family: var(--font-display); font-size: var(--fs-2xl); margin-top: var(--space-1); }

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-header p { margin: 0; }
