/* Shared finishing layer: preserve the portal's FFL colors and existing views. */
:root {
  --paper: #f5f7f3;
  --line: #dce5de;
  --shadow: 0 8px 28px rgba(7, 59, 41, .055);
}

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 20px; }
body { line-height: 1.5; }
button, input, select, textarea { font-family: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: rgba(0, 111, 59, .12); }
button:disabled { cursor: not-allowed; opacity: .6; transform: none; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #41885b;
  outline-offset: 3px;
}
.app-shell, main, .view, .title-row > *, .actions, .controls > *, .import-layout > * { min-width: 0; }
.mast, .nav-inner, main { padding-left: max(clamp(18px, 3vw, 42px), env(safe-area-inset-left)); padding-right: max(clamp(18px, 3vw, 42px), env(safe-area-inset-right)); }
.mast { gap: 20px; }
.wordmark { min-width: 0; }
.account { min-width: 0; overflow-wrap: anywhere; }
.account b { line-height: 1.35; }
.sign-out { min-height: 36px; margin-top: 0; padding: 6px 0 6px 12px; }
.nav-inner { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.nav-btn { min-height: 50px; flex-shrink: 0; white-space: nowrap; }
main { padding-top: 34px; padding-bottom: max(64px, env(safe-area-inset-bottom)); }
.title-row { align-items: center; gap: 20px; }
h1 { line-height: 1.15; }
.lede { line-height: 1.65; max-width: 760px; }
.actions { align-items: center; gap: 10px; }
.primary, .secondary { min-height: 44px; line-height: 1.35; border-radius: 9px; }
.secondary { border-color: #c7d8cc; color: #176241; }
.primary { box-shadow: 0 3px 8px rgba(0, 111, 59, .12); }
.summary { margin-bottom: 24px; border-radius: 12px; }
.metric { min-width: 0; padding: 20px 22px; }
.metric span { line-height: 1.5; letter-spacing: .065em; }
.metric b, .review-stat b { font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric small { display: block; margin-top: 4px; line-height: 1.45; }
.controls { align-items: stretch; gap: 14px; }
.month-tabs { min-width: 0; max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.month-tab { min-height: 44px; flex-shrink: 0; }
.region { display: block; padding: 0; border: 0; box-shadow: none; background: none; width: min(330px, 100%); flex: 0 1 330px; }
.region-select { min-height: 44px; min-width: 0; max-width: 100%; width: 100%; font-size: 14px; }
.legend { line-height: 1.5; gap: 9px 16px; }
.matrix-shell, .master-table-wrap, .scan-table {
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #a7beb0 #eff4ef;
}
.matrix-shell { isolation: isolate; max-height: 66vh; max-height: 66dvh; }
.matrix { width: 100%; font-variant-numeric: tabular-nums; }
.matrix tbody tr:hover td:not(.id):not(.name):not(.date):not(.group):not(.hours) { box-shadow: inset 0 0 0 999px rgba(7, 59, 41, .025); }
.matrix .ledger-input { min-height: 40px; }
.matrix .remove-client { min-height: 38px; }
.import-layout { border-radius: 13px; }
.drop { padding: 38px; }
.drop h2 { line-height: 1.25; }
.drop p, .file-name, .scan-result, .auth-error { overflow-wrap: anywhere; }
.drop-icon { margin-bottom: 20px; }
.file-name { line-height: 1.6; }
.scan-panel { padding: 34px 28px; }
.scan-panel h3 { margin-bottom: 20px; line-height: 1.6; }
.step { padding-top: 16px; padding-bottom: 16px; }
.review-card { padding: 26px; border-radius: 13px; }
.review-grid { border-radius: 9px; overflow: hidden; }
.review-stat { min-width: 0; padding: 20px; }
.review-stat span { line-height: 1.6; }
.review-identity:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.review-identity label { display: grid; min-width: 0; gap: 7px; color: #365b44; font-size: 12px; font-weight: 700; }
.review-identity input { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #cbd9ce; border-radius: 7px; background: #fff; color: var(--deep); padding: 11px 12px; font-size: 14px; }
.review-identity input::-webkit-date-and-time-value { text-align: left; }
.scan-table { border-radius: 9px; }
.scan-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.scan-table th { background: #0b3e2d; color: #fff; padding: 13px 14px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.scan-table td { padding: 12px; border-bottom: 1px solid #e4ebe5; line-height: 1.5; }
.scan-table tr:last-child td { border-bottom: 0; }
.scan-table input, .scan-table select { min-height: 44px; border-radius: 6px; color: var(--deep); }
.scan-remove { min-height: 44px; border: 1px solid #e2c6c1; border-radius: 7px; background: #fff8f6; color: #963d32; padding: 10px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.scan-remove:hover { background: #fff0ed; }
.scan-intake-help, .scan-review-notice { padding: 16px; border: 1px solid #dccb9f; border-radius: 9px; background: #fffaec; color: #58451d; line-height: 1.65; }
.scan-review-notice { margin-top: 18px; }
.scan-review-notice p { margin: 6px 0 0; }
.scan-source { margin-top: 16px; border: 1px solid var(--line); border-radius: 9px; padding: 12px 16px; }
.scan-source summary { cursor: pointer; min-height: 44px; padding: 12px 0; font-weight: 600; color: var(--deep); }
.scan-source a { display: inline-block; padding: 12px 0; color: #075b3b; text-decoration: underline; }
.scan-source img { display: block; max-width: 100%; height: auto; margin: 10px auto; }
.scan-day { display: block; color: #52675a; margin-top: 5px; }
.scan-table input[aria-invalid="true"], .scan-table select[aria-invalid="true"], .review-identity input[aria-invalid="true"] { border: 2px solid #a83a28; background: #fff9f7; }
.scan-table tr.has-error td { background: #fff3ee; }
.scan-table td:first-child { min-width: 165px; }
.scan-table td:nth-child(2) { min-width: 160px; }
.scan-add { margin-top: 16px; }
.scan-review-feedback { margin: 16px 0; padding: 14px 16px; border: 1px solid #cbd9ce; border-radius: 9px; background: #f3f8f4; color: #284c36; line-height: 1.65; }
.scan-review-feedback.is-error { background: #fff6f0; border-color: #dfb59e; color: #7f3521; }
.scan-review-feedback ul { margin: 8px 0 0; padding-left: 22px; }
.scan-hours-help { color: var(--muted); font-size: 13px; line-height: 1.65; }
.scan-verification { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; padding: 16px; background: #f3f8f4; border: 1px solid #cbd9ce; border-radius: 9px; color: var(--deep); font-size: 14px; line-height: 1.65; cursor: pointer; }
.scan-verification input { flex: 0 0 22px; width: 22px; height: 22px; margin-top: 2px; accent-color: #075b3b; }
.master-controls {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  gap: 14px;
  box-shadow: 0 3px 12px rgba(7, 59, 41, .025);
}
.master-controls label, .master-form-grid label, .staffing-month { line-height: 1.5; }
.master-controls input, .master-controls select, .master-form-grid input, .master-form-grid select, .staffing-month input { min-height: 44px; }
.master-controls input, .master-controls select, .master-form-grid input, .master-form-grid select, .master-form-grid textarea, .staffing-month input, .staffing-assignment input, .staffing-assignment textarea { font-family: inherit; }
.master-table-wrap { border-radius: 10px; }
.master-table td { padding-top: 15px; padding-bottom: 15px; }
.master-name { min-height: 44px; line-height: 1.45; }
.master-open { min-height: 44px; }
.master-pagination { line-height: 1.6; flex-wrap: wrap; }
.master-pagination > div { flex-wrap: wrap; }
.master-pagination button { min-height: 44px; min-width: 44px; }
.master-presentation { max-width: 100%; }
.master-presentation button { min-height: 44px; justify-content: center; }
.master-dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.master-dialog form { max-height: calc(100vh - 34px); max-height: calc(100dvh - 34px); min-height: 0; }
.master-dialog-heading, .master-dialog-footer { flex-shrink: 0; }
.master-dialog-heading h2 { overflow-wrap: anywhere; line-height: 1.2; }
.master-dialog-heading > button, .master-dialog-footer button, .staffing-assignment button { min-height: 44px; }
.master-dialog-body { min-height: 0; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
.master-dialog-footer { flex-wrap: wrap; }
.master-dialog-footer > div { flex-wrap: wrap; margin-left: auto; }
.master-checkbox, .auth-card .password-option { min-height: 44px; }
.master-checkbox input, .password-option input { flex-shrink: 0; }
.staffing-panel-heading h2 { line-height: 1.2; }
.staffing-source summary { min-height: 44px; padding: 10px 0; }
.staffing-start > * { min-width: 0; }
.tmap { font-family: inherit; border-radius: 12px; box-shadow: var(--shadow); }
.tmap-heading { padding: 20px 22px; }
.tmap-heading h2, .tmap-sidebar-heading h3, .tmap-consumer, .tmap-popup { font-family: inherit; }
.tmap-map-tools button, .tmap-message button, .tmap-popup > button { min-height: 44px; }
.tmap-consumers { -webkit-overflow-scrolling: touch; }
.tmap-consumer { transition: background-color .12s ease, border-color .12s ease; }
.tmap-map .leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; }
.tmap-map .leaflet-popup-close-button { min-width: 32px; min-height: 32px; padding-top: 5px; }
.auth-screen {
  overflow-y: auto;
  align-items: safe center;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at top, #edf4ed 0, #f8faf6 65%);
  -webkit-overflow-scrolling: touch;
}
.auth-card { width: min(440px, 100%); min-height: 0; border: 1px solid #dbe5dd; border-top: 4px solid var(--green); border-radius: 18px; box-shadow: 0 18px 60px rgba(7, 59, 41, .09); padding: 34px; }
.auth-card p { font-size: 14px; }
.auth-card label { margin-top: 18px; line-height: 1.5; }
.auth-card input:not([type="checkbox"]) { min-height: 48px; }
.auth-card .password-option { margin: 8px 0; }
.auth-logo { width: 195px; height: 100px; margin-top: -8px; }
.auth-error { line-height: 1.6; }
.toast { max-width: min(460px, calc(100vw - 32px)); border-radius: 10px; line-height: 1.6; bottom: max(20px, env(safe-area-inset-bottom)); overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .title-row { align-items: flex-start; flex-direction: column; }
  .title-row > .actions { width: 100%; }
  .import-layout { grid-template-columns: minmax(0, 1fr) 310px; }
}

@media (max-width: 850px) {
  .mast { min-height: 78px; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .account { max-width: 55%; font-size: 12px; }
  .sign-out { min-height: 44px; }
  .nav-btn { min-height: 48px; }
  main { padding-top: 26px; }
  .title-row { gap: 18px; }
  .actions .primary, .actions .secondary { flex: 1 1 auto; }
  .controls { align-items: stretch; }
  .region { width: 100%; flex-basis: auto; }
  .import-layout { grid-template-columns: minmax(0, 1fr); }
  .auth-screen { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 28px 24px; }
  body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), body select, body textarea { font-size: 16px; }
  .review-card { padding: 22px; }
  .review-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .review-stat { padding: 16px 12px; }
  .review-stat + .review-stat { border-top: 0; }
  .review-stat span { font-size: 10px; letter-spacing: .035em; }
  .review-stat b { font-size: 24px; }
  .master-controls { padding: 15px; }
}

@media (max-width: 600px) {
  .summary, .summary.master-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary > .metric, .summary.master-summary > .metric { padding: 16px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .summary > .metric:nth-child(2n), .summary.master-summary > .metric:nth-child(2n) { border-right: 0; }
  .summary > .metric:nth-last-child(-n+2), .summary.master-summary > .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .metric span, .master-summary .metric span { font-size: 10px; letter-spacing: .035em; }
  .metric b { margin-top: 5px; font-size: 25px; }
  .metric small { font-size: 11px; }
  .month-tabs { border-radius: 8px; }
  .legend { font-size: 11px; gap: 8px 12px; }
  .matrix-shell { max-height: 62vh; max-height: 62dvh; }
  /* Five fixed columns used to cover all daily cells on a phone. */
  .matrix td.date, .matrix td.group, .matrix td.hours { position: static; }
  .matrix th.date, .matrix th.group, .matrix th.hours { left: auto; z-index: 4; }
  .matrix .name { min-width: 164px; max-width: 180px; }
  .matrix td.name b { display: block; overflow-wrap: anywhere; }
  .matrix td.name .ledger-input { min-width: 150px; }
  .matrix th.name, .matrix td.name { box-shadow: 2px 0 0 #dce5de; }
  .matrix .ledger-input { min-height: 44px; }
  .drop { padding: 28px 22px; }
  .drop h2 { font-size: 26px; }
  .scan-panel { padding: 26px 22px; }
  .review-card { padding: 20px 16px; }
  .review-identity:not([hidden]) { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .scan-table td { padding: 10px; }
  .master-controls, #master-paramount .master-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 10px; }
  .master-controls label:first-child, #master-paramount .master-controls label:first-child, #master-paramount .master-controls .staffing-trainer-control { grid-column: 1 / -1; }
  .master-pagination { gap: 12px; font-size: 12px; }
  .master-pagination > div { gap: 8px; }
  .master-pagination button { font-size: 12px; padding: 10px 12px; }
  .master-dialog { max-width: calc(100vw - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
  .master-dialog form { max-height: calc(100vh - 22px); max-height: calc(100dvh - 22px); }
  .master-dialog-heading, .master-dialog-body { padding: 20px 18px; }
  .master-dialog-footer { padding: 14px; }
  .master-dialog-footer button { font-size: 12px; padding: 10px 13px; }
  .master-dialog-footer > div { gap: 8px; }
  .master-dialog-heading > button { min-width: 44px; }
  .master-presentation { width: 100%; }
  .master-presentation button { flex: 1 1 0; padding-left: 10px; padding-right: 10px; }
  .staffing-month { flex: 1 1 100%; min-width: 0; }
  .staffing-month input { width: 100%; }
  .staffing-assignment { padding: 14px; }
  .tmap-heading { padding: 18px; }
  .tmap-map { height: 380px; height: clamp(320px, 54dvh, 420px); }
  .tmap-map .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
  .tmap-sidebar-heading { min-height: 54px; }
  .tmap-consumers { height: 310px; }
  .tmap-map .leaflet-popup-content { min-width: 180px; max-width: 230px; margin: 16px; }
  .tmap-map-tools { top: 10px; right: 10px; }
  .tmap-map-tools button { padding: 10px; }
  .toast { right: 16px; left: 16px; max-width: none; font-size: 13px; }
}

@media (max-width: 380px) {
  .mast, .nav-inner, main { padding-left: 14px; padding-right: 14px; }
  .brand-logo { width: 112px; }
  .summary > .metric, .summary.master-summary > .metric { padding: 14px 12px; }
  .master-controls, #master-paramount .master-controls { grid-template-columns: minmax(0, 1fr); }
  .master-controls label { grid-column: auto; }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .review-stat + .review-stat { border-top: 1px solid var(--line); }
  .auth-card { padding: 26px 20px; }
}

@media (hover: none) {
  .primary:hover, .secondary:hover { transform: none; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .primary, .secondary, .tmap-consumer { transition: none; }
}
