:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #64748b;
  --line: #dbe3ec;
  --ok: #16803c;
  --warning: #c77700;
  --danger: #c33131;
  --offline: #7f1d1d;
  --unknown: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.page {
  min-height: 100vh;
}

.page-center {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box,
.agent-card,
.dashboard-toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.login-box {
  width: min(420px, 100%);
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 36px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin-bottom: 4px;
  font-size: 24px;
}

h2 {
  margin-bottom: 5px;
  font-size: 15px;
  line-height: 1.2;
}

h3 {
  margin: 12px 0 8px;
  font-size: 13px;
}

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

.eyebrow {
  margin-bottom: 8px;
  color: #0f62fe;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.content {
  width: min(1900px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 28px);
}

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

.toolbar-group,
.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-meta {
  color: var(--muted);
  font-size: 13px;
}

.refresh-error {
  color: var(--danger);
  font-weight: 700;
}

.system-grid.compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, 320px);
  gap: 12px;
  justify-content: start;
  align-items: start;
}

.system-grid.expanded {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.agent-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left-width: 6px;
}

.system-grid.compact .agent-card {
  width: 320px;
  min-height: 405px;
  padding: 12px;
}

.system-grid.compact h2 {
  font-size: 16px;
}

.system-grid.expanded .agent-card {
  min-height: 520px;
  padding: 16px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-head p,
.last-seen {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status-pill {
  align-self: flex-start;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--unknown);
  color: white;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-ok {
  border-color: var(--ok);
  background: #fbfffc;
}

.status-warning {
  border-color: var(--warning);
  background: #fffaf0;
}

.status-critical,
.status-offline {
  border-color: var(--danger);
  background: #fff5f5;
}

.status-unknown {
  border-color: var(--unknown);
  background: #f8fafc;
}

.status-ok .status-pill {
  background: var(--ok);
}

.status-warning .status-pill {
  background: var(--warning);
}

.status-critical .status-pill,
.status-offline .status-pill {
  background: var(--danger);
}

.status-unknown .status-pill {
  background: var(--unknown);
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}

.mini-card strong {
  font-size: 14px;
}

.mini-card small {
  display: block;
  margin-top: 4px;
  font-weight: 700;
}

.mini-card.ok {
  border-color: rgba(22, 128, 60, 0.35);
  background: #effaf3;
}

.mini-card.warning {
  border-color: rgba(199, 119, 0, 0.35);
  background: #fff7e8;
}

.mini-card.danger {
  border-color: rgba(195, 49, 49, 0.35);
  background: #fff0f0;
}

.mini-card.unknown {
  background: #f1f5f9;
}

.expanded-details {
  display: none;
  margin: 4px 0 12px;
}

.expanded-details[hidden],
.system-grid.compact .expanded-details {
  display: none !important;
}

.system-grid.expanded .expanded-details:not([hidden]) {
  display: block;
}

.detail-empty {
  color: var(--muted);
  font-size: 12px;
}

.detail-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.name-item {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #ffffff;
  font-size: 12px;
  line-height: 1.2;
}

.name-item.ok {
  border-color: rgba(22, 128, 60, 0.35);
  background: #effaf3;
}

.name-item.warning {
  border-color: rgba(199, 119, 0, 0.4);
  background: #fff7e8;
}

.name-item.danger {
  border-color: rgba(195, 49, 49, 0.4);
  background: #fff0f0;
}

.name-item.unknown {
  background: #f1f5f9;
}

.snapshot {
  margin-top: auto;
}

.snapshot span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.snapshot img,
.snapshot-placeholder {
  width: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f6;
}

.system-grid.compact .snapshot img,
.system-grid.compact .snapshot-placeholder {
  height: 105px;
}

.system-grid.expanded .snapshot img,
.system-grid.expanded .snapshot-placeholder {
  height: 160px;
}

.snapshot-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: #0f62fe;
  color: white;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary {
  background: #eef2f6;
  color: var(--text);
}

.form {
  display: grid;
  gap: 14px;
}

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

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 10px;
  font: inherit;
}

.alert {
  padding: 10px 12px;
  margin: 16px 0;
  border-radius: 8px;
  background: #fff0f0;
  color: var(--danger);
}

.empty {
  grid-column: 1 / -1;
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1600px) {
  .system-grid.compact {
    grid-template-columns: repeat(auto-fill, 320px);
  }
}

@media (max-width: 1200px) {
  .system-grid.expanded {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .system-grid.expanded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar,
  .dashboard-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .system-grid.compact,
  .system-grid.expanded {
    grid-template-columns: 1fr;
  }

  .system-grid.compact .agent-card {
    width: 100%;
  }

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

  .detail-name-list {
    display: grid;
    grid-template-columns: 1fr;
  }
}
