/* Neox's two-level navigation; full-height rail and independently scrolling menu. */
@scope (body:has(.shell)) {
  :scope {
    --nav-surface: #f8fafc;
    --nav-rail: #edf2f7;
    --nav-text: #294157;
    --nav-muted: #596d80;
    --nav-selected: #dceefb;
    --nav-selected-text: #08649e;
  }
  .shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .sidebar {
    width: 280px;
    height: 100dvh;
    max-height: none;
    padding: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: visible;
    background: var(--nav-surface);
    color: var(--nav-text);
    border-right: 1px solid var(--line);
    border-radius: 0;
  }
  .nav-rail {
    width: 60px;
    flex: 0 0 60px;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    background: var(--nav-rail);
    border-right: 1px solid var(--line);
  }
  .rail-sections,
  .rail-bottom {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }
  .rail-bottom {
    margin-top: auto;
  }
  .nav-rail button {
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid transparent;
    color: var(--nav-muted);
    background: transparent;
    box-shadow: none;
    border-radius: 9px;
  }
  .nav-rail button svg {
    width: 21px;
    height: 21px;
  }
  .nav-rail button:hover {
    background: var(--nav-selected);
    color: var(--nav-selected-text);
  }
  .nav-rail .rail-brand {
    color: white;
    background: #0878b7;
    border-color: #0878b7;
  }
  .nav-rail .selected {
    color: var(--nav-selected-text);
    background: var(--nav-selected);
    border-color: var(--line);
  }
  .navigation-panel {
    width: 220px;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .navigation-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 22px 14px 14px 18px;
  }
  .navigation-heading strong {
    font-size: 14px;
    display: block;
    color: var(--nav-text);
  }
  .navigation-heading span {
    font-size: 11px;
    color: var(--nav-muted);
    display: block;
    margin-top: 4px;
  }
  .sidebar-collapse {
    display: grid;
    place-items: center;
    width: 30px;
    min-height: 32px;
    padding: 6px;
    background: transparent;
    border: 0;
    color: var(--nav-muted);
    box-shadow: none;
  }
  .sidebar-collapse svg {
    width: 18px;
    height: 18px;
  }
  .sidebar .nav {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: block;
    padding: 4px 10px 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  .navigation-section {
    margin: 0 0 15px;
  }
  .nav .nav-group-title {
    color: var(--nav-muted);
    margin: 12px 10px 7px;
    font-size: 10px;
    letter-spacing: 0.06em;
  }
  .nav button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 39px;
    padding: 9px 10px;
    margin: 3px 0;
    color: var(--nav-text);
    border: 1px solid transparent;
    font-size: 13px;
    background: transparent;
    border-radius: 7px;
  }
  .nav button svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: var(--nav-muted);
  }
  .nav button:hover {
    background: var(--nav-rail);
    border-color: transparent;
  }
  .nav button.active {
    background: var(--nav-selected);
    color: var(--nav-selected-text);
    box-shadow: none;
    border-color: transparent;
  }
  .nav button.active svg {
    color: var(--nav-selected-text);
  }
  .sidebar-bottom {
    margin: 0;
    padding: 16px 18px;
    border-top: 1px solid var(--line);
    font-size: 10px;
    color: var(--nav-muted);
  }
  .nav-version {
    display: block;
    margin-top: 5px;
    font-size: 10px;
  }
  .nav-rail .rail-avatar {
    position: relative;
    color: #085575;
    background: #ccecf5;
    border: 1px solid #a9d7e5;
    font-size: 13px;
    font-weight: 650;
  }
  .account-online {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--nav-rail);
    border-radius: 50%;
    background: #248b64;
  }
  .navigation-account {
    position: fixed;
    left: 68px;
    bottom: 12px;
    width: 278px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 16px 50px #10283d2b;
    z-index: 60;
  }
  .account-menu-identity {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 8px 17px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
  }
  .account-menu-identity strong {
    font-size: 14px;
    overflow-wrap: anywhere;
  }
  .account-menu-identity small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
  }
  .account-menu-avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--nav-selected);
    color: var(--nav-selected-text);
  }
  .navigation-account > button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: flex-start;
    padding: 10px;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--ink);
  }
  .navigation-account svg {
    width: 18px;
    height: 18px;
  }
  .navigation-account > button:hover {
    background: var(--bg);
  }
  .account-theme {
    border-block: 1px solid var(--line);
    margin: 8px 0;
    padding: 14px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
  }
  .account-theme [role="group"] {
    display: flex;
    padding: 3px;
    border-radius: 8px;
    background: var(--bg);
    gap: 3px;
  }
  .account-theme button {
    min-height: 32px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    font-size: 12px;
    box-shadow: none;
  }
  .account-theme button[aria-pressed="true"] {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
  }
  .mobile-account {
    display: none;
  }
  @media (min-width: 761px) {
    .shell.navigation-compact {
      grid-template-columns: 60px minmax(0, 1fr);
    }
    .navigation-compact .sidebar {
      width: 60px;
    }
    .navigation-compact .navigation-panel {
      display: none;
    }
  }
  @media (max-width: 1100px) {
    .project-tabs {
      flex-wrap: wrap;
      overflow: visible;
    }
    .project-tabs .project-link {
      margin-left: 0;
    }
  }
  @media (max-width: 760px) {
    .shell {
      display: block;
    }
    .sidebar {
      inset: 0 auto 0 0;
      width: 280px;
      max-width: calc(100vw - 48px);
      height: 100dvh;
      max-height: none;
      border-radius: 0;
      z-index: 50;
    }
    .navigation-open .sidebar {
      inset: 0 auto 0 0;
      border-radius: 0;
    }
    .navigation-open::before {
      content: "";
      position: fixed;
      inset: 0;
      z-index: 40;
      background: #09152288;
    }
    .navigation-heading {
      padding-top: 18px;
    }
    .navigation-account {
      left: 12px;
      bottom: 12px;
      width: min(300px, calc(100vw - 24px));
    }
    .sidebar:has(.navigation-account:not([hidden])) {
      visibility: visible;
    }
    .mobile-account {
      display: inline-flex;
    }
    .mobile-account svg {
      width: 19px;
      height: 19px;
    }
    .topbar {
      position: relative;
      z-index: 30;
    }
  }
}

