:root {
  /* 85% Achromatic Aluminum Canvas & Skeleton */
  --canvas: #EAE7E0;
  --surface: #F6F4EF;
  --surface-raised: #FDFCF9;
  --surface-hover: #EFECE4;
  --surface-recessed: #DFDBD1;
  --hairline: #C8C4BA;
  --hairline-strong: #9E998E;

  /* Ink & Contrast (WCAG AA >= 4.5:1 verified on #F6F4EF & #EFECE4) */
  --ink: #16181A;
  --ink-secondary: #43474D;
  --ink-muted: #5A5F66;

  /* 10% Single Low-Value Anchor (Matte Obsidian Command Module & Table Header) */
  --obsidian: #16181A;
  --obsidian-surface: #22252A;
  --obsidian-border: #363B42;
  --obsidian-text: #F6F4EF;
  --obsidian-muted: #B0B6BF;

  /* 5% Signal Highlights (Locked Single Amber Token #F5B700) */
  --amber: #F5B700;
  --amber-hover: #FFCA28;
  --amber-wash: rgba(245, 183, 0, 0.14);
  --amber-ink: #111315;

  /* LED & Status Tokens (Dots use pure signal; text uses high-contrast dark ink) */
  --led-green: #129A52;
  --status-green-bg: rgba(18, 154, 82, 0.12);
  --status-green-border: rgba(18, 154, 82, 0.36);
  --status-green-ink: #0B5830;

  --led-red: #D93829;
  --status-red-bg: rgba(217, 56, 41, 0.12);
  --status-red-border: rgba(217, 56, 41, 0.36);
  --status-red-ink: #8C1B11;

  --status-neutral-bg: #E5E1D7;
  --status-neutral-ink: #3D4147;

  /* Typography */
  --font-display: "Big Shoulders Display", Impact, "Arial Narrow", sans-serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Tactile Motion Curves */
  --ease-snap: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 4px;
}

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

html,
body {
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(22, 24, 26, 0.055) 1px, transparent 0);
  background-size: 16px 16px;
  padding: 12px 16px 16px;
}

.rack-shell {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   1. TOP INSTRUMENT RAIL (56px)
   ========================================================================== */
.instrument-rail {
  min-height: 56px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.screw-head {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-recessed);
  border: 1px solid var(--hairline-strong);
  position: relative;
  flex-shrink: 0;
}

.screw-head::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 1px;
  right: 1px;
  height: 1px;
  background: var(--ink-muted);
  transform: rotate(-35deg);
}

.screw-head.sm {
  width: 8px;
  height: 8px;
}

.led-beacon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--led-green);
  box-shadow: 0 0 0 3px rgba(18, 154, 82, 0.2);
  flex-shrink: 0;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--obsidian-text);
  background: var(--ink);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.04em;
}

.brand-title-row h1 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  color: var(--ink);
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-secondary);
}

.brand-sub code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* 10-LED Quota Line-Card Gauge */
.rail-quota {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-recessed);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 5px 12px;
  flex-shrink: 0;
}

.quota-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.quota-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: 0.04em;
}

.quota-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.led-bar-10 {
  display: grid;
  grid-template-columns: repeat(10, 8px);
  gap: 3px;
  align-items: center;
  padding: 3px 5px;
  background: var(--obsidian);
  border-radius: 3px;
}

.led-seg {
  width: 8px;
  height: 14px;
  border-radius: 1px;
  background: #2E333A;
  transition: background-color 180ms var(--ease-snap), transform 180ms var(--ease-snap);
}

.led-seg.is-on {
  background: var(--amber);
  box-shadow: 0 0 5px rgba(245, 183, 0, 0.55);
}

.led-seg.is-full {
  background: var(--led-red);
}

/* Top Rail Ghost Utilities */
.rail-utilities {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn-ghost {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 80ms var(--ease-snap), background-color 150ms ease, border-color 150ms ease;
}

.btn-ghost svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--ink-secondary);
}

.btn-ghost:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn-ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost-strong {
  border-color: var(--ink);
  background: var(--surface);
}

/* ==========================================================================
   2. INLINE PATCH COMMAND BAR (10% Focal Anchor — Matte Obsidian #16181A)
   ========================================================================== */
