/* Shared visual finish. Loaded after legacy page styles. */
:root {
    --ink: #172a3b;
    --muted: #647489;
    --line: #dce5eb;
    --line-strong: #c8d5df;
    --panel: #fff;
    --soft: #f4f7fa;
    --soft-2: #eaf0f5;
    --accent: #176c7a;
    --accent-dark: #105661;
    --blue: #176c7a;
    --blue-dark: #105661;
    --shadow: 0 8px 28px rgba(20, 43, 60, .055);
}
body { color: var(--ink); background: #f4f7fa; font-size: 14px; line-height: 1.5; }
.workflow-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,280px),1fr)); gap: 12px; }
.workflow-cards .panel { margin: 0; }
.workflow-cards h2 { font-size: 16px; }
.task-assign { margin-top: 12px; }
.task-assign summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.task-assign form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.task-assign label { flex: 1 1 160px; min-width: 0; }
.task-assign select { width: 100%; }
.request-navigation { margin-bottom: 16px; flex-wrap: wrap; }
.wps-fee-option { flex: 1 0 100%; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.wps-fee-option .wps-fee-confirm { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 13px; font-weight: 500; line-height: 1.5; }
.wps-fee-confirm input[type=checkbox] { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; }
.wps-fee-option small { display: block; margin: 6px 0; }
.wps-fee-option p { margin-bottom: 0; }
[hidden] { display: none !important; }
.task-history-choice { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.task-history-choice input[type=checkbox] { width: 18px; height: 18px; min-height: 18px; margin: 0; }
/* Scoped notification controls: compact without shrinking touch targets. */
.email-settings { max-width: 1180px; margin: 0 auto; }
.email-settings-grid { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.email-settings .panel { padding: 20px; min-width: 0; margin: 0; }
.email-settings h2 { font-size: 17px; margin: 0 0 12px; }
.email-settings h3 { font-size: 14px; margin: 18px 0 10px; }
.email-settings .email-address-grid { display: grid; gap: 12px; }
.email-settings label { font-size: 13px; }
.email-settings input[type=email], .email-settings input[name=confirmation] { min-width: 0; width: 100%; min-height: 44px; box-sizing: border-box; }
.email-settings .email-sender { font-size: 12px; overflow-wrap: anywhere; margin: 0 0 16px; color: var(--muted); }
.email-caution { font-size: 12px; color: #775922; background: #fff9eb; padding: 10px 12px; border-radius: 8px; }
.email-status { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--soft); border-radius: 20px; padding: 5px 10px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.email-status.is-on { background: #edf8f2; color: #226245; border-color: #cee6d9; }
.email-settings .email-recipient-matrix { width: 100%; min-width: 0; table-layout: fixed; }
.email-recipient-matrix th:first-child { width: 32%; text-align: left; }
.email-settings .email-recipient-matrix thead th { text-transform: none; letter-spacing: 0; }
.email-settings .email-recipient-matrix th, .email-settings .email-recipient-matrix td { padding: 4px; vertical-align: middle; text-align: center; white-space: normal; overflow-wrap: anywhere; }
.email-settings .email-recipient-matrix tbody th { text-align: left; padding-left: 10px; background: transparent; font-size: 12px; text-transform: none; }
.email-settings .email-setting-check { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin: 0; cursor: pointer; }
.email-settings input[type=checkbox] { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; padding: 0; margin: 0; accent-color: var(--accent); }
.email-frequency-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.email-frequency-list label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.email-frequency-list label:has(:checked) { background: #eff7f8; border-color: #b7d8dd; }
.email-settings .email-controls { padding: 0; margin-bottom: 10px; }
.email-controls > details > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 15px 20px; cursor: pointer; font-weight: 650; list-style: none; }
.email-controls > details > summary::-webkit-details-marker { display: none; }
.email-controls > details > summary::before { content: '+'; font-size: 20px; color: var(--accent); }
.email-controls > details[open] > summary::before { content: '−'; }
.email-controls > details > summary .email-status { margin-left: auto; }
.email-control-body { padding: 0 20px 20px; border-top: 1px solid var(--line); }
.email-confirm-form { display: grid; gap: 12px; margin-top: 16px; max-width: 640px; }
.email-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.email-settings button { min-height: 44px; }
.cashflow-report-panel tr:target td { background: #eaf6f8; }
.cashflow-classification-chart { min-width: 0; max-width: 100%; }
@media (max-width: 760px) {
    .email-settings-grid { grid-template-columns: minmax(0,1fr); gap: 12px; }
    .email-settings .panel { padding: 14px; }
    .email-settings .email-controls { padding: 0; }
    .email-controls > details > summary { padding: 12px 14px; }
    .email-control-body { padding: 0 14px 14px; }
    .email-settings input[type=email], .email-settings input[name=confirmation] { font-size: 16px; }
    .email-settings .info-popover { left: auto; right: 0; max-width: calc(100vw - 64px); }
}
body, input, select, textarea, button { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.topbar { min-height: 66px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); box-shadow: 0 2px 12px rgba(20,43,60,.045); }
.primary-nav { border-color: var(--line); background: #f7f9fb; }
.primary-nav a, .nav-menu summary { font-weight: 700; }
.page { max-width: 1720px; }
.page-heading, .cashflow-hero { border-radius: 16px; }
.page-heading h1, .cashflow-hero h1 { letter-spacing: -.025em; }
.cashflow-hero h1 { color: #fff; }
.page-heading, .panel, .employee-card, .cashflow-report-panel { box-shadow: var(--shadow); }
.panel, .employee-card, .compact-filter-panel { border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.panel:hover { box-shadow: var(--shadow); }
.panel h2, .panel h3 { letter-spacing: -.014em; }
.eyebrow { font-weight: 750; letter-spacing: .075em; }
input, select, textarea { border-color: var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(23,108,122,.32); outline-offset: 2px; }
button, .button { border-radius: 9px; font-weight: 750; }
button.secondary, .button.secondary { background: #eaf3f4; color: #155765; border: 1px solid #c9dfe3; }
button.secondary:hover, .button.secondary:hover { background: #dcebee; color: #0d4450; }
.compact-filter-panel, .compact-filter-form { gap: 10px; }
.compact-filter-panel { padding: 14px 16px; }
.compact-filter-grid { align-items: end; }
.table-wrap { border: 1px solid var(--line); border-radius: 11px; background: #fff; }
table { border-collapse: separate; border-spacing: 0; }
th { background: #f1f5f8; color: #415366; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
td { border-bottom-color: #e8eef2; vertical-align: top; }
tbody tr:hover td { background: #f7fafb; }
.app-footer { color: var(--muted); }

.info-tip { display: inline-block; position: relative; vertical-align: middle; margin-left: 8px; font-style: normal; font-weight: 400; text-align: left; }
.info-tip > summary { display: inline-grid; width: 20px; height: 20px; place-items: center; list-style: none; border: 1px solid #9fbdc5; border-radius: 50%; color: #176c7a; background: #eef7f8; font-size: 12px; font-weight: 850; font-family: Georgia, serif; line-height: 1; cursor: pointer; user-select: none; }
.info-tip > summary::-webkit-details-marker { display: none; }
.info-tip[open] > summary, .info-tip > summary:hover { border-color: #176c7a; background: #176c7a; color: #fff; }
label:has(.info-tip) { position: relative; }
label .info-tip { position: absolute; top: 0; right: 0; margin: 0; }
label .info-tip .info-popover { left: auto; right: 0; }
.page-heading:has(.info-tip[open]), .cashflow-hero:has(.info-tip[open]), .panel:has(.info-tip[open]), .employee-card:has(.info-tip[open]) { overflow: visible; }
.page-heading h1:has(+ .info-tip), .section-title-row h2:has(+ .info-tip), .cashflow-hero h1:has(+ .info-tip) { display: inline-block; margin-right: 2px; }
.info-popover { position: absolute; z-index: 80; top: calc(100% + 8px); left: 0; width: min(330px, calc(100vw - 34px)); padding: 13px 15px; border: 1px solid #cbdce1; border-radius: 11px; background: #fff; box-shadow: 0 15px 32px rgba(23,46,61,.16); color: #243b4a; font-size: 12px; font-weight: 500; line-height: 1.5; letter-spacing: normal; text-transform: none; white-space: normal; }
.info-popover p { margin: 0 0 8px; color: inherit; font: inherit; }
.info-popover p:last-child { margin-bottom: 0; }
.info-popover .field-help { display: block; margin: 0; color: inherit; font: inherit; }
.section-title-row > div > h2 + .info-tip, .page-heading h1 + .info-tip { margin-top: 5px; }
.cashflow-hero .info-tip > summary { color: #fff; border-color: rgba(255,255,255,.7); background: rgba(255,255,255,.15); }

.user-add-panel { margin-bottom: 14px; }
.user-add-panel > details > summary, .user-card > details > summary { cursor: pointer; font-weight: 800; }
.user-add-panel > details > summary { font-size: 15px; padding: 2px 0; }
.access-form { margin-top: 14px; }
.access-form-basics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.access-form-basics label { display: grid; gap: 5px; font-size: 12px; font-weight: 750; color: #42566a; }
.access-form-basics input, .access-form-basics select { width: 100%; min-height: 41px; }
.access-role-line { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 13px 0; padding: 10px 12px; border: 1px solid #d9e8ea; border-radius: 10px; background: #f3f9fa; font-size: 12px; }
.access-role-line strong { color: #165663; }
.access-role-line span { color: #52697a; }
.access-active-switch { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 700; }
.access-permissions { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.access-permissions > summary, .access-group > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; }
.access-permissions > summary::-webkit-details-marker, .access-group > summary::-webkit-details-marker { display: none; }
.access-permissions > summary { min-height: 42px; padding: 9px 12px; color: #214759; font-size: 13px; font-weight: 800; }
.access-permissions > summary::after, .access-group > summary::after { content: '⌄'; margin-left: 7px; color: #607789; font-size: 17px; line-height: 1; }
.access-permissions[open] > summary::after, .access-group[open] > summary::after { transform: rotate(180deg); }
.access-permissions > summary small, .access-group > summary small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.access-groups { display: grid; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--line); }
.access-group { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.access-group > summary { min-height: 38px; padding: 7px 10px; font-size: 12px; font-weight: 800; }
.access-group[open] > summary { border-bottom: 1px solid var(--line); background: #f7fafb; }
.access-group-body { padding: 8px 10px 10px; }
.access-group-actions { display: flex; justify-content: flex-end; gap: 5px; margin: 0 0 5px; }
.access-group-actions button { min-height: 30px; padding: 4px 8px; font-size: 11px; }
.access-rights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; }
.access-form .access-right { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 34px; padding: 5px 7px; border: 0; border-radius: 6px; color: #344b5c; font-size: 12px; font-weight: 600; cursor: pointer; }
.access-form .access-right:has(input:checked) { background: #eef7f8; }
.access-right.is-fixed { cursor: default; }
.access-right.is-unavailable { opacity: .46; cursor: not-allowed; }
.access-form .access-right input[type="checkbox"] { flex: 0 0 18px; width: 18px; min-width: 18px; max-width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 0; border-radius: 3px; accent-color: #176c7a; }
.access-right span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.access-right small { flex: 0 0 auto; margin-left: auto; color: #397282; font-size: 10px; }
.access-role-scope { margin: 0 0 6px; font-size: 12px; color: #546b7a; }
.access-role-features { margin: 0; padding-left: 19px; font-size: 12px; }
.access-read-group { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.access-read-group strong { color: #2f5261; }
.user-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.user-card { min-width: 0; margin: 0; }
.user-summary { grid-template-columns: minmax(0, 1fr); gap: 9px; }
.user-summary .employee-mini { display: flex; flex-wrap: wrap; gap: 10px; }
.user-card .employee-edit[open] { margin-top: 10px; }
@media (max-width: 1100px) { .access-form-basics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .access-rights { grid-template-columns: 1fr; } .page { padding-left: 14px; padding-right: 14px; } }
@media (max-width: 580px) { .access-form-basics { grid-template-columns: 1fr; } .info-popover { left: auto; right: 0; } .access-read-group { grid-template-columns: 1fr; gap: 2px; } .user-summary .employee-mini { font-size: 11px; } }

/* Quieter desktop typography without shrinking touch targets or triggering iOS input zoom. */
@media (min-width: 761px) {
    body { font-size: 13px; }
    .page-heading h1, .cashflow-hero h1 { font-size: clamp(23px, 2vw, 28px); line-height: 1.18; }
    .panel h2, .section-title-row h2 { font-size: 18px; line-height: 1.28; }
    .panel h3 { font-size: 15px; }
    input, select, textarea, button, .button { font-size: 13px; }
    td { font-size: 12.5px; }
    .cashflow-kpis strong, .cashflow-period-total-strip strong { font-size: clamp(18px, 1.55vw, 23px); }
}
@media (max-width: 760px) {
    body { font-size: 14px; }
    .page-heading h1, .cashflow-hero h1 { font-size: clamp(21px, 6vw, 26px); }
    .panel h2, .section-title-row h2 { font-size: 17px; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea { font-size: 16px; min-height: 42px; }
    button, .button { min-height: 42px; }
}
#cf-closing-balances { background: #edf7f1; border-color: #9fcdb2; }
#cf-closing-balances legend { color: #176748; }
#cf-closing-balances input { background: #fff; border-color: #a7cdb5; }
.cashflow-inline-add { display: inline; width: auto; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: inherit; font-weight: 750; text-decoration: underline; cursor: pointer; }
.cashflow-inline-add:disabled { opacity: .5; cursor: wait; }
.cashflow-product-dialog { width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 22px 60px rgba(20,43,60,.22); }
.cashflow-product-dialog::backdrop { background: rgba(17,37,49,.42); }
.cashflow-product-dialog h3 { margin: 0 0 14px; }
.cashflow-product-dialog label { display: block; }
.cashflow-product-dialog input { width: 100%; margin-top: 6px; }
.cashflow-product-dialog .actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.cashflow-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cashflow-product-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); font-size: 12px; }
#cashflow-settlement-net { background: #edf7f1; border-color: #9fcdb2; color: #176748; font-weight: 800; }
@media (max-width: 900px) {
    .workflow-table { display: block; min-width: 0 !important; width: 100%; }
    .workflow-table thead { position: absolute; clip: rect(0,0,0,0); width: 1px; height: 1px; overflow: hidden; }
    .workflow-table tbody, .workflow-table tr { display: block; width: 100%; }
    .workflow-table tr + tr { border-top: 2px solid var(--line); }
    .workflow-table td { display: block; width: auto !important; white-space: normal; overflow-wrap: anywhere; padding: 9px 12px; border: 0; }
    .workflow-table td::before { content: attr(data-label); display: block; color: #64748b; font-size: 11px; font-weight: 700; margin-bottom: 3px; }
    .workflow-table td form, .workflow-table td select { width: 100%; max-width: 100%; min-width: 0; }
    .workflow-table td button { margin-top: 8px; }
    .access-form .access-right { min-height: 44px; }
}

/* Desktop density: reduce visual emphasis, not already-small reading text.
   Touch devices retain their existing headings and comfortable input sizing. */
@media (min-width: 1201px) and (hover: hover) and (pointer: fine) {
    body { font-size: 12.5px; }
    input, select, textarea, button, .button { font-size: 12.5px; }
    .page h1, .page-heading h1, .cashflow-hero h1, .employee-records-heading h1,
    .annual-leave-hero h1, .payroll-master-hero h1, .dashboard-page > h1 {
        font-size: 20px; font-weight: 650; line-height: 1.25;
    }
    .page h2, .panel h2, .section-title-row h2, .card h2, .employee-record-card h2,
    .annual-leave-record h2, .payroll-record-head h2 { font-size: 14px; font-weight: 650; }
    .panel h3 { font-size: 13px; font-weight: 650; }
    .cashflow-kpis strong, .cashflow-period-total-strip strong,
    .metric strong, .metric.compact strong, .action-metric strong { font-size: 16px; font-weight: 650; }
    .cashflow-insights-hero h2 { font-size: 20px; font-weight: 650; }
    .primary-nav a, .nav-menu summary, button, .button { font-weight: 600; }
    .cashflow-tabs a { font-weight: 650; }
    .page-heading, .cashflow-hero, .employee-records-heading,
    .annual-leave-hero, .payroll-master-hero { padding-top: 14px; padding-bottom: 14px; }
    .email-settings h2 { font-size: 14px; }
}
/* Fix legacy filter rules that overrode the mobile input size. */
@media (max-width: 1100px), (pointer: coarse) {
    body .page input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
    body .page select, body .page textarea { font-size: 16px; min-height: 44px; }
    body:is(.private-shell, .public-shell) .page button,
    body:is(.private-shell, .public-shell) .page .button { min-height: 44px; }
}
/* Payroll payment and its cash posting are a single compact form. */
.payroll-payment-form .payroll-cash-options { grid-column: 1 / -1; min-width: 0; }
.payroll-payment-form .payroll-wps-fee { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.payroll-payment-form .payroll-wps-fee[hidden] { display: none; }
.payroll-payment-form .payroll-wps-fee input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; }
.payroll-cash-options details { margin-top: 6px; }
.payroll-cash-options details label { max-width: 320px; }
@media (min-width: 1201px) {
    .payroll-payment-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .payroll-payment-form > button { align-self: end; }
}
