:root {
  color-scheme: light;
  --blue: #2596be;
  --blue-dark: #197da2;
  --ink: #18323d;
  --muted: #74858c;
  --line: #e6edf0;
  --surface: #fff;
  --background: #f4f8fa;
  --green: #1b8b66;
  --red: #bc4b4b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; color: var(--ink); background: var(--background); font-size: 15px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--background); }
.auth-card { width: min(100%, 390px); padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 16px 50px #1234440c; }
.brand-mark { width: 58px; height: 58px; object-fit: contain; border-radius: 16px; }
.eyebrow { margin: 20px 0 4px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 17px; letter-spacing: -.02em; }
h3 { margin-bottom: 14px; font-size: 15px; }
.muted { color: var(--muted); }
.auth-card > .muted { margin: 8px 0 24px; font-size: 14px; }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #48606a; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid #dce6ea; border-radius: 11px; outline: none; background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #2596be20; }
textarea { min-height: 80px; resize: vertical; }
.button { min-height: 44px; padding: 10px 16px; border: 0; border-radius: 11px; font-weight: 750; }
.primary { color: #fff; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: var(--blue-dark); background: #e8f5f9; }
.danger { color: var(--red); background: #fff0ef; }
.small-button { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.topbar { height: 66px; padding: 0 max(20px, calc((100% - 1120px) / 2)); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-small { width: 38px; height: 38px; border-radius: 11px; object-fit: contain; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; gap: 8px; }
.icon-button { min-height: 36px; padding: 7px 10px; color: #48606a; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 12px; font-weight: 650; }
.page-heading { width: min(calc(100% - 32px), 1080px); margin: 28px auto 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.page-heading h1 { font-size: 24px; }
.page-heading .muted { margin: 4px 0 0; font-size: 13px; }
.month-picker { display: block; width: 155px; }
.month-picker input { min-height: 40px; }
.page-content { width: min(calc(100% - 32px), 1080px); margin: 0 auto 100px; }
.connection-banner { width: min(calc(100% - 32px), 1080px); margin: 12px auto; padding: 11px 14px; color: #8a5a10; border-radius: 11px; background: #fff3d7; font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-grid .stat-card { min-height: 82px; }
.summary-grid .stat-card strong { font-size: 18px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stat-card { min-height: 106px; padding: 16px; }
.stat-card span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: clamp(18px, 2.4vw, 23px); letter-spacing: -.04em; }
.stat-card.accent { border-color: #c5e6f1; background: #eff9fc; }
.panel { padding: 18px; }
.panel-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; }
.worker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.worker-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.worker-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.worker-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.worker-avatar { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; object-fit: cover; }
.worker-avatar-placeholder { display: grid; place-items: center; color: var(--blue-dark); background: #e8f5f9; font-size: 17px; font-weight: 750; }
.worker-card h3 { margin: 0 0 4px; }
.worker-card .muted { margin: 0; font-size: 12px; }
.worker-metrics { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.worker-metrics div { color: var(--muted); font-size: 11px; }
.worker-metrics strong { display: block; margin-top: 3px; color: var(--ink); font-size: 14px; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 99px; color: var(--green); background: #e9f7f1; font-size: 10px; font-weight: 750; }
.status-pill.inactive { color: #7c8589; background: #edf0f1; }
.empty { padding: 30px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.section-gap { margin-top: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 10px; }
.worker-picker { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.worker-picker legend { padding: 0 6px; color: var(--ink); font-size: 14px; font-weight: 750; }
.worker-picker > .muted { margin: 0 0 10px; font-size: 12px; }
.worker-choice-list, .job-list { display: grid; gap: 8px; }
.worker-choice { grid-template-columns: minmax(0, 1fr) 100px 100px; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.worker-choice > span:first-child { display: flex; align-items: center; gap: 8px; }
.worker-choice input[type="checkbox"] { width: 18px; min-height: 18px; margin: 0; padding: 0; border-radius: 4px; accent-color: var(--blue); }
.weight-control { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.weight-control input { min-height: 36px; padding: 6px; }
.share-preview { text-align: right; font-size: 12px; }
.split-total { margin: 0; font-size: 12px; }
.job-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.job-heading { display: flex; justify-content: space-between; gap: 12px; }
.job-heading h3 { margin: 0 0 4px; }
.job-heading .muted { margin: 0; font-size: 12px; }
.job-actions { display: flex; align-items: flex-start; gap: 8px; }
.job-total { text-align: right; }
.job-total span, .job-total strong { display: block; }
.job-total span { color: var(--muted); font-size: 11px; }
.job-shares { margin-top: 12px; padding-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; border-top: 1px solid var(--line); }
.job-shares div { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.job-shares small { color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.amount-positive { color: var(--green) !important; }
.amount-due { color: #b06c18 !important; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
.report-actions { display: flex; gap: 8px; align-items: center; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; min-height: 66px; padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); display: flex; justify-content: center; border-top: 1px solid var(--line); background: #fffffff2; backdrop-filter: blur(14px); }
.nav-item { width: min(20%, 130px); display: grid; place-content: center; gap: 3px; color: #86959b; border: 0; border-radius: 10px; background: transparent; font-size: 10px; font-weight: 650; }
.nav-item span { font-size: 20px; line-height: 20px; }
.nav-item.active { color: var(--blue-dark); background: #eaf6fa; }

.modal { width: min(calc(100% - 24px), 460px); max-height: min(90dvh, 760px); padding: 22px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: #fff; box-shadow: 0 24px 90px #102c3c40; }
.modal::backdrop { background: #102c3c70; backdrop-filter: blur(3px); }
.modal-close { display: flex; justify-content: flex-end; margin: -10px -10px 8px; }
.modal-close button { width: 34px; padding: 0; font-size: 22px; }
.modal h2 { margin-bottom: 18px; font-size: 19px; }
.modal-form { display: grid; gap: 14px; }
.photo-preview { display: flex; align-items: center; gap: 10px; }
.photo-preview[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; z-index: 10; right: 16px; bottom: 84px; left: 16px; width: max-content; max-width: calc(100% - 32px); margin: auto; padding: 12px 16px; color: #fff; border-radius: 12px; background: #173946; box-shadow: 0 6px 25px #0002; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .topbar { height: 60px; padding: 0 16px; }
  .page-heading { margin-top: 21px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 92px; padding: 13px; }
  .worker-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid > :last-child { grid-column: 1 / -1; }
  .worker-choice { grid-template-columns: minmax(0, 1fr) 85px 75px; }
  .job-shares { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
}

@media (max-width: 380px) {
  .page-heading { align-items: flex-start; }
  .month-picker { width: 135px; }
  .stat-card strong { font-size: 17px; }
  .worker-choice { grid-template-columns: minmax(0, 1fr) 76px 62px; gap: 5px; padding: 6px; }
}