.patch-command-bar {
  background: var(--obsidian);
  color: var(--obsidian-text);
  border: 1px solid #0B0C0E;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(22, 24, 26, 0.12);
}

.patch-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1.5fr) minmax(160px, 1.2fr) 144px 120px auto auto;
  align-items: end;
  gap: 10px;
}

.patch-stage-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 10px;
  border-right: 1px solid var(--obsidian-border);
  height: 48px;
}

.stage-tag {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--amber);
  line-height: 1.05;
}

.stage-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--obsidian-muted);
  white-space: nowrap;
}

.field-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--obsidian-muted);
  white-space: nowrap;
}

.patch-command-bar input,
.patch-command-bar select {
  height: 34px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--obsidian-border);
  background: var(--obsidian-surface);
  color: var(--obsidian-text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  width: 100%;
  transition: border-color 140ms ease;
}

.patch-command-bar input::placeholder {
  color: #8A919C;
}

.patch-command-bar input:focus,
.patch-command-bar select:focus {
  border-color: var(--amber);
}

/* Credentials Popover inside Command Bar */
.cred-popover {
  position: relative;
}

.cred-trigger {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.cred-trigger::-webkit-details-marker {
  display: none;
}

.cred-summary-val {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--obsidian-border);
  background: var(--obsidian-surface);
  color: var(--obsidian-text);
  font-family: var(--font-mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.cred-popover[open] .cred-summary-val {
  border-color: var(--amber);
}

.cred-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 260px;
  background: var(--obsidian);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.btn-amber-patch {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--amber);
  background: var(--amber);
  color: var(--amber-ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 80ms var(--ease-snap), background-color 140ms ease;
}

.btn-amber-patch svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-amber-patch:hover:not(:disabled) {
  background: var(--amber-hover);
  border-color: var(--amber-hover);
}

.btn-amber-patch:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
}

.btn-amber-patch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ==========================================================================
   3. MATRIX FILTER & TELEMETRY STRIP (42px)
   ========================================================================== */
.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

.filter-tabs {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface-recessed);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.filter-glider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: 112px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: 3px;
  transition: transform 220ms var(--ease-snap), width 220ms var(--ease-snap);
  pointer-events: none;
  z-index: 0;
}

.filter-tab {
  position: relative;
  z-index: 1;
  height: 28px;
  padding: 0 11px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: 3px;
  transition: color 150ms ease;
}

.filter-tab.is-active {
  color: var(--ink);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 2px;
  background: rgba(22, 24, 26, 0.08);
  color: var(--ink);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.telemetry-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 4px 10px;
}

.tel-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.led-dot.green {
  background: var(--led-green);
}

.led-dot.red {
  background: var(--led-red);
}

.led-dot.amber {
  background: var(--amber);
}

.search-box {
  height: 32px;
  width: 256px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-muted);
}

.search-box svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.search-box input {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 100%;
  outline: none;
}

.search-box input::placeholder {
  color: var(--ink-muted);
}

.search-box:focus-within {
  border-color: var(--ink);
}

/* ==========================================================================
   4. PROTAGONIST: ACTIVE PROXY PATCHBAY MATRIX
   ========================================================================== */
.patchbay-stage {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-frame {
  width: 100%;
  overflow-x: auto;
}

.patchbay-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.patchbay-table thead tr {
  background: var(--obsidian);
  color: var(--obsidian-text);
}

.patchbay-table th {
  height: 34px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--obsidian-muted);
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

.patchbay-table tbody tr {
  height: 48px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  transition: background-color 140ms ease;
}

.patchbay-table tbody tr:nth-child(even) {
  background: #F2EFE8;
}

.patchbay-table tbody tr:hover {
  background: var(--surface-hover);
}

.patchbay-table td {
  padding: 5px 10px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--ink);
}

/* Port Jack Stencil Number */
.jack-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.jack-socket {
  width: 8px;
  height: 16px;
  border: 1px solid var(--ink-secondary);
  background: var(--surface-recessed);
  border-radius: 1px;
  display: inline-block;
}

