/* Baiee Manager — chrome (rail + side + topbar) */

:root {
  --bm-bg: oklch(99% 0.002 260);
  --bm-bg-alt: oklch(97.5% 0.003 260);
  --bm-surface: #ffffff;
  --bm-surface-2: oklch(98.5% 0.003 260);
  --bm-border: oklch(92% 0.005 260);
  --bm-border-strong: oklch(86% 0.007 260);
  --bm-divider: oklch(94% 0.004 260);
  --bm-text: oklch(22% 0.01 260);
  --bm-text-2: oklch(42% 0.01 260);
  --bm-text-3: oklch(58% 0.008 260);
  --bm-text-muted: oklch(68% 0.006 260);
  --bm-brand: #8B1A2B;
  --bm-brand-600: #A52038;
  --bm-brand-700: #6B1421;
  --bm-brand-tint: #f5e0e4;
  --bm-brand-tint-2: #edccd2;

  /* Semantic */
  --bm-info: #3b6bd4;
  --bm-info-tint: #e8eefb;
  --bm-success: #2f9e5e;
  --bm-success-tint: #e6f4ec;
  --bm-warning: #c68321;
  --bm-warning-tint: #fbf0db;
  --bm-danger: #c94a3d;
  --bm-danger-tint: #fbe8e6;
  --bm-rail-bg: oklch(18% 0.008 260);
  --bm-rail-fg: oklch(88% 0.005 260);
  --bm-rail-fg-muted: oklch(68% 0.008 260);
  --bm-rail-border: oklch(14% 0.008 260);
  --bm-rail-hover: oklch(22% 0.01 260);
  --bm-rail-active: oklch(24% 0.012 260);
  --bm-shadow-1: 0 1px 2px rgba(15,23,42,0.04);

  --bm-rail-w: 64px;
  --bm-side-w: 240px;
  --bm-topbar-h: 56px;

  --bm-ff-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* App shell */
.bm-app {
  display: grid;
  grid-template-columns: var(--bm-rail-w) var(--bm-side-w) 1fr;
  grid-template-rows: var(--bm-topbar-h) 1fr;
  min-height: 100vh;
  background: var(--bm-bg);
  font-family: var(--bm-ff-sans);
  color: var(--bm-text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bm-app * { box-sizing: border-box; }
.bm-app a { color: inherit; text-decoration: none; }
.bm-app button { font-family: inherit; }

/* Rail (persistent dark icon column) */
.bm-rail {
  grid-row: 1 / 3;
  grid-column: 1 / 2;
  background: var(--bm-rail-bg);
  color: var(--bm-rail-fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  border-right: 1px solid var(--bm-rail-border);
  z-index: 10;
}

.bm-rail .bm-logo-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  overflow: hidden;
}

.bm-rail-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--bm-rail-fg-muted);
  cursor: pointer;
  position: relative;
  transition: background 120ms, color 120ms;
  border: 0;
  background: transparent;
  padding: 0;
}

.bm-rail-item:hover {
  background: var(--bm-rail-hover);
  color: oklch(94% 0.004 260);
}

.bm-rail-item.active {
  color: #fff;
  background: var(--bm-rail-active);
}

.bm-rail-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--bm-brand);
  border-radius: 2px;
}

.bm-rail-item i { font-size: 18px; line-height: 1; }
.bm-rail-spacer { flex: 1; }

/* Tooltip on rail items */
.bm-rail-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bm-rail-active);
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* Secondary sidebar (current group's children) */
.bm-side {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  background: var(--bm-surface);
  border-right: 1px solid var(--bm-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bm-side-head {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--bm-divider);
}

.bm-side-head .bm-brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--bm-text);
}

.bm-side-head .bm-brand-sub {
  font-size: 11.5px;
  color: var(--bm-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.bm-side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 12px;
}

.bm-side-section {
  padding: 12px 0 4px;
}

.bm-side-section + .bm-side-section {
  margin-top: 8px;
}

.bm-side-section .bm-eyebrow {
  padding: 0 10px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bm-text-3);
}

.bm-side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--bm-text-2);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

.bm-side-link:hover {
  background: var(--bm-surface-2);
  color: var(--bm-text);
}

.bm-side-link.active {
  background: var(--bm-bg-alt);
  color: var(--bm-text);
  font-weight: 500;
}

.bm-side-link i {
  font-size: 14px;
  width: 16px;
  text-align: center;
  color: var(--bm-text-3);
  flex-shrink: 0;
}

.bm-side-link.active i { color: var(--bm-brand-700); }

.bm-side-link .bm-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--bm-text-3);
  background: var(--bm-surface-2);
  border-radius: 4px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

.bm-side-foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--bm-divider);
  display: flex;
  align-items: center;
  gap: 10px;
}

