@layer base {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    z-index: var(--z-sidebar);
    transition: width 160ms ease, min-width 160ms ease, max-width 160ms ease;
    display: flex;
    flex-direction: column;
    background:
      linear-gradient(165deg, rgba(17, 28, 52, 0.97) 0%, rgba(8, 15, 32, 0.99) 48%, rgba(10, 20, 42, 1) 100%),
      radial-gradient(120% 80% at 50% -20%, rgba(56, 189, 248, 0.12), transparent 55%);
    color: #e5e7eb;
    padding: 14px 14px 12px;
    border-right: 1px solid rgba(148, 163, 184, 0.14);
    gap: 8px;
    box-shadow:
      inset -1px 0 0 rgba(148, 163, 184, 0.08),
      18px 0 42px rgba(2, 6, 23, 0.45);
    overflow-x: hidden;
    overflow-y: hidden;
  }

  #menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0;
    scrollbar-gutter: stable;
    position: relative;
    z-index: 2;
  }

  #menu::-webkit-scrollbar {
    width: 5px;
  }

  #menu::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.45);
    border-radius: 99px;
  }

  .brand {
    flex: 0 0 auto;
    margin-bottom: 0;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    max-height: 72px;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.42);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 28px rgba(2, 6, 23, 0.22);
    position: relative;
    z-index: 2;
  }

  .brand-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
  }

  .sidebar .brand .brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 11px;
    flex: 0 0 auto;
    filter: drop-shadow(0 4px 12px rgba(15, 23, 42, 0.55));
  }

  .brand-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #f8fafc;
    line-height: 1.15;
    white-space: nowrap;
    text-shadow: 0 2px 18px rgba(56, 189, 248, 0.16);
  }

  .brand-logo-print {
    width: 44px;
    height: 44px;
    object-fit: contain;
  }

  .brand-watermark {
    position: absolute;
    right: 10px;
    top: 8px;
    width: 64px;
    height: 64px;
    object-fit: contain;
    opacity: 0.06;
    pointer-events: none;
    user-select: none;
  }

  .sidebar-bottom-cluster {
    flex: 0 0 auto;
    margin-top: auto;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Command Center — single bottom card */
  .sidebar-command-card {
    margin-top: 0;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    padding: 14px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    background:
      linear-gradient(155deg, rgba(30, 41, 59, 0.55) 0%, rgba(15, 23, 42, 0.92) 45%, rgba(8, 15, 28, 0.96) 100%),
      radial-gradient(90% 55% at 50% 0%, rgba(56, 189, 248, 0.09), transparent 60%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 14px 34px rgba(2, 6, 23, 0.42),
      0 0 0 1px rgba(15, 23, 42, 0.55);
    flex: 0 0 auto;
    z-index: 1;
  }

  .sidebar-command-card::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -25%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.14) 0%, transparent 68%);
    pointer-events: none;
  }

  .sidebar-command-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    min-height: 22px;
  }

body.use-new-ui .sidebar .sidebar-command-kicker {
  font-size: var(--type-sidebar-meta);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
  line-height: 1.2;
}

