/* WB R4 visual adapter. Real routes, controls, permissions and data stay in existing modules. */
body.work-console-layout {
  --console-ink: #10233f;
  --console-muted: #4c5d73;
  --console-line: #dfe6eb;
  --console-paper: #f6f8fa;
  --console-brand: #126b62;
}
body.work-console-layout #appShell {
  grid-template-columns: 212px minmax(0, 1fr);
  color: var(--console-ink);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--console-paper);
}
body.work-console-layout #primarySidebar {
  padding: 0 0 16px;
  background: linear-gradient(180deg, #081d40 0%, #0d3478 52%, #1d5fe0 100%);
}
body.work-console-layout #primarySidebar .brand {
  min-height: 72px;
  padding: 14px 16px;
  gap: 9px;
}
body.work-console-layout #primarySidebar .brand img { width: 34px; height: 34px; }
body.work-console-layout #primarySidebar .brand div { display: grid; min-width: 0; }
body.work-console-layout #primarySidebar .brand strong { font-size: 13px; line-height: 1.55; }
body.work-console-layout #primarySidebar .brand div span { font-size: 10.5px; }
body.work-console-layout #primarySidebar > nav { display: block; margin: 0; }
body.work-console-layout .work-console-nav-group { margin: 0 0 4px; }
body.work-console-layout .work-console-nav-group h2 {
  margin: 0;
  padding: 12px 16px 5px;
  color: rgba(255,255,255,.52);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 1.2px;
}
body.work-console-layout #primarySidebar .nav-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  min-height: 36px;
  margin: 0;
  padding: 8.5px 16px;
  gap: 5px 9px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  text-align: left;
  color: rgba(255,255,255,.8);
  font-size: 12.5px;
  line-height: 1.45;
  text-decoration: none;
}
body.work-console-layout #primarySidebar .nav-item > span {
  width: 17px;
  flex: 0 0 17px;
  font-size: 15px;
  text-align: center;
}
body.work-console-layout #primarySidebar .nav-item b { font-weight: inherit; }
body.work-console-layout #primarySidebar .nav-item small {
  display: block;
  flex: 0 0 calc(100% - 26px);
  margin: 0 0 0 26px;
  color: rgba(255,255,255,.52);
  font-size: 10px;
  line-height: 1.4;
}
body.work-console-layout #primarySidebar .nav-item:hover { background: rgba(255,255,255,.08); }
body.work-console-layout #primarySidebar .nav-item.active {
  color: #fff;
  border-left-color: #7fe6d6;
  background: rgba(255,255,255,.16);
}
body.work-console-layout #primarySidebar .nav-item.active > span { color: #7fe6d6; }
body.work-console-layout #primarySidebar .security-note { margin: 16px; padding: 12px; font-size: 10.5px; }
body.work-console-layout #appShell > main { min-width: 0; }
body.work-console-layout #appShell .topbar {
  min-height: 54px;
  height: auto;
  padding: 8px 20px;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--console-line);
}
body.work-console-layout #appShell .topbar .eyebrow { display: none; }
body.work-console-layout #appShell .topbar h1 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.5; letter-spacing: .2px; }
body.work-console-layout #appShell .user-area { gap: 10px; min-width: 0; }
body.work-console-layout #appShell .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 14px; }
body.work-console-layout #appShell .user-area strong { font-size: 12.5px; }
body.work-console-layout #appShell .user-area span { font-size: 11px; }
body.work-console-layout #appShell .logout-button { min-height: 30px; padding: 5px 10px; font-size: 12px; border-radius: 6px; }
body.work-console-layout .work-console-rolebar {
  padding: 7px 20px;
  background: #fff;
  border-bottom: 1px solid var(--console-line);
  overflow-x: auto;
}
body.work-console-layout .work-console-rolebar .role-chip {
  display: inline-block;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid #d8eee7;
  border-radius: 20px;
  background: #eef8f4;
  color: var(--console-brand);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.work-console-layout #appShell .content { padding: 18px 20px 30px; }
body.work-console-layout #appShell .content > .hero-strip {
  padding: 16px 18px;
  color: var(--console-ink);
  border: 1px solid var(--console-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
}
body.work-console-layout #appShell .content > .hero-strip span { color: var(--console-brand); }
body.work-console-layout #appShell .content > .hero-strip .button.ghost { color: var(--console-brand); border-color: #c4dcd6; background: #f3faf7; }
body.work-console-layout #appShell .content > .hero-strip h2 { font-size: 18px; line-height: 1.5; font-weight: 600; letter-spacing: .2px; }
body.work-console-layout #appShell .content > .hero-strip p { font-size: 12.5px; line-height: 1.65; color: var(--console-muted); }
body.work-console-layout #appShell .content .button { min-height: 30px; padding: 6px 13px; border-radius: 6px; font-size: 12.5px; }
body.work-console-layout #appShell .content .toolbar { gap: 10px; padding: 12px 16px; }
body.work-console-layout #appShell .content .table-wrap { border-radius: 8px; }
body.work-console-layout #appShell .content table { font-size: 12.5px; }
body.work-console-layout #appShell .content th { padding: 9px 12px; font-size: 12px; font-weight: 500; background: #f6f8fa; }
body.work-console-layout #appShell .content td { height: 42px; padding: 10px 12px; font-size: 12.5px; border-bottom-color: #eff3f6; }
body.work-console-layout #appShell .content tbody tr:not([class]):nth-child(even) { background: #fafcfd; }
body.work-console-layout #appShell .content tbody tr:not([class]):hover { background: #eef8f4; }
body.work-console-layout #appShell .content td:is(.numeric, .number, .amount) { text-align: right; font-variant-numeric: tabular-nums; }

/* Existing drawer markup remains mounted by its original business modules. */
body.work-console-layout #crmCustomerDrawer { width: min(78vw, 1180px); }
body.work-console-layout #crmCustomerDrawer > header { padding: 14px 20px; }
body.work-console-layout #crmCustomerDrawer > header h2 { font-size: 18px; line-height: 1.5; font-weight: 600; }
body.work-console-layout #crmCustomerDrawer .crm-drawer-summary { padding: 10px 20px; font-size: 12px; }
body.work-console-layout #crmCustomerDrawer .crm-drawer-body { padding: 16px 20px 26px; }
body.work-console-layout #crmCustomerDrawer .crm-customer-modules { gap: 14px; }
body.work-console-layout #crmCustomerDrawer :is(.crm-detail-grid, .field-grid) { gap: 12px 18px; }
body.work-console-layout #crmCustomerDrawer :is(.crm-detail-grid, .field-grid) label { font-size: 12px; line-height: 1.5; }
body.work-console-layout #crmCustomerDrawer :is(.crm-detail-grid, .field-grid) :is(input:not([type=checkbox]):not([type=radio]),select,textarea) {
  min-width: 0;
  min-height: 31px;
  padding: 6px 10px;
  border-radius: 5px;
  font: inherit;
}
body.work-console-layout #crmCustomerDrawer :is(.crm-detail-grid, .field-grid) textarea { min-height: 60px; line-height: 1.5; }
body.work-console-layout .crm-create-dialog { width: min(920px, 100%); border-radius: 10px; font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif; }
body.work-console-layout .crm-create-dialog > header { padding: 15px 20px; }
body.work-console-layout .crm-create-dialog > header h2 { font-size: 18px; font-weight: 600; line-height: 1.5; letter-spacing: .2px; }
body.work-console-layout .crm-create-intro { padding: 10px 20px; font-size: 12px; line-height: 1.6; }
body.work-console-layout .crm-create-dialog form { gap: 12px; padding: 16px 20px 20px; }
body.work-console-layout .crm-create-dialog fieldset { padding: 12px 14px; border-radius: 8px; }
body.work-console-layout .crm-create-dialog legend { flex-wrap: wrap; gap: 5px 9px; }
body.work-console-layout .crm-create-dialog legend b { font-size: 13px; }
body.work-console-layout .crm-create-dialog legend span { font-size: 11px; line-height: 1.5; }
body.work-console-layout .crm-create-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
body.work-console-layout .crm-create-grid > label { font-size: 12px; gap: 6px; line-height: 1.5; }
body.work-console-layout .crm-create-grid :is(input,select,textarea) { min-width: 0; min-height: 31px; padding: 6px 10px; border-radius: 5px; font-size: 12.5px; }
body.work-console-layout .crm-create-grid textarea { min-height: 60px; line-height: 1.5; }
body.work-console-layout .crm-create-grid small { font-size: 11px; line-height: 1.5; }
body.work-console-layout .crm-create-dialog form > footer { bottom: -20px; margin: 0 -20px -20px; padding: 11px 20px; }
body.work-console-layout .crm-create-dialog footer .button { min-height: 32px; padding: 6px 13px; font-size: 12.5px; border-radius: 6px; }

