:root {
  --bg: #050505;
  --panel: #121212;
  --line: #2b2b2b;
  --text: #f5efe8;
  --muted: #a7a29b;
  --accent: #d97706;
  --accent-soft: rgba(217,119,6,0.16);
  --accent-strong: #ff9f43;
  --success: #4d4a46;
  --danger: #b65b3a;
}

* {
  box-sizing: border-box;
}

.staging-banner {
    position: sticky;
    top: 0;
    z-index: 9999;

    width: 100%;
    padding: 10px 20px;

    background: #ff9800;
    color: #222;

    font-weight: bold;
    font-size: 15px;
    text-align: center;

    border-bottom: 2px solid #d97b00;

    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.staging-banner span {
    font-weight: normal;
    margin-left: 10px;
    opacity: 0.9;
}


html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 20% 0, rgba(20, 20, 20, 0.78), rgba(5, 5, 5, 0.9) 55%),
    url("core/background.png") center/cover fixed no-repeat;
  color: var(--text);
  font: 15px/1.5 system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font: inherit;
}

button {
  background: #1a1a1a;
  color: var(--text);
  border: 1px solid #333333;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: #b85e00;
  color: #140d06;
}

button.danger {
  background: var(--danger);
  border-color: #cf704e;
}

main {
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px;
}

.card {
  display: block;
  width: 100%;
  background: linear-gradient(145deg, rgba(30, 30, 30, 0.6), rgba(12, 12, 12, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: 0 12px 35px rgba(0, 0, 0, .28);
}

.login {
  max-width: 420px;
  margin: 10vh auto;
}

.login form,
.card form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input, select {
  width: 100%;
  padding: 10px 12px;
  background: #0b0b0b;
  color: var(--text);
  border: 1px solid #3a3a3a;
  border-radius: 8px;
}

.title-row,
.peer-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.title-row {
  margin-bottom: 24px;
}

h1, h2, h3, p {
  margin-top: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tabs a {
  padding: 9px 14px;
  border-radius: 9px;
  color: var(--muted);
}

.tabs .active {
  background: #232323;
  color: white;
}

.portfolio-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 18px;
}

.portfolio-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}

.portfolio-chip:hover {
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.portfolio-chip.active {
  border-color: #b85e00;
  background: rgba(217, 119, 6, 0.22);
  color: #ffe1bf;
}

.chip-count {
  font-size: 12px;
  line-height: 1;
  min-width: 22px;
  text-align: center;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  color: #e9e4dc;
}

.peer-grid,
.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  min-width: 0;
}

.peer-card {
  display: block;
  min-width: 0;
  transition: .15s;
}

.peer-card:hover {
  border-color: var(--accent-strong);
  transform: translateY(-2px);
}

.badge,
.tag {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 99px;
  background: #2b241f;
}

.badge.online,
.badge.approved {
  background: #1f4d3b;
  color: #8be0bb;
}

.badge.warning,
.badge.pending {
  background: #45331f;
  color: #ffb96d;
}

.badge.offline,
.badge.rejected {
  background: #4c2834;
  color: #ff9aa4;
}

.metrics {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.metrics span {
  color: var(--muted);
  display: grid;
}

.metrics b {
  color: var(--text);
  font-size: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

dt {
  color: var(--muted);
}

dd {
  text-align: right;
}

.endpoint img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
}

.live-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.live-timer {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
}

.live-grid {
  display: block;
  width: 100%;
}

.live-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.live-controls label {
  display: grid;
  gap: 6px;
}

.live-panel {
  min-height: 320px;
}

.live-panel-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--muted);
}

.live-frame-shell {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(145deg, #111111, #060606);
  border: 1px solid rgba(255,255,255,0.06);
  min-height: 400px;
  display: grid;
  place-items: center;
}

.live-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #060606;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #647087;
}

