:root {
  color-scheme: dark;
  --bg: #0e1218;
  --bg-elev: #151b24;
  --bg-soft: #1b2330;
  --line: #2a3444;
  --line-strong: #3a465a;
  --text: #e8edf4;
  --muted: #93a0b5;
  --faint: #6d7b90;
  --accent: #3db8a5;
  --accent-2: #7ee0d0;
  --danger: #f07178;
  --warn: #e6b450;
  --ok: #7fd47b;
  --chip-hv: #8b7cf7;
  --chip-sv: #5b9cff;
  --chip-vm: #3db8a5;
  --chip-ws: #93a0b5;
  --chip-mac: #e39b4a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-elev: #ffffff;
    --bg-soft: #e8edf4;
    --line: #d5dde8;
    --line-strong: #b7c2d3;
    --text: #1b2330;
    --muted: #4b5a70;
    --faint: #6d7b90;
    --shadow: 0 10px 28px rgba(27, 35, 48, 0.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  height: 52px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--text); text-decoration: none; }
.brand strong { letter-spacing: 0.02em; }
.brand span { color: var(--faint); font-size: 12px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
}
.nav a:hover, .nav a.active { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.who { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 10px; }
.who button { margin: 0; }

.wrap { width: min(1280px, calc(100% - 28px)); margin: 18px auto 40px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.sub { color: var(--muted); margin: 4px 0 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat, .card, .panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat { padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }
.card { padding: 14px; }
.panel { overflow: hidden; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--faint); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; background: var(--bg-soft); position: sticky; top: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--bg-soft) 70%, transparent); }
.host { font-family: var(--mono); font-weight: 500; color: var(--text); }
.muted { color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--bg-soft);
  color: var(--muted);
}
.chip.hypervisor { color: var(--chip-hv); background: color-mix(in srgb, var(--chip-hv) 16%, transparent); }
.chip.server { color: var(--chip-sv); background: color-mix(in srgb, var(--chip-sv) 16%, transparent); }
.chip.vm { color: var(--chip-vm); background: color-mix(in srgb, var(--chip-vm) 16%, transparent); }
.chip.workstation { color: var(--chip-ws); }
.chip.mac { color: var(--chip-mac); background: color-mix(in srgb, var(--chip-mac) 16%, transparent); }
.chip.host, .chip.personal { color: var(--accent-2); }
.chip.unassigned { color: var(--warn); }

.filters {
  position: sticky;
  top: 52px;
  z-index: 30;
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filters.extended { grid-template-columns: repeat(4, 1fr); margin-top: -4px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
input, select { height: 34px; padding: 0 8px; }
textarea { width: 100%; min-height: 110px; padding: 8px; }
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  background: var(--accent);
  color: #06221d;
  border: 0;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}
button.secondary, .btn.secondary { background: var(--bg-soft); color: var(--text); border: 1px solid var(--line); }
button:hover, .btn:hover { filter: brightness(1.05); text-decoration: none; }
.filter-actions { display: flex; align-items: end; gap: 8px; }

.office-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.office-card { display: block; padding: 12px; color: inherit; text-decoration: none; }
.office-card:hover { border-color: var(--accent); text-decoration: none; }
.office-card b { display: block; margin-bottom: 4px; }
.office-card span { color: var(--muted); font-size: 12px; }

.detail-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-word; }
.section-title { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(420px, 100%); padding: 22px; }
.login h1 { margin: 0 0 6px; font-size: 22px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.alert { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 14%, var(--bg-elev)); color: var(--danger); }
.alert.ok { background: color-mix(in srgb, var(--ok) 14%, var(--bg-elev)); color: var(--ok); }
.drop {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
}
.htmx-indicator { display: none; color: var(--muted); font-size: 12px; }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { display: inline; }

@media (max-width: 900px) {
  .stats, .detail-grid, .filters, .filters.extended { grid-template-columns: 1fr 1fr; }
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 12px; }
  .nav { order: 3; width: 100%; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats, .filters, .filters.extended, .detail-grid { grid-template-columns: 1fr; }
  .wrap { width: calc(100% - 16px); }
}