@media (max-width: 1280px) {
  body.work-console-layout #crmCustomerDrawer { width: 92vw; }
}
@media (max-width: 1000px) and (min-width: 701px) {
  body.work-console-layout #appShell { grid-template-columns: 188px minmax(0, 1fr); }
  body.work-console-layout #primarySidebar .nav-item { justify-content: flex-start; }
  body.work-console-layout #appShell .topbar { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  body.work-console-layout .crm-create-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 700px) {
  body.work-console-layout:not(.work-product-edit-page) #appShell { display: block; }
  /* mobile-nav.css retains its off-canvas transform, backdrop, focus and close controls. */
  body.work-console-layout #primarySidebar { width: min(86vw, 320px); padding-top: 10px; }
  body.work-console-layout #primarySidebar .nav-item { min-height: 44px; font-size: 14px; }
  body.work-console-layout #appShell .topbar { min-height: 62px; padding: 8px 12px; gap: 8px; }
  body.work-console-layout #appShell .topbar h1 { font-size: 15px; }
  body.work-console-layout #appShell .user-area { gap: 6px; }
  body.work-console-layout .work-console-rolebar { padding: 6px 12px; }
  body.work-console-layout #appShell .content { padding: 12px; }
  body.work-console-layout #appShell .content > .hero-strip { padding: 12px; }
  body.work-console-layout #appShell .content .button { min-height: 38px; }
  body.work-console-layout #crmCustomerDrawer { width: 100vw; }
  body.work-console-layout #crmCustomerDrawer .crm-drawer-body { padding: 14px 12px 22px; }
  body.work-console-layout #crmCustomerDrawer > header { padding: 12px; }
  body.work-console-layout #crmCustomerDrawer .crm-drawer-summary { padding: 10px 12px; }
  body.work-console-layout .crm-create-dialog > header { padding: 14px 16px; }
  body.work-console-layout .crm-create-intro { padding: 10px 16px; }
  body.work-console-layout .crm-create-dialog form { padding: 14px 16px 20px; }
  body.work-console-layout .crm-create-grid :is(input,select,textarea) { min-height: 40px; font-size: 14px; }
  body.work-console-layout .crm-create-dialog form > footer { margin: 0 -16px -20px; padding: 11px 16px; }
  body.work-console-layout .crm-create-dialog footer .button { min-height: 40px; }
}

