:root {
  --ink: #161A20;
  --ink-2: #1E2530;
  --paper: #EEF0ED;
  --panel: #FFFFFF;
  --line: #DCE0DC;
  --line-2: #E8EBE7;
  --muted: #6A726C;
  --muted-2: #939A93;
  --brand: #1F6F6B;
  --brand-ink: #134845;

  --sig-use: #2E9E5B;
  --sig-use-bg: #E7F4EC;
  --sig-avail: #3B82C4;
  --sig-avail-bg: #E6EFF7;
  --sig-repair: #D98A2B;
  --sig-repair-bg: #FBF0E0;
  --sig-retired: #8A9099;
  --sig-retired-bg: #EDEEEC;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22,26,32,.04), 0 8px 28px rgba(22,26,32,.06);
  --shadow-lg: 0 18px 60px rgba(22,26,32,.22);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.side {
  background: var(--ink);
  color: #C7CDC9;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 6px;
}
.brand .glyph {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--brand);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  flex: none;
}
.brand .glyph span {
  width: 9px; height: 9px; border-radius: 50%;
  background: #BFEDE6; box-shadow: 0 0 0 3px rgba(191,237,230,.18);
}
.brand b { font-family: var(--font-display); color: #fff; font-weight: 600; letter-spacing: .04em; font-size: 14px; }
.brand small { display:block; font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); letter-spacing: .14em; }

.nav-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: #6F776F; padding: 0 8px 8px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: #B9C0BA;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px;
  transition: background .12s ease, color .12s ease;
}
.nav button .cat-name { display:flex; align-items:center; gap: 9px; }
.nav button .dot { width: 7px; height: 7px; border-radius: 2px; background: #4A524C; flex:none; }
.nav button .count { font-family: var(--font-mono); font-size: 11px; color: #7A827B; }
.nav button:hover { background: rgba(255,255,255,.05); color: #EDEFEC; }
.nav button.active { background: var(--brand); color: #fff; }
.nav button.active .count { color: #BFEDE6; }
.nav button.active .dot { background: #BFEDE6; }

.side-foot { margin-top: auto; font-family: var(--font-mono); font-size: 10.5px; color: #5C645D; line-height: 1.6; padding: 0 8px; }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 {
  font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 0;
  letter-spacing: -.01em;
}
.topbar h1 .sub { display:block; font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-weight: 400; letter-spacing: .02em; margin-top: 2px; }
.topbar .spacer { flex: 1; }

.search {
  position: relative; width: min(340px, 38vw);
}
.search input {
  width: 100%; border: 1px solid var(--line); background: var(--paper);
  border-radius: var(--radius-sm); padding: 9px 12px 9px 34px; font-size: 13px;
  color: var(--ink); transition: border-color .12s, background .12s;
}
.search input::placeholder { color: var(--muted-2); }
.search input:focus { background: #fff; border-color: var(--brand); outline: none; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { border-color: var(--muted-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { color: #B5402F; border-color: var(--line); }
.btn-danger:hover { background: #FBECE9; border-color: #E7C3BC; }

/* ---------- Stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stat { background: var(--panel); padding: 16px 28px; }
.stat .k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display:flex; align-items:center; gap:7px; }
.stat .k i { width: 8px; height: 8px; border-radius: 50%; display:inline-block; }
.stat .v { font-family: var(--font-display); font-size: 27px; font-weight: 600; margin-top: 6px; line-height: 1; letter-spacing: -.02em; }
.stat .v small { font-size: 13px; color: var(--muted-2); font-weight: 400; font-family: var(--font-body); }

/* ---------- Toolbar / filters ---------- */
.work { padding: 20px 28px 40px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  padding: 6px 12px; border-radius: 100px; font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px; transition: all .12s;
}
.chip:hover { border-color: var(--muted-2); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.chip .c { font-family: var(--font-mono); font-size: 11px; opacity: .65; }
.filters .div { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* ---------- Table ---------- */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: #FAFBFA;
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--ink); }
thead th .arr { color: var(--brand); font-family: var(--font-body); margin-left: 3px; }
tbody tr { border-bottom: 1px solid var(--line-2); transition: background .1s; cursor: pointer; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: #F6F8F6; }
tbody td { padding: 13px 18px; vertical-align: middle; }
.tag { font-family: var(--font-mono); font-size: 12px; color: var(--brand-ink); font-weight: 500; }
.asset-name { font-weight: 600; font-size: 13.5px; }
.asset-sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.assignee { display:flex; align-items:center; gap: 9px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color:#fff; display:grid; place-items:center; font-size: 11px; font-weight: 600; font-family: var(--font-display); flex:none; }
.avatar.none { background: var(--line); color: var(--muted-2); }
.loc { color: var(--muted); font-size: 13px; }
.val { font-family: var(--font-mono); font-size: 12.5px; text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 9px; border-radius: 100px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge .led { width: 7px; height: 7px; border-radius: 50%; position: relative; }
.badge .led::after { content:""; position:absolute; inset:-3px; border-radius:50%; opacity:.4; }
.b-use { color:#1E6B40; background: var(--sig-use-bg); }
.b-use .led { background: var(--sig-use); } .b-use .led::after{ box-shadow:0 0 0 2px var(--sig-use); }
.b-avail { color:#235D8C; background: var(--sig-avail-bg); }
.b-avail .led { background: var(--sig-avail); }
.b-repair { color:#9A5C12; background: var(--sig-repair-bg); }
.b-repair .led { background: var(--sig-repair); }
.b-retired { color:#5E6469; background: var(--sig-retired-bg); }
.b-retired .led { background: var(--sig-retired); }

.rowact { text-align: right; }
.iconbtn { border: 0; background: transparent; color: var(--muted-2); padding: 6px; border-radius: 6px; line-height: 0; }
.iconbtn:hover { background: var(--line-2); color: var(--ink); }

/* ---------- Empty ---------- */
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; border-radius: 12px; background: var(--paper); display:grid; place-items:center; margin: 0 auto 16px; color: var(--muted-2); }
.empty h3 { font-family: var(--font-display); color: var(--ink); margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 320px; line-height: 1.55; }

/* ---------- Modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(22,26,32,.42); display: none; align-items: flex-start; justify-content: center; padding: 6vh 20px; z-index: 40; overflow-y: auto; }
.scrim.open { display: flex; }
.modal {
  background: var(--panel); border-radius: 14px; width: min(560px, 100%);
  box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity:1; transform: none; } }
.modal header { padding: 22px 24px 4px; }
.modal header .eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); }
.modal header h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 5px 0 0; letter-spacing: -.01em; }
.form { padding: 18px 24px 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13.5px;
  background: var(--paper); color: var(--ink); transition: border-color .12s, background .12s; width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); background: #fff; }
.field.mono input { font-family: var(--font-mono); font-size: 12.5px; }
.modal footer { padding: 18px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.modal footer .err { margin-right: auto; color: #B5402F; font-size: 12.5px; display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 100px; font-size: 13px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
  display: flex; align-items: center; gap: 9px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .led { width: 8px; height: 8px; border-radius: 50%; background: var(--sig-use); }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; }
  .nav-label, .side-foot { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav button { width: auto; }
  .stats { grid-template-columns: repeat(2,1fr); }
  .topbar { flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .col-loc, .col-val, thead .col-loc, thead .col-val { display: none; }
  .form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
