/* ============================================================
   layout.css — login screens, app shell, topbar, sidebar,
                entity selector, user menu, sliding panel
   ============================================================ */

/* ================= LOGIN / CHANGE-PASSWORD SCREENS ================= */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--bg);
  z-index: 300;
  overflow-y: auto;
}

.login__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px clamp(24px, 6vw, 80px);
  background: var(--surface);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.login__logo {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 21px;
  font-weight: 800;
  flex: none;
}

.login__logo--warn {
  background: linear-gradient(135deg, var(--warning), var(--danger));
}

.login__product { font-size: 16px; font-weight: 700; line-height: 1.2; }
.login__phase { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.login__title { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.login__sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.55;
}

.login__hint {
  margin-top: 22px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.9;
  color: var(--text-muted);
}
.login__hint strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: 3px;
}
.login__hint code {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}
.login__hint-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  line-height: 1.6;
}

/* Clickable demo-account chips */
.demo-accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 4px;
}
.demo-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.demo-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.demo-chip:active {
  transform: translateY(1px);
}
.demo-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.demo-chip[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.demo-chip__name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.demo-chip__role {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Right-hand marketing/security panel */
.login__aside {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(15, 157, 143, 0.28), transparent 55%),
    radial-gradient(800px 520px at -10% 110%, rgba(31, 95, 191, 0.35), transparent 55%),
    linear-gradient(150deg, #16233a, #1d3153 70%);
  color: #cfdcec;
}

.login__aside-inner { max-width: 400px; }

.login__aside-badge {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9fd0ff;
  margin-bottom: 18px;
}

.login__aside-title {
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: #fff;
  margin-bottom: 22px;
}

.login__aside-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14.5px;
}

.login__aside-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}

.login__aside-list li::before {
  content: '✓';
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #7fd8c8;
  font-size: 11px;
  font-weight: 800;
}

/* Inline form-level alert (login errors) */
.form-alert {
  padding: 10px 13px;
  background: var(--danger-soft);
  border: 1px solid rgba(198, 47, 47, 0.35);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

/* ================= APP SHELL ================= */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) auto minmax(0, 1fr);
  grid-template-areas:
    'topbar topbar'
    'sidebar ribbon'
    'sidebar main';
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

#erp-ribbon-container {
  grid-area: ribbon;
  z-index: 45;
  background: var(--toolbar-bg, var(--panel, var(--surface)));
}

/* ================= TOPBAR ================= */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--topbar-bg, var(--panel, var(--surface)));
  border-bottom: 1px solid var(--toolbar-border, var(--line, var(--border)));
  color: var(--topbar-text, var(--text));
  z-index: var(--z-header);
}

.topbar__crumb {
  font-size: 14px;
  font-weight: 500;
  color: var(--topbar-text, var(--text));
}

.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line, var(--border));
  background: var(--panel2, var(--surface));
  color: var(--topbar-text, var(--text-2));
  cursor: pointer;
  flex: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sidebar-toggle-btn:hover {
  background: var(--hover, var(--surface-2));
  border-color: var(--accent, var(--border-strong));
  color: var(--accent, var(--text));
}

.menu-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: none;
}
.menu-toggle:hover { background: var(--surface-2); }

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.topbar__brand:hover { text-decoration: none; }

.topbar__logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  flex: none;
}

.topbar__brand-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.topbar__crumb {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* ---- Entity selector ---- */
.entity-selector { position: relative; }

.entity-selector__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text);
}
.entity-selector__btn:hover { border-color: var(--border-strong); background: var(--surface); }

.entity-selector__flag {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex: none;
}

.entity-selector__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  min-width: 0;
}

.entity-selector__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.entity-selector__name {
  max-width: 210px;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-selector__caret { color: var(--text-faint); font-size: 10px; flex: none; }

.entity-selector__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: var(--z-dropdown);
}

.entity-selector__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text);
}
.entity-selector__item:hover { background: var(--surface-2); }
.entity-selector__item.is-active { background: var(--primary-soft); color: var(--primary-dark); }
.entity-selector__item .emi-name { font-weight: 600; }
.entity-selector__item .emi-meta { font-size: 11.5px; color: var(--text-muted); }

.entity-selector__empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ---- User menu ---- */
.user-menu { position: relative; }

.user-menu__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.user-menu__btn:hover { background: var(--surface-2); border-color: var(--border); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}

.user-menu__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.user-menu__name {
  font-size: 13px;
  font-weight: 600;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__role { font-size: 11px; color: var(--text-muted); }

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 250px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: var(--z-dropdown);
}

