.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, rgba(16, 12, 8, 0.97) 0%, rgba(8, 6, 4, 0.98) 100%);
  border-right: 1px solid var(--border-brass);
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.5), inset -1px 0 0 rgba(0, 245, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, var(--neon-cyan), transparent 30%, transparent 70%, var(--neon-magenta));
  opacity: 0.4;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-brass);
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-emblem {
  position: relative;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-gear {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 50%;
  animation: gear-spin 30s linear infinite;
}

.logo-gear::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(201, 162, 39, 0.14);
  border-radius: 50%;
  animation: gear-spin 18s linear infinite reverse;
}

.logo-af-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 0 10px rgba(201, 162, 39, 0.7)) drop-shadow(0 0 3px rgba(255, 100, 0, 0.5));
  z-index: 1;
  transition: filter 0.3s ease;
}

.logo-af-img:hover {
  filter: drop-shadow(0 0 16px rgba(201, 162, 39, 0.95)) drop-shadow(0 0 6px rgba(255, 140, 0, 0.7));
}

.logo-text-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brass-light) 0%, var(--neon-cyan) 50%, var(--brass) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.06em;
}

.logo-tagline {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}

.sidebar-nav {
  /* No flex-grow: let the matrix rain claim the remaining space */
  flex: 0 0 auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 2px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: all 0.25s ease;
  position: relative;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(201, 162, 39, 0.08);
  color: var(--brass-light);
  border-color: rgba(201, 162, 39, 0.2);
  text-decoration: none;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(0, 245, 255, 0.12), transparent);
  color: var(--neon-cyan);
  border-color: rgba(0, 245, 255, 0.35);
  box-shadow: inset 0 0 20px rgba(0, 245, 255, 0.08);
}

.nav-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-glow {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
  border-radius: 0 2px 2px 0;
}

/* ── Matrix rain ──────────────────────────────── */
.matrix-rain-wrap {
  /* Flex-grow to fill all space between nav and footer */
  flex: 1;
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(0, 255, 65, 0.12);
  border-bottom: 1px solid rgba(0, 255, 65, 0.08);
  min-height: 160px;
  max-height: 320px;
  background: #000;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Forge / Crucible target lock — gold heavy rain (matches forge progress vibe) */
.matrix-rain-wrap--intense {
  border-top-color: rgba(255, 180, 40, 0.45);
  border-bottom-color: rgba(255, 120, 0, 0.35);
  box-shadow:
    inset 0 0 28px rgba(255, 140, 0, 0.12),
    0 0 18px rgba(255, 160, 0, 0.15);
}

.matrix-rain-wrap--intense .matrix-rain-scanlines {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(40, 20, 0, 0.22) 1px,
    rgba(40, 20, 0, 0.22) 2px
  );
}

.matrix-rain-wrap--crucible.matrix-rain-wrap--intense {
  box-shadow:
    inset 0 0 32px rgba(255, 200, 80, 0.14),
    0 0 22px rgba(255, 180, 50, 0.2);
}

.matrix-rain-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* CRT scanline overlay */
.matrix-rain-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.18) 1px,
    rgba(0, 0, 0, 0.18) 2px
  );
  z-index: 2;
}

/* Top fade — blends into nav area */
.matrix-rain-vignette-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, #000 0%, transparent 100%);
  pointer-events: none;
  z-index: 3;
}

/* Bottom fade — blends into footer */
.matrix-rain-vignette-btm {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(to top, #000 0%, transparent 100%);
  pointer-events: none;
  z-index: 3;
}

.sidebar-footer {
  padding: 1rem 1.25rem 1.1rem;
  border-top: 1px solid var(--border-brass);
}

/* ── Fleet readout widget ─────────────────────── */
.fleet-readout {
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.readout-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-tech);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.readout-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.readout-dot-online {
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
  animation: readout-pulse 2s ease-in-out infinite;
}

.readout-dot-idle {
  background: rgba(255, 255, 255, 0.18);
}

@keyframes readout-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--neon-green); }
  50%       { opacity: 0.7; box-shadow: 0 0 12px var(--neon-green); }
}

.readout-glyph {
  width: 7px;
  text-align: center;
  color: var(--neon-cyan);
  font-size: 0.75rem;
  flex-shrink: 0;
  line-height: 1;
}

.readout-label {
  flex: 1;
  color: var(--text-muted);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

.readout-value {
  color: var(--neon-cyan);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: right;
  transition: color 0.2s;
}

.readout-value-machines {
  color: var(--neon-green);
}

.readout-dim {
  color: var(--text-muted);
  font-weight: 400;
}

@keyframes readout-tick {
  0%   { opacity: 0.4; color: #fff; }
  50%  { opacity: 1;   color: var(--neon-amber); }
  100% { opacity: 1;   color: var(--neon-cyan); }
}

.readout-flash {
  animation: readout-tick 0.6s ease-out forwards;
}

/* Readout progress bar */
.readout-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.readout-bar-track {
  flex: 1;
  height: 3px;
  background: rgba(201, 162, 39, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.readout-bar-fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.readout-bar-fill.readout-bar-active {
  background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
  box-shadow: 0 0 6px rgba(0, 245, 255, 0.35);
  animation: bar-shimmer 2.5s ease-in-out infinite;
  background-size: 200% 100%;
}

@keyframes bar-shimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.readout-bar-pct {
  font-family: var(--font-tech);
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  min-width: 2.2rem;
  text-align: right;
}

/* ── Signature ────────────────────────────────── */
.sidebar-sig {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(201, 162, 39, 0.1);
}

.sig-love {
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.sig-heart {
  color: #f87171;
  animation: heart-beat 1.8s ease-in-out infinite;
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  20%       { transform: scale(1.3); }
  40%       { transform: scale(0.95); }
}

.sig-ver {
  font-size: 0.55rem;
  color: rgba(0, 245, 255, 0.35);
  letter-spacing: 0.18em;
}

.main-with-status {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-with-status .main-content {
  margin-left: 0;
  flex: 1;
}

.main-content {
  flex: 1;
  margin-left: 0;
  padding: 2rem 2.5rem;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  .sidebar {
    width: 72px;
  }

  .logo-text-block,
  .nav-label,
  .fleet-readout,
  .sidebar-sig,
  .matrix-rain-wrap {
    display: none;
  }

  .sidebar-header {
    padding: 1rem 0.5rem;
    justify-content: center;
  }

  .logo {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 0.85rem;
  }

  .main-with-status {
    margin-left: 72px;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }
}
