/* 員工姓名區保留原本開啟詳細資料的按鈕行為。 */
.people-table .person-detail-trigger{display:block;width:100%;height:auto;min-width:0;padding:8px 0;border:0;border-radius:0;background:transparent;color:inherit;text-align:left;cursor:pointer}
.people-table .person-detail-trigger span{display:block}
.people-table .person-detail-trigger strong,.people-table .person-detail-trigger small{display:block}
.people-table .person-detail-trigger:hover{background:#e6eeea}
.people-table .person-detail-trigger:focus-visible{outline:2px solid #17685f;outline-offset:3px}
@media(min-width:901px){.account-stats.people-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.account-stats.people-stats>article,.account-stats.people-stats>a{min-width:0;padding:12px}.account-stats.people-stats span{white-space:nowrap}}

.qichen-desktop-embedded .account-stats.people-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.qichen-desktop-embedded .account-stats.people-stats>article,.qichen-desktop-embedded .account-stats.people-stats>a{min-width:0;padding:12px}.qichen-desktop-embedded .account-stats.people-stats span{white-space:nowrap}

/* 全站功能頁共用水平外距；新增頁面沿用 dashboard-main 即可。 */
:root { --qichen-page-gutter: 10px; --qichen-page-top-gap: 12px; --qichen-max-vertical-padding: 12px; --qichen-table-cell-padding-inline: 5px; --qichen-description-font-size: 10px; --qichen-table-header-padding-block: 10px; --qichen-table-header-font-size: 12px; }
@media screen {
  body.dashboard-page .account-stats.customer-part-summary {
    display: flex; flex-wrap: nowrap; align-items: stretch; gap: 10px; overflow-x: auto;
  }
  .account-stats.customer-part-summary > article {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex: 1 0 145px; min-width: 145px;
  }
  .customer-part-summary-actions { display: flex; align-items: center; flex: none; gap: 8px; }
  .customer-part-summary-actions button { height: 40px; min-height: 40px; white-space: nowrap; }
  .customer-part-import-dialog { width: min(1200px, calc(100vw - 24px)); max-width: none; }
  .customer-part-import-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
  .customer-part-import-tools label { display: grid; gap: 4px; }
  .customer-part-import-table { max-height: 50vh; overflow: auto; }
  .customer-part-import-table table { min-width: 1100px; }
  .customer-part-import-table th { position: sticky; top: 0; }
  .customer-part-import-error { background: #fff0ec; }
  .customer-part-import-error td:last-child { color: #a32519; min-width: 200px; }
  .customer-part-import-dialog [hidden] { display: none !important; }
}
/* 客戶清單的搜尋與新增操作共用同一列，頂端與清單標題對齊。 */
@media screen {
  .customer-toolbar-heading { gap: 16px; align-items: flex-start; }
  .customer-list-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .customer-list-actions .customer-search { display: flex; gap: 8px; margin: 0; min-width: 0; }
  .customer-list-actions :is(input, button) {
    box-sizing: border-box; height: 40px; min-height: 40px; margin: 0;
    padding-top: 8px; padding-bottom: 8px;
  }
  .customer-list-actions input { width: clamp(260px, 32vw, 440px); min-width: 0; }
  .customer-list-actions button { flex: none; white-space: nowrap; }
  .customer-toolbar-heading h2 { margin-top: 0; }
  .customer-toolbar-heading p { margin-bottom: 0; }
}
@media screen and (max-width: 700px) {
  .customer-toolbar-heading { align-items: stretch; flex-direction: column; }
  .customer-list-actions { width: 100%; gap: 6px; }
  .customer-list-actions .customer-search { flex: 1; gap: 6px; }
  .customer-list-actions input { width: 100%; flex: 1; }
  .customer-list-actions button { padding-right: 10px; padding-left: 10px; font-size: 12px; }
}
/* 區塊說明獨立於另開視窗按鈕，滑鼠與鍵盤皆可開啟。 */
.qichen-title-help-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; min-height: 0; margin: 0 0 0 6px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #17685f;
  font-size: 20px; line-height: 1; vertical-align: middle; cursor: pointer;
}
.qichen-title-help-button:hover { background: #e6eeea; }
.qichen-title-help-button:focus-visible { outline: 2px solid #17685f; outline-offset: 2px; }
.qichen-title-help-content[popover] {
  position: fixed; inset: auto; box-sizing: border-box; margin: 0;
  width: max-content; max-width: min(360px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px); overflow: auto; padding: 10px 12px;
  border: 1px solid #b6ccc5; border-radius: 8px; background: #fff;
  color: #234a43; font-size: var(--qichen-description-font-size); line-height: 1.6;
  white-space: normal; overflow-wrap: anywhere; box-shadow: 0 4px 18px #12332f26;
}
.dashboard-main .qichen-title-help-content:popover-open,
#person-detail-dialog .dialog-heading > .qichen-title-help-content:popover-open { display: block !important; }
@media print {
  .qichen-title-help-button { display: none !important; }
  .qichen-title-help-content[popover] { display: block !important; position: static; width: auto; max-width: none; max-height: none; border: 0; padding: 0; box-shadow: none; }
}
/* 桌面內嵌功能頁共用外層提示；獨立開啟時保留自己的提示。 */
html.qichen-desktop-embedded > body > .qichen-test-mode-banner { display: none !important; }
.desktop-home .sidebar [data-url][aria-current="page"] {
  background: #d9e4df; color: #12332f; font-weight: 800;
  box-shadow: inset 3px 0 0 #17685f;
}
/* 登入狀態在足夠寬度時將資訊排到標題右側；共用格線確保頂端對齊。 */
@media screen and (min-width: 800px) {
  #person-login-dialog[open] {
    grid-template-columns: minmax(190px, .7fr) minmax(0, 2fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
    column-gap: 20px;
  }
  #person-login-dialog > .dialog-heading { display: contents; }
  #person-login-dialog > .dialog-heading > .eyebrow { grid-column: 1; grid-row: 1; }
  #person-login-dialog > .dialog-heading > h2 { grid-column: 1; grid-row: 2; align-self: start; }
  #person-login-dialog #person-login-name { grid-column: 1; grid-row: 3; align-self: start; overflow-wrap: anywhere; }
  #person-login-dialog > .login-status-details {
    grid-column: 2; grid-row: 2 / span 2; align-self: start;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 12px; margin: 0; padding-right: 44px;
  }
  #person-login-dialog > .login-status-details > div { min-width: 0; padding-top: 0; padding-bottom: 0; }
  #person-login-dialog > .login-status-details dd { margin-top: 2px; }
  #person-login-dialog > .login-history-section { grid-column: 1 / -1; grid-row: 4; margin-top: 16px; }
}
.dashboard-main h2 > .section-window-button,
.dashboard-main [data-open-window-title] > .section-window-button {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  width: auto; min-height: 0; margin: 0; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #edf4f0; color: inherit; font: inherit;
  letter-spacing: inherit; text-align: left; cursor: pointer;
}
.dashboard-main .section-window-button:hover { background: #dfece5; }
.dashboard-main .section-window-button:focus-visible { outline: 2px solid var(--green-700); outline-offset: 3px; }
.section-window-icon { flex: none; font-size: .75em; }
@media print {
  .dashboard-main .section-window-button { padding: 0 !important; border: 0 !important; background: transparent !important; }
  .section-window-icon { display: none; }
}
@media screen {
  /* 新增與編輯人員表單共用緊湊列間距，保留原字級與水平欄距。 */
  #employee-form :is(.employee-form-grid-new, .employee-contact-grid,
    .employee-address-grid, .employee-employment-grid, .employee-account-grid) {
    margin-top: 8px; row-gap: 6px;
  }
  #employee-form .employee-address-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  #employee-form :is(.employee-form-grid-new, .employee-contact-grid,
    .employee-address-grid, .employee-employment-grid, .employee-account-grid) > * { min-width: 0; }
  /* 員工詳細資料僅縮減垂直留白，字級與左右內距沿用原設定。 */
  #person-detail-dialog { padding-top: 6px; padding-bottom: 6px; }
  #person-detail-dialog > .dialog-heading > p { display: none; }
  #person-detail-dialog > .dialog-close-form { top: 6px; }
  #person-detail-dialog > .employee-summary-scroll { margin-top: 8px; }
  #person-detail-dialog :is(.employee-summary-profile, .employee-summary-card,
    .employee-detail-empty, .employee-insurance-summary article) {
    padding-top: 6px; padding-bottom: 6px;
  }
  #person-detail-dialog .employee-summary-grid { margin-top: 10px; row-gap: 10px; }
  #person-detail-dialog .employee-summary-profile p { margin-top: 4px; }
  #person-detail-dialog .employee-summary-badges { margin-top: 8px; row-gap: 4px; }
  #person-detail-dialog .employee-summary-card > h3 { padding-bottom: 6px; }
  #person-detail-dialog .employee-details > div { padding-top: 4px; padding-bottom: 4px; }
  #person-detail-dialog .employee-dependent-table :is(th, td) { padding-top: 4px !important; padding-bottom: 4px !important; }
  /* 說明使用明確的內容結構與語意類別，不以所有段落或 small 選取資料內容。 */
  body :is(.data-panel-heading, .page-header, .dialog-heading, .section-heading,
    .quotation-page-header, .forecast-section-heading) p:not(.eyebrow),
  body :is(.module-card, .system-management-card, .card, .simple-action-card) > p,
  body .data-panel > h2 + p:not(.order-note-text),
  body :is(.description, .help-text, .hint, .field-hint, .account-detail-hint,
    .header-page-context-description, .people-link-note, .qichen-home-summary-note,
    .secure-note, .test-note, .order-help, .forecast-note, [data-description-text]),
  body .duty-help :is(p, li),
  body :is(.form-panel, .report-form, .account-form) label > small,
  body :is(.summary-card, .stat) > small,
  .desktop-home .intro > .sub {
    font-size: var(--qichen-description-font-size) !important;
  }
  /* 全站資料表只統一左右內距，保留各表格的上下內距。 */
  html body table :is(th, td),
  html body.dashboard-page :is(table[class], table:not([class])) :is(th, td) {
    padding-left: var(--qichen-table-cell-padding-inline) !important;
    padding-right: var(--qichen-table-cell-padding-inline) !important;
  }
  /* 導覽使用獨立字級；不受一般內文字級上限影響。 */
  .desktop-home .sidebar :is(.nav button, .side-link, .explorer-branch > summary, .label) {
    font-size: 15px !important;
  }
  .people-table .people-select-label > span { display: none; }
  body.dashboard-page .people-table tbody > tr > td {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  .people-table .person-detail-trigger { padding-top: 2px; padding-bottom: 2px; }
  .people-table .people-role-status { gap: 4px; }
  .people-table :is(.person-detail-trigger strong, tbody td:nth-child(3) > strong,
    tbody td:nth-child(4) > strong, .people-birthday-toggle, tbody td:nth-child(5) > strong,
    .people-address-cell, .people-role-status > span:first-child) {
    font-size: 12px !important;
  }
  /* 依既有無帳號資訊按鈕辨識資料列，保留其他帳號狀態的標籤設定。 */
  .people-table tr:has(.connection-detail-button[aria-label="查看無帳號人員資訊"]) .people-role-status > .badge-warn {
    padding: 1px !important;
    font-size: 10px !important;
  }
  /* 員工統計列與清單之間沿用上方留白，讓上下間距一致。 */
  body:not(.embedded-inline-editor) > main.dashboard-main .people-stats + .data-panel {
    margin-top: var(--qichen-page-top-gap) !important;
  }
  /* 覆蓋全站統計卡片的強制內距，僅調整員工頁四張卡片的上下內距。 */
  body.dashboard-page .account-stats.people-stats > :is(article, a) {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
  body:not(.embedded-inline-editor) > main.dashboard-main,
  .desktop-home .main > .content {
    box-sizing: border-box;
    width: calc(100% - var(--qichen-page-gutter) - var(--qichen-page-gutter)) !important;
    max-width: none !important;
    min-width: 0;
    margin-top: 0 !important;
    margin-right: var(--qichen-page-gutter) !important;
    margin-left: var(--qichen-page-gutter) !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    padding-top: var(--qichen-page-top-gap) !important;
  }
  /* 搬到共用頁首的標題與隱藏元素不佔首個內容位置，避免原有上外距疊加。 */
  :is(body:not(.embedded-inline-editor) > main.dashboard-main, .desktop-home .main > .content)
    > :nth-child(1 of :not(.back-link, .page-header-context-moved, [hidden], script, style, template, dialog, input[type="hidden"])) {
    margin-top: 0 !important;
  }
}
@media screen and (min-width: 800px) {
  #employee-form .employee-contact-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media screen and (max-width: 680px) {
  #employee-form .employee-address-grid { grid-template-columns: 1fr; }
}


/* 頁首介紹已從來源移除；保留的操作列沿用全站間距。 */
@media screen {
  main.dashboard-main .qichen-page-actions:empty { display:none; }
  main.dashboard-main .qichen-page-actions {
    margin-top:0 !important; margin-bottom:12px !important;
    min-height:0 !important; padding-top:0 !important; padding-bottom:0 !important;
  }
}

/* 初始版型完成後一次顯示，避免先顯示預設尺寸再切換。 */
@media screen {
  html.qichen-layout-pending > body { visibility:hidden; }
  html.qichen-desktop-embedded > body > :is(.topbar,.dashboard-footer) { display:none !important; }
}