.user-menu__section {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-menu__section:empty { display: none; border: 0; margin: 0; padding: 0; }

.user-menu__section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.user-menu__assignment {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  padding: 2px 0;
  color: var(--text-2);
}
.user-menu__assignment b { font-weight: 600; }
.user-menu__assignment span { color: var(--text-muted); }

.user-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  color: var(--text);
}
.user-menu__item:hover { background: var(--surface-2); }
.user-menu__item--danger { color: var(--danger); }
.user-menu__item--danger:hover { background: var(--danger-soft); }

/* ================= SIDEBAR ================= */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Sidebar quick controls (Collapse all / Expand all) */
.sidebar__quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 4px;
  flex: none;
}

.sidebar__quick-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #63758f;
}

.sidebar__quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar__quick-btn {
  background: none;
  border: 0;
  color: #8295b0;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.sidebar__quick-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar__quick-sep {
  color: rgba(255, 255, 255, 0.18);
  font-size: 10px;
}

.menu { flex: 1; padding-bottom: 12px; }

/* Collapsible section headers */
.nav-section {
  margin-bottom: 2px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px 6px 18px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #7484a0;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
  transition: color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.nav-section-header:hover {
  color: #d8e5f8;
  background: rgba(255, 255, 255, 0.04);
}

.nav-section-header:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.nav-section.has-active .nav-section-header {
  color: #adc6e9;
}

.nav-section-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-section-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  color: #5d6d84;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
  flex: none;
  margin-left: 6px;
}

.nav-section-header:hover .nav-section-caret {
  color: #b0c4de;
}

/* Collapsed menu section */
.nav-section.is-collapsed .nav-section-caret {
  transform: rotate(-90deg);
}

.nav-section-items {
  overflow: hidden;
  transition: max-height 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  max-height: 1200px;
  opacity: 1;
}

.nav-section.is-collapsed .nav-section-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Backward-compatibility fallback */
.nav-section-label {
  padding: 18px 18px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #7484a0;
  white-space: nowrap;
}

.nav-item > a,
.nav-item > button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 18px;
  border: 0;
  background: none;
  color: var(--sidebar-text);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
  transition: background 0.12s ease;
  text-decoration: none;
}
.nav-item > a:hover,
.nav-item > button:hover {
  background: var(--sidebar-bg-2);
  color: #fff;
  text-decoration: none;
}
.nav-item.is-active > a {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}

.nav-icon { width: 18px; text-align: center; font-size: 15px; flex: none; opacity: 0.9; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-caret { font-size: 9px; transition: transform 0.18s ease; opacity: 0.7; }
.nav-item.is-expanded > button .nav-caret { transform: rotate(90deg); }

.nav-submenu { display: none; }
.nav-submenu .nav-item > a { padding-left: 46px; font-size: 13px; }
.nav-item.is-expanded > .nav-submenu { display: block; }

.sidebar__footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar__version {
  font-size: 11px;
  color: #7484a0;
  white-space: nowrap;
}

.sidebar__footer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9cb0cc;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar__footer-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar__footer-toggle-icon {
  font-size: 9px;
  transition: transform 0.2s ease;
}

/* ================= SIDEBAR COLLAPSED (RAIL MODE) ================= */
body.sidebar-collapsed .layout,
.layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-width-collapsed, 64px) minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed, 64px);
}

body.sidebar-collapsed .sidebar__quick-bar {
  display: none;
}

body.sidebar-collapsed .sidebar__version {
  display: none;
}

body.sidebar-collapsed .sidebar__footer {
  padding: 10px 6px;
  justify-content: center;
}

body.sidebar-collapsed .sidebar__footer-toggle-text {
  display: none;
}

body.sidebar-collapsed .sidebar__footer-toggle {
  padding: 6px;
  width: 100%;
  justify-content: center;
}

body.sidebar-collapsed .nav-section-header {
  padding: 8px 0;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin: 4px 8px;
}

body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-section-caret {
  display: none;
}

