:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #16202a;
  --muted: #657282;
  --line: #dce3ea;
  --brand: #176b57;
  --brand-2: #0f4c3f;
  --red: #c73737;
  --red-bg: #fff1f1;
  --amber: #b96e13;
  --amber-bg: #fff6df;
  --blue: #286fbe;
  --blue-bg: #eef6ff;
  --green: #177245;
  --green-bg: #ebf8f0;
  --shadow: 0 12px 34px rgba(20, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: #101820;
  color: #ecf3f1;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #1f7a63;
  color: #fff;
  font-weight: 800;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-subtitle,
.tenant-label,
.tenant-meta {
  color: #9db1ac;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  border-radius: 7px;
  color: #cad7d4;
  padding: 0 11px;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #8ed4bd;
  font-size: 15px;
}

.tenant-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 14px;
}

.tenant-name {
  margin: 5px 0;
  font-weight: 750;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

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

.panel-header p,
.service-row,
.chart-axis,
.metric-note {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 4px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field select,
.search input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.field select {
  min-width: 154px;
  padding: 0 32px 0 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(34vw, 340px);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 10px;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
}

.icon-button,
.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
}

.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--red);
}

.avatar {
  background: var(--brand-2);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

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

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 31px;
  line-height: 1;
}

.metric.critical strong {
  color: var(--red);
}

.metric.healthy strong {
  color: var(--green);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.75fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.panel-header.tight {
  align-items: center;
}

.panel-header p {
  margin-bottom: 0;
  font-size: 13px;
}

.alerts-panel,
.config-panel {
  grid-column: span 1;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfcfd;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
}

.badge.critical {
  background: var(--red-bg);
  color: var(--red);
}

.badge.warning {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.success {
  background: var(--green-bg);
  color: var(--green);
}

.badge.info {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge.muted {
  background: #edf0f2;
  color: #5d6875;
}

.secondary-button,
.primary-button {
  height: 34px;
  border-radius: 7px;
  padding: 0 12px;
  font-weight: 750;
  white-space: nowrap;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.primary-button {
  border: 1px solid var(--brand-2);
  background: var(--brand);
  color: #fff;
}

.appliance-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px;
}

.appliance-hero > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.tiny-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.service-list,
.site-list,
.config-list {
  display: grid;
  gap: 0;
  padding: 0 16px 16px;
}

.service-row,
.site-row,
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.service-row:last-child,
.site-row:last-child,
.config-item:last-child {
  border-bottom: 0;
}

.site-info {
  min-width: 0;
}

.site-info strong,
.config-item strong {
  display: block;
  margin-bottom: 3px;
}

.site-info span,
.config-item p {
  color: var(--muted);
  font-size: 12px;
}

.config-item {
  justify-content: flex-start;
  padding: 12px 0;
}

.config-item > div {
  flex: 1;
  min-width: 0;
}

.config-item p {
  margin-bottom: 0;
}

.config-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.config-dot.warning {
  background: var(--amber);
}

.config-dot.info {
  background: var(--blue);
}

.activity-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 190px;
  padding: 20px 16px 10px;
}

.activity-chart span {
  flex: 1;
  min-width: 10px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #2c7d67, #85b9aa);
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 10px 16px 16px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav-item span:last-child,
  .tenant-card {
    display: none;
  }

  .brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: block;
    padding: 10px;
  }

  .brand {
    justify-content: flex-start;
    padding: 0;
  }

  .brand div:not(.brand-mark) {
    display: block;
  }

  .nav-list,
  .tenant-card {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  .search,
  .field.compact,
  .field select {
    width: 100%;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .appliance-hero {
    grid-template-columns: 1fr;
  }
}
