/* ============================================================================
   ATLAS REDESIGN — Left nav rebuilt to the Claude design mock-up (2026-06-30)
   Source of truth: _redesign_handoff_v1.6_2026-06-30 .dc.html (Calm 74-164 / Operator 1859-1945).
   Loads AFTER redesign-shell.css so it owns the rail. Token-driven (--r-*) → both
   Calm + Operator themes. Routing classes (.rail-item[data-dept]) are preserved.
   ========================================================================== */

/* ── DESKTOP-ONLY (≥768px). At phone widths v6-mobile.css turns #rail into the
      fixed 64px bottom tab dock; this file's 212px width/grid locks and item
      cosmetics were beating those dock rules (they load later + carry the
      html[data-rtheme] specificity), crushing the 4 dock tabs into 4px slivers.
      The whole desktop rail spec is therefore media-guarded. ─────────────────── */
@media (min-width: 768px) {

/* ── rail width: mock is ~188-212px (NOT the old 286). v6-nav.css pins width/min/max
      to 286 !important and adds 18px padding — override all of it. ─────────────── */
html[data-rtheme] .frame { grid-template-columns: 212px 1fr !important; }
html[data-rtheme] #rail.sidebar {
  width: 212px !important; min-width: 212px !important; max-width: 212px !important;
  padding: 0 !important;
  background: var(--r-rail-bg) !important;
  border-right: 1px solid var(--r-rail-border) !important;
}
html[data-rtheme] #rail .sidebar-nav {
  padding: 12px 12px 8px !important;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto; overflow-x: hidden;
}

/* ── QUICK ACTION button (mock: primary-fill CTA + ⌘N chip) ─────────────────── */
html[data-rtheme] #rail .rail-quick {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: var(--r-primary) !important; color: var(--r-primary-ink) !important;
  border: none; border-radius: var(--r-radius-control, 10px);
  padding: 9px 11px; margin: 0 0 12px; cursor: pointer;
  font-family: var(--r-font-body); font-size: 13px; font-weight: 600;
  overflow: visible; /* undo v6-shell [class*="rail"] overflow leak */
  transition: filter var(--r-dur,.14s) var(--r-ease);
}
/* v6-shell.css's `.sidebar, [class*="rail"]` sets width:var(--sidebar-width) (286px)
   + overflow:hidden + the DARK RAIL GRADIENT on EVERY rail-* class — including
   this button's ico/label/kbd — which squashed the label to 1px AND painted a
   near-black box behind the lightning icon and the label text inside the green
   pill (Bryan 2026-07-03: "looks like it's not finished"). Reset width/overflow
   AND background on the children; the kbd chip rule below re-asserts its own
   translucent chip bg (higher specificity). */
html[data-rtheme] #rail .rail-quick > * { width: auto; overflow: visible; background: none; }
html[data-rtheme] #rail .rail-quick:hover { filter: brightness(.95); }
html[data-rtheme] #rail .rail-quick .rail-quick-ico { font-size: 16px; flex: none; }
html[data-rtheme] #rail .rail-quick .rail-quick-label { flex: 1; text-align: left; white-space: nowrap; }
html[data-rtheme] #rail .rail-quick .rail-quick-kbd {
  font-family: var(--r-font-mono); font-size: 9.5px; font-weight: 600;
  background: rgba(255,255,255,.16); border-radius: 5px; padding: 1px 5px;
  color: color-mix(in srgb, var(--r-primary-ink) 80%, transparent);
}
html[data-rtheme] #rail .rail-quick:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* ── SECTION HEADERS — clickable toggle buttons (mock: mono uppercase + caret) ─ */
html[data-rtheme] #rail .v6-nav-group { display: block; }
/* The ★ Favorites strip is removed per the mock — keep its stub hidden even if
   v7-tools.js repopulates it (the .v6-nav-group display:block above would otherwise
   beat the [hidden] attribute). */