.dot.up {
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.dot.down {
  background: var(--red);
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.change-list {
  display: grid;
  gap: 14px;
}

.change-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 18px;
}

.change-card {
  border-left: 4px solid transparent;
  padding: 14px;
}

.change-card.change-pending {
  border-left-color: rgba(255, 185, 109, 0.65);
}

.change-card.change-approved {
  border-left-color: rgba(139, 224, 187, 0.65);
}

.change-card.change-rejected {
  border-left-color: rgba(255, 154, 164, 0.65);
}

.change-head p {
  margin: 4px 0 0;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.change-head h2 {
  margin-bottom: 2px;
  font-size: 18px;
  line-height: 1.2;
}

.change-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.change-meta b {
  color: var(--text);
  font-weight: 600;
  margin-right: 6px;
}

.change-diff-panel {
  margin-top: 8px;
}

.change-diff-panel > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  user-select: none;
}

.change-diff-panel > summary:hover {
  color: var(--text);
}

.change-diff-panel[open] > summary {
  margin-bottom: 10px;
}

.change-diff-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}

.change-diff {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.change-diff th,
.change-diff td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: top;
  font-size: 13px;
}

.change-diff th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.change-value {
  display: inline-flex;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  word-break: break-word;
  line-height: 1.3;
}

.change-value.old {
  background: rgba(180, 91, 58, 0.12);
  border-color: rgba(180, 91, 58, 0.22);
}

.change-value.new {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.22);
}

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

.router-overview-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.router-overview-title {
  margin: 0 0 6px;
  line-height: 1.2;
}

.router-overview-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.router-overview-head-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.router-overview-table-wrap {
  overflow-x: auto;
}

.router-overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.router-overview-table th,
.router-overview-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.router-overview-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.router-signal-metrics {
  margin-top: 6px;
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.router-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 240px;
}

.router-actions button,
.router-actions a {
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12px;
}

.router-overview-empty {
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.router-overview-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.endpoint {
  border: 1px solid rgba(255,255,255,0.08);
}

.endpoint.endpoint-up {
  border-color: rgba(34, 197, 94, 0.28);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.08);
}

.endpoint.endpoint-down {
  border-color: rgba(255, 99, 132, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 99, 132, 0.08);
}

.endpoint.endpoint-unknown {
  border-color: rgba(255, 255, 255, 0.10);
}

.endpoint-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.state-up {
  background: rgba(34, 197, 94, 0.16);
  color: #8be0bb;
}

.state-down {
  background: rgba(255, 99, 132, 0.16);
  color: #ff9aa4;
}

.state-unknown {
  background: rgba(255,255,255,0.08);
  color: var(--muted);
}

.endpoint-summary {
  margin-bottom: 6px;
}

.endpoint-check-label {
  display: block;
  color: var(--muted);
}

/* ── User management ── */
.user-mgmt-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.user-table th,
.user-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.user-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.user-table .row-inactive td {
  opacity: 0.5;
}

.user-actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form {
  display: inline;
}

.small-btn {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
}

.user-create-form {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.portfolio-summary {
  display: grid;
  gap: 8px;
}

.portfolio-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.portfolio-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(217, 119, 6, 0.16);
  border: 1px solid rgba(217, 119, 6, 0.28);
  color: #ffd9ad;
  font-size: 12px;
  line-height: 1.2;
}

.portfolio-empty,
.portfolio-helper {
  color: var(--muted);
}

.portfolio-edit-trigger {
  justify-self: start;
}

.portfolio-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  max-height: 320px;
  overflow: auto;
}

.portfolio-checklist-create {
  max-height: 240px;
}

.portfolio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 12, 0.7);
  color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}

.portfolio-option:hover {
  border-color: rgba(217, 119, 6, 0.34);
  background: rgba(217, 119, 6, 0.08);
}

.portfolio-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.portfolio-option span {
  min-width: 0;
}

@media (max-width: 900px) {
  .user-mgmt-grid {
    grid-template-columns: 1fr;
  }
}

pre {
  white-space: pre-wrap;
  color: #b9c8e2;
}

.flash {
  padding: 13px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-left-width: 5px;
  background: #1d1d1d;
  color: #f8fbff;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.flash.error {
  background: #3b1712;
  border-color: #e36a55;
  border-left-color: #ff7d66;
  color: #fff2ef;
}

