/* ==========================================================================
   Palette source: T568B twisted-pair colour code + equipment chassis greys.
   The signal colours are the four cable pairs; they carry meaning everywhere:
     green  = link up / paid / active
     orange = blocked / warning
     blue   = interactive / primary
     brown  = lapsed / inactive
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --rack:     #1A2028;
  --panel:    #222A34;
  --panel-2:  #2A343F;
  --panel-3:  #323E4A;
  --line:     #36434F;
  --line-hi:  #465360;
  --text:     #DCE4EC;
  --dim:      #7C8B9B;
  --dimmer:   #56636F;

  --green:    #3FB37F;
  --orange:   #E8873A;
  --blue:     #4A90D9;
  --brown:    #A0714F;
  --red:      #D95B5B;

  --green-bg: rgba(63, 179, 127, .12);
  --orange-bg:rgba(232, 135, 58, .12);
  --blue-bg:  rgba(74, 144, 217, .12);
  --brown-bg: rgba(160, 113, 79, .12);

  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --sans: 'Archivo', system-ui, -apple-system, sans-serif;

  --r: 3px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--rack);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  /* Faint horizontal rule lines, like a rack unit grid. */
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 43px, rgba(255,255,255,.014) 43px 44px);
}

/* --- typography ---------------------------------------------------------- */

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

.mono { font-family: var(--mono); font-variant-ligatures: none; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.dim { color: var(--dim); }
.tiny { font-size: 11px; }

a { color: var(--blue); }

/* --- layout -------------------------------------------------------------- */

.shell { max-width: 1400px; margin: 0 auto; padding: 0 20px 80px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar .spacer { flex: 1; }

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -.03em;
  color: var(--text);
}
.brand-mark::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--green);
}

.grid { display: grid; gap: 12px; }
.cols-5 { grid-template-columns: repeat(5, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1000px) {
  .cols-5, .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cols-5, .cols-4 { grid-template-columns: 1fr; }
  .shell { padding: 0 12px 60px; }
}

/* --- panels -------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head .spacer { flex: 1; }

.panel-body { padding: 14px; }

/* --- stat cards ---------------------------------------------------------- */

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  /* A 3px colour bar on the left edge — the cable pair this stat belongs to. */
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--edge, var(--line));
}
.stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin: 6px 0 2px;
}
.stat-sub { font-size: 11px; color: var(--dim); }

.edge-green  { --edge: var(--green); }
.edge-orange { --edge: var(--orange); }
.edge-blue   { --edge: var(--blue); }
.edge-brown  { --edge: var(--brown); }

/* --- patch panel (signature element) ------------------------------------- */

.patchpanel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.ports {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.port {
  position: relative;
  width: 20px;
  height: 26px;
  border-radius: 2px 2px 1px 1px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform .12s ease, border-color .12s ease;
}
/* The RJ45 keyway notch. */
.port::before {
  content: '';
  position: absolute;
  left: 50%; top: 0;
  transform: translateX(-50%);
  width: 7px; height: 6px;
  background: var(--rack);
  border-radius: 0 0 2px 2px;
}
/* The link LED. */
.port::after {
  content: '';
  position: absolute;
  left: 50%; bottom: 3px;
  transform: translateX(-50%);
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--led, var(--dimmer));
  box-shadow: 0 0 5px var(--led, transparent);
}
.port:hover, .port:focus-visible {
  transform: translateY(-2px);
  border-color: var(--dim);
  outline: none;
}
.port:focus-visible { box-shadow: 0 0 0 2px var(--blue); }

.port.up      { --led: var(--green); }
.port.blocked { --led: var(--orange); }
.port.lapsed  { --led: var(--brown); }
.port.idle    { --led: var(--dimmer); }

/* Live ports get a slow breathing LED; disabled by reduced-motion. */
.port.up.live::after { animation: blink 2.4s ease-in-out infinite; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11px;
  color: var(--dim);
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block;
}

/* --- tables -------------------------------------------------------------- */

.tablewrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dimmer);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--panel);
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(54, 67, 79, .5);
  vertical-align: middle;
}

tbody tr:hover { background: rgba(255,255,255,.02); }

td.num, th.num { text-align: right; font-family: var(--mono); }

/* --- badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.badge.green  { color: var(--green);  background: var(--green-bg); }
.badge.orange { color: var(--orange); background: var(--orange-bg); }
.badge.blue   { color: var(--blue);   background: var(--blue-bg); }
.badge.brown  { color: var(--brown);  background: var(--brown-bg); }
.badge.grey   { color: var(--dim);    background: rgba(124,139,155,.12); }

/* --- controls ------------------------------------------------------------ */

.btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--line); border-color: var(--dimmer); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary { background: var(--blue); border-color: var(--blue); color: #0C1620; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--red); border-color: rgba(217,91,91,.4); }
.btn.danger:hover { background: rgba(217,91,91,.14); }
.btn.warn { color: var(--orange); border-color: rgba(232,135,58,.4); }
.btn.warn:hover { background: var(--orange-bg); }
.btn.sm { padding: 3px 7px; font-size: 11px; }

input[type=text], input[type=email], input[type=number], select, textarea {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--rack);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 7px 9px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}
select { font-family: var(--sans); }

label { font-size: 12px; color: var(--dim); display: block; margin-bottom: 5px; }

/* --- toggle -------------------------------------------------------------- */

.toggle {
  position: relative;
  width: 34px; height: 19px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: background .15s ease;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s ease, background .15s ease;
}
.toggle[aria-checked=true] { background: var(--green-bg); border-color: var(--green); }
.toggle[aria-checked=true]::after { transform: translateX(15px); background: var(--green); }
.toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --- tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--blue); }
.tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

/* --- misc ---------------------------------------------------------------- */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--dimmer);
  font-family: var(--mono);
  font-size: 12px;
}

.spark { display: block; width: 100%; height: 44px; }

.toast {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 13px;
  z-index: 90;
  transition: transform .2s ease;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-left-color: var(--red); }

dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  padding: 0;
  max-width: 560px;
  width: calc(100vw - 32px);
}
dialog::backdrop { background: rgba(10,14,18,.7); }

.tip {
  position: fixed;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 7px 9px;
  font-size: 11px;
  font-family: var(--mono);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .1s ease;
}
.tip.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
