:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #657168;
  --line: #dfe6dd;
  --blue: #2866d8;
  --green: #1f8a5b;
  --red: #c44135;
  --amber: #b46a16;
  --teal: #127b7f;
  --shadow: 0 14px 40px rgba(31, 40, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #17201b;
  color: #f7fbf6;
}

.brand,
.sync-panel {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f0cf63;
  color: #17201b;
  font-weight: 850;
}

.brand strong,
.sync-panel strong {
  display: block;
}

.brand span:last-child,
.sync-panel span:last-child {
  display: block;
  color: #b7c5bc;
  font-size: 0.86rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  color: #dbe5dd;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sync-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.sync-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #44d07b;
  box-shadow: 0 0 0 6px rgba(68, 208, 123, 0.14);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3.2rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

select,
.icon-button,
.segmented button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

select {
  padding: 0 34px 0 12px;
}

.icon-button {
  width: 42px;
  font-size: 1.1rem;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-tile,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-tile {
  padding: 16px;
}

.metric-tile span,
.metric-tile small {
  display: block;
  color: var(--muted);
}

.metric-tile strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 2rem;
  letter-spacing: 0;
}

.metric-tile.critical {
  border-color: rgba(196, 65, 53, 0.36);
  background: #fff7f5;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.7fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.wide {
  grid-column: span 1;
}

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

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.blue {
  background: var(--blue);
}

.green {
  background: var(--green);
}

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

.segmented {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
}

.segmented button {
  min-height: 32px;
  border: 0;
  padding: 0 10px;
  background: transparent;
  cursor: pointer;
}

.segmented button.active {
  background: var(--panel);
  box-shadow: 0 2px 9px rgba(31, 40, 34, 0.08);
}

.chart-wrap {
  width: 100%;
  min-height: 300px;
}

canvas {
  width: 100%;
  height: auto;
}

.alert-list,
.opportunity-list {
  display: grid;
  gap: 10px;
}

.alert-item,
.opportunity-item {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: #fbfcfa;
}

.alert-item.critical {
  border-left-color: var(--red);
  background: #fff8f6;
}

.alert-item strong,
.opportunity-item strong {
  font-size: 0.95rem;
}

.alert-item span,
.opportunity-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 790px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.site-cell {
  display: grid;
  gap: 2px;
}

.site-cell span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf7ef;
  color: #1d6a41;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.warning {
  background: #fff3df;
  color: #8b4e08;
}

.status-pill.critical {
  background: #ffe7e3;
  color: #9d2f25;
}

.delta-up {
  color: var(--green);
  font-weight: 750;
}

.delta-down,
.bad {
  color: var(--red);
  font-weight: 750;
}

.neutral {
  color: var(--muted);
}

.data-panel {
  margin-top: 14px;
}

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

.integration-grid div {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.integration-grid span {
  color: var(--muted);
  line-height: 1.45;
}

.site-manager {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.site-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.site-manager-header strong,
.site-manager-header span {
  display: block;
}

.site-manager-header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.site-manager-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.site-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.site-toggle input {
  margin-top: 3px;
}

.site-toggle span,
.site-toggle strong,
.site-toggle small {
  min-width: 0;
}

.site-toggle span {
  display: grid;
  gap: 2px;
}

.site-toggle strong,
.site-toggle small {
  overflow-wrap: anywhere;
}

.site-toggle small {
  color: var(--muted);
}

.connect-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.sync-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sync-controls select {
  min-height: 34px;
}

button.connect-link {
  border: 0;
  cursor: pointer;
}

button.connect-link:disabled {
  cursor: wait;
  opacity: 0.72;
}

.hidden {
  display: none !important;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2ec;
}

@media (max-width: 1160px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .integration-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar select {
    flex: 1;
    min-width: 160px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}
