* { box-sizing: border-box; }
/* 流程只加排列與順序；狀態色沿用既有 office-card、ledger-status 與 quota-warning。 */
.home-next { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 20px; margin-bottom: 26px; }
.home-section { margin: 24px 0; }
.home-setup { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; list-style: none; padding: 0; }
.home-step { padding: 18px; display: flex; flex-direction: column; align-items: flex-start; overflow-wrap: anywhere; }
.home-step h3 { margin-bottom: 12px; }
.home-step > a { margin-top: auto; }
.home-links { display: flex; flex-wrap: wrap; gap: 12px; }
.home-links > a { padding: 14px 18px; }
.setup-progress { margin: 16px 0 22px; }
.setup-progress-links { display: flex; flex-wrap: wrap; gap: 12px 24px; list-style: none; padding: 0; }
.setup-progress-links [aria-current="step"] { font-weight: 700; text-decoration: underline; text-underline-offset: 5px; }
#epoch-manifest-digest { font-size: 1.25rem; letter-spacing: .05em; }
@media (max-width: 1100px) { .home-setup { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .home-setup { grid-template-columns: 1fr; } }
body { margin: 0; background: #FBFAF8; color: #1B1F24; font-size: 14px; line-height: 1.5;
    font-family: "IBM Plex Sans", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
a { color: #0F345B; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid #8CAACB; outline-offset: 3px; }
.portal-top { display: flex; align-items: center; gap: 24px; min-height: 56px; padding: 10px 28px;
    background: #0F345B; color: white; flex-wrap: wrap; }
.portal-top a { color: #fff; }
.portal-brand { font-weight: 600; }
/* ── 品牌標誌（Site:Logo；沒有設定時這一區完全不生效）──
   規則：只設高度、寬度自動（不變形、不改色）；Viettron 字標寬度不得小於 120px（最小高度 12px 時約 148px，自然滿足）；
   標誌與分隔線之間至少留一個標誌高度的空白（Viettron）；不在字標旁放公司名，只放站名。
   尺寸（高度）：頁首 Viettron 14px／Mobipus 34px，手機（≤640px）12px／28px；
   登入頁深藍品牌欄 22px／64px；淺色底（註冊頁、匿名頁頁首）18px／44px。 */
.brand-logo { display: block; width: auto; max-width: 100%; flex: 0 0 auto; }
.brand-logo-viettron.brand-logo-reverse { --logo-h: 14px; height: 14px; }
.brand-logo-mobipus.brand-logo-reverse { --logo-h: 34px; height: 34px; }
.brand-logo-viettron.brand-logo-color { --logo-h: 18px; height: 18px; }
.brand-logo-mobipus.brand-logo-color { --logo-h: 44px; height: 44px; }
.portal-top .brand-logo-viettron { --logo-h: 14px; height: 14px; }
.brand-sep { align-self: center; width: 1px; height: 22px; flex: 0 0 1px; }
.brand-sep-reverse { background: rgba(255, 255, 255, .4); }
.brand-sep-color { background: #B7C1CE; }
/* 分隔線兩側的空白：Viettron 至少等於標誌高度（頁首 14px、淺色底 18px）；Mobipus 固定 16px。 */
.brand-sep-viettron.brand-sep-reverse { margin-inline: 14px; }
.brand-sep-viettron.brand-sep-color { margin-inline: 18px; }
.brand-sep-mobipus { margin-inline: 16px; }
.portal-brand.has-logo { display: inline-flex; align-items: center; }
.portal-brand.anonymous-brand { margin-right: auto; color: #0F345B; }
.portal-top .portal-brand.has-logo { gap: 0; }
@media (max-width: 640px) {
    .portal-top .brand-logo-viettron { height: 12px; --logo-h: 12px; }
    .portal-top .brand-logo-mobipus { height: 28px; --logo-h: 28px; }
    .brand-sep-viettron.brand-sep-reverse { margin-inline: 12px; }
}
/* 註冊頁：標題上方的彩色標誌＋分隔線＋站名。 */
.brand-lockup { display: flex; align-items: center; margin-bottom: 22px; color: #0F345B; font-weight: 600; }
.brand-lockup-name { font-size: 14px; }
.portal-who { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.portal-who form { margin: 0; }
.portal-top .text-muted { color: #C9D6E5 !important; }
.portal-button { border: 1px solid #CFD6DE; border-radius: 4px; padding: 8px 16px; background: white; color: #3A4654; }
.portal-button.primary { background: #0F345B; color: white; border-color: #0F345B; min-height: 40px; }
.sign-out { background: transparent; color: white; border-color: #69819C; padding: 4px 10px; }
.anonymous-top { display: flex; justify-content: flex-end; padding: 24px 28px; }
.login-page .anonymous-top { position: absolute; top: 32px; right: 60px; z-index: 2; padding: 24px 0; }
.tenant-scope { display: flex; align-items: center; gap: 12px; padding: 9px 28px;
    border-bottom: 1px solid #D8DFE8; font-size: 13px; flex-wrap: wrap; }
.office-tenant { background: #EEF2F7; color: #3A4654; }
.cross-tenant { background: #FBF6EA; color: #6B5316; }
.office-pill { background: #0F345B; color: #fff; padding: 3px 9px; border-radius: 3px; }
.portal-content { padding: 26px 28px 34px; }
.portal-footer { padding: 20px 28px; color: #8A8A88; font-size: 12px; }
/* 法規備案標示（大陸站的 ICP／公安備案號）。★未設定的站台整個元素不渲染，
   所以這幾條樣式在台灣站與越創站完全不會生效。
   ★登入頁沒有上面那個 portal-footer，這一區會是唯一的頁尾，所以上方留白不設 0。 */
.portal-filing { padding-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.portal-filing a { color: inherit; text-decoration: underline; }
.login-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 100vh; }
.login-brand { background: #0F345B; color: #fff; padding: 56px 60px; display: flex;
    flex-direction: column; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; right: -160px; bottom: -200px;
    width: 520px; height: 520px; border-radius: 50%; background: #172645; opacity: .55; }
.login-mark { font-weight: 600; font-size: 16px; position: relative; z-index: 1; }
/* 登入頁品牌欄的標誌（白字版）：Viettron 高 22px、Mobipus 高 64px；站名縮成標誌下方的小字，顏色同 .login-brand-body p。
   站名與標誌以標誌的中線對齊（Mobipus 標誌本身是置中構圖，站名靠左會看起來偏一邊）；整組仍放在品牌欄左上角。 */
.login-mark-logo { align-self: flex-start; display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-mark-logo .brand-logo-login.brand-logo-viettron { height: 22px; }
.login-mark-logo .brand-logo-login.brand-logo-mobipus { height: 64px; }
.login-mark-caption { margin-top: 12px; font-size: 13px; font-weight: 400; color: #B9C9DC; }
/* 越創字標四周留白不得小於字標高度（設計系統 §6）：登入頁字標高 22px，下方站名至少隔 22px。 */
.login-mark-logo .brand-logo-viettron + .login-mark-caption { margin-top: 22px; }
.login-brand-body { margin-top: auto; position: relative; z-index: 1; padding-top: 80px; }
.login-brand-body h2 { font-size: 34px; line-height: 1.32; margin: 0 0 18px; font-weight: 600; text-wrap: pretty; }
.login-brand-body p { color: #B9C9DC; font-size: 14.5px; line-height: 1.7; max-width: 38ch; }
.login-brand-foot { margin-top: 38px; color: #9FB4CC; font-size: 13px; position: relative; z-index: 1; }
.login-right { padding: 130px 60px 56px; display: flex; flex-direction: column; min-height: 100vh; }
.login-form { margin: auto 0; width: 100%; max-width: 392px; align-self: center;
    display: flex; flex-direction: column; gap: 19px; }
.login-form h1 { margin: 0; font-size: 24px; font-weight: 600; }
.signup-right > * { width: 100%; max-width: 392px; align-self: center; }
.login-lead { margin: -8px 0 4px; color: #595757; font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: #3A4654; }
.field input { min-height: 38px; border: 1px solid #CFD6DE; border-radius: 4px; background: white; padding: 8px 11px; width: 100%; }
.field input:focus { border-color: #0F345B; box-shadow: 0 0 0 3px rgba(15,52,91,.10); }
/* 上面那條是給文字欄位的；勾選框／圓鈕套到會被撐成整欄寬、38px 高的大方框。 */
.field input[type="checkbox"], .field input[type="radio"] { width: auto; min-height: 0; padding: 0; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; font-size: 13px; color: #3A4654; }
.remember { display: flex; align-items: center; gap: 8px; color: #595757; font-size: 12.5px; }
.login-error { padding: 11px 13px; border-radius: 5px; font-size: 12.5px; line-height: 1.55;
    background: #FCF1F1; border: 1px solid #EDCFCF; color: #8C2126; }
/* 欄位內的錯誤訊息（例如註冊頁的算式）：間距交給 .field 的 gap，答錯的輸入框用同一個紅色標出。 */
.field .login-error { margin: 0; }
.field input[aria-invalid="true"] { border-color: #8C2126; }
.login-footer { color: #8A8A88; font-size: 12px; text-align: center; margin-top: 40px; }
.account-card { display: flex; justify-content: center; flex-direction: column; align-items: center; padding: 32px 0; }
@media (max-width: 800px) {
    .login-split { grid-template-columns: 1fr; }
    .login-brand { padding: 30px 24px; }
    .login-brand-body { padding-top: 30px; }
    .login-brand-body h2 { font-size: 27px; }
    .login-brand-foot { margin-top: 16px; }
    .login-right { padding: 100px 24px 32px; min-height: 600px; position: relative; }
    .login-page .anonymous-top { position: static; padding: 16px 24px; background: #FBFAF8; }
    .portal-who { margin-left: 0; justify-content: flex-start; }
    .portal-top { gap: 14px; }
}

/* 代理會影響帳本歸屬，以深藍色持續提示目前的操作範圍。 */
.acting-tenant { background: #0F345B; color: #fff; border-top: 1px solid #69819C; }
.tenant-switch { display: flex; align-items: center; gap: 8px; margin: 0 0 0 auto; flex-wrap: wrap; }
.tenant-switch select, .audit-filter select { max-width: 100%; min-height: 38px; padding: 6px 10px;
    border: 1px solid #CFD6DE; border-radius: 4px; background: #fff; color: #1B1F24; }
.portal-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.page-heading { margin: 0 0 4px; font-size: 23px; font-weight: 600; }
.page-subtitle { margin: 0 0 22px; color: #595757; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.admin-stat, .office-card, .admin-note { background: #fff; border: 1px solid #E3E1DC; border-radius: 6px; }
.admin-stat { padding: 15px 17px; }
.admin-stat h2 { font-size: 13px; color: #595757; margin: 0; font-weight: 400; }
.stat-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.admin-stat p { color: #595757; font-size: 12px; margin: 2px 0 0; }
.section-heading { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 13px; }
.section-heading h2 { font-size: 16px; margin: 0; }
.section-heading p { margin: 0; font-size: 13px; color: #595757; }
.office-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.office-card { min-width: 0; overflow: hidden; }
.office-card header { padding: 15px 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
    border-bottom: 1px solid #EFEDE8; overflow-wrap: anywhere; }
.office-card h3 { font-size: 16px; font-weight: 600; margin: 0; }
.office-card-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.office-row { display: flex; justify-content: space-between; gap: 12px; color: #595757; font-size: 13px; flex-wrap: wrap; overflow-wrap: anywhere; }
.brand-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.brand-chip { border: 1px solid #DCD9D3; border-radius: 3px; padding: 3px 9px; color: #3A4654;
    background: #FBFAF8; font-size: 12px; }
.quota-bar { height: 7px; border-radius: 4px; background: #EFEDE8; overflow: hidden; margin-top: 6px; }
.quota-bar span { display: block; height: 100%; background: #0F345B; }
.quota-bar span.warning { background: #9A6B12; }
.quota-warning { color: #9A6B12; }
.office-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.portal-button:disabled { opacity: .55; cursor: not-allowed; }
/* 軟體產品切換（額度頁、名額頁）：目前的產品用粗體，其他產品是連結。 */
.product-switch { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; margin: 8px 0 16px; }
.admin-note { padding: 12px 14px; margin-top: 22px; color: #595757; font-size: 13px; }
.admin-note p { margin: 0 0 6px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }
.audit-filter, .audit-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.audit-table-wrap { overflow-x: auto; background: #fff; border: 1px solid #E3E1DC; border-radius: 6px; }
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table th, .audit-table td { padding: 12px; border-bottom: 1px solid #EFEDE8; text-align: left; vertical-align: top;
    overflow-wrap: anywhere; min-width: 100px; }
.audit-table th { background: #EEF2F7; }
.audit-time, .audit-ip { white-space: nowrap; }
.audit-table pre { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 220px; max-width: 500px; margin-top: 8px; }
.audit-table summary { cursor: pointer; color: #0F345B; }
/* 代理操作的標記。用紅底是刻意的——這一列不是這個辦公室自己做的。 */
.audit-delegated-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px;
    background: #C8161D; color: #fff; font-size: 11px; white-space: nowrap; }
.issue-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 22px; border: 0; padding: 0; }
.issue-card { background: #fff; border: 1px solid #E3E1DC; border-radius: 6px; padding: 20px; margin-bottom: 22px; min-width: 0; }
.issue-card h2 { font-size: 16px; margin: 0 0 18px; }
.issue-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.issue-wide { grid-column: 1 / -1; }
.issue-fields select, .issue-fields textarea { width: 100%; padding: 8px 11px; border: 1px solid #CFD6DE; border-radius: 4px; background: #fff; }
/* 期間＝數值＋單位並排。單位下拉要夠寬裝得下最長的字（英文 "months from now"），所以給數值固定寬度、
   單位吃掉剩下的空間，而不是各半——中／英三語的字長差很多，平分會讓英文被截掉。 */
.issue-duration { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; align-items: center; }
.issue-duration input { width: 100%; }
/* ★這一條是必要的，不是防禦性多寫。上面 .field 有明寫 display: flex，而作者樣式勝過瀏覽器對
   [hidden] 的預設 display: none ⇒ issue.js 把 el.hidden 設成 true 時欄位【不會】消失，
   到期方式切換看起來完全沒反應（required 搬動是對的，所以也不會報錯，純粹是靜默失效）。 */
.field[hidden] { display: none; }
.issue-hint { font-size: 12px; color: #595757; margin: 4px 0 14px; }
.issue-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow-wrap: anywhere; }
.issue-summary dt { font-weight: 400; color: #595757; }
.issue-summary dd { margin: 0; }
.issue-warning { background: #FBF6EA; color: #6B5316; border: 1px solid #E9DAB2; padding: 13px; border-radius: 5px; }
.issue-licenses { padding-left: 18px; overflow-wrap: anywhere; }
.issue-result { max-width: 850px; margin-top: 22px; }
.issue-columns:disabled { opacity: .65; }
@media (max-width: 800px) {
    .issue-columns, .issue-fields { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
    .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .admin-stats, .office-cards { grid-template-columns: 1fr; }
    .portal-content { padding: 22px 16px; }
    .tenant-scope { padding: 12px 16px; }
    .tenant-switch { margin-left: 0; }
}
.office-form { max-width: 760px; }

/* 公鑰為長字串；外部樣式讓嚴格 CSP 下仍能自動換行。 */
.public-key-hex { overflow-wrap: anywhere; }

/* 服務條款與隱私權政策（_LegalDocument 的 article）。
   ★範本是不帶 class 的純 HTML，而且範本內容決定文件版本與雜湊：在範本加 class 或改結構會讓政策改版、
     所有客戶下次使用都要重新同意。所以版面一律在這裡用 .legal-document 底下的元素選擇器控制。
   表格固定兩欄（資料／說明、對象／範圍、資料／保存期間）：固定版面讓每張表的分欄位置一致，
   第一欄 32% 放得下最長的項目名稱（約 15 個中文字）並自動換行。 */
.legal-document { max-width: 860px; font-size: 14px; line-height: 1.75; color: #2B3440; }
.legal-document h2 { font-size: 19px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid #E4E1DA; }
.legal-document h2:first-child { margin-top: 8px; }
.legal-document h3 { font-size: 15.5px; margin: 26px 0 10px; }
.legal-document p, .legal-document ul, .legal-document ol { margin: 0 0 12px; }
.legal-document li + li { margin-top: 4px; }
.legal-document table { width: 100%; table-layout: fixed; border-collapse: collapse; margin: 6px 0 20px; }
.legal-document th, .legal-document td { padding: 9px 12px; border: 1px solid #E4E1DA; text-align: start;
    vertical-align: top; overflow-wrap: anywhere; }
.legal-document thead th { background: #F6F5F2; color: #3A4654; font-weight: 600; }
.legal-document tr > :first-child { width: 32%; }
@media (max-width: 700px) {
    .legal-document { font-size: 13.5px; }
    .legal-document th, .legal-document td { padding: 8px 9px; }
    .legal-document tr > :first-child { width: 38%; }
}
