/* Colour in this interface means cable identity. Everything structural is
   painted rack steel so that a busy screen genuinely means a busy rack. */

:root {
  --steel-900: #171b20;
  --steel-850: #1c2127;
  --steel-800: #232931;
  --steel-750: #29303a;
  --steel-700: #333b46;
  --steel-600: #414b58;
  --steel-500: #5a6675;

  --text:      #dbe0e6;
  --dim:       #8a94a1;
  --faint:     #626d7b;

  --blue:   #2f7fd6;
  --yellow: #d4ad2c;
  --red:    #c8443c;
  --green:  #3d9e5f;
  --grey:   #8a94a1;
  --orange: #d9772f;
  --violet: #8a6fd0;
  --black:  #4a4f57;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --pad: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--steel-900);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid #a8c4e6;
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ shell --- */

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 260px 1fr 320px;
  grid-template-areas: "top top top" "tree canvas inspect";
  height: 100%;
}

.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad);
  height: 52px;
  background: var(--steel-850);
  border-bottom: 1px solid var(--steel-700);
}

.brand {
  font: 600 15px/1 var(--mono);
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand span { color: var(--faint); }

.search {
  flex: 1;
  max-width: 460px;
  position: relative;
}
.search input {
  width: 100%;
  padding: 7px 10px;
  background: var(--steel-900);
  border: 1px solid var(--steel-700);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 13px;
}
.search input::placeholder { color: var(--faint); font-family: var(--sans); }

.results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--steel-800);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
  z-index: 40;
}
.results:empty { display: none; }
.results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--steel-750);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
}
.results button:hover { background: var(--steel-750); }
.results .where { color: var(--faint); font-size: 11px; }

.who { margin-left: auto; color: var(--dim); font-size: 13px; }

/* ------------------------------------------------------------- panes --- */

.tree    { grid-area: tree;    background: var(--steel-850); border-right: 1px solid var(--steel-700); overflow-y: auto; }
.canvas  { grid-area: canvas;  overflow: auto; position: relative; }
.inspect { grid-area: inspect; background: var(--steel-850); border-left: 1px solid var(--steel-700); overflow-y: auto; }

.pane-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--pad);
  background: var(--steel-850);
  border-bottom: 1px solid var(--steel-750);
  font-size: 12px;
  color: var(--dim);
  z-index: 5;
}
.pane-head .grow { flex: 1; }

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li > ul { margin-left: 12px; border-left: 1px solid var(--steel-750); }

.node {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 10px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.node:hover { background: var(--steel-800); }
.node.on { background: var(--steel-750); box-shadow: inset 2px 0 0 #a8c4e6; }
.node code { font: 500 12px/1 var(--mono); }
.node .sub { color: var(--faint); font-size: 11px; margin-left: auto; }
.node.site  { color: var(--text); font-weight: 600; }
.node.rack  { color: var(--dim); }
.node.room  { color: var(--dim); }

/* ------------------------------------------------------------- forms --- */

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; color: var(--dim); margin-bottom: 3px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 6px 8px;
  background: var(--steel-900);
  border: 1px solid var(--steel-700);
  border-radius: 3px;
  font-size: 13px;
}
.field.mono input { font-family: var(--mono); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn {
  padding: 6px 12px;
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { background: var(--steel-600); }
.btn.primary { background: #2b4a6f; border-color: #3b6494; }
.btn.primary:hover { background: #34567f; }
.btn.danger { color: #e08b85; }
.btn.small { padding: 3px 8px; font-size: 12px; }

.msg { padding: 8px 10px; border-radius: 3px; font-size: 13px; margin-bottom: 10px; }
.msg.err { background: #3a2020; border: 1px solid #6b3733; color: #eba9a3; }
.msg.ok  { background: #1e3226; border: 1px solid #35603f; color: #a5d8b6; }

.empty {
  padding: 40px var(--pad);
  color: var(--dim);
  font-size: 13px;
  max-width: 46ch;
}
.empty h2 { font-size: 15px; color: var(--text); margin: 0 0 6px; font-weight: 600; }

/* -------------------------------------------------------------- rack --- */

.rack-wrap { padding: 24px; display: flex; gap: 32px; align-items: flex-start; }

.u-label { font: 500 9px/1 var(--mono); fill: var(--faint); }
.dev-code { font: 600 11px/1 var(--mono); fill: var(--text); }
.dev-meta { font: 400 9px/1 var(--mono); fill: var(--dim); }
.port-label { font: 500 6px/1 var(--mono); fill: #cfd6de; pointer-events: none; }

.port rect { cursor: pointer; }
.port:hover rect.face { stroke: #cfe0f5; stroke-width: 1.2; }

svg .dim { opacity: 0.34; }

/* ----------------------------------------------------------- inspect --- */

.insp-body { padding: var(--pad); }
.insp-title { font: 600 15px/1.2 var(--mono); margin: 0 0 2px; }
.insp-where { color: var(--faint); font: 400 11px/1.4 var(--mono); margin: 0 0 14px; }

.kv { display: grid; grid-template-columns: 76px 1fr; gap: 3px 10px; font-size: 12px; margin-bottom: 14px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; font-family: var(--mono); }

.section-title {
  font-size: 12px;
  color: var(--dim);
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--steel-750);
}

/* The path readout is the reason this tool exists, so it gets the one
   piece of real structure in the inspector: a continuous spine. */
.path { list-style: none; margin: 0; padding: 0 0 0 16px; position: relative; }
.path::before {
  content: "";
  position: absolute;
  left: 4px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--steel-600);
}
.path li { position: relative; padding: 5px 0; font: 12px/1.4 var(--mono); }
.path li::before {
  content: "";
  position: absolute;
  left: -16px; top: 11px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--steel-900);
  border: 1.5px solid var(--steel-500);
}
.path li.here::before { border-color: #cfe0f5; background: #cfe0f5; }
.path li .cable { color: var(--faint); font-size: 11px; display: block; }

.chip {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  vertical-align: -1px;
  margin-right: 5px;
}

/* --------------------------------------------------------- floorplan --- */

.plan-wrap { padding: 24px; }
.plan-svg { background: var(--steel-850); border: 1px solid var(--steel-700); border-radius: 3px; }
.plan-wall { fill: var(--steel-800); stroke: var(--steel-500); stroke-width: 2; }
.plan-grid { stroke: var(--steel-800); stroke-width: 1; }
.marker { cursor: grab; }
.marker.dragging { cursor: grabbing; }
.marker text { font: 500 9px/1 var(--mono); fill: var(--text); }

.toolbar { display: flex; gap: 8px; align-items: center; padding: 10px var(--pad); border-bottom: 1px solid var(--steel-750); background: var(--steel-850); position: sticky; top: 0; z-index: 5; }
.toolbar .hint { color: var(--faint); font-size: 12px; }

/* -------------------------------------------------------------- auth --- */

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--steel-850);
  border: 1px solid var(--steel-700);
  border-radius: 4px;
  padding: 26px;
}
.auth-card h1 { font: 600 17px/1 var(--mono); margin: 0 0 4px; }
.auth-card p.lede { color: var(--dim); font-size: 13px; margin: 0 0 20px; }
.auth-card .btn { width: 100%; margin-top: 6px; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 220px 1fr; grid-template-areas: "top top" "tree canvas" "inspect inspect"; grid-template-rows: auto 1fr auto; }
  .inspect { border-left: 0; border-top: 1px solid var(--steel-700); max-height: 45vh; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "canvas" "inspect"; }
  .tree { display: none; }
}
