/* Inventory view */
.inv-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  background: var(--bg);
  overflow: hidden;
}

/* Header */
.inv-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  align-items: end;
}
.inv-title-block h1 { margin: 4px 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.inv-bc { display: flex; gap: 6px; font-size: 12px; color: var(--text-dim); }
.inv-bc .bc-current { color: var(--text); font-weight: 600; }
.inv-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.inv-meta b { color: var(--text); font-family: var(--mono); }
.inv-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.inv-search {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  width: 260px;
  outline: none;
}

/* KPI strip */
.inv-kpis {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  padding: 16px 24px 0;
}
.inv-kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
.inv-kpi.accent { border-left: 3px solid var(--accent); }
.inv-kpi.warn { border-left: 3px solid var(--warn); }
.inv-kpi.danger { border-left: 3px solid var(--danger); }
.inv-kpi.ok { border-left: 3px solid var(--ok); }
.inv-kpi.info { border-left: 3px solid var(--info); }
.inv-kpi-label { font-size: 9px; font-family: var(--mono); letter-spacing: .1em; color: var(--text-dim); margin-bottom: 6px; font-weight: 700; text-transform: uppercase; }
.inv-kpi-row { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.inv-kpi-val { font-size: 24px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; line-height: 1; }
.inv-kpi-val span { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: 4px; }
.inv-kpi-sub { font-size: 10px; color: var(--text-dim); font-family: var(--mono); margin-top: 6px; }
.inv-kpi-trend { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.inv-kpi-trend.up { color: var(--ok); }
.inv-kpi-trend.down { color: var(--danger); }

/* Body grid: filters | table | detail */
.inv-body {
  display: grid;
  grid-template-columns: 230px 1fr 440px;
  gap: 16px;
  padding: 16px 24px;
  flex: 1;
  min-height: 0;
}

/* Filter rail */
.inv-rail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.inv-rail .rail-section-title {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.inv-rail .rail-section-title a { color: var(--accent); font-size: 10px; }
.inv-rail .rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.inv-rail .rail-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  align-items: center;
  color: var(--text);
}
.inv-rail .rail-item:hover { background: var(--bg-2); }
.inv-rail .rail-item.active { background: color-mix(in oklch, var(--accent) 12%, transparent); }
.inv-rail .rail-item .ico {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}
.inv-rail .rail-item.active .ico { color: var(--accent); }
.inv-rail .rail-count { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.inv-rail .rail-item.active .rail-count { color: var(--text); }

/* Tree of locations */
.inv-tree { list-style: none; margin: 0; padding: 0; }
.inv-tree li {
  font-size: 12px;
  padding: 4px 6px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text);
}
.inv-tree li:hover { background: var(--bg-2); }
.inv-tree li.active { background: color-mix(in oklch, var(--accent) 12%, transparent); }
.inv-tree li .lvl-1 { padding-left: 0; }
.inv-tree .tree-l1 { font-weight: 600; }
.inv-tree .tree-l2 { padding-left: 14px; color: var(--text-dim); }
.inv-tree .tree-l3 { padding-left: 28px; color: var(--text-dim); font-family: var(--mono); font-size: 11px; }
.inv-tree .tcount { font-family: var(--mono); font-size: 10px; color: var(--text-muted); }

/* List wrap */
.inv-list-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.inv-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.inv-toolbar .lt-count { font-size: 12px; font-weight: 600; }
.inv-toolbar .lt-count span { color: var(--text-dim); font-family: var(--mono); margin-left: 6px; font-weight: 500; font-size: 11px; }
.inv-toolbar .lt-actions { display: flex; gap: 6px; align-items: center; }

.inv-bulk-bar {
  display: flex; gap: 8px; align-items: center;
  background: color-mix(in oklch, var(--accent) 8%, var(--panel));
  border-bottom: 1px solid color-mix(in oklch, var(--accent) 30%, var(--border));
  padding: 8px 14px;
  font-size: 12px;
}
.inv-bulk-count { font-family: var(--mono); font-weight: 700; }
.inv-bulk-spacer { flex: 1; }

/* Segmented view switch */
.inv-seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 1px;
}
.inv-seg button {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: calc(var(--radius) - 2px);
  font-family: inherit;
}
.inv-seg button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}

/* Table */
.inv-table-scroll {
  flex: 1;
  overflow: auto;
}
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.inv-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
.inv-table thead th.num { text-align: right; }
.inv-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.inv-table tbody tr:hover { background: var(--bg-2); }
.inv-table tbody tr.selected { background: color-mix(in oklch, var(--accent) 10%, transparent); }
.inv-table tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.inv-table td {
  padding: 8px 10px;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-table td.num { text-align: right; font-family: var(--mono); }
.inv-table td.host { font-family: var(--mono); font-weight: 600; }
.inv-table td.host b { color: var(--text); }
.inv-table td.dim { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }

.inv-check {
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-2);
  display: inline-grid; place-items: center;
  cursor: pointer;
  vertical-align: middle;
}
.inv-check.on { background: var(--accent); border-color: var(--accent); color: oklch(0.18 0.01 240); }
.inv-check.on::after { content: "✓"; font-size: 11px; font-weight: 700; }

.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.type-pill .ti {
  width: 6px; height: 6px; border-radius: 50%;
}
.type-pill.server .ti { background: var(--info); }
.type-pill.network .ti { background: oklch(0.74 0.15 290); }
.type-pill.storage .ti { background: oklch(0.74 0.13 180); }
.type-pill.pdu .ti { background: var(--warn); }
.type-pill.ups .ti { background: oklch(0.74 0.15 60); }
.type-pill.kvm .ti { background: var(--text-muted); }
.type-pill.misc .ti { background: var(--text-muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status-pill.prod { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.status-pill.maint { background: color-mix(in oklch, var(--warn) 18%, transparent); color: var(--warn); }
.status-pill.spare { background: color-mix(in oklch, var(--info) 18%, transparent); color: var(--info); }
.status-pill.eol { background: color-mix(in oklch, var(--danger) 18%, transparent); color: var(--danger); }
.status-pill.deco { background: var(--bg-2); color: var(--text-muted); }

.health-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.health-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.health-dot.ok { background: var(--ok); }
.health-dot.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.health-dot.crit { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: pulse-crit 1.5s infinite; }
.health-dot.off { background: var(--text-muted); }

.utz-cell { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.utz-bar { flex: 1; height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.utz-bar div { height: 100%; }
.utz-val { font-family: var(--mono); font-size: 10px; color: var(--text-dim); }

.warranty-pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
}
.warranty-pill.ok { color: var(--ok); background: color-mix(in oklch, var(--ok) 10%, transparent); }
.warranty-pill.warn { color: var(--warn); background: color-mix(in oklch, var(--warn) 12%, transparent); }
.warranty-pill.danger { color: var(--danger); background: color-mix(in oklch, var(--danger) 12%, transparent); }

/* Detail panel */
.inv-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.id-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.id-title { font-family: var(--mono); font-size: 16px; font-weight: 700; letter-spacing: 0; }
.id-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.id-sub b { color: var(--text); font-family: var(--mono); }
.id-pills { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.id-actions {
  display: flex; gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-wrap: wrap;
}
.id-actions .btn { flex: 1; min-width: 0; justify-content: center; height: 30px; font-size: 12px; }

.id-tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.id-tabs button {
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.id-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.id-tabs button:hover:not(.active) { color: var(--text); }

.id-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.id-section { display: flex; flex-direction: column; gap: 8px; }
.id-section-title { font-size: 9px; font-family: var(--mono); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }

/* Asset hero */
.asset-hero {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.asset-fig {
  height: 90px;
  background: oklch(0.18 0.01 240);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .asset-fig { background: oklch(0.9 0.005 240); }
.asset-fig .face {
  position: absolute; inset: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.asset-fig .row {
  flex: 1;
  background: linear-gradient(90deg, oklch(0.5 0.008 240) 0%, oklch(0.42 0.008 240) 100%);
  border-radius: 1px;
  position: relative;
}
.asset-fig .row::after {
  content: ""; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; background: var(--ok); border-radius: 50%;
  box-shadow: 0 0 4px var(--ok);
}
[data-theme="light"] .asset-fig .row {
  background: linear-gradient(90deg, oklch(0.62 0.008 240) 0%, oklch(0.52 0.008 240) 100%);
}
.asset-info-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-content: start; }
.asset-info-grid .k { font-size: 9px; font-family: var(--mono); color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; align-self: center; }
.asset-info-grid .v { font-family: var(--mono); font-size: 12px; font-weight: 600; }

/* KV grid */
.id-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.id-kv > div { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.id-kv .k { font-size: 9px; font-family: var(--mono); color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; }
.id-kv .v { font-family: var(--mono); font-size: 12px; font-weight: 600; }

/* Spec tile grid */
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.spec-tile {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.spec-tile .k { font-size: 9px; font-family: var(--mono); color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.spec-tile .v { font-size: 18px; font-weight: 700; font-family: var(--mono); line-height: 1; }
.spec-tile .v span { font-size: 11px; color: var(--text-dim); margin-left: 2px; font-weight: 500; }
.spec-tile .sub { font-size: 10px; color: var(--text-dim); font-family: var(--mono); margin-top: 4px; }
.spec-bar { margin-top: 6px; height: 4px; background: var(--panel); border-radius: 2px; overflow: hidden; }
.spec-bar div { height: 100%; }

/* Network table mini */
.mini-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.mini-table th, .mini-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-family: var(--mono);
}
.mini-table th {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.mini-table td.up { color: var(--ok); }
.mini-table td.down { color: var(--danger); }

/* Activity */
.id-activity { list-style: none; margin: 0; padding: 0; position: relative; }
.id-activity::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.id-activity li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 10px;
  padding: 6px 0;
  font-size: 12px;
  align-items: start;
}
.id-activity .tdot {
  width: 8px; height: 8px; border-radius: 50%; margin: 5px 0 0 4px;
  border: 2px solid var(--panel);
  background: var(--text-muted);
  box-sizing: content-box;
}
.id-activity .tdot.ok { background: var(--ok); }
.id-activity .tdot.warn { background: var(--warn); }
.id-activity .tdot.crit { background: var(--danger); }
.id-activity .tdot.info { background: var(--info); }
.id-activity .text { color: var(--text); }
.id-activity .text b { font-family: var(--mono); }
.id-activity .time { font-family: var(--mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* Empty */
.empty-id {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 12px;
}
.empty-id svg { opacity: 0.4; margin-bottom: 12px; }

/* Rack lifecycle gauge */
.lifecycle {
  position: relative;
  height: 36px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  overflow: hidden;
}
.lifecycle .seg {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-family: var(--mono);
  letter-spacing: .04em;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  position: relative;
  text-transform: uppercase;
}
.lifecycle .seg:last-child { border-right: 0; }
.lifecycle .seg.active { color: var(--text); background: color-mix(in oklch, var(--accent) 14%, transparent); }
.lifecycle .seg.done { color: var(--text-dim); background: var(--panel-2); }
.lifecycle .marker {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Map placeholder */
.rack-map {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.rack-map-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}
.rm-cell {
  aspect-ratio: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text-muted);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
}
.rm-cell.has { background: oklch(0.42 0.008 240); color: oklch(0.95 0 0); border-color: var(--border-strong); }
[data-theme="light"] .rm-cell.has { background: oklch(0.78 0.008 240); color: oklch(0.22 0.01 240); }
.rm-cell.has.warn { background: var(--warn); color: oklch(0.18 0.01 240); }
.rm-cell.has.crit { background: var(--danger); color: oklch(0.98 0 0); }
.rm-cell.you {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 1;
}

/* Card grid (cards view) */
.inv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.asset-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .12s, background .12s;
}
.asset-card:hover { background: var(--panel-2); border-color: var(--border-strong); }
.asset-card.selected { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, var(--bg-2)); }
.asset-card .ac-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.asset-card .ac-host { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.asset-card .ac-model { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.asset-card .ac-loc { font-family: var(--mono); font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.asset-card .ac-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; }

/* Compare bar */
.compare-bar {
  position: sticky;
  bottom: 0;
  margin: 0 -1px -1px;
  background: color-mix(in oklch, var(--info) 8%, var(--panel));
  border-top: 1px solid color-mix(in oklch, var(--info) 30%, var(--border));
  padding: 8px 14px;
  display: flex; gap: 8px; align-items: center;
  font-size: 12px;
}

/* Responsive */
@media (max-width: 1500px) {
  .inv-kpis { grid-template-columns: repeat(4, 1fr); }
  .inv-body { grid-template-columns: 210px 1fr 400px; }
}
@media (max-width: 1200px) {
  .inv-body { grid-template-columns: 1fr; }
  .inv-rail, .inv-detail { display: none; }
}