/* Work navigation and header */
body.work-console-layout {
  --console-paper: #f4f7fa;
  --console-sidebar: #0b203b;
}

body.work-console-layout #primarySidebar {
  background: var(--console-sidebar);
  scrollbar-color: #46617b transparent;
  scrollbar-width: thin;
}

body.work-console-layout #primarySidebar .brand {
  min-height: 64px;
  padding: 12px 14px;
  margin-bottom: 4px;
  border-color: #ffffff20;
  color: #edf5ff;
  text-decoration: none;
}

body.work-console-layout #primarySidebar .brand strong {
  font-size: 13px;
  min-width: 0;
}

body.work-console-layout #primarySidebar .brand img {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
}

body.work-console-layout #primarySidebar > nav {
  padding: 0 9px 12px;
}

body.work-console-layout .work-console-nav-group {
  margin: 0 0 6px;
}

body.work-console-layout .work-console-nav-group:not(:has(.nav-item:not([hidden]))) {
  display: none;
}

body.work-console-layout .work-console-nav-group h2 {
  padding: 10px 9px 4px;
  color: #9bb0c7;
  font-weight: 600;
}

body.work-console-layout #primarySidebar .nav-item {
  min-height: 35px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  padding: 7px 9px;
  border-left: 0;
  border-radius: 7px;
  color: #d4e0eb;
}