/* Visible destination labels stay readable with mouse, keyboard and touch. */
@scope (body:has(.shell)) {
  .shell {
    grid-template-columns: 316px minmax(0, 1fr);
  }
  .sidebar {
    width: 316px;
  }
  .nav-rail {
    width: 96px;
    flex-basis: 96px;
    padding: 14px 8px;
    gap: 18px;
  }
  .rail-sections {
    width: 100%;
    gap: 4px;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
  }
  .nav-rail .rail-button,
  .nav-rail .rail-avatar {
    width: 78px;
    height: auto;
    min-height: 60px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }
  .rail-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  .rail-initials {
    font-size: 14px;
    line-height: 20px;
  }
  .rail-bottom {
    gap: 6px;
  }
  .account-online {
    bottom: 18px;
    right: 15px;
  }
  .navigation-account {
    left: 104px;
  }
  .sidebar .nav button:not(:disabled):hover,
  .sidebar .nav button:not(:disabled):focus-visible {
    background: #e6f1f8;
    color: #17354d;
  }
  .sidebar .nav button:not(:disabled):hover svg {
    color: #08649e;
  }
  .document-table .document-row-actions .row-action-group {
    grid-template-columns: minmax(0, 1fr);
    width: 158px;
    max-width: 100%;
    margin-left: auto;
    gap: 7px;
  }
  .document-table .document-row-actions .row-action-group button {
    width: 100%;
    min-height: 38px;
    height: 38px;
    white-space: nowrap;
  }
  @media (max-width: 1250px) {
    .document-table .invoice-group-header {
      padding: 0;
    }
    .document-table:has(.quote-status) .invoice-group-header th {
      display: block;
      width: 100%;
      padding: 16px 20px;
    }
  }
  @media (min-width: 761px) {
    .shell.navigation-compact,
    .shell:has(.nav-standalone) {
      grid-template-columns: 96px minmax(0, 1fr);
    }
    .navigation-compact .sidebar,
    .sidebar.nav-standalone {
      width: 96px;
    }
  }
  @media (max-width: 760px) {
    .shell {
      display: block;
    }
    .sidebar {
      width: 316px;
    }
    .navigation-account {
      left: 12px;
    }
    .document-table .document-row-actions .row-action-group button {
      min-height: 44px;
      height: 44px;
    }
  }
}

@media (min-width: 761px) {
  body:has(.shell) .shell:has(.nav-standalone) {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  body:has(.shell) .sidebar.nav-standalone {
    width: 96px;
  }
  body:has(.shell) .sidebar.nav-standalone .navigation-panel {
    display: none;
  }
}

@scope (body:has(.shell)) {
  .workspace
    main
    .document-row-actions
    .row-action-group
    button[data-action^="invoice-receipt:"],
  .workspace main .doc-actions button[data-action^="invoice-receipt:"] {
    background: #dceefb;
    border-color: #c6e1f3;
    color: #08649e;
  }
  .workspace
    main
    .document-row-actions
    .row-action-group
    button[data-action^="invoice-receipt:"]:hover,
  .workspace main .doc-actions button[data-action^="invoice-receipt:"]:hover {
    background: #cce5f7;
    border-color: #a8d0eb;
    color: #075585;
  }
}
