.btn-block {
    width: 100%;
}

body {
    font-size: .875rem;
}

/*
 * Sidebar
 */

.sidebar {
    position: relative;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100; /* Behind the navbar */
    padding: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: var(--bs-body-tertiary);
}

@media (max-width: 767.98px) {
    .sidebar {
        top: 0;
    }
}

.sidebar-sticky {
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}

.sidebar .nav-link {
    font-weight: 500;
    color: var(--bs-body-color);
}

.sidebar .nav-link .bi {
    margin-right: 4px;
    color: var(--bs-secondary-color);
}

.sidebar .nav-link.active {
    color: var(--bs-primary);
}

.sidebar .nav-link:hover .bi,
.sidebar .nav-link.active .bi {
    color: inherit;
}

.sidebar-heading {
    font-size: .75rem;
}

/* ---- libraNav: light theme = dark slate rows (except first) + light-blue active; dark theme = #212529 rows ---- */
nav.sidebar { background-color: #32404e !important; }
nav.sidebar .navbar-brand { color: #dfe4e8 !important; }
[data-xtype=nav] tr[data-selected] td,
[data-xtype=nav] tbody tr[data-selected] td,
[data-xtype=nav] td[data-selected] { background-color: #35baf6 !important; color: #fff !important; }
nav.sidebar libra-nav a { color: #dfe4e8; }
nav.sidebar libra-nav a:hover { color: #fff; }
nav.sidebar libra-nav tr[data-selected] a,
nav.sidebar libra-nav td[data-selected] a { color: #fff !important; }
.brand-band { background-color: #35baf6 !important; color: #fff !important; }
body { background-color: #f6f6f6 !important; }
[data-xtype=nav] :first-child td { background-color: #35baf6 !important; color: #fff !important; }
[data-xtype=nav] tr[data-selected]:first-child td { background-color: #35baf6 !important; color: #fff !important; }

/* ---- nav theme tokens (inherit into shadow DOM); nav rows except first match the header bg ---- */
:root, [data-bs-theme="light"] {
  --libra-nav-bg: #32404e;
  --libra-nav-text: #dfe4e8;
  --libra-nav-hover-bg: #3c4854;
  --libra-nav-active-bg: #35baf6;
  --libra-nav-active-text: #ffffff;
  --libra-nav-first-bg: #35baf6;   /* light keeps the accent row */
  --libra-tree-hover-bg: #e9ecef;
}
[data-bs-theme="cool-dark"] {
  --libra-nav-bg: #212529;
  --libra-nav-text: #e9ecef;
  --libra-nav-hover-bg: #1a1d1f;
  --libra-nav-active-bg: #161719;
  --libra-nav-active-text: #e9ecef;
  --libra-nav-first-bg: #161719;   /* the first node is its own shade in the dark themes */
  --libra-tree-hover-bg: #1a1d1f;
}
[data-bs-theme="warm-dark"] {
  --libra-nav-bg: #272727;
  --libra-nav-text: #ffffff;
  --libra-nav-hover-bg: #323232;
  --libra-nav-active-bg: #373737;
  --libra-nav-active-text: #ffffff;
  --libra-nav-first-bg: #151515;   /* the first node is its own shade (warm dark) */
  --libra-tree-bg: #272727;
  --libra-tree-hover-bg: #323232;
  --libra-panel-bg: #272727;
  --libra-range-track: #4a4a4a;
}

/* ---- dark themes: nav rows except first match the header bg; first button + body darker ---- */
[data-bs-theme="cool-dark"] nav.sidebar { background-color: #212529 !important; }
[data-bs-theme="warm-dark"] nav.sidebar { background-color: #272727 !important; }
[data-bs-theme="cool-dark"] body { background-color: #161719 !important; }
[data-bs-theme="warm-dark"] body { background-color: #2c2c2c !important; }
[data-bs-theme="cool-dark"] nav.sidebar .navbar-brand { color: #e9ecef !important; }
[data-bs-theme="warm-dark"] nav.sidebar .navbar-brand { color: #ffffff !important; }
[data-bs-theme="cool-dark"] nav.sidebar libra-nav a { color: #e9ecef; }
[data-bs-theme="warm-dark"] nav.sidebar libra-nav a { color: #ffffff; }
[data-bs-theme="cool-dark"] nav.sidebar libra-nav a:hover { color: #f8f9fa; }
[data-bs-theme="warm-dark"] nav.sidebar libra-nav a:hover { color: #d4d4d3; }
[data-bs-theme="cool-dark"] [data-xtype=nav] tr[data-selected] td,
[data-bs-theme="cool-dark"] [data-xtype=nav] td[data-selected] { background-color: #1a1d1f !important; color: #e9ecef !important; }
[data-bs-theme="warm-dark"] [data-xtype=nav] tr[data-selected] td,
[data-bs-theme="warm-dark"] [data-xtype=nav] td[data-selected] { background-color: #373737 !important; color: #ffffff !important; }
[data-bs-theme="cool-dark"] .brand-band,
[data-bs-theme="cool-dark"] [data-xtype=nav] :first-child td,
[data-bs-theme="cool-dark"] [data-xtype=nav] tr[data-selected]:first-child td { background-color: #161719 !important; color: #e9ecef !important; }
[data-bs-theme="warm-dark"] .brand-band,
[data-bs-theme="warm-dark"] [data-xtype=nav] :first-child td,
[data-bs-theme="warm-dark"] [data-xtype=nav] tr[data-selected]:first-child td { background-color: #151515 !important; color: #ffffff !important; }
[data-bs-theme="cool-dark"] .wmMenuView tbody[data-xtype=tree] tr[data-loid]:hover,
[data-bs-theme="cool-dark"] .wmMenuView tbody[data-xtype=tree] tr:hover,
[data-bs-theme="cool-dark"] .wmMenuView tbody[data-xtype=table] tr:hover { background-color: #1a1d1f; }
[data-bs-theme="warm-dark"] .wmMenuView tbody[data-xtype=tree] tr[data-loid]:hover,
[data-bs-theme="warm-dark"] .wmMenuView tbody[data-xtype=tree] tr:hover,
[data-bs-theme="warm-dark"] .wmMenuView tbody[data-xtype=table] tr:hover { background-color: #323232; }

/* ---- warm-dark panels: header bar #272727; menuView title #151515 ---- */
/* PLAIN rule (no [data-bs-theme] prefix): --libra-panel-bg inherits into any shadow root. */
header.topbar { background-color: var(--libra-panel-bg, var(--bs-body-bg)) !important; }
[data-bs-theme="warm-dark"] .wmMenuView .carousel-item.active > .card-header { background-color: #151515 !important; }

/* ---- header layout: attach to nav, no gaps ---- */
nav.sidebar + div { margin: 0; padding: 0; }

/* ---- nav menu: fill the sidebar; scroll only when items overflow ---- */
nav.sidebar { overflow: hidden !important; }
nav.sidebar libra-nav { height: 100% !important; }
nav.sidebar libra-nav [data-xtype=nav] { overflow: hidden !important; }
nav.sidebar .sidebar-sticky { height: 100%; }
/* fixed per-item row height (no color change) */
nav.sidebar libra-nav tbody tr { height: 56px; }
nav.sidebar libra-nav tbody tr td { height: 56px; }

/* ---- wmView: transparent, no border; same 7px gutter as wmMenuView (all sides) ---- */
.wmView { margin: 7px !important; }
.wmMenuView { margin: 7px 0 7px 7px !important; }
.wmPocket { margin: 7px 7px 7px 0 !important; }

/* ---- wmView view roots that use Bootstrap .container: keep the root a FULL-WIDTH scroller (so the
   vertical scrollbar sits on the wmView right border) while its content stays centered like a
   Bootstrap container. `.carousel-item` (float + margin-right:-100%) otherwise overrode `.container`'s
   auto-margins, leaving the box left-aligned with an inset scrollbar. Widths are reproduced as
   symmetric padding; height stays 100% so tables/lists keep their internal scroll. ---- */
.wmView > .carousel-item.container{
  float:none !important; margin-left:0 !important; margin-right:0 !important;
  max-width:none !important; width:100% !important; box-sizing:border-box;
  padding-left:12px !important; padding-right:12px !important;
}
@media (min-width:576px){.wmView>.carousel-item.container{padding-left:max(12px,calc((100% - 540px)/2))!important;padding-right:max(12px,calc((100% - 540px)/2))!important}}
@media (min-width:768px){.wmView>.carousel-item.container{padding-left:max(12px,calc((100% - 720px)/2))!important;padding-right:max(12px,calc((100% - 720px)/2))!important}}
@media (min-width:992px){.wmView>.carousel-item.container{padding-left:max(12px,calc((100% - 960px)/2))!important;padding-right:max(12px,calc((100% - 960px)/2))!important}}
@media (min-width:1200px){.wmView>.carousel-item.container{padding-left:max(12px,calc((100% - 1140px)/2))!important;padding-right:max(12px,calc((100% - 1140px)/2))!important}}
@media (min-width:1400px){.wmView>.carousel-item.container{padding-left:max(12px,calc((100% - 1320px)/2))!important;padding-right:max(12px,calc((100% - 1320px)/2))!important}}

/* ---- pocket GNOME taskbar: Bootstrap btn-outline-secondary look (icons left) ---- */
.widgets-container .btn { border-radius: var(--bs-btn-border-radius, var(--bs-border-radius, 0.375rem)); }
.widgets-container .btn-outline-secondary { border-color: var(--bs-secondary); color: var(--bs-secondary); }
.widgets-container .btn-outline-secondary:hover { background-color: var(--bs-secondary); color: #fff; }
.widgets-container .btn .bi { font-size: 1rem; }

/* ---- header tools: vertical alignment (anonymous === globe icon) ---- */
header .btn, header libra-a, header .nav-link,
header libra-menu > a, header a.nav-link {
  display: inline-flex !important; align-items: center !important;
  line-height: 1 !important; vertical-align: middle !important;
}
header libra-menu { display: inline-flex !important; align-items: center !important; }
header libra-menu .nav-link { padding-top: .35rem !important; padding-bottom: .35rem !important; }
header libra-container, header libra-container * { vertical-align: middle !important; }
/* binding: [hidden] must win over the inline-flex alignment above */
header .btn[hidden], header libra-a[hidden], header libra-menu[hidden],
header .nav-link[hidden], header libra-container button[hidden] { display: none !important; }
/* responsive display utilities must also win over `header .btn { display:inline-flex !important }`:
   `.d-none` (mobile-only hide, e.g. the desktop `clps` collapse) and `.d-md-none` (mobile-only show,
   e.g. the mobile drawer icons) */
@media (max-width: 767.98px) { header .btn.d-none { display: none !important; } }
@media (min-width: 768px) { header .btn.d-md-none { display: none !important; } }
[hidden] { display: none !important; }

/*
 * Navbar
 */

.navbar-brand {
    padding-top: .75rem;
    padding-bottom: .75rem;
    background-color: rgba(var(--bs-emphasis-color-rgb), .05);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}

.navbar .navbar-toggler {
    top: .25rem;
    right: 1rem;
}

.navbar .form-control {
    padding: .75rem 1rem;
}

.form-control-dark {
    color: var(--bs-body-color);
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

.form-control-dark:focus {
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(53, 186, 246, .25);
}

/* ---- auth views (signin/signup/signon) ---- */
.auth-left { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 2rem 1.5rem; }
.auth-right { min-height: 100vh; background-color: var(--bs-tertiary-bg); display: flex; align-items: center; justify-content: center; }
.auth-logo { margin-bottom: 1.5rem; }
.auth-logo img { max-height: 48px; width: auto; }
.auth-title { font-weight: 700; color: var(--bs-body-color); }
.auth-subtitle { color: var(--bs-secondary-color); }
.divider { display: flex; align-items: center; justify-content: center; gap: .75rem; }
.divider:before, .divider:after { content: ""; flex: 1; border-top: 1px solid var(--bs-border-color); }
.text-gray-600 { color: var(--bs-secondary-color); }
.has-icon-left { position: relative; }
.has-icon-left .form-control-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); z-index: 2; }
.has-icon-left .form-control { padding-left: 2.5rem; }

/* ---- user menu (WmOne header) ---- */
#user-menu .dropdown-toggle { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem; }
#user-menu .dropdown-menu { min-width: 11rem; padding-left: 0; padding-right: 0; }
#user-menu .dropdown-menu .dropdown-item { display: flex; align-items: center; gap: .5rem; padding-left: 1rem; text-align: left; }
#user-menu .dropdown-menu .dropdown-item .bi { margin-right: .5rem; flex: 0 0 auto; }
#user-menu a.nav-link.dropdown-toggle { cursor: pointer; }
#user-menu .dropdown-menu .dropdown-item { justify-content: flex-start; text-align: left; }
#user-menu .dropdown-menu .dropdown-item > a,
#user-menu .dropdown-menu .dropdown-item > button { display: flex; align-items: center; justify-content: flex-start; text-align: left; gap: .5rem; }
#user-menu .dropdown-menu .dropdown-item > button.btn { padding-left: 0; padding-right: .5rem; }

/* ---- header libra-menu dropdown items: space between the icon and the label ---- */
header libra-menu .dropdown-menu .dropdown-item { display: flex; align-items: center; gap: .5rem; padding-left: 1rem; text-align: left; }
header libra-menu .dropdown-menu .dropdown-item .bi { margin-right: .5rem; flex: 0 0 auto; }
header libra-menu .dropdown-menu .dropdown-item > button,
header libra-menu .dropdown-menu .dropdown-item > a { display: flex; align-items: center; justify-content: flex-start; text-align: left; gap: .5rem; }
header libra-menu .dropdown-menu .dropdown-item > button.btn { padding-left: 0; padding-right: .5rem; }

/* ---- libra-menu: nested libra-container trigger (dropdown toggle) ---- */
.menu > li > libra-container { display: inline-flex !important; align-items: center !important; gap: .5rem; padding: .25rem .5rem; cursor: pointer; }
.menu > li > libra-container libra-button, .menu > li > libra-container .btn { display: inline-flex; align-items: center; }
.menu > li > libra-container > * { align-self: center; }
#user-menu .dropdown-menu { min-width: 11rem; padding-left: 0; padding-right: 0; }
#user-menu .dropdown-menu .dropdown-item { display: flex; align-items: center; gap: .5rem; padding-left: 1rem; text-align: left; }
#user-menu .dropdown-menu .dropdown-item .bi { margin-right: .5rem; flex: 0 0 auto; }
#user-menu a.nav-link.dropdown-toggle, #user-menu libra-container.nav-link.dropdown-toggle { cursor: pointer; }

/* ---- fix top-right menu overflow: keep dropdown border inside the window (+5px) ---- */
#bd-theme-menu .dropdown-menu,
#bd-theme-menu.dropdown-menu,
#user-menu .dropdown-menu { right: 5px !important; left: auto !important; max-width: calc(100vw - 10px); }

/* ---- pocket theme menu: dropdown items like the user-menu (plain, no button box) ---- */
#bd-theme-menu .dropdown-item { display: flex; align-items: center; gap: .5rem; padding-left: 1rem; text-align: left; }
#bd-theme-menu .dropdown-item .bi { margin-right: .5rem; flex: 0 0 auto; }
#bd-theme-menu .dropdown-item.btn,
#bd-theme-menu .dropdown-item.cp { border: 0; border-radius: 0; background-color: transparent; }

/* ---- wmMenuView: fixed centered menu title (card-header) + scrollable body ---- */
.wmMenuView .carousel-item.active { display: flex !important; flex-direction: column; overflow-x: hidden !important; overflow-y: hidden !important; }
.wmMenuView .carousel-item.active > .card-header { flex: 0 0 auto; min-height: 0; text-align: center; padding: .4rem .75rem; font-size: .8rem; font-weight: 600; border-bottom: 1px solid var(--bs-border-color); }
.wmMenuView .carousel-item.active > libra-tree,
.wmMenuView .carousel-item.active > libra-table,
.wmMenuView .carousel-item.active > libra-expander { flex: 1 1 auto !important; min-height: 0; overflow-y: auto; }


/* ---- table filters panel: compact and/or toggle (pressed smaller), narrow left-aligned rule select ---- */
.le-tog{ padding:.08rem .3rem; font-size:.66rem; line-height:1.15; min-width:1.9rem }
.le-tog.le-tog-on, .le-tog.le-tog-on:hover, .le-tog.le-tog-on:focus{ padding:.03rem .18rem; font-size:.58rem; min-width:1.5rem }
.le-rule{ width:2.3rem; flex:0 0 auto; padding:.15rem .1rem; font-size:.62rem; text-align:left }

/* ---- mobile shell (WmOne responsive): off-canvas menuNav (right) + wmMenuView (left) ---- */
@media (max-width: 767.98px) {
  /* keep header/main at the top, full width (libra.css wraps the row at <=575.98px) */
  .d-flex.flex-row.fit { flex-wrap: nowrap !important; }
  .d-flex.flex-row.fit > div.fit { flex: 1 1 100% !important; min-width: 0 !important; width: 100% !important; }

  /* menuNav: slide in from the right edge (width fits the widest node, capped) */
  nav.sidebar {
    position: fixed !important;
    top: 0; right: 0; left: auto;
    height: 100vh !important;
    min-height: 0 !important;
    width: fit-content !important;
    max-width: min(82vw, 320px) !important;
    min-width: 12rem !important;
    flex: 0 0 auto !important;
    transform: translateX(101%);
    transition: transform .25s ease;
    z-index: 1050;
    overflow: hidden !important;
  }
  nav.sidebar.nav-open { transform: translateX(0); }
  nav.sidebar .sidebar-sticky { height: 100%; }

  /* wmMenuView: slide in from the left edge */
  libra-carousel.wmMenuView, .wmMenuView {
    position: fixed !important;
    top: 0; left: 0; right: auto;
    height: 100vh !important;
    width: min(82vw, 320px) !important;
    margin: 0 !important;
    transform: translateX(-101%);
    transition: transform .25s ease;
    z-index: 1050;
  }
  libra-carousel.wmMenuView:not([hidden]), .wmMenuView:not([hidden]) { display: block !important; }
  libra-carousel.wmMenuView.mv-open, .wmMenuView.mv-open { transform: translateX(0); }

  /* pocket (wmPocket, opened by the account-menu "more"): full width UNDER the wmView carousel,
     in normal flow; the main row scrolls vertically to reach it (not pinned in the displayed area) */
  .d-flex.flex-row.fit.wmMain {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }
  .d-flex.flex-row.fit.wmMain > libra-carousel.wmView,
  .d-flex.flex-row.fit.wmMain > .wmView {
    flex: 0 0 auto !important;
    height: calc(100% - 14px) !important;
    min-height: 0 !important;
    width: auto !important;
  }
  .d-flex.flex-row.fit.wmMain > .wmPocket {
    flex: 0 0 auto !important;
    height: auto !important;
    width: auto !important;
    max-height: none !important;
    margin: 7px !important;
  }

  /* dim backdrop behind an open drawer */
  .libra-scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
  }

  /* mobile burger (libraMenu) popup: keep it inside the window */
  #wm-header-menu .dropdown-menu {
    right: 5px !important; left: auto !important;
    max-width: calc(100vw - 10px);
    max-height: calc(100vh - 4.5rem);
    max-height: calc(100dvh - 4.5rem);
    overflow-y: auto; overscroll-behavior: contain;
  }
}
