: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;
}

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

body {
  background: radial-gradient(circle at 20% 0, #161616, var(--bg) 45%);
  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: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

.card {
  display: block;
  width: 100%;
  background: linear-gradient(145deg, #151515, #0f0f0f);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  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;
}

.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-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: cover;
  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;
}

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

.flash {
  padding: 12px 16px;
  border-radius: 9px;
  margin-bottom: 18px;
  background: #1d1d1d;
}

.flash.error {
  background: #2f221d;
}

.flash.success {
  background: #231f1a;
}

.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);
}

.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;
  transition: width .3s ease, min-width .3s ease;
  width: 280px;
  min-width: 280px;
  overflow: 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: #2a2f37;
  color: white;
  font-weight: 800;
}

.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.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;
}

.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);
}

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

.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%;
  }
}