html[data-rtheme] #rail #v7-fav-group { display: none !important; }
html[data-rtheme] #rail .v6-nav-group + .v6-nav-group { margin-top: 0; border-top: none; padding-top: 0; }
html[data-rtheme] #rail .v6-nav-heading {
  display: flex !important; align-items: center; gap: 6px; width: 100%;
  background: none !important; border: none !important; cursor: pointer;
  font-family: var(--r-font-mono) !important; font-size: 11.5px !important; font-weight: 700 !important;
  letter-spacing: .07em !important; text-transform: uppercase;
  color: var(--r-body) !important; opacity: 1 !important;
  margin: 14px 0 4px !important; padding: 5px 8px !important; text-align: left;
  justify-content: flex-start !important;
}
html[data-rtheme] #rail .v6-nav-group:first-of-type .v6-nav-heading,
html[data-rtheme] #rail .rail-quick + .v6-nav-group .v6-nav-heading { margin-top: 4px !important; }
html[data-rtheme] #rail .v6-nav-heading > span { flex: 1; }
html[data-rtheme] #rail .v6-nav-heading::after { display: none !important; } /* kill redesign-shell's pseudo caret */
html[data-rtheme] #rail .v6-nav-caret {
  font-size: 13px; color: var(--r-faint); transition: transform var(--r-dur,.16s) var(--r-ease); flex: none;
}
html[data-rtheme] #rail .v6-nav-group.rd-collapsed .v6-nav-caret { transform: rotate(-90deg); }
/* collapsed section hides its items (reuse redesign-shell behavior, scoped) */
html[data-rtheme] #rail .v6-nav-group.rd-collapsed .v6-nav-item { display: none !important; }

/* ── NAV ITEMS — single line: icon + label (+ badge / chip) ─────────────────── */
html[data-rtheme] #rail .v6-nav-item {
  display: flex !important; align-items: center; gap: 10px;
  padding: 8px 10px !important; margin-bottom: 1px;
  border-radius: 9px !important; text-decoration: none;
  background: transparent !important; border: none !important; box-shadow: none !important;
  color: var(--r-rail-ink) !important;
  font-family: var(--r-font-body) !important; font-size: 13.5px !important; font-weight: 500 !important;
  white-space: nowrap; cursor: pointer;
  transition: background var(--r-dur,.14s) var(--r-ease), color var(--r-dur,.14s) var(--r-ease);
}
html[data-rtheme] #rail .v6-nav-item .v6-nav-icon {
  font-size: 18px !important; flex: none; line-height: 1;
  color: var(--r-rail-muted) !important; width: auto !important; height: auto !important;
}
html[data-rtheme] #rail .v6-nav-item .v6-nav-label {
  flex: 1; color: var(--r-rail-ink) !important; -webkit-text-fill-color: var(--r-rail-ink) !important;
  font-weight: 500 !important; text-shadow: none !important; overflow: hidden; text-overflow: ellipsis;
}
/* hover */
html[data-rtheme] #rail .v6-nav-item:hover { background: var(--r-rail-bg-2) !important; }
html[data-rtheme="almanac"] #rail .v6-nav-item:hover { background: rgba(47,93,80,.07) !important; }
html[data-rtheme] #rail .v6-nav-item:hover .v6-nav-icon { color: var(--r-rail-ink) !important; }
/* active */
html[data-rtheme] #rail .v6-nav-item.active {
  background: var(--r-rail-active-bg) !important; box-shadow: none !important;
}
html[data-rtheme] #rail .v6-nav-item.active .v6-nav-label,
html[data-rtheme] #rail .v6-nav-item.active .v6-nav-icon {
  color: var(--r-rail-active-ink) !important; -webkit-text-fill-color: var(--r-rail-active-ink) !important;
}