.row-green .jack-socket {
  background: var(--led-green);
  border-color: var(--status-green-ink);
}
.jack-socket.empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--hairline-strong);
}

.jack-port.muted {
  color: var(--ink-secondary);
  opacity: 0.75;
}

.mod-empty {
  background: var(--surface-recessed);
  border: 1px dashed var(--hairline-strong);
  color: var(--ink-secondary);
}

.row-empty td {
  opacity: 0.75;
}

.fresh-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  white-space: nowrap;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--surface-recessed);
}

.row-red .jack-socket {
  background: var(--led-red);
  border-color: var(--status-red-ink);
}

.jack-port {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Source Module Chip */
.mod-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.mod-nord {
  background: var(--ink);
  color: var(--obsidian-text);
}

.mod-xray {
  background: var(--surface-recessed);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
}

/* Location & Upstream */
.loc-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.loc-cc {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-recessed);
  border: 1px solid var(--hairline);
  padding: 1px 5px;
  border-radius: 2px;
}

.loc-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
}

.upstream-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.upstream-host {
  color: var(--ink);
  font-weight: 600;
}

.load-pill {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--surface-recessed);
  color: var(--ink-secondary);
}

/* Exit IP Copy Button */
.ip-copy-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 7px;
  margin-left: -7px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.ip-copy-btn:hover {
  background: var(--surface-raised);
  border-color: var(--hairline-strong);
}

.ip-copy-icon {
  font-size: 11px;
  color: var(--ink-muted);
}

/* Latency Meter + Status Badge */
.status-cell-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.status-pill.green {
  background: var(--status-green-bg);
  border: 1px solid var(--status-green-border);
  color: var(--status-green-ink);
}

.status-pill.red {
  background: var(--status-red-bg);
  border: 1px solid var(--status-red-border);
  color: var(--status-red-ink);
}

.status-pill.unknown {
  background: var(--status-neutral-bg);
  border: 1px solid var(--hairline);
  color: var(--status-neutral-ink);
}

.lat-meter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.lat-track {
  width: 44px;
  height: 7px;
  background: #D8D3C8;
  border: 1px solid var(--hairline-strong);
  border-radius: 2px;
  overflow: hidden;
}

.lat-fill {
  display: block;
  height: 100%;
  background: var(--led-green);
  transition: width 260ms var(--ease-snap);
}

/* Credentials Column */
.cred-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
  white-space: nowrap;
}

/* Single-Row Action Bar in Matrix (NEVER wraps to 3 lines) */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.btn-row {
  height: 28px;
  padding: 0 9px;
  border-radius: 3px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 80ms var(--ease-snap), background-color 120ms ease, border-color 120ms ease;
}

.btn-row:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--ink);
}

.btn-row:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
}

.btn-row:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary Row Action: Ganti IP (Amber Accent) */
.btn-row-patch {
  background: var(--amber);
  border-color: #C99600;
  color: var(--amber-ink);
  font-weight: 700;
}

.btn-row-patch:hover:not(:disabled) {
  background: var(--amber-hover);
  border-color: var(--ink);
}

.btn-row-del {
  padding: 0 7px;
  color: var(--status-red-ink);
  border-color: var(--status-red-border);
  background: var(--surface-raised);
}

.btn-row-del:hover:not(:disabled) {
  background: var(--status-red-bg);
  border-color: var(--led-red);
}