body.use-new-ui .sidebar .sidebar-online-dot {
  flex-shrink: 0;
  font-size: var(--fs-2xs);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  line-height: 1;
  color: #86efac;
  background: rgba(22, 163, 74, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.38);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.12);
}

  .sidebar-online-dot {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 999px;
    line-height: 1;
    color: #86efac;
    background: rgba(22, 163, 74, 0.18);
    border: 1px solid rgba(74, 222, 128, 0.38);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.12);
  }

  .sidebar-online-dot--offline {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(252, 165, 165, 0.38);
    box-shadow: none;
  }

  .sidebar-command-clock {
    position: relative;
    text-align: center;
    margin-bottom: 12px;
  }

  .sidebar-command-clock .sidebar-clock-time {
    font-size: var(--type-sidebar-clock, 44px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.03em;
    color: #f0f9ff;
    text-shadow: 0 4px 28px rgba(56, 189, 248, 0.22);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
  }

  .sidebar-clock-sub {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.35;
    min-width: 0;
  }

  .sidebar-clock-sub-dot {
    opacity: 0.45;
    user-select: none;
  }

  .sidebar-fx-chip-grid {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 4px;
  }

  .sidebar-fx-chip {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
    padding: 8px;
    min-width: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .sidebar-fx-chip .fx-icon {
    grid-row: 1 / -1;
    font-size: 15px;
    line-height: 1;
    opacity: 0.92;
    align-self: center;
  }

  .sidebar-fx-chip .fx-label {
    grid-column: 2;
    grid-row: 1;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-fx-chip strong {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: 13px;
    font-weight: 800;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
  }

  .sidebar-mini-stats {
    position: relative;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
  }

  .sidebar-mini-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-top: 1px solid rgba(148, 163, 184, 0.07);
    min-width: 0;
  }

  .sidebar-mini-stat:first-child {
    border-top: none;
    padding-top: 2px;
  }

  .sidebar-mini-stat span {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.02em;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-mini-stat strong {
    margin: 0;
    font-size: 12.5px;
    font-weight: 750;
    color: #f1f5f9;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
  }

  .sidebar-command-foot {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 11px;
    min-width: 0;
  }

  .sidebar-command-foot-label {
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .sidebar-command-foot-time {
    margin: 0;
    font-weight: 750;
    font-size: 11px;
    color: #cbd5e1;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  body.dark .sidebar-mini-stat strong {
    color: #f8fafc;
  }

  .menu-item {
    border: 1px solid transparent;
    background: transparent;
    color: #c7d5ee;
    text-align: left;
    padding: 10px 12px;
    min-height: 46px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--type-sidebar-menu, var(--fs-md));
    font-weight: 600;
    transition:
      background-color var(--instant-ms) var(--instant-ease),
      color var(--instant-ms) var(--instant-ease),
      box-shadow var(--instant-ms) var(--instant-ease),
      border-color var(--instant-ms) var(--instant-ease);
  }

  .menu-label {
    line-height: 1.25;
    min-width: 0;
  }

  .menu-ico {
    width: 28px;
    min-width: 28px;
    font-size: 17px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    opacity: 0.9;
    transition: opacity var(--instant-ms) var(--instant-ease);
  }

  .menu-item:hover .menu-ico,
  .menu-item.active .menu-ico {
    opacity: 1;
  }

  .menu-item:hover {
    background: rgba(51, 65, 85, 0.42);
    color: #ffffff;
    border-color: rgba(148, 163, 184, 0.12);
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.08), 0 10px 26px rgba(2, 6, 23, 0.25);
  }

  .menu-item.active {
    min-height: 46px;
    background: linear-gradient(94deg, rgba(56, 189, 248, 0.14) 0%, rgba(99, 102, 241, 0.2) 100%);
    color: #ffffff;
    border-color: rgba(147, 197, 253, 0.38);
    box-shadow:
      0 0 0 1px rgba(147, 197, 253, 0.22),
      0 0 28px rgba(56, 189, 248, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .menu-item.active:hover {
    box-shadow:
      0 0 0 1px rgba(147, 197, 253, 0.32),
      0 0 32px rgba(56, 189, 248, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .sidebar-menu-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .sidebar-menu-group__toggle {
    width: 100%;
  }

  .sidebar-menu-group__chev {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.75;
    flex-shrink: 0;
  }

  .sidebar-sublist {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0 0 2px 10px;
    margin-left: 8px;
    border-left: 1px solid rgba(148, 163, 184, 0.22);
  }

  .sidebar-sublist[hidden] {
    display: none !important;
  }

  .sidebar-subitem {
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: var(--type-sidebar-sub, 13px) !important;
    font-weight: 600 !important;
  }

  .sidebar-subitem .menu-ico {
    width: 22px;
    min-width: 22px;
    font-size: 14px;
  }

  .sidebar-menu-group.is-active-hub > .sidebar-menu-group__toggle {
    border-color: rgba(147, 197, 253, 0.2);
  }

  body.sidebar-collapsed .sidebar-sublist,
  body.sidebar-collapsed .sidebar-menu-group__chev {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-menu-group__toggle .menu-label {
    display: none;
  }

  .sidebar-toggle {
    display: none;
    border: 1px solid rgba(148, 163, 184, 0.26);
    background: rgba(15, 23, 42, 0.45);
    color: #e2e8f0;
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
    position: relative;
    z-index: 2;
  }

  body.sidebar-collapsed .sidebar {
    width: 82px;
    min-width: 82px;
    max-width: 82px;
  }

  @media (max-height: 760px) {
    .sidebar {
      padding: 12px 14px 10px;
      gap: 6px;
    }

    .sidebar-fx-chip-grid {
      display: none !important;
    }

    .sidebar-command-clock .sidebar-clock-time {
      font-size: 34px;
    }

    #menu {
      gap: 4px;
    }

    .menu-item {
      padding: 9px 12px;
      min-height: 44px;
    }

    .menu-item.active {
      min-height: 44px;
    }
  }

  @media (max-height: 640px) {
    .sidebar-command-card {
      display: none !important;
    }

    .sidebar-bottom-cluster {
      gap: 0;
    }
  }

  /* Desktop dashboard only — flatter sidebar (QA: other routes unchanged) */
  @media (min-width: 769px) {
    body.use-new-ui.route-dashboard .sidebar {
      background: linear-gradient(180deg, #0f172a 0%, #0c1424 52%, #0a101c 100%);
      border-right-color: rgba(51, 65, 85, 0.42);
      box-shadow: inset -1px 0 0 rgba(148, 163, 184, 0.05);
    }

    body.use-new-ui.route-dashboard .brand {
      background: rgba(15, 23, 42, 0.38);
      border-color: rgba(71, 85, 105, 0.42);
      box-shadow: none;
    }

    body.use-new-ui.route-dashboard .brand-title {
      color: #e2e8f0;
      letter-spacing: 0.045em;
      text-shadow: none;
    }

    body.use-new-ui.route-dashboard .sidebar .brand .brand-logo {
      filter: none;
    }

    body.use-new-ui.route-dashboard .menu-item {
      color: #94a3b8;
    }

    body.use-new-ui.route-dashboard .menu-item:hover {
      background: rgba(255, 255, 255, 0.045);
      color: #e2e8f0;
      border-color: rgba(71, 85, 105, 0.5);
      box-shadow: none;
    }

    body.use-new-ui.route-dashboard .menu-item.active {
      background: rgba(255, 255, 255, 0.07);
      color: #f8fafc;
      border-color: rgba(148, 163, 184, 0.22);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }

    body.use-new-ui.route-dashboard .menu-item.active:hover {
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
    }

    /* Command clock + FX: blend with flatter nav (dashboard route only) */
    body.use-new-ui.route-dashboard .sidebar-command-card {
      border-color: rgba(71, 85, 105, 0.52);
      background: linear-gradient(180deg, rgba(30, 41, 59, 0.38), rgba(15, 23, 42, 0.9));
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 6px 18px rgba(2, 6, 23, 0.28);
    }

    body.use-new-ui.route-dashboard .sidebar-command-card::before {
      opacity: 0.08;
    }

    body.use-new-ui.route-dashboard .sidebar-command-kicker {
      color: #94a3b8;
      letter-spacing: 0.12em;
    }

    body.use-new-ui.route-dashboard .sidebar-command-clock .sidebar-clock-time {
      color: #e2e8f0;
      text-shadow: none;
      font-weight: 800;
    }

    body.use-new-ui.route-dashboard .sidebar-online-dot {
      color: #bbf7d0;
      background: rgba(22, 163, 74, 0.14);
      border-color: rgba(74, 222, 128, 0.28);
      box-shadow: none;
    }

    body.use-new-ui.route-dashboard .sidebar-fx-chip {
      background: rgba(255, 255, 255, 0.045);
      border: 1px solid rgba(71, 85, 105, 0.48);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    }

    body.use-new-ui.route-dashboard .sidebar-fx-chip .fx-label {
      color: #94a3b8;
    }

    body.use-new-ui.route-dashboard .sidebar-fx-chip strong {
      color: #e2e8f0;
      font-weight: 800;
    }

    body.use-new-ui.route-dashboard .sidebar-mini-stats {
      border-top-color: rgba(71, 85, 105, 0.42);
    }

    body.use-new-ui.route-dashboard .sidebar-mini-stat span {
      color: #94a3b8;
    }

    body.use-new-ui.route-dashboard .sidebar-mini-stat strong {
      color: #e2e8f0;
    }
  }
}

/* Shell isolation — sidebar nav must not inherit page/route table density (unlayered wins vs style.css) */
body.use-new-ui .sidebar #menu .menu-item,
body.use-new-ui .sidebar .menu-item {
  box-sizing: border-box;
  min-height: 46px;
  padding: 10px 12px;
  font-size: var(--type-sidebar-menu, var(--fs-md));
  font-weight: 600;
  line-height: var(--lh-tight, 1.25);
  border-radius: 14px;
}

body.use-new-ui .sidebar #menu .menu-ico,
body.use-new-ui .sidebar .menu-ico {
  width: 28px;
  min-width: 28px;
  font-size: 17px;
}

body.use-new-ui .sidebar .brand,
body.use-new-ui .sidebar .brand-logo,
body.use-new-ui .sidebar .brand-title,
body.use-new-ui .sidebar .menu-label {
  box-sizing: border-box;
}

/* Right-edge glow — separates navy rail from workspace canvas */
body.use-new-ui .sidebar {
  box-shadow:
    inset -1px 0 rgba(255, 255, 255, 0.04),
    8px 0 30px rgba(15, 23, 42, 0.08);
}
