:root {
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6; /* blue - primary actions */

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;

    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #d03b3b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

a { color: var(--series-1); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

button, .btn {
  font-family: inherit;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 8px 14px;
  cursor: pointer;
}

button.primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: white;
}

button:hover { filter: brightness(0.97); }
button.primary:hover { filter: brightness(1.08); }

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-tile .label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.stat-tile .value {
  font-size: 28px;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.dot.good { background: var(--status-good); }
.dot.warning { background: var(--status-warning); }
.dot.critical { background: var(--status-critical); }
.dot.neutral { background: var(--text-muted); }

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

.toolbar input[type="text"] {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  min-width: 260px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

a.btn {
  text-decoration: none;
  display: inline-block;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 11.5px;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 7px 6px;
  border-bottom: 1px solid var(--gridline);
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.25;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}
thead th.sortable:hover { color: var(--text-primary); }

thead th .sort-arrow {
  display: inline-block;
  width: 10px;
  margin-left: 2px;
  color: var(--series-1);
}

tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--series-1) 6%, transparent); }

.company-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.company-cell input[type="text"] {
  font-family: inherit;
  font-size: 11px;
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  width: 100%;
}

.company-cell button {
  padding: 2px 6px;
  font-size: 10px;
  align-self: flex-start;
}

.company-cell .saved-flash {
  font-size: 10px;
  color: var(--status-good);
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.online { color: var(--status-good); }
.badge.stale { color: var(--status-warning); }
.badge.offline { color: var(--status-critical); }

.muted { color: var(--text-muted); }
.hostname { font-weight: 600; }

.icon-btn {
  padding: 3px 6px;
  font-size: 10.5px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 340px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}
.login-card p.sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 20px;
}

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
}

.error-msg {
  color: var(--status-critical);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 16px;
}

.login-card button {
  width: 100%;
}