/* ── BADGES (real-data-or-hidden) + CMA "AI" chip ───────────────────────────── */
html[data-rtheme] #rail .v6-nav-badge {
  flex: none; font-family: var(--r-font-mono); font-size: 12px; font-weight: 700;
  background: var(--r-mint-surface); color: var(--r-mint-ink);
  border-radius: 20px; padding: 1px 7px; line-height: 1.5;
}
html[data-rtheme] #rail .v6-nav-badge:empty { display: none !important; }
html[data-rtheme] #rail .v6-nav-chip {
  flex: none; font-family: var(--r-font-mono); font-size: 10px; font-weight: 700; letter-spacing: .04em;
  background: var(--r-mint-surface); color: var(--r-primary);
  border-radius: 5px; padding: 1px 5px; line-height: 1.6;
}

/* ── FOOTER — mock = single user card + Collapse; hide side-card/health/clock ── */
html[data-rtheme] #rail .v6-side-card,
html[data-rtheme] #rail .sb-health,
html[data-rtheme] #rail .sb-clock { display: none !important; }
html[data-rtheme] #rail .sidebar-foot {
  flex: none; padding: 8px 12px 14px !important; border-top: 1px solid var(--r-rail-border) !important;
  display: flex; flex-direction: column; gap: 4px;
}
/* Collapse nav item */
html[data-rtheme] #rail .rd-rail-collapse {
  display: flex !important; align-items: center; gap: 10px;
  padding: 8px 10px !important; border-radius: 9px !important; text-decoration: none; cursor: pointer;
  background: transparent !important; border: none !important;
  color: var(--r-rail-muted) !important; font-family: var(--r-font-body) !important;
  font-size: 13.5px !important; font-weight: 500 !important; width: auto !important; height: auto !important;
  min-width: 0 !important; max-width: none !important;
}
html[data-rtheme] #rail .rd-rail-collapse:hover { background: var(--r-rail-bg-2) !important; color: var(--r-rail-ink) !important; }
html[data-rtheme] #rail .rd-rail-collapse .v6-nav-icon { font-size: 18px !important; flex: none; color: var(--r-rail-muted) !important; }
html[data-rtheme] #rail .rd-rail-collapse .v6-nav-label { color: inherit !important; -webkit-text-fill-color: currentColor !important; }
/* user card (mock: bordered surface tile) */
html[data-rtheme] #rail .sb-user {
  display: flex !important; align-items: center; gap: 10px; width: 100%;
  padding: 10px !important; border: 1px solid var(--r-border) !important; border-radius: 11px !important;
  background: var(--r-surface) !important; text-align: left; cursor: pointer;
}
html[data-rtheme] #rail .sb-user:hover { background: var(--r-surface-2) !important; }
html[data-rtheme] #rail .sb-user-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 9px !important;
  background: var(--r-primary) !important; color: var(--r-primary-ink) !important;
  font-family: var(--r-font-mono); font-weight: 600; font-size: 12.5px;
  display: inline-flex; align-items: center; justify-content: center;
}
html[data-rtheme] #rail .sb-user-info { flex: 1; min-width: 0; line-height: 1.25; }
html[data-rtheme] #rail .sb-user-name { color: var(--r-ink) !important; -webkit-text-fill-color: var(--r-ink) !important; font-size: 13px !important; font-weight: 600 !important; }
html[data-rtheme] #rail .sb-user-role { color: var(--r-faint) !important; font-size: 12px !important; }
html[data-rtheme] #rail .sb-user-pill { display: none !important; }

} /* end @media (min-width: 768px) — desktop rail spec */