.bm-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bm-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.bm-side-foot .bm-user { min-width: 0; line-height: 1.25; }
.bm-side-foot .bm-user .bm-n {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--bm-text);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.bm-side-foot .bm-user .bm-e {
  font-size: 11px;
  color: var(--bm-text-3);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Topbar */
.bm-top {
  grid-row: 1 / 2;
  grid-column: 3 / 4;
  height: var(--bm-topbar-h);
  background: var(--bm-surface);
  border-bottom: 1px solid var(--bm-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.bm-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--bm-text-3);
  min-width: 0;
}

.bm-crumbs .bm-sep { color: var(--bm-text-muted); }
.bm-crumbs .bm-cur {
  color: var(--bm-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 320px;
  max-width: 40vw;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--bm-border);
  border-radius: 6px;
  background: var(--bm-bg-alt);
  color: var(--bm-text-3);
  font-size: 12.5px;
}

.bm-search:focus-within {
  background: var(--bm-surface);
  border-color: var(--bm-brand);
  box-shadow: 0 0 0 3px var(--bm-brand-tint);
}

.bm-search input {
  border: 0;
  background: transparent;
  outline: none;
  flex: 1;
  color: var(--bm-text);
  font-family: inherit;
  font-size: 12.5px;
  min-width: 0;
}

.bm-search .bm-kbd {
  margin-left: auto;
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--bm-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--bm-text-2);
  background: var(--bm-surface);
}

.bm-top .bm-divider-v {
  width: 1px;
  height: 24px;
  background: var(--bm-divider);
}

.bm-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--bm-text-2);
  cursor: pointer;
  position: relative;
  background: transparent;
  border: 0;
  padding: 0;
}

.bm-icon-btn:hover {
  background: var(--bm-surface-2);
  color: var(--bm-text);
}

.bm-icon-btn i { font-size: 16px; line-height: 1; }

.bm-icon-btn .bm-pip {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bm-brand);
  border: 1.5px solid var(--bm-surface);
}

/* User dropdown trigger */
.bm-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--bm-text);
  font-family: inherit;
  font-size: 13px;
}

.bm-user-btn:hover { background: var(--bm-surface-2); }
.bm-user-btn .bm-user-name { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Override Bootstrap dropdown menu look to match */
.bm-top .dropdown-menu {
  border: 1px solid var(--bm-border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
  padding: 6px;
  font-size: 13px;
}
.bm-top .dropdown-item {
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--bm-text-2);
}
.bm-top .dropdown-item:hover { background: var(--bm-surface-2); color: var(--bm-text); }
.bm-top .dropdown-divider { margin: 4px 0; border-top-color: var(--bm-divider); }

/* Main content */
.bm-main {
  grid-row: 2 / 3;
  grid-column: 3 / 4;
  min-width: 0;
  overflow: auto;
  background: var(--bm-bg);
}

.bm-main-inner {
  padding: 24px 28px 48px;
}

/* Mobile menu button */
.bm-mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--bm-text);
  cursor: pointer;
  font-size: 20px;
}
.bm-mobile-toggle:hover { background: var(--bm-surface-2); }

/* Responsive */
@media (max-width: 1024px) {
  .bm-app {
    grid-template-columns: var(--bm-rail-w) 1fr;
  }
  .bm-side {
    display: none;
    position: fixed;
    top: 0;
    left: var(--bm-rail-w);
    bottom: 0;
    width: var(--bm-side-w);
    z-index: 20;
    box-shadow: 4px 0 16px rgba(15,23,42,0.10);
  }
  .bm-app.bm-side-open .bm-side { display: flex; }
  .bm-top, .bm-main {
    grid-column: 2 / 3;
  }
  .bm-mobile-toggle { display: inline-flex; }
}

@media (max-width: 640px) {
  .bm-search { display: none; }
  .bm-user-btn .bm-user-name { display: none; }
  .bm-main-inner { padding: 16px 16px 32px; }
}

/* RTL */
[dir="rtl"] .bm-rail {
  border-right: 0;
  border-left: 1px solid var(--bm-rail-border);
}
[dir="rtl"] .bm-rail-item.active::before { left: auto; right: -10px; }
[dir="rtl"] .bm-side {
  border-right: 0;
  border-left: 1px solid var(--bm-border);
}
[dir="rtl"] .bm-side-link .bm-count { margin-left: 0; margin-right: auto; }
[dir="rtl"] .bm-search { margin-left: 0; margin-right: auto; }
[dir="rtl"] .bm-search .bm-kbd { margin-left: 0; margin-right: auto; }
[dir="rtl"] .bm-rail-item[data-tip]:hover::after {
  left: auto;
  right: calc(100% + 10px);
}
@media (max-width: 1024px) {
  [dir="rtl"] .bm-side {
    left: auto;
    right: var(--bm-rail-w);
  }
}
