:root {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #192624;
  background: #f2f5f3;
  --accent: #235c49;
  --border: #dbe4df;
  --muted: #596964;
}
* { box-sizing: border-box; }
body { margin: 0; }
header {
  background: #132c25; color: #fff; display: flex; justify-content: space-between;
  align-items: center; gap: 16px; padding: 18px clamp(16px, 4vw, 56px);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .08em; }
.brand span { display: grid; place-items: center; width: 42px; height: 42px; background: #e7c58a; color: #132c25; border-radius: 9px; }
.brand small { display: block; margin-top: 3px; color: #b8c9c0; }
main { max-width: 1500px; margin: auto; padding: 28px clamp(14px, 3vw, 46px); }
.workspace { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 25px; }
nav { display: grid; align-content: start; gap: 6px; }
nav a { padding: 11px 12px; border-radius: 8px; text-decoration: none; color: #243832; }
nav a:hover, nav a.active { background: #dbece3; color: #153d30; }
nav a.active { font-weight: 700; }
.top, .actions, .filters { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.top { justify-content: space-between; margin-bottom: 16px; }
.top p { margin: 5px 0 0; }
.eyebrow { color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 5px 0; font-size: clamp(1.55rem, 3vw, 2.35rem); }
h2 { margin: 0 0 12px; font-size: 1.08rem; }
.actions { margin-bottom: 16px; }
section { background: white; border: 1px solid var(--border); border-radius: 11px; margin-bottom: 16px; padding: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.cards small { color: var(--muted); }
.cards strong { display: block; margin-top: 7px; font-size: 1.4rem; color: var(--accent); }
label { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; }
input, select, button, .button { font: inherit; border-radius: 7px; min-height: 40px; padding: 7px 10px; }
input, select { width: 100%; min-width: 0; color: inherit; border: 1px solid #c7d5ce; background: #fff; }
button, .button { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border: 1px solid transparent; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { filter: brightness(.9); }
a { color: var(--accent); }
.button { background: white; border-color: var(--border); color: var(--accent); }
.button.selected { background: #dbece3; border-color: #a7c9b8; }
.quiet { background: #285143; }
.fields { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.fields label { flex: 1 1 145px; }
fieldset { border: 1px solid var(--border); border-radius: 7px; }
.check { display: inline-flex; align-items: center; margin-right: 12px; }
.check input { width: auto; min-height: 24px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 10px 9px; text-align: left; border-bottom: 1px solid #e8eeea; }
th { background: #f1f6f3; white-space: nowrap; }
td { overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
.inline { display: inline-block; vertical-align: middle; }
.inline label { display: inline-grid; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.muted { color: var(--muted); }
.error { color: #9c342c; }
.login { max-width: 440px; margin: 55px auto; }
.login form { display: grid; gap: 14px; }
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  nav { display: flex; flex-wrap: wrap; }
  nav a { padding: 7px 9px; font-size: .85rem; }
  .top { align-items: start; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
.batch-row { border-top: 1px solid var(--border); padding: 12px 0; }
section details { margin: 12px 0; }
.notice { padding: 12px 16px; background: #dbece3; color: #153d30; border-radius: 8px; }
#staff h3 { font-size: 1rem; margin: 18px 0 8px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.language-switch { color: #fff; padding: 8px 10px; white-space: nowrap; }

.settings-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.settings-buttons > button { min-height: 40px; max-width: 100%; overflow-wrap: anywhere; }
.settings-buttons > button.inactive { background: white; color: var(--accent); border-color: var(--border); }
dialog {
  width: min(720px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  background: white; color: #192624; overflow: auto;
}
dialog::backdrop { background: rgb(19 44 37 / 50%); }
.dialog-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; background: white; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.dialog-heading h2 { margin: 0; overflow-wrap: anywhere; }
.dialog-heading button { flex-shrink: 0; }
.dialog-body { padding: 16px; }
.dialog-body > form + form { margin-top: 12px; }

.settings-panel[hidden] { display: none; }
.settings-buttons > a[aria-current="true"] { background: var(--accent); color: white; }
.settings-buttons > button[data-open-settings^="new-"] {
  background: #fef3c7; color: #653500; border-color: #d99a32;
}

.report-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.report-heading h2 { margin: 0; }
.report-selection { display: grid; justify-items: start; gap: 12px; }
.report-selection fieldset { display: flex; flex-wrap: wrap; gap: 8px; }
.print-preview { max-width: 1250px; }
.print-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.print-report { margin-bottom: 20px; background: white; padding: 18px; border: 1px solid var(--border); border-radius: 12px; }
.print-identity { font-size: .75rem; letter-spacing: .09em; margin: 0; }
.print-context { margin: 4px 0 16px; }
@page monthly-report { size: landscape; margin: 12mm; }
@media print {
  body:has(.print-preview) { background: white; color: black; }
  .print-preview { max-width: none; padding: 0; }
  .print-toolbar { display: none; }
  .print-report { page: monthly-report; border: 0; margin: 0; padding: 0; }
  .print-report + .print-report { break-before: page; }
  .print-report .scroll { overflow: visible; }
  .print-report section { border-radius: 0; padding: 8px; margin-bottom: 10px; }
  .print-report h1, .print-report h2 { break-after: avoid; }
  .print-report .cards { display: flex; gap: 8px; break-inside: avoid; }
  .print-report .cards section { flex: 1; }
  .print-report table { font-size: 9pt; table-layout: fixed; }
  .print-report thead { display: table-header-group; }
  .print-report th, .print-report td { padding: 4px; white-space: normal; overflow-wrap: anywhere; }
  .print-report tr { break-inside: avoid; }
}

.category-block { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.category-block h3 { margin: 4px 0 8px; font-size: 1rem; }
.category-block > .settings-buttons + .settings-buttons { margin-top: 8px; }
.category-checks { display: grid; grid-template-columns: repeat(auto-fit,minmax(185px,1fr)); gap: 6px; margin-bottom: 12px; }

.report-fold { border: 1px solid var(--border); border-radius: 8px; }
.report-fold > summary { padding: 10px 12px; }
.report-fold > summary > span:first-child { margin-left: 5px; }
.report-fold-meta { display: inline-flex; align-items: baseline; gap: 12px; float: right; margin-left: 10px; }
.report-fold-note { color: var(--muted); font-size: .85rem; font-weight: normal; }
.report-fold > summary::after { content: ""; display: block; clear: both; }
.report-fold-body { padding: 0 12px 10px; }
.report-fold .report-fold { margin: 8px 0 0; }
@media (max-width: 600px) {
  .report-fold-meta { float: none; display: flex; flex-wrap: wrap; margin: 5px 0 0 16px; }
  .report-fold-body { padding-inline: 6px; }
}
@media print {
  .print-report .report-fold { margin: 6px 0; }
  .print-report .report-fold > summary { break-after: avoid; }
  .print-report .report-fold-body { padding-inline: 5px; }
}

.print-group-heading {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px;
  margin: 0; padding: 8px 10px; font-size: 1rem; color: var(--accent); break-after: avoid;
}

.cash-advance { flex: 1 0 100%; }
.cash-advance[hidden] { display: none; }
.payroll-manual { margin-bottom: 16px; }
.payroll-manual > summary { margin-bottom: 8px; }
.payroll-batch td label { min-width: 115px; }

.date-flow-row { align-items: start; }
.batch-date-field { flex: 1 1 145px; min-width: 0; }
.batch-date-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.batch-date-buttons button {
  background: white; color: var(--accent); border-color: var(--border); font-size: .82rem;
}
.batch-date-buttons button:disabled { opacity: .45; cursor: default; }

.report-scope-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.report-scope-fields[hidden] { display: none; }


.attendance-grid table { min-width: 920px; }
.attendance-grid th, .attendance-grid td { text-align: center; padding: 6px 5px; }
.attendance-grid th:first-child, .attendance-grid td:first-child { text-align: left; }
@media print {
  .print-report .attendance-grid table { min-width: 0; font-size: 7pt; }
  .print-report .attendance-grid th, .print-report .attendance-grid td { padding: 3px 2px; }
}

.roster-day-count label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.roster-day-count input { max-width: 9rem; }
.detail-filters { margin: 0; }
.detail-filters select { max-width: 100%; }