/* ════════════════════════════════════════════════════════════════════════════
   COLLAPSED (icon-only) — footer "Collapse" item toggles html[data-rail-collapsed]
   (rail-collapse.js). Desktop-only so the mobile drawer is never icon-ified.
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  html[data-rail-collapsed][data-rtheme] .frame { grid-template-columns: var(--r-rail-w-collapsed, 76px) 1fr !important; }
  html[data-rail-collapsed][data-rtheme] #rail.sidebar {
    width: var(--r-rail-w-collapsed, 76px) !important; min-width: var(--r-rail-w-collapsed, 76px) !important; max-width: var(--r-rail-w-collapsed, 76px) !important;
  }
  html[data-rail-collapsed] #rail .sidebar-nav { padding-left: 0 !important; padding-right: 0 !important; }
  /* Quick action → just the lightning icon, centered */
  html[data-rail-collapsed] #rail .rail-quick { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
  html[data-rail-collapsed] #rail .rail-quick .rail-quick-label,
  html[data-rail-collapsed] #rail .rail-quick .rail-quick-kbd { display: none !important; }
  /* headings hidden; every item shown icon-only & centered */
  html[data-rail-collapsed] #rail .v6-nav-heading { display: none !important; }
  html[data-rail-collapsed] #rail .v6-nav-group.rd-collapsed .v6-nav-item { display: flex !important; }
  html[data-rail-collapsed] #rail .v6-nav-item,
  html[data-rail-collapsed] #rail .rd-rail-collapse { justify-content: center !important; gap: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
  html[data-rail-collapsed] #rail .v6-nav-item .v6-nav-label,
  html[data-rail-collapsed] #rail .v6-nav-item .v6-nav-badge,
  html[data-rail-collapsed] #rail .v6-nav-item .v6-nav-chip,
  html[data-rail-collapsed] #rail .rd-rail-collapse .v6-nav-label { display: none !important; }
  html[data-rail-collapsed] #rail .v6-nav-item .v6-nav-icon { margin: 0 auto !important; }
  /* footer user card → avatar only */
  html[data-rail-collapsed] #rail .sb-user { justify-content: center !important; padding-left: 0 !important; padding-right: 0 !important; }
  html[data-rail-collapsed] #rail .sb-user-info { display: none !important; }
}

/* ── S9 (2026-07-04): rail brand polish — align the Quick-action CTA and the
   workspace switcher with the gold BrokerDIY wordmark. Single warm accent,
   zero raw hex: every gold derives from the --r-amber token via color-mix,
   so both themes stay calibrated. ──────────────────────────────────────── */
html[data-rtheme] #rail .rail-quick {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--r-amber) 72%, white) 0%,
    var(--r-amber) 46%,
    color-mix(in srgb, var(--r-amber) 72%, black) 100%) !important;
  color: color-mix(in srgb, black 84%, var(--r-amber)) !important;
  font-weight: 700;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--r-amber) 28%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 40%, transparent);
}
html[data-rtheme] #rail .rail-quick:hover { filter: brightness(1.06); }
html[data-rtheme] #rail .rail-quick .rail-quick-ico { color: inherit; }
html[data-rtheme] #rail .rail-quick .rail-quick-kbd {
  background: color-mix(in srgb, black 20%, transparent);
  color: color-mix(in srgb, black 72%, var(--r-amber));
}

/* Workspace switcher — quiet premium: hairline gold ring, gold monogram tile */
html[data-rtheme] #rail .org-switcher.v7-ws {
  border: 1px solid color-mix(in srgb, var(--r-amber) 32%, var(--r-line)) !important;
  border-radius: var(--r-radius-control, 10px) !important;
  background: color-mix(in srgb, var(--r-amber) 5%, var(--r-surface)) !important;
  transition: border-color .15s ease, box-shadow .15s ease;
}
html[data-rtheme] #rail .org-switcher.v7-ws:hover {
  border-color: color-mix(in srgb, var(--r-amber) 60%, var(--r-line)) !important;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--r-amber) 16%, transparent);
}
html[data-rtheme] #rail .org-switcher.v7-ws .v7-ws-tile {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--r-amber) 80%, white),
    color-mix(in srgb, var(--r-amber) 68%, black)) !important;
  color: color-mix(in srgb, black 78%, var(--r-amber)) !important;
  font-weight: 800;
  border-radius: 7px !important;
}
html[data-rtheme] #rail .org-switcher.v7-ws .v7-ws-name { letter-spacing: .04em; font-weight: 750; }
html[data-rtheme] #rail .org-switcher.v7-ws .v7-ws-arrow { color: color-mix(in srgb, var(--r-amber) 65%, var(--r-faint)); }
