/* W-DESKTOP-REVIEW: desktop workspace; existing mobile rules remain the fallback. */
#desktop-nav, .desktop-home-priorities, .desktop-home-focus, .desktop-section-nav, .desktop-event-workflow, .desktop-approval-finder, .desktop-display-filter, .desktop-barcode-hint { display: none; }
@media (min-width: 1024px) {
  .desktop-event-workflow, .desktop-approval-finder, .desktop-barcode-hint { display: block; }
  .desktop-nav-badge { margin-inline-start: auto; background: #e60020; color: white; border-radius: 12px; padding: 1px 6px; font-size: 11px; }
  :root { --desktop-nav-width: 216px; --topbar-height: 64px; }
  html, body { overflow-x: clip; overflow-y: visible; }
  body.task-create-modal-open { overflow: hidden; }
  .app-shell { padding-inline-start: var(--desktop-nav-width); }
  #desktop-nav { position: fixed; z-index: 45; inset-block: 0; inset-inline-start: 0; width: var(--desktop-nav-width); display: flex; flex-direction: column; background: #f1f3f6; border-inline-end: 1px solid #dfe3e8; color: #303744; }
  .desktop-brand { display: flex; gap: 9px; align-items: center; min-height: 64px; padding: 14px 18px; }
  .desktop-brand img { width: 28px; padding: 4px; border-radius: 6px; background: var(--red); }
  .desktop-brand strong { font-size: 17px; white-space: nowrap; letter-spacing: -.4px; }
  .desktop-brand span { font-weight: 450; }
  .desktop-primary { padding: 4px 10px 12px; border-bottom: 1px solid #dfe3e8; }
  .desktop-primary button, .desktop-link { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 38px; padding: 9px 12px; border: 0; border-radius: 7px; color: #454c58; background: transparent; font-size: 13px; text-align: start; cursor: pointer; }
  .desktop-primary button:hover, .desktop-link:hover { background: #e6e9ee; }
  .desktop-primary button.is-active, .desktop-link.is-active { background: #fff; color: #c40010; font-weight: 700; box-shadow: 0 1px 3px #202c3a12; }
  .desktop-primary svg, .desktop-link-icon { flex: 0 0 19px; width: 19px; height: 19px; }
  .desktop-link-body { min-width: 0; }
  .desktop-link-body strong { font-size: 13px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
  .desktop-link-body small { display: none; }
  .desktop-directory { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 20px; scrollbar-width: thin; }
  .desktop-group-title { margin: 16px 12px 6px; color: #717985; font-size: 11px; font-weight: 600; }
  .desktop-grid { display: grid; gap: 2px; }
  #bottom-nav { display: none !important; }
  .topbar { inset-inline-start: var(--desktop-nav-width); color: #202733; background: #fff; box-shadow: none; border-bottom: 1px solid var(--line); padding-inline: 24px; }
  .topbar .mini-mark:not(.brand-mark--room) { background: var(--red); border-radius: 7px; padding: 4px; }
  .topbar .mini-mark:not(.brand-mark--room) img { width: 26px; }
  .topbar .topbar-action { color: #4d5664; border-radius: 7px; }
  .topbar .topbar-action:hover, .topbar .icon-button:hover { background: #f0f2f5; }
  .topbar-back:not([hidden]) { margin-inline-end: 0; }
  .topbar-brand strong { font-size: 17px; }
  .topbar-status { color: #565e69; background: #f0f2f5; }
  #main { width: 100%; max-width: 1440px; min-height: calc(100dvh - 64px); padding: 24px 28px 32px; margin-inline: auto; }
  body.no-nav #main { padding-bottom: 32px; }
  body[data-desktop-route='worktask'] #main, body[data-desktop-route='approval'] #main,
  body[data-desktop-route='knowledge-doc'] #main, body[data-desktop-route='payslip'] #main,
  body[data-desktop-route='new-inspection'] #main, body[data-desktop-route='profile'] #main,
  body[data-desktop-route='position-guide'] #main { max-width: 1040px; }
  .section-heading { margin-top: 22px; }
  .primary-button, .secondary-button, .ghost-button, .danger-button { min-height: 40px; border-radius: 8px; font-size: 14px; box-shadow: none; }
  .primary-button { border: 1px solid transparent; }
  .form-card, .list-card { border-radius: 10px; box-shadow: none; }
  .field input, .field select, .field textarea { border-radius: 7px; font-size: 14px; }
  :is(button,a,input,textarea,select,[role='button']):focus-visible { outline: 2px solid #215eb0; outline-offset: 3px; }
  button:disabled { cursor: not-allowed; }
  input[type='file']::file-selector-button { border: 1px solid #d7dce3; background: #fff; color: #303744; border-radius: 7px; padding: 9px 12px; margin-inline-end: 10px; cursor: pointer; font: inherit; }
  .hero-card { margin: 0 0 20px; padding: 0; color: var(--ink); background: transparent; border-radius: 0; }
  .hero-card h2 { color: var(--ink); font-size: 24px; }
  .hero-card .hero-sub, .hero-card .hero-date { color: #686f7a !important; }
  .hero-card .hero-date { font-size: 13px; }
  .desktop-home-priorities { display: grid; gap: 12px; grid-template-columns: repeat(3,minmax(0,1fr)); margin-bottom: 24px; }
  .desktop-home-priorities > h2 { grid-column: 1/-1; font-size: 16px; margin: 0; }
  .desktop-home-priorities button { display: grid; text-align: start; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; cursor: pointer; }
  .desktop-home-priorities button:hover { border-color: #dd9097; }
  .desktop-home-priorities strong { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
  .desktop-home-priorities span { font-size: 14px; color: #555d69; }
  .desktop-home-focus { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 20px; margin: -8px 0 24px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px; }
  .desktop-home-focus > button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; border: 0; border-bottom: 1px solid #eef0f3; background: transparent; font-size: 13px; text-align: start; cursor: pointer; }
  .desktop-home-focus > button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-home-focus small { flex: none; color: #686f7a; font-size: 12px; }
  .desktop-home-focus > p { grid-column: 1/-1; font-size: 13px; color: #686f7a; }
  body[data-desktop-route='home'] #main > section:last-child { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 8px 24px; }
  .app-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .app-tile { min-height: 72px; border-radius: 9px; }
  /* A real sticky footer owns its flow height; no absolute viewport offsets or mobile nav gaps. */
  .sticky-actions, body.no-nav .sticky-actions { bottom: 0; padding: 12px 0; margin: 16px 0 0; background: var(--canvas); border-top: 1px solid var(--line); }
  .sticky-actions > * { flex: 0 1 auto; min-width: 140px; width: auto; }
  .sticky-actions { justify-content: flex-end; }
  .desktop-task-dock { position: sticky; bottom: 0; z-index: 20; background: #fff; border: 1px solid #dce1e8; border-radius: 10px; padding: 12px; margin-top: 18px; box-shadow: 0 -4px 20px #202c3a08; }
  .desktop-task-dock .task-progress-compose { position: static; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .desktop-task-dock .task-complete-actions { position: static; transform: none; width: 100%; margin: 10px 0 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; backdrop-filter: none; background: #fff; }
  .desktop-task-dock .task-progress-complete { width: auto; min-height: 40px; }
  #main:has(.task-complete-actions) { padding-bottom: 24px; }
  .inspection-sticky-actions { position: sticky; left: auto; transform: none; width: 100%; border-radius: 0; box-shadow: none; }
  #main:has(.inspection-sticky-actions) { padding-bottom: 24px; }
  .modal-backdrop:not(.is-keyboard-aware):not(:has(.chat-message-popover,.chat-room-popover)) { align-items: center; justify-content: center; padding: 24px; }
  .modal { border-radius: 12px; max-height: calc(100dvh - 48px); width: min(640px,100%); padding: 24px; }
  .modal--approval-create { width: min(820px,calc(100vw - 48px)); }
  .modal--approval-create .approval-create-scroll { padding-inline: 24px; }
  .modal-actions { background: #fff; padding-top: 14px; gap: 12px; }
  .modal-actions > button { min-height: 40px; }
  .leave-datetime-stack { grid-template-columns: 1fr 140px 1fr; align-items: start; }
  .desktop-approval-finder { margin-bottom: 14px; }
  .desktop-approval-finder input { width: 100%; min-height: 40px; padding: 10px 12px; border: 1px solid #d4dae3; border-radius: 7px; }
  .desktop-approval-options { max-height: 180px; overflow-y: auto; border: 1px solid #d4dae3; padding: 6px; margin-top: 6px; border-radius: 7px; }
  .desktop-approval-options button { display: block; width: 100%; background: #fff; border: 0; padding: 10px; text-align: start; cursor: pointer; }
  .desktop-approval-options button:hover { background: #f1f3f6; }
  .task-hub-card-wrap > .list-card { padding: 12px 18px; border-radius: 8px; display: grid; grid-template-columns: minmax(0,1fr) 240px; column-gap: 24px; align-items: center; }
  .task-hub-card-wrap .list-card-header { grid-row: span 2; }
  .task-hub-card-wrap .list-card-header h3 { font-size: 15px; }
  .task-hub-card-wrap .task-hub-card-meta, .task-hub-card-wrap .list-card > p { margin: 0; font-size: 13px; }
  .shift-board-shell { max-height: calc(100dvh - 310px); overflow: auto; scrollbar-gutter: stable; }
  .shift-board { min-width: calc(210px + var(--shift-days) * 100px); }
  .shift-board-head, .shift-board-row { grid-template-columns: 210px repeat(var(--shift-days), minmax(100px,1fr)); }
  .shift-person-cell strong, .shift-person-cell small { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .shift-board-cell { font-size: 13px; min-height: 58px; }
  .shift-board-cell > small { font-size: 11px; }
  .inspection-nav { flex-wrap: wrap; overflow: visible; }
  .inspection-nav.is-fixed { inset-inline-start: var(--desktop-nav-width); inset-inline-end: 0; width: auto; margin-inline: 28px; }
  .personnel-directory .person-row-copy strong { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .personnel-admin { grid-template-columns: minmax(280px,340px) minmax(0,1fr); }
  .desktop-barcode-hint { flex-basis: 100%; margin: 0; font-size: 14px; color: #555d69; }
  .stock-manual { flex-wrap: wrap; }
  .stock-manual:has(#stock-manual-input) { background: #fff; border-color: #d6dce5; padding: 20px; }
  .stock-scan-button { min-height: 44px; }
  .display-overview-row { display: grid; grid-template-columns: minmax(0,1fr) 180px; gap: 20px; padding: 12px 18px; margin: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
  .display-overview-row > span:first-child { display: grid; grid-template-columns: minmax(130px,1fr) minmax(160px,1.2fr); gap: 4px 16px; align-items: center; }
  .display-overview-row strong { grid-row: span 2; }
  .display-overview-row small { font-size: 12px; }
  .display-section .list { gap: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
  .desktop-display-filter { display: flex; gap: 12px; margin-block: 16px; }
  .desktop-display-filter input, .desktop-display-filter select { min-height: 40px; border: 1px solid #d7dce3; border-radius: 7px; background: #fff; padding: 8px 12px; }
  .desktop-display-filter input { flex: 1; }
  .event-structured-form { width: 100%; max-width: 1120px; margin-inline: auto; display: grid; grid-template-columns: 190px minmax(0,1fr); column-gap: 28px; align-items: start; }
  .event-structured-form > * { grid-column: 2; }
  .event-structured-form > .desktop-event-workflow { grid-column: 1/-1; margin-bottom: 22px; }
  .desktop-event-workflow strong { font-size: 16px; }
  .desktop-event-workflow p { font-size: 13px; color: #686f7a; margin: 8px 0 0; }
  .event-structured-form > .desktop-section-nav { grid-column: 1; grid-row: 2 / span 8; position: sticky; top: 88px; display: grid; gap: 6px; }
  .desktop-section-nav button { text-align: start; display: grid; gap: 5px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
  .desktop-section-nav small { color: #686f7a; }
  .event-form-group { scroll-margin-top: 88px; }
  .event-form-submit { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 16px; }
  /* Conversation list and thread scroll separately; the current room DOM remains untouched. */
  body.chat-listing .app-shell, body.conversation-room .app-shell { position: fixed; inset: 0; min-height: 0; height: 100dvh; padding: 64px 0 0; padding-inline-start: var(--desktop-nav-width); display: flex; flex-direction: column; overflow: hidden; }
  body.chat-listing .topbar, body.conversation-room .topbar { position: fixed; inset-block-start: 0; inset-inline-start: var(--desktop-nav-width); inset-inline-end: 0; width: auto; }
  body.chat-listing #main, body.conversation-room #main { flex: 1; min-height: 0; max-width: none; width: 100%; height: 100%; padding: 0; overflow: hidden; }
  .chat-desktop { display: grid; grid-template-columns: minmax(250px,300px) minmax(0,1fr); height: 100%; min-height: 0; }
  .chat-desktop-list { min-width: 0; height: 100%; overflow-y: auto; background: #fff; border-inline-end: 1px solid var(--line); scrollbar-width: thin; }
  .chat-desktop-list .chat-list { border-radius: 0; }
  .chat-desktop-list .chat-row { border-radius: 0; padding: 12px; }
  .chat-desktop-list .chat-row.is-active { background: #e9edf4; }
  .chat-desktop-list .chat-row-name { font-size: 14px; }
  .chat-desktop-list .chat-row-preview { font-size: 12px; }
  .chat-desktop-list .chat-avatar { width: 38px; height: 38px; flex-basis: 38px; font-size: 14px; }
  .chat-desktop-list .chat-list-tabs { position: sticky !important; top: 0 !important; inset-inline: auto; width: 100%; margin: 0; padding: 10px; background: #fff; z-index: 3; }
  .chat-desktop-list .chat-list-tabs-anchor { display: none; }
  .chat-desktop-list .chat-pinned-items { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .chat-desktop-list .chat-pin-room { min-height: 60px; border: 0; background: transparent; border-radius: 6px; }
  .chat-desktop-list .chat-pin-open { min-height: 58px; padding: 6px; }
  .chat-desktop-list .chat-pin-open .chat-avatar { width: 28px; height: 28px; min-height: 28px; flex-basis: 28px; }
  .chat-desktop-thread { min-height: 0; min-width: 0; height: 100%; overflow: hidden; }
  .chat-desktop-thread > .chat-room { height: 100%; min-height: 0; }
  .desktop-chat-empty { display: flex; height: 100%; align-items: center; justify-content: center; flex-direction: column; padding: 32px; color: #6a7380; text-align: center; }
  .desktop-chat-empty h2 { color: #404a58; font-size: 20px; }
  body.chat-conversation .topbar-brand > div { position: static; inset: auto; transform: none; width: auto; text-align: start; }
  body.chat-conversation .topbar-brand strong, body.chat-conversation .topbar-brand small { text-align: start; }
  .chat-desktop-thread .chat-messages { padding-inline: 28px; }
  .chat-desktop-thread .chat-bubble { max-width: min(640px,100%); }
  .chat-desktop-thread .chat-compose { padding: 12px 20px; border-top: 1px solid #dfe3e8; background: #fff; }
  .chat-desktop-thread .chat-input-editor { background: #fff; border-color: #d8dfe8; border-radius: 8px; }
  .chat-desktop-thread .chat-tool-btn { width: 40px; min-width: 40px; }
  .chat-desktop-thread #chat-compose .chat-compose-toolbar { display: flex; gap: 8px; justify-content: start; }
  .chat-desktop-thread #chat-compose .chat-compose-toolbar > button { flex: none; }
  .chat-desktop-thread .chat-select-bar { position: absolute; inset-inline: 0; bottom: 0; }
  body.org-graph-fullscreen #desktop-nav, body.interp-focus #desktop-nav { display: none; }
  /* The interpreter fixes its canvas to the viewport; reserve the same sidebar
     space as the header, including RTL. Normal-flow shell padding cannot do this. */
  body.interp-page #main { inset-inline-start: var(--desktop-nav-width); inset-inline-end: 0; width: auto; max-width: none; min-height: 0; padding: 0; margin: 0; }
  body.interp-focus { --desktop-nav-width: 0px; }
  @media (max-width: 1200px) { :root { --desktop-nav-width: 188px; } .chat-desktop { grid-template-columns: 250px minmax(0,1fr); } #main { padding-inline: 20px; } }
}
