:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #1b2430;
  --muted: #657083;
  --border: #d9e1eb;
  --ok: #15803d;
  --ok-bg: #e8f7ee;
  --warn: #b45309;
  --warn-bg: #fff4df;
  --bad: #b91c1c;
  --bad-bg: #fdecec;
  --accent: #116466;
  --accent-2: #174c5a;
  --shadow: 0 12px 32px rgba(32, 48, 64, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

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

button,
.button,
input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-2);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  background: white;
  color: var(--text);
}

textarea.risky {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.check-line {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
}

.check-line input {
  width: auto;
  min-height: auto;
}

.danger-check {
  padding: 9px 10px;
  border: 1px solid #f1b8b8;
  border-radius: 7px;
  background: var(--bad-bg);
  color: var(--bad) !important;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

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

code,
pre {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

pre {
  max-width: 560px;
  white-space: pre-wrap;
  margin: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #10242c;
  color: white;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #24b1a8;
  color: #062025;
  font-weight: 900;
}

.brand small {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  padding: 10px 12px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.78);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.menu-toggle {
  display: none;
}

.logout {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: rgba(255, 255, 255, 0.72);
}

.content {
  padding: 28px;
}

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

.page-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.page-header p {
  margin: 7px 0 0;
  color: var(--muted);
}

.summary-row,
.metric-row,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.summary-row span,
.summary-row .summary-link,
.metric-row span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  color: var(--muted);
}

.summary-row .summary-link {
  color: var(--accent);
  text-decoration: none;
}

.summary-row strong {
  color: var(--text);
}

.ok {
  color: var(--ok) !important;
}

.warn {
  color: var(--warn) !important;
}

.bad,
.danger {
  color: var(--bad) !important;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 180px 220px auto;
  gap: 10px;
  margin-bottom: 20px;
}

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

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.device-card,
.panel,
.login-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.device-card {
  overflow: hidden;
}

.card-link {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.card-top {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
}

.card-top strong {
  overflow-wrap: anywhere;
}

.card-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.card-top small {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}

.card-title small {
  text-transform: none;
  font-weight: 700;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

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

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

.status-offline .status-dot {
  background: var(--bad);
}

.facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
}

.facts.wide div {
  grid-template-columns: 160px minmax(0, 1fr);
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
}

.badge.ok {
  background: var(--ok-bg);
}

.badge.warn,
.badge.warning {
  background: var(--warn-bg);
}

.badge.bad,
.badge.danger {
  background: var(--bad-bg);
}

.wake-badge {
  cursor: pointer;
  background: #e8f2ff;
  color: #174c5a !important;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.panel-title-row h2,
.panel-title-row p {
  margin: 0;
}

.panel-title-row p,
.command-message {
  color: var(--muted);
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 12px;
}

.stack label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.metric-row.large span {
  min-width: 150px;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.dashboard-metrics span {
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label unit"
    "value value";
  align-items: center;
  gap: 1px 4px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.dashboard-metrics small {
  grid-area: label;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.dashboard-metrics strong {
  grid-area: value;
  color: var(--text);
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-metrics b {
  font: inherit;
}

.dashboard-metrics em {
  grid-area: unit;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.dashboard-metrics.last-known span {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.dashboard-metrics.last-known strong,
.dashboard-metrics.last-known b {
  color: #1d4ed8;
}

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.period-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.live-badges {
  margin-top: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid span {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.summary-grid strong {
  color: var(--text);
  font-size: 20px;
}

.metrics-chart {
  width: 100%;
  height: auto;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.panel-title-row.tight {
  margin-bottom: 8px;
}

.panel-title-row.tight h2 {
  margin: 0;
}

.check-list {
  max-height: 280px;
  display: grid;
  gap: 6px;
  overflow: auto;
  padding-right: 4px;
}

.device-check-list {
  max-height: 420px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.list-search {
  width: 100%;
  margin: 0 0 8px;
}

.check-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.check-row small,
.meta-note,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.info-filter-panel {
  display: grid;
  gap: 12px;
}

.info-filters {
  display: grid;
  grid-template-columns: 220px minmax(180px, 1fr) 220px auto;
  gap: 10px;
  align-items: end;
}

.info-filter-panel .info-filters {
  grid-template-columns: 220px minmax(180px, 1fr) auto;
}

.info-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.info-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.info-device-list {
  max-height: 360px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.info-summary-grid span {
  background: white;
}

.info-layout {
  align-items: stretch;
}

.info-rank-list {
  display: grid;
  gap: 9px;
}

.info-rank-item {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.info-rank-item span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.info-rank-item small {
  color: var(--muted);
  font-size: 12px;
}

.info-rank-item meter {
  width: 100%;
  height: 10px;
}

.chart-wrap {
  position: relative;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 170px;
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
}

.chart-tooltip span {
  color: var(--muted);
}

.compact-label {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 13px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  min-width: 150px;
}

.new-pc-form {
  min-width: 320px;
}

.new-pc-form input,
.new-pc-form select {
  min-width: 140px;
}

.permission-cell {
  min-width: 620px;
}

.top-filter-panel {
  display: grid;
  gap: 12px;
}

.top-chart-wrap {
  min-height: 560px;
}

.top-chart {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.series-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 560px;
}

.series-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.series-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.top-rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.compact-rank-list {
  display: grid;
  gap: 8px;
}

.compact-rank-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.compact-rank-item:last-child {
  border-bottom: 0;
}

.compact-rank-item span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.compact-rank-item strong,
.compact-rank-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-rank-item small {
  color: var(--muted);
}

.compact-rank-item meter {
  width: 92px;
}

.small-button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

.small-button.danger-button {
  width: auto;
}

.permission-form {
  display: grid;
  gap: 10px;
}

.permission-grid {
  display: grid;
  gap: 6px;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 72px 74px 90px;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.permission-row strong,
.permission-row small {
  display: block;
}

.permission-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.permission-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.permission-row input {
  width: auto;
  min-height: auto;
}

.command-message.error {
  color: var(--bad);
}

.command-message.ok {
  color: var(--ok);
}

.timeline,
.check-list,
.plain-list {
  margin: 0;
  padding-left: 18px;
}

.timeline {
  display: grid;
  gap: 10px;
  list-style: none;
  padding-left: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 155px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.timeline time {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #10242c, #f6f8fb 72%);
}

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

.login-brand {
  margin-bottom: 24px;
}

.login-brand small {
  color: var(--muted);
}

.alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--bad-bg);
  font-size: 14px;
}

.alert.ok {
  background: var(--ok-bg);
  color: var(--ok) !important;
}

.alert-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.panel-rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.danger-button {
  width: 100%;
  background: var(--bad);
}

.danger-button:hover {
  background: #991b1b;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    top: 0;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand small {
    display: none;
  }

  .menu-toggle {
    position: relative;
    z-index: 2;
    display: inline-flex;
    min-height: 34px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.08);
  }

  .brand {
    width: 100%;
    max-width: calc(100vw - 120px);
    overflow: hidden;
  }

  .brand > span:not(.brand-mark) {
    min-width: 0;
    overflow: hidden;
  }

  .brand strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .sidebar.menu-open .nav {
    display: grid;
  }

  .nav a {
    padding: 8px 10px;
  }

  .logout {
    display: none;
    grid-column: 1 / -1;
    margin-top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .sidebar.menu-open .logout {
    display: grid;
  }

  .toolbar,
  .two-column,
  .settings-grid,
  .summary-grid,
  .info-filters,
  .top-rank-grid {
    grid-template-columns: 1fr;
  }

  .panel-title-row {
    flex-direction: column;
  }

  .page-header {
    flex-direction: column;
  }

  .series-legend {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .content {
    min-width: 0;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 16px;
  }

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

  .facts div,
  .facts.wide div,
  .timeline li {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 8px;
  }

  .permission-cell {
    min-width: 520px;
  }

  .permission-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .top-chart {
    min-height: 300px;
  }

  .compact-rank-item {
    grid-template-columns: 1fr;
  }
}
