* { box-sizing:border-box }
:root { font-family:Inter,"Microsoft YaHei",system-ui,sans-serif; color:#192842; background:#f6f8fc; --accent:#325ba8; --button-bg:#edf4ff; --button-strong:#dce9fd; --button-border:#cbdcf6; --caution:#765414; --blue:#244777; --line:#e1e7f0; --muted:#53647b }
body { margin:0; font-size:14px }
button,input,select,textarea { font:inherit }
button,.button { cursor:pointer; display:inline-flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--button-border); background:var(--button-bg); color:var(--blue); border-radius:7px; padding:9px 13px; text-decoration:none; white-space:nowrap }
button:hover,.button:hover { background:#dceaff; border-color:#9cb8e5 }
button:focus-visible,.button:focus-visible { outline:2px solid #24598b; outline-offset:2px }
button:disabled { opacity:.5; cursor:wait }
button.primary,.button.primary { background:var(--button-strong); color:var(--blue); border-color:#aac4ec; font-weight:650 }
button.danger { color:var(--caution); border-style:dashed; font-weight:650 }
button.link { padding:3px 8px; font-weight:650 }
h1,h2,h3,p { margin:0 }
h1 { font-size:27px; letter-spacing:-.03em }
h2 { font-size:18px }
h3 { font-size:15px }
p { line-height:1.65 }
small,.muted { color:var(--muted) }
.shell { display:grid; grid-template-columns:225px minmax(0,1fr); min-height:100vh }
.sidebar { background:#fff; color:#192842; border-right:1px solid var(--line); padding:24px 15px; display:flex; flex-direction:column; gap:34px; position:sticky; top:0; height:100vh }
.brand { display:flex; align-items:center; gap:10px; padding:0 6px }
.brand strong { display:block; line-height:1.45 }
.brand span { color:var(--muted); display:block; font-size:12px; margin-top:3px }
.mark { width:43px; height:43px; border-radius:9px; background:#fff; color:var(--accent); display:grid; place-items:center; font-weight:850; overflow:hidden; flex:none }
.brand .mark span { grid-area:1/1; margin:0; color:var(--accent) }
.mark img { grid-area:1/1 }
.mark img { width:100%; height:100%; object-fit:contain; transform:scale(1.18) }
.sidebar nav { display:grid; gap:6px }
.sidebar nav button { justify-content:flex-start; padding:11px 12px; border-color:transparent }
.sidebar nav button.active { background:var(--button-strong); border-color:#b9cef0; box-shadow:inset 3px 0 var(--accent); font-weight:700 }
.nav-icon { width:20px; font-size:17px; text-align:center }
.side-footer { margin-top:auto; padding:0 8px; color:var(--muted); font-size:12px }
.top { background:#fff; min-height:65px; border-bottom:1px solid var(--line); padding:12px 27px; display:flex; align-items:center; justify-content:space-between; gap:12px }
.top-brand { display:flex; align-items:center; min-width:0; flex:1 }
.top-brand .company { display:block; width:clamp(110px, 20vw, 220px); min-width:0; max-width:100%; height:auto; aspect-ratio:5.4; object-fit:cover }
.top-brand .company[hidden] { display:none }
main { max-width:1510px; margin:auto; padding:26px }
.heading { display:flex; justify-content:space-between; gap:13px; align-items:flex-end; margin-bottom:20px; flex-wrap:wrap }
.heading p { color:var(--muted); margin-top:5px }
.toolbar,.row { display:flex; flex-wrap:wrap; align-items:center; gap:8px }
.toolbar { margin:0 0 13px }
#payroll-print-query { align-items:flex-end }
#payroll-print-query input[type=date], #payroll-print-query > button { height:38px }
#payroll-print-query > .error { flex-basis:100%; margin-top:0 }
#payroll-print-query > .error:empty { display:none }
.panel { background:#fff; border:1px solid var(--line); border-radius:14px; box-shadow:0 2px 5px #1d355308; padding:18px; margin-bottom:16px; min-width:0 }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:14px }
.settlement-controls { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px 20px; margin-bottom:13px; padding:12px; border:1px solid var(--line); border-radius:8px; background:#f7f9fc }
.settlement-fields { display:grid; grid-template-columns:100px minmax(0,1fr); gap:10px; width:min(300px, 100%) }
.settlement-fields label { min-width:0; font-size:12px; font-weight:650 }
.settlement-fields input,.settlement-fields select { width:100%; height:38px; font-size:14px; font-weight:400 }
.settlement-status { display:grid; gap:5px; min-width:0; font-variant-numeric:tabular-nums }
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(112px,1fr)); gap:12px; margin-bottom:16px }
.metric { background:#f3f7ff; border-color:#dce7f7; padding:15px; border-radius:10px; text-align:left; display:block; width:100% }
.metric strong { display:block; margin-top:6px; font-size:27px; font-variant-numeric:tabular-nums }
.metric-reminder strong { color:var(--caution) }
.metric-reminder[aria-pressed=true] { background:var(--button-strong); border-color:var(--button-border) }
.split { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px }
.split > .panel { display:flex; flex-direction:column }
.chart { display:flex; flex:1; align-items:center; justify-content:center; align-content:center; flex-wrap:wrap; gap:16px 22px; min-height:172px }
.donut { width:150px; height:150px; border-radius:50%; position:relative; display:grid; place-items:center; flex:none }
.donut::before { content:""; position:absolute; inset:24px; border-radius:50%; background:#fff }
.donut b { position:relative; font-size:23px }
.legend { flex:none; width:214px; max-width:100%; display:grid; gap:5px }
.legend button { background:#f3f7ff; border-color:transparent; padding:4px 8px; justify-content:space-between; gap:14px; font-size:14px }
.legend b { font-variant-numeric:tabular-nums }
.legend i { width:10px; height:10px; border-radius:3px; display:inline-block; margin-right:6px }
input,select,textarea { min-height:37px; padding:7px 9px; border:1px solid #c9d4df; background:#fff; color:var(--blue); border-radius:7px; max-width:100%; min-width:0 }
input[type=checkbox] { min-height:0; accent-color:var(--accent) }
label { display:grid; gap:5px; color:#34465a }
label.joined-range-toggle { display:flex; align-items:center; justify-content:flex-start; gap:8px; cursor:pointer }
.joined-range-toggle input[type=checkbox] { width:16px; height:16px; min-width:16px; margin:0; padding:0; flex:0 0 16px }
.joined-range-hint { margin:0; line-height:1.5 }
.table-wrap { overflow:auto; max-height:60vh; border:1px solid var(--line); border-radius:8px }
table { border-collapse:separate; border-spacing:0; width:100%; text-align:left; white-space:nowrap }
th,td { border-bottom:1px solid #e7edf3; padding:10px 11px }
th { font-size:12px; color:#40556b; background:#f4f7fa; position:sticky; top:0; z-index:1 }
tbody tr:last-child td { border-bottom:0 }
tbody tr:hover { background:#f8fafc }
.table-wrap td.frozen { position:sticky; z-index:1; background:#fff }
.table-wrap tr:hover td.frozen { background:#f8fafc }
.table-wrap th.frozen { z-index:2 }
.table-wrap .frozen-edge { box-shadow:2px 0 0 #dfe7f1 }
.empty { text-align:center; padding:30px 12px; color:var(--muted) }
.tag { display:inline-block; border-radius:20px; background:#e9eef5; padding:4px 9px; color:#364b62; font-size:12px }
.tag.good { color:#19624a; background:#e5f5ed }
.tag.warn { color:#80500b; background:#fff1d5 }
.tag.alert { color:#563a79; background:#eee6f7 }
.tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px }
.tabs button.active { border-color:#a9c3eb; background:var(--button-strong); font-weight:700 }
dialog { border:1px solid var(--line); border-radius:13px; padding:0; width:min(820px, calc(100% - 30px)); max-height:90vh; color:inherit; box-shadow:0 24px 80px #081d425c }
dialog::backdrop { background:#10203599 }
.dialog-head,.dialog-foot { padding:15px 20px; display:flex; align-items:center; justify-content:space-between; gap:10px; background:#fff }
.dialog-head { border-bottom:1px solid var(--line) }
.dialog-foot { border-top:1px solid var(--line); justify-content:flex-end }
.dialog-body { padding:18px 20px }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px }
.form-grid h3,.wide { grid-column:1/-1 }
.form-grid h3 { margin-top:6px; padding:6px 0; border-bottom:1px solid var(--line) }
.form-grid input,.form-grid select,.form-grid textarea { width:100% }
.error { color:var(--caution); white-space:pre-wrap; margin-top:8px }
.gate { min-height:100vh; display:grid; place-items:center; padding:20px; background:linear-gradient(135deg,#e6edfb,#f6f8fc 68%,#e9f2fa) }
.gate-login { background-image:linear-gradient(#10243822,#10243840),url("assets/dawn.webp"); background-position:center; background-size:cover; background-repeat:no-repeat }
.login { width:min(428px,100%); background:white; border:1px solid var(--line); box-shadow:0 20px 80px #0b21354d; border-radius:16px; padding:30px }
.login-brand { text-align:center }
.login .company { width:min(250px, 100%); height:auto; aspect-ratio:5.4; object-fit:cover; margin-bottom:15px }
.login form { display:grid; gap:12px; margin-top:18px }
.login h1 { font-size:23px }
#toast { position:fixed; bottom:22px; right:22px; background:#15283e; color:#fff; border-radius:8px; padding:10px 15px; z-index:10; display:none }
@media(max-width:960px) { .shell { grid-template-columns:172px minmax(0,1fr) } .split { grid-template-columns:1fr } main,.top { padding:16px } .cards { grid-template-columns:repeat(3,1fr) } }
@media(max-width:640px) { .shell { display:block } .sidebar { position:static; height:auto; gap:10px; padding:10px } .sidebar nav { display:flex; flex-wrap:wrap } .sidebar nav button { padding:8px } .side-footer { display:none } .top { flex-wrap:wrap } .top-brand { flex-basis:100% } .top-brand .company { width:min(240px, 100%) } .form-grid { grid-template-columns:1fr } }


.form-grid:has(.employee-search) { align-items:start }
.employee-search { position:relative; min-width:0 }
.employee-search-popup { position:absolute; top:calc(100% + 4px); inset-inline:0; z-index:3 }
.employee-search-popup:has(.employee-search-status:not(:empty)) {
  background:#fff; border:1px solid var(--line); border-radius:8px; padding:7px;
  box-shadow:0 8px 20px #1d355326
}
.employee-results:not(:empty) { display:grid; gap:4px; max-height:180px; overflow:auto; padding:4px 2px }
.employee-results button { justify-content:flex-start; white-space:normal; text-align:left }
.employee-search-status:not(:empty) { display:block; padding:2px 4px }
#log-export { align-items:flex-end }
#log-export input[type=date], #log-export button { min-height:38px }

.heading:has(.dashboard-filters) { flex-direction:column; align-items:stretch }
.dashboard-filters { display:grid; grid-template-columns:138px 112px minmax(0,1fr); gap:8px; width:min(100%, 900px) }
.dashboard-filters > :is(input,select) { width:100%; text-overflow:ellipsis }
@media(max-width:480px) {
  .dashboard-filters { grid-template-columns:repeat(2,minmax(0,1fr)) }
  .dashboard-filters > :last-child { grid-column:1/-1 }
}
.payroll-print-output { display:none }
@media print {
  @page payroll { size:A4 landscape; margin:8mm }
  body.printing-payroll > :not(.payroll-print-output) { display:none !important }
  body.printing-payroll { margin:0; background:white; color:black }
  .payroll-print-output { display:block }
  .payroll-slip { page:payroll; break-after:page; min-height:192mm; display:flex; flex-direction:column; font-size:9pt; line-height:1.25 }
  .payroll-slip:last-child { break-after:auto }
}

.payroll-slip h1 { text-align:center; font-size:14pt; margin:0 0 1.5mm }
.payroll-slip h2 { font-size:10pt; margin:2mm 0 1mm }
.payroll-slip-right { text-align:right; margin:1.5mm 0 }
.payroll-slip-meta { display:flex; justify-content:flex-end; gap:12mm }
.payroll-slip-fields { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); margin:0; border:1px solid #777 }
.payroll-slip-fields > div { display:flex; gap:2mm; padding:1mm 1.5mm; min-width:0 }
.payroll-slip-standard .payroll-slip-fields { grid-template-columns:repeat(5,minmax(0,1fr)); border-top:0 }
.payroll-slip-fields dt { font-weight:bold; flex:none }
.payroll-slip-fields dd { margin:0; min-width:0; overflow-wrap:anywhere }
.payroll-slip .table-wrap { overflow:visible; max-height:none; border:0; border-radius:0; margin-bottom:2mm }
.payroll-slip table { width:100%; border-collapse:collapse; min-width:0 }
.payroll-slip col.slip-month { width:19mm }
.payroll-slip col.slip-date { width:45mm }
.payroll-slip col.slip-days { width:10mm }
.payroll-slip col.slip-total { width:26mm }
.payroll-slip th,.payroll-slip td { position:static; padding:.55mm 1mm; border:1px solid #777; color:black }
.payroll-slip tr { break-inside:avoid }
.payroll-slip th { white-space:normal }
.payroll-slip td { vertical-align:middle; line-height:12px }
.payroll-slip :is(thead,tbody) :is(th,td):nth-child(n+3) { text-align:right; font-variant-numeric:tabular-nums }
.payroll-slip thead th:nth-child(n) { text-align:center }
.payroll-slip :is(thead,tbody) tr > :last-child { border-right:1.5px solid #444 }
.payroll-slip tbody tr:last-child td { border-bottom:1px solid #777; font-weight:bold }
.payroll-slip tfoot td { border:0; padding-top:5mm }
.payroll-slip footer { transform:translateX(-5em); display:flex; justify-content:space-evenly; gap:6mm; margin-top:36px; line-height:12px; break-inside:avoid }