body.work-console-layout #primarySidebar .nav-item > span {
  color: #a5c1d9;
}

body.work-console-layout #primarySidebar .nav-item small {
  display: none;
}

body.work-console-layout #primarySidebar .nav-item.active {
  background: #1c3a55;
  box-shadow: inset 3px 0 #70d9c0;
}

body.work-console-layout #primarySidebar .nav-item.active .work-nav-label {
  color: #fff;
  font-weight: 700;
}

body.work-console-layout #primarySidebar :is(.brand, .nav-item):focus-visible {
  outline: 2px solid #8fe8d7;
  outline-offset: -2px;
}

body.work-console-layout #appShell > main > .topbar {
  min-height: 64px;
  flex-wrap: nowrap;
  padding-inline: 22px;
}

.work-topbar-location, .work-topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.work-topbar-location a {
  flex: 0 0 auto;
  color: #4c5d73;
  font-size: 13px;
  text-decoration: none;
}

.work-topbar-location a:hover {
  color: var(--console-brand);
  text-decoration: underline;
}

.work-topbar-divider {
  flex: 0 0 5px;
  height: 5px;
  margin-right: 2px;
  border-right: 1px solid #718096;
  border-top: 1px solid #718096;
  transform: rotate(45deg);
}

body.work-console-layout #appShell .topbar .work-topbar-location h1 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-topbar-actions {
  flex-shrink: 0;
  margin-left: auto;
}

.work-topbar-actions #userName,
.work-topbar-actions #userDepartment {
  display: block;
  line-height: 1.35;
}

.work-account-roles {
  position: relative;
}

.work-account-roles summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--console-line);
  border-radius: 8px;
  color: var(--console-muted);
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}

.work-account-roles summary::-webkit-details-marker {
  display: none;
}

.work-account-roles summary::after {
  flex: 0 0 5px;
  height: 5px;
  margin-top: -3px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  content: "";
}

.work-account-roles[open] summary {
  color: var(--console-brand);
  background: #eff8f5;
}

body.work-console-layout .work-account-roles .work-console-rolebar {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 89;
  width: min(320px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--console-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 35px #17314b26;
}

body.work-console-layout .work-account-roles #roleChip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--console-muted);
}

.work-account-roles #roleChip span {
  padding: 3px 8px;
  border: 1px solid #d3e8e3;
  border-radius: 7px;
  background: #eff8f5;
  color: #126b62;
}

@media (max-width: 700px) {
  body.work-console-layout #appShell > main > .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 60px;
    gap: 7px;
    padding-inline: 12px;
  }

  body.work-console-layout #appShell .topbar .mobile-menu-toggle {
    min-width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .mobile-menu-toggle > span:nth-child(2) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .work-topbar-location :is(a, .work-topbar-divider) {
    display: none;
  }

  .work-topbar-actions {
    gap: 6px;
  }

  .work-account-roles summary {
    min-height: 36px;
    padding-inline: 7px;
    gap: 5px;
  }

  body.work-console-layout .work-topbar-actions #headerTodoPanel,
  body.work-console-layout .work-account-roles .work-console-rolebar {
    position: fixed;
    top: 62px;
    right: 12px;
  }

  body.work-console-layout #primarySidebar .nav-item {
    min-height: 43px;
    padding-inline: 11px;
  }

  body.work-console-layout #appShell:not(.mobile-nav-open) #primarySidebar {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.work-console-layout #primarySidebar {
    transition: none;
  }
}