.flash.success {
  background: #163123;
  border-color: #44b27d;
  border-left-color: #5fe19b;
  color: #edfff4;
}

.flash.warning {
  background: #3a2a0f;
  border-color: #d2a24a;
  border-left-color: #ffc766;
  color: #fff7e8;
}

.flash.info {
  background: #112b3a;
  border-color: #4ba6d2;
  border-left-color: #70c7f0;
  color: #ecf8ff;
}

.flash.danger {
  background: #3b1712;
  border-color: #e36a55;
  border-left-color: #ff7d66;
  color: #fff2ef;
}

.back {
  display: inline-block;
  color: var(--muted);
  margin-bottom: 18px;
}

small {
  color: var(--muted);
}

.peer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
}

.peer-filters input,
.peer-filters select,
.peer-filters button,
.peer-filters .refresh-status {
  min-width: 0;
}

.peer-filters input,
.peer-filters select {
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1a0e00;
  color: var(--text);
}

.peer-filters input:focus,
.peer-filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.peer-filters input {
  flex: 2 1 320px;
  min-width: 220px;
}

.peer-filters select {
  flex: 1 1 180px;
  max-width: 260px;
}

.peer-filters button {
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.peer-filters .refresh-status {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.95rem;
}

.reports-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.reports-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.reports-tabs a.active,
.reports-tabs a:hover {
  background: var(--accent-soft);
  color: var(--text);
  border-color: rgba(225,146,75,.28);
}

.report-panel {
  display: none;
}

.report-panel.active {
  display: block;
}

.report-card table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.report-card th,
.report-card td {
  text-align: left;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.report-card th {
  color: var(--muted);
  font-weight: 600;
}

.report-card td a {
  color: var(--text);
}

.reports-page {
  display: grid;
  gap: 18px;
}

.report-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.report-metric-card {
  background: linear-gradient(145deg, #161616, #101010);
  border: 1px solid rgba(255,255,255,0.07);
  border-left: 4px solid rgba(217,119,6,0.55);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 35px rgba(0,0,0,.22);
  display: grid;
  gap: 8px;
}

.report-metric-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-metric-card strong {
  font-size: 30px;
  line-height: 1;
  color: var(--text);
}

.report-metric-card small {
  line-height: 1.35;
}

.report-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.report-panel-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.report-panel-count {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.07);
  font-size: 13px;
  font-weight: 600;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.report-table thead th {
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-table th,
.report-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: middle;
}

.report-table tbody tr:nth-child(odd) td {
  background: rgba(255,255,255,0.015);
}

.report-table tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.metric-pill.neutral {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
  color: var(--text);
}

.metric-pill.online,
.metric-pill.success {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.22);
  color: #8be0bb;
}

.metric-pill.offline,
.metric-pill.danger {
  background: rgba(255, 99, 132, 0.14);
  border-color: rgba(255, 99, 132, 0.22);
  color: #ff9aa4;
}

.metric-pill.warning,
.metric-pill.pending {
  background: rgba(255, 185, 109, 0.14);
  border-color: rgba(255, 185, 109, 0.22);
  color: #ffcf9b;
}

.report-panel .card,
.report-panel {
  backdrop-filter: blur(2px);
}

.report-panel p {
  margin-bottom: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.app-shell.collapsed {
  grid-template-columns: 80px 1fr;
}

.app-shell.no-sidebar {
  grid-template-columns: 1fr;
}

.sidebar {
  background: rgba(8,8,8,.96);
  border-right: 1px solid rgba(255,159,67,.16);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width .3s ease, min-width .3s ease;
  width: 280px;
  min-width: 280px;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 80px;
  min-width: 80px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 20px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  overflow: hidden;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  opacity: 1;
  transition: opacity .2s ease;
}

.sidebar.collapsed .brand-name {
  opacity: 0;
}

.sidebar-toggle {
  border: none;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: rgba(225,146,75,.14);
}

.sidebar-toggle-icon {
  width: 20px;
  height: 20px;
  display: block;
  filter: invert(100%) sepia(20%) saturate(400%) hue-rotate(10deg) brightness(1.1);
  box-shadow: 0 0 0 1px rgba(225,146,75,0.24);
  border-radius: 5px;
  padding: 2px;
  background: rgba(255,255,255,0.08);
}

.sidebar-toggle-top {
  margin-right: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  color: var(--muted);
  transition: background .2s ease, color .2s ease;
}

.sidebar-nav .nav-icon {
  width: 20px;
  height: 20px;
  filter: invert(100%) sepia(20%) saturate(400%) hue-rotate(10deg) brightness(1.1);
  box-shadow: 0 0 0 1px rgba(225,146,75,0.24);
  border-radius: 5px;
  padding: 2px;
  background: rgba(255,255,255,0.08);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--text);
}

.sidebar-nav a.nav-with-badge {
  position: relative;
}

.nav-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ff9f43;
  color: #050505;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
}

.nav-badge.nav-badge-dept {
  top: 6px;
  right: 6px;
  background: #2f7df7;
  color: #f3f8ff;
}

.nav-badge.nav-badge-user {
  top: 28px;
  right: 6px;
  background: #8a4df0;
  color: #f9f2ff;
}

.sidebar.collapsed .label {
  display: none;
}

.app-main {
  display: flex;
  flex-direction: column;
  background: transparent;
  min-width: 0;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(217,119,6,.18);
  position: sticky;
  top: 0;
  background: rgba(8,8,8,.94);
  z-index: 1;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-name {
  color: var(--text);
  font-weight: 600;
}

.text-button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
}

.text-button.active {
  border-color: rgba(217,119,6,.5);
  background: var(--accent-soft);
}

@media (min-width: 1600px) {
  main {
    padding-left: 36px;
    padding-right: 36px;
  }
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  background: #111111;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.42);
}

.portfolio-modal-card {
  max-width: 720px;
}

.portfolio-modal-form {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.snapshot-modal {
  z-index: 70;
}

.snapshot-modal-card {
  width: min(92vw, 1200px);
  max-height: 90vh;
  background: linear-gradient(145deg, rgba(20, 20, 20, 0.94), rgba(10, 10, 10, 0.9));
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.snapshot-modal-head,
.snapshot-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.snapshot-modal-actions {
  justify-content: flex-end;
  border-bottom: none;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.snapshot-modal-head h3 {
  margin: 0;
}

.snapshot-modal-body {
  padding: 10px;
  overflow: auto;
  display: grid;
  place-items: center;
}

.snapshot-modal-body img {
  width: 100%;
  height: auto;
  max-height: calc(90vh - 130px);
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.38);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 70px 1fr;
  }
  .sidebar {
    width: 70px;
    min-width: 70px;
  }
  .sidebar.collapsed {
    width: 70px;
    min-width: 70px;
  }
  .sidebar-brand {
    justify-content: center;
    padding: 20px 12px;
  }
  .sidebar-nav a {
    justify-content: center;
    padding: 14px 12px;
  }
  .sidebar-toggle {
    display: none;
  }
  .app-main {
    padding-top: 0;
  }
  main {
    padding: 24px 18px;
  }
  .peer-filters input,
  .peer-filters select,
  .peer-filters button,
  .peer-filters .refresh-status {
    flex: 1 1 100%;
  }
  .change-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .report-metrics {
    grid-template-columns: 1fr;
  }
  .report-panel-head {
    flex-direction: column;
  }
  .router-overview-head {
    flex-direction: column;
    align-items: stretch;
  }
  .router-overview-head-actions {
    width: 100%;
  }
  .router-overview-head-actions .primary,
  .router-overview-head-actions .text-button {
    flex: 1 1 auto;
    text-align: center;
  }
  .router-overview-table th,
  .router-overview-table td {
    padding: 7px 6px;
    font-size: 12px;
  }
  .router-actions {
    min-width: 180px;
  }
}

@media (max-width: 1200px) {
  .report-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