/* Memorable Moment: Hot-Patch Sweep & Digit Roll */
@keyframes patchSweep {
  0% {
    background-color: var(--amber-wash);
  }
  50% {
    background-color: rgba(245, 183, 0, 0.28);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes digitRollIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

tr.is-patching {
  background: var(--amber-wash) !important;
}

tr.just-patched td {
  animation: patchSweep 900ms var(--ease-snap);
}

tr.just-patched .ip-copy-btn,
tr.just-patched .upstream-host,
tr.just-patched .status-cell-inner {
  animation: digitRollIn 260ms var(--ease-snap);
}

/* First-Load Staggered Entrance */
@keyframes rackRowEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rack-shell[data-boot="entering"] .instrument-rail {
  animation: rackRowEnter 220ms var(--ease-snap) both;
}

.rack-shell[data-boot="entering"] .patch-command-bar {
  animation: rackRowEnter 240ms var(--ease-snap) 45ms both;
}

.rack-shell[data-boot="entering"] .patchbay-table tbody tr {
  animation: rackRowEnter 240ms var(--ease-snap) both;
  animation-delay: calc(80ms + var(--row-idx, 0) * 30ms);
}

/* ==========================================================================
   5. RACK FOOTER, TOAST & MODALS
   ========================================================================== */
.rack-footer {
  min-height: 36px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-secondary);
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rack-footer strong,
.rack-footer code {
  color: var(--ink);
  font-weight: 700;
}

.empty-cell {
  text-align: center;
  padding: 36px 16px !important;
  font-family: var(--font-mono);
  color: var(--ink-secondary);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--obsidian);
  color: var(--obsidian-text);
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 100;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  max-width: 420px;
}

.toast.error {
  border-color: var(--led-red);
  border-left-color: var(--led-red);
}

/* Modals */
.rack-modal {
  margin: auto;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  width: min(560px, 94vw);
  padding: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.rack-modal::backdrop {
  background: rgba(22, 24, 26, 0.65);
}

.modal-head {
  background: var(--obsidian);
  color: var(--obsidian-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.05em;
  display: block;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.btn-modal-close {
  background: transparent;
  border: 1px solid var(--obsidian-border);
  color: var(--obsidian-text);
  width: 28px;
  height: 28px;
  border-radius: 3px;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-hint {
  font-size: 13px;
  color: var(--ink-secondary);
}

.format-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.fmt-btn {
  height: 32px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
}

.fmt-btn.is-active {
  background: var(--ink);
  color: var(--obsidian-text);
  border-color: var(--ink);
}

#export-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

.oauth-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oauth-step-card {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.oauth-step-card input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
}

.oauth-ext-link {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: underline;
}

.btn-ghost-dark {
  border-color: var(--ink);
}

.full-width {
  width: 100%;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Tablet & Mobile 390x844)
   ========================================================================== */
@media (max-width: 1180px) {
  .patch-form {
    grid-template-columns: repeat(3, 1fr);
  }
  .patch-stage-label {
    grid-column: 1 / -1;
    border-right: none;
    border-bottom: 1px solid var(--obsidian-border);
    height: auto;
    padding-bottom: 6px;
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .instrument-rail {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }

  .rail-quota {
    justify-content: space-between;
  }

  /* Mandatory Refinement #4: Pinned quota gauge above, horizontally scrollable utility strip */
  .rail-utilities {
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .patch-form {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .field-country,
  .field-server {
    grid-column: 1 / -1;
  }

  .patch-cta-cell {
    grid-column: 1 / -1;
  }

  .patch-cta-cell .btn-amber-patch {
    width: 100%;
  }

  .cred-dropdown {
    left: 0;
    right: auto;
    width: min(280px, 88vw);
  }

  .matrix-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  /* Transform Table Rows into Structured Rack-Slot Cards on Mobile (No Horizontal Overflow) */
  .patchbay-table thead {
    display: none;
  }

  .patchbay-table,
  .patchbay-table tbody {
    display: block;
    width: 100%;
  }

  .patchbay-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    height: auto;
    padding: 12px;
    border-bottom: 2px solid var(--hairline);
  }

  .patchbay-table td {
    padding: 0;
    display: block;
  }

  .patchbay-table td.cell-port {
    grid-column: 1 / 2;
  }

  .patchbay-table td.cell-source {
    grid-column: 2 / 3;
    justify-self: end;
  }

  .patchbay-table td.cell-loc {
    grid-column: 1 / -1;
  }

  .patchbay-table td.cell-upstream {
    grid-column: 1 / -1;
  }

  .patchbay-table td.cell-ip {
    grid-column: 1 / -1;
  }

  .patchbay-table td.cell-status {
    grid-column: 1 / -1;
  }

  .patchbay-table td.cell-cred {
    grid-column: 1 / -1;
  }

  .patchbay-table td.cell-actions {
    grid-column: 1 / -1;
    padding-top: 4px;
  }

  .row-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  .row-actions .btn-row {
    flex: 1 1 auto;
    justify-content: center;
  }

  .rack-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

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