body.sidebar-collapsed .nav-section.is-collapsed .nav-section-items {
  max-height: none;
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-collapsed .nav-item > a {
  padding: 10px 0;
  justify-content: center;
}

body.sidebar-collapsed .nav-label {
  display: none;
}

body.sidebar-collapsed .nav-icon {
  font-size: 18px;
  margin: 0;
}

/* Tooltip on hovering item in collapsed mode */
body.sidebar-collapsed .nav-item {
  position: relative;
}

body.sidebar-collapsed .nav-item:hover::after {
  content: attr(data-tooltip);
  position: fixed;
  left: calc(var(--sidebar-width-collapsed, 64px) + 8px);
  transform: translateY(-50%);
  background: #0f172a;
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

/* Suppress tooltips on nav-items when sidebar is expanded */
body:not(.sidebar-collapsed) .nav-item::before,
body:not(.sidebar-collapsed) .nav-item::after {
  display: none !important;
  content: none !important;
}

/* ================= MAIN ================= */
.main {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 26px 48px;
  outline: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#page-root {
  padding-top: 22px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* ================= SLIDING PANEL ================= */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 30, 50, 0.45);
  z-index: var(--z-overlay);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.panel-backdrop.is-open { opacity: 1; }

.sliding-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 100vw;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.sliding-panel.is-open { transform: translateX(0); }
.sliding-panel.wide { width: min(980px, 94vw); }

/* Left-edge draggable resize handle */
.sliding-panel__resizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  z-index: 50;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sliding-panel__resizer::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s ease;
}

.sliding-panel__resizer::after {
  content: '';
  width: 4px;
  height: 54px;
  border-radius: 2px;
  background: var(--border-color, #cbd5e1);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
  opacity: 0.75;
}

.sliding-panel__resizer:hover::before,
.sliding-panel.is-resizing .sliding-panel__resizer::before {
  background: var(--primary, #2563eb);
}

.sliding-panel__resizer:hover::after,
.sliding-panel.is-resizing .sliding-panel__resizer::after {
  background: var(--primary, #2563eb);
  height: 90px;
  opacity: 1;
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.45);
}

.sliding-panel.is-resizing {
  user-select: none !important;
  transition: none !important;
}

body.is-resizing-panel {
  user-select: none !important;
  cursor: col-resize !important;
}

.sliding-panel__header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sliding-panel__heading { flex: 1; min-width: 0; }

.sliding-panel__eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 3px;
}
.sliding-panel__eyebrow:empty { display: none; }

.sliding-panel__title { font-size: 16.5px; font-weight: 700; line-height: 1.3; }

.sliding-panel__subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.45;
}
.sliding-panel__subtitle:empty { display: none; }

.sliding-panel__progress {
  display: flex;
  gap: 5px;
  padding: 10px 18px 0;
  flex: none;
}
.sliding-panel__progress span {
  height: 3px;
  flex: 1;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  background-size: 200% 100%;
  animation: panel-progress 1s linear infinite;
  opacity: 0.85;
}
.sliding-panel__progress span:nth-child(2) { animation-delay: 0.15s; }
.sliding-panel__progress span:nth-child(3) { animation-delay: 0.3s; }

@keyframes panel-progress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sliding-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}
.sliding-panel__body.flush { padding: 0; }

.sliding-panel__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex: none;
}
.sliding-panel__footer .footer-info {
  margin-right: auto;
  font-size: 12px;
  color: var(--text-muted);
}
.sliding-panel__footer .footer-info:empty { display: none; }

/* Sticky sub-tabs inside a panel body */
.panel-sticky-tabs {
  position: sticky;
  top: -18px;
  z-index: 2;
  background: var(--surface);
  padding: 12px 0;
  margin-top: -4px;
  border-bottom: 1px solid var(--border);
}

/* ================= RESPONSIVE SHELL ================= */
@media (max-width: 992px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) auto minmax(0, 1fr);
    grid-template-areas:
      'topbar'
      'ribbon'
      'main';
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 12px 0 30px rgba(16, 30, 54, 0.25);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgba(18, 30, 50, 0.5);
    z-index: calc(var(--z-sidebar) - 1);
  }

  .menu-toggle { display: inline-flex; }
  .sidebar-toggle-btn { display: none; }
  .sidebar__footer-toggle { display: none; }

  /* Reset collapsed rail mode overrides on mobile viewports so drawer displays fully */
  body.sidebar-collapsed .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width);
  }
  body.sidebar-collapsed .sidebar__quick-bar {
    display: flex;
  }
  body.sidebar-collapsed .sidebar__version {
    display: block;
  }
  body.sidebar-collapsed .nav-section-header {
    padding: 10px 16px 6px 18px;
    justify-content: space-between;
    border-bottom: 0;
    margin: 0;
  }
  body.sidebar-collapsed .nav-section-title {
    display: inline;
  }
  body.sidebar-collapsed .nav-section-caret {
    display: inline-flex;
  }
  body.sidebar-collapsed .nav-item > a {
    padding: 9px 18px;
    justify-content: flex-start;
  }
  body.sidebar-collapsed .nav-label {
    display: inline;
  }
  body.sidebar-collapsed .nav-icon {
    font-size: 15px;
  }
  body.sidebar-collapsed .nav-item:hover::after {
    display: none;
  }

  .main { padding: 0 16px 40px; }
  #page-root { padding-top: 16px; }
  .user-menu__meta { display: none; }
  .entity-selector__name { max-width: 130px; }
}

@media (max-width: 860px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login__aside { display: none; }
}
