:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #cfd8dc;
  --text: #1f2a2e;
  --muted: #65737a;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #c62828;
  --header: #e8f0ef;
  --highlight: #ffe66d;
  --surface-radius: .65rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  font-size: 20px;
  font-weight: 800;
}

.subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

.user {
  color: var(--muted);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
}

.page {
  padding: 18px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(31, 42, 46, 0.08);
}

.login-panel h1,
.section-header h1,
.sheet-header h1 {
  margin: 0;
}

.login-form,
.user-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
}

button[type="submit"],
.user-form button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef6f5;
  border: 1px solid #b9d8d4;
}

.message.error {
  background: #fff0f0;
  border-color: #efb6b6;
}

.sheet-header,
.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.sheet-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.action-buttons button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  padding: 6px 10px;
  font-weight: 700;
}

.print-meta {
  display: none;
}

.unit-report-link {
  display: inline-flex;
  margin-left: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.unit-report-page {
  width: min(960px, 100%);
  margin: 0 auto;
}

.unit-report {
  display: grid;
  gap: 16px;
}

.unit-report-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #123d3a 0%, #0f766e 72%, #d89b38 145%);
}

.unit-report-header h1,
.unit-report-card h2 {
  margin: 0;
}

.unit-report-kicker {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.unit-report-subtitle {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.82);
}

.unit-report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.unit-report-actions a,
.unit-report-actions button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  padding: 9px 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.unit-report-disclaimer {
  margin: 0;
  border-left: 4px solid #d89b38;
  padding: 12px 14px;
  color: #5b4217;
  background: #fff7e8;
  font-weight: 700;
}

.unit-report-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(31, 42, 46, 0.06);
}

.unit-report-card h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.unit-report-context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.unit-report-context-grid div {
  min-width: 0;
  padding: 11px 12px;
  border-radius: 10px;
  background: #f4f8f7;
}

.unit-report-context-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.unit-report-context-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.unit-report-table-shell {
  overflow-x: auto;
}

.unit-report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.unit-report-table th,
.unit-report-table td {
  border-bottom: 1px solid #e4ebed;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.unit-report-table th {
  color: #415158;
  background: #eef4f3;
  font-size: 12px;
}

.unit-report-status {
  display: inline-flex;
  min-width: 32px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-weight: 900;
}

.unit-report-status.is-done {
  color: #0f5b44;
  background: #dff5ea;
}

.unit-report-status.is-open {
  color: #8a3d24;
  background: #fff0e8;
}

.unit-report-empty {
  margin: 0;
  border: 1px dashed #bfd0d3;
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  background: #f8fafb;
  text-align: center;
}

.floor-report-link {
  display: inline-flex;
  margin-left: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.floor-report-page {
  width: min(960px, 100%);
  margin: 0 auto;
}

.floor-report {
  display: grid;
  gap: 16px;
}

.floor-report-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #173d4a 0%, #176b78 72%, #d89b38 145%);
}

.floor-report-header h1,
.floor-report-card h2,
.floor-report-card h3 {
  margin: 0;
}

.floor-report-kicker {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.floor-report-subtitle {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.82);
}

.floor-report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.floor-report-actions a,
.floor-report-actions button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  padding: 9px 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.floor-report-disclaimer {
  margin: 0;
  border-left: 4px solid #d89b38;
  padding: 12px 14px;
  color: #5b4217;
  background: #fff7e8;
  font-weight: 700;
}

.floor-report-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(31, 42, 46, 0.06);
}

.floor-report-card h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.floor-report-card h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  color: #415158;
  font-size: 14px;
}

.floor-report-card h2 + h3 {
  margin-top: 0;
}

.floor-report-context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.floor-report-context-grid div {
  min-width: 0;
  padding: 11px 12px;
  border-radius: 10px;
  background: #f4f8f7;
}

.floor-report-context-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.floor-report-context-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.floor-report-table-shell {
  overflow-x: auto;
}

.floor-report-table {
  width: 100%;
  border-collapse: collapse;
}

.floor-report-table th,
.floor-report-table td {
  border-bottom: 1px solid #e4ebed;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.floor-report-table th {
  color: #415158;
  background: #eef4f3;
  font-size: 12px;
}

.floor-report-status {
  display: inline-flex;
  min-width: 32px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-weight: 900;
}

.floor-report-status.is-done {
  color: #0f5b44;
  background: #dff5ea;
}

.floor-report-status.is-open {
  color: #8a3d24;
  background: #fff0e8;
}

.floor-report-empty {
  margin: 0;
  border: 1px dashed #bfd0d3;
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  background: #f8fafb;
  text-align: center;
}

.sheet-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.sync-state {
  min-width: 86px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.sync-state.saving {
  color: #8a5a00;
}

.sync-state.error {
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-bottom-color: var(--panel);
  border-radius: 6px 6px 0 0;
  padding: 9px 14px;
  background: var(--panel);
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.table-shell {
  overflow: auto;
  height: calc(100vh - 170px);
  border: 1px solid var(--line);
  background: var(--panel);
}

.crew-form-shell {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.crew-form-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.crew-form-header h2 {
  margin: 0;
}

.crew-form-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.crew-form-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.crew-form-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e0f2fe;
  color: #075985;
  font-size: 13px;
  font-weight: 800;
}

.crew-form-hint,
.crew-toolbar-note,
.crew-label {
  color: var(--muted);
}

.crew-form-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.crew-form-toolbar button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
  cursor: not-allowed;
}

.crew-form-toolbar button:not(:disabled) {
  cursor: pointer;
}

.crew-vendor-list {
  display: grid;
  gap: 16px;
}

.crew-vendor-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfefe;
}

.crew-vendor-card-header {
  display: grid;
  gap: 4px;
}

.crew-vendor-card-header h3,
.crew-vendor-card-header p {
  margin: 0;
}

.crew-vendor-card-header p {
  color: var(--muted);
}

.crew-vendor-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.crew-vendor-meta div,
.crew-entry-row div {
  display: grid;
  gap: 4px;
}

.crew-entry-list {
  display: grid;
  gap: 12px;
}

.crew-entry-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f5fbfb;
}

.crew-empty-state,
.crew-error-state {
  padding: 14px;
  border-radius: 8px;
}

.crew-empty-state {
  border: 1px dashed var(--line);
  color: var(--muted);
  background: #fafcfc;
}

.crew-error-state {
  margin-bottom: 12px;
  border: 1px solid #efb6b6;
  color: var(--danger);
  background: #fff4f4;
}

.control-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 4200px;
  width: max-content;
  font-size: 13px;
  table-layout: fixed;
}

.control-table.filtered-columns {
  min-width: max-content;
  width: max-content;
}

.control-table th,
.control-table td {
  min-width: 54px;
  max-width: 92px;
  height: 32px;
  padding: 4px 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}

.control-table .task-col {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}

.control-table .hidden-task-col {
  display: none !important;
}

.control-table .extra-head {
  min-width: 132px;
  writing-mode: horizontal-tb !important;
}

.control-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--header);
  font-weight: 800;
}

.control-table thead .task-row th {
  top: 32px;
  height: 88px;
  writing-mode: horizontal-tb;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.control-table .meta {
  left: 0;
  width: 92px;
  min-width: 92px;
  max-width: 92px;
}

.control-table .count {
  left: 92px;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
}

.control-table .unit {
  left: 150px;
  width: 84px;
  min-width: 84px;
  max-width: 84px;
}

.control-table thead .meta,
.control-table thead .count,
.control-table thead .unit {
  z-index: 32;
  background: var(--header);
}

.control-table tbody td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 18;
  width: 92px;
  min-width: 92px;
  max-width: 92px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.control-table tbody td:nth-child(2) {
  position: sticky;
  left: 92px;
  z-index: 18;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.control-table tbody td:nth-child(3) {
  position: sticky;
  left: 150px;
  z-index: 18;
  width: 84px;
  min-width: 84px;
  max-width: 84px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.control-table tfoot th {
  left: 0;
  z-index: 18;
  background: #fff7df;
}

.control-table tfoot .footer-label-floor,
.control-table tfoot .footer-label-count {
  border-right: 0;
}

.floor-row td {
  background: #f0f4f3;
  font-weight: 800;
}

.floor-row td:nth-child(1),
.floor-row td:nth-child(2),
.floor-row td:nth-child(3) {
  background: #f0f4f3;
  z-index: 22;
}

.selected-axis,
.selected-task,
.control-table th.selected-axis,
.control-table th.selected-task,
.floor-row td.selected-axis {
  background: var(--highlight) !important;
}

.floor-cell {
  text-align: left !important;
}

.toggle {
  width: 24px;
  height: 24px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.unit-row.hidden {
  display: none;
}

.parent-status {
  font-weight: 900;
  font-size: 15px;
}

.parent-status.ok {
  color: #000;
}

.parent-status.bad {
  color: var(--danger);
}

.progress-select {
  width: 100%;
  min-width: 44px;
  min-height: 28px;
  border-radius: 4px;
  padding: 2px;
  text-align: center;
}

.extra-input,
.extra-select {
  min-width: 190px;
  width: 100%;
  min-height: 28px;
  border-radius: 4px;
  padding: 2px 4px;
}

.extra-select {
  min-width: 54px;
}

.date-popover {
  position: absolute;
  z-index: 1000;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 42, 46, 0.18);
}

.hidden,
.date-popover.hidden,
.filtered-out {
  display: none !important;
}

.date-popover button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  padding: 5px 10px;
}

.date-control {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  gap: 4px;
  align-items: center;
  min-width: 246px;
}

.date-save {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  padding: 2px 8px;
}

.control-table .extra-head {
  min-width: 246px;
}

tfoot th,
tfoot td {
  position: sticky;
  z-index: 3;
  background: #fff7df;
  font-weight: 900;
}

tfoot tr:nth-child(1) th,
tfoot tr:nth-child(1) td {
  bottom: 64px;
}

tfoot tr:nth-child(2) th,
tfoot tr:nth-child(2) td {
  bottom: 32px;
}

tfoot tr:nth-child(3) th,
tfoot tr:nth-child(3) td {
  bottom: 0;
}

.users-table {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  background: var(--panel);
}

.users-table th,
.users-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.users-table input,
.users-table select {
  width: 100%;
  min-height: 34px;
}

.users-table button {
  min-height: 34px;
  white-space: nowrap;
}

.user-form {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-edit-form {
  display: grid;
  gap: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-section h2 {
  margin: 0 0 12px;
}

.edit-table {
  width: 100%;
  border-collapse: collapse;
}

.edit-table th,
.edit-table td {
  border: 1px solid var(--line);
  padding: 6px;
}

.edit-table input {
  width: 100%;
}

.floor-edit {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.floor-edit summary {
  cursor: pointer;
  font-weight: 800;
}

.unit-edit-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.form-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: var(--bg);
}

.form-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.sheet-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.add-row {
  margin-bottom: 12px;
}

.danger-button,
.link-danger {
  border: 1px solid #efb6b6;
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  background: var(--danger);
  cursor: pointer;
}

.link-danger {
  padding: 5px 8px;
  font-size: 12px;
}

.crew-formal-cancel-btn,
.crew-formal-cancellation-actions button {
  min-height: 44px;
}

.crew-formal-cancel-btn:focus-visible,
.crew-formal-cancellation-dialog button:focus-visible,
.crew-formal-cancellation-dialog textarea:focus-visible {
  outline: 3px solid rgba(198, 40, 40, 0.32);
  outline-offset: 3px;
}

.crew-formal-lifecycle-meta,
.crew-formal-integrity-warning,
.crew-formal-action-blocked {
  grid-column: 1 / -1;
}

.crew-formal-lifecycle-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.crew-formal-integrity-warning,
.crew-formal-action-blocked {
  color: var(--danger);
  font-weight: 700;
}

.crew-formal-cancellation-dialog {
  width: min(560px, calc(100% - 32px));
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid rgba(198, 40, 40, 0.32);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  color: var(--ink);
}

.crew-formal-cancellation-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.crew-formal-cancellation-dialog-content {
  display: grid;
  gap: 16px;
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.crew-formal-cancellation-dialog-content header,
.crew-formal-cancellation-dialog-content h2,
.crew-formal-cancellation-dialog-content p,
.crew-formal-cancellation-context {
  margin: 0;
}

.crew-formal-cancellation-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.crew-formal-cancellation-context div {
  display: grid;
  gap: 4px;
}

.crew-formal-cancellation-context dt {
  color: var(--muted);
  font-size: 13px;
}

.crew-formal-cancellation-context dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.crew-formal-cancellation-dialog textarea {
  min-height: 120px;
  resize: vertical;
}

.crew-formal-cancellation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.crew-formal-cancellation-feedback[data-feedback-state="error"] {
  color: var(--danger);
}

.unit-edit-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.vendor-work-entry-page .vendor-mobile-quick-entry {
  display: none;
}

.sheet-page .sheet-mobile-work-hub-access {
  display: none;
}

.sheet-page .sheet-bidirectional-floating-navigation {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  gap: 6px;
}

.sheet-page .sheet-bidirectional-floating-navigation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(15, 118, 110, 0.58);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px rgba(31, 42, 46, 0.18);
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.sheet-page .sheet-bidirectional-floating-navigation-link:hover {
  box-shadow: 0 10px 26px rgba(31, 42, 46, 0.24);
  transform: translateY(-1px);
}

.sheet-page .sheet-bidirectional-floating-navigation-link:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.96), 0 10px 26px rgba(31, 42, 46, 0.24);
  transform: translateY(-2px);
}

.sheet-page .sheet-ai-ux-001b-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.3);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.sheet-page .sheet-ai-ux-001b-entry:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 26px rgba(15, 118, 110, 0.38);
  transform: translateY(-1px);
}

.sheet-page .sheet-ai-ux-001b-entry:active {
  box-shadow: 0 5px 14px rgba(15, 118, 110, 0.3);
  transform: translateY(1px);
}

.sheet-page .sheet-ai-ux-001b-entry:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.96), 0 10px 26px rgba(15, 118, 110, 0.38);
}

.sheet-page .sheet-ai-ux-001b-dialog {
  width: min(560px, calc(100% - 32px));
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  color: var(--ink);
  overflow: hidden;
}

.sheet-page .sheet-ai-ux-001b-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.sheet-page .sheet-ai-ux-001b-dialog-content {
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-page .sheet-ai-ux-001b-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sheet-page .sheet-ai-ux-001b-dialog-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
}

.sheet-page .sheet-ai-ux-001b-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e6fffb;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
}

.sheet-page .sheet-ai-ux-001b-description {
  margin: 16px 0 20px;
  color: var(--muted);
  line-height: 1.65;
}

.sheet-page .sheet-ai-ux-001b-field {
  display: grid;
  gap: 8px;
}

.sheet-page .sheet-ai-ux-001b-field label {
  color: var(--ink);
  font-weight: 700;
}

.sheet-page .sheet-ai-ux-001b-field textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
}

.sheet-page .sheet-ai-ux-001b-field textarea:disabled,
.sheet-page .sheet-ai-ux-001b-microphone:disabled {
  background: #f1f5f4;
  color: #718096;
  cursor: not-allowed;
  opacity: 1;
}

.sheet-page .sheet-ai-ux-001b-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.sheet-page .sheet-ai-ux-001b-microphone,
.sheet-page .sheet-ai-ux-001b-close {
  min-height: 44px;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
}

.sheet-page .sheet-ai-ux-001b-microphone {
  border: 1px dashed #94a3b8;
}

.sheet-page .sheet-ai-ux-001b-close {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
}

.sheet-page .sheet-ai-ux-001b-close:hover {
  background: #e6fffb;
}

.sheet-page .sheet-ai-ux-001b-close:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 3px;
}

@media (max-width: 760px) {
  .topbar,
  .sheet-header,
  .section-header,
  .crew-form-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    flex-wrap: wrap;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .unit-edit-grid,
  .crew-vendor-meta,
  .crew-entry-row {
    grid-template-columns: 1fr;
  }

  .crew-formal-cancellation-context {
    grid-template-columns: 1fr;
  }

  .crew-formal-cancellation-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .floor-report-header {
    align-items: stretch;
    flex-direction: column;
  }

  .floor-report-actions {
    justify-content: flex-start;
  }

  .floor-report-context-grid {
    grid-template-columns: 1fr;
  }

  .sheet-page .sheet-mobile-work-hub-access {
    display: flex;
    margin-top: 12px;
  }

  .sheet-page .sheet-mobile-work-hub-access-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: #eef8f6;
    color: var(--accent-dark);
    font-weight: 800;
    text-decoration: none;
  }

  .sheet-page .sheet-mobile-work-hub-access-link:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 3px;
  }

  .sheet-page .crew-work-hub-shell#sheet-work-hub-overview {
    scroll-margin-top: 16px;
  }

  .sheet-page .crew-work-hub-shell#sheet-work-hub-overview:target,
  .sheet-page .crew-work-hub-shell#sheet-work-hub-overview:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 4px;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid #99c9c3;
    border-radius: 10px;
    background: #eef8f6;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry > div {
    flex: 1 1 180px;
    min-width: 0;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-title {
    margin: 0;
    font-weight: 800;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-context {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-context div {
    display: flex;
    gap: 4px;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-context dt,
  .vendor-work-entry-page .vendor-mobile-quick-entry-context dd {
    margin: 0;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-context dd {
    color: var(--text);
    font-weight: 700;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-link {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
  }

  .vendor-work-entry-page .vendor-mobile-quick-entry-link:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 3px;
  }

  .vendor-work-entry-page #vendor-work-entry-draft-form-target {
    scroll-margin-top: 16px;
  }

  .vendor-work-entry-page #vendor-work-entry-draft-form-target:target {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 3px;
  }

  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] input:not([type="hidden"]),
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] select,
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] textarea,
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-submit-button"] {
    min-height: 44px;
    padding: 9px 10px;
  }

  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] input:not([type="hidden"]),
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] select,
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] textarea,
  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-submit-button"] {
    width: 100%;
  }

  .vendor-work-entry-page [data-testid="vendor-work-entry-draft-form"] textarea {
    min-height: 104px;
    resize: vertical;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .sheet-page .table-shell {
    --sheet-matrix-viewport-offset: 10rem;
    --sheet-matrix-viewport-offset: clamp(8rem, 24dvh, 12rem);
    --sheet-matrix-min-height: 16rem;
    --sheet-matrix-safe-gap: 2rem;
    height: calc(100vh - var(--sheet-matrix-viewport-offset));
    height: calc(100dvh - var(--sheet-matrix-viewport-offset));
    min-height: min(var(--sheet-matrix-min-height), calc(100vh - var(--sheet-matrix-safe-gap)));
    min-height: min(var(--sheet-matrix-min-height), calc(100dvh - var(--sheet-matrix-safe-gap)));
    max-height: calc(100vh - var(--sheet-matrix-safe-gap));
    max-height: calc(100dvh - var(--sheet-matrix-safe-gap));
    overflow-x: auto;
    overflow-y: auto;
  }

  .sheet-page .control-table .count {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding: 0;
    border: 0;
  }

  .sheet-page .control-table th.count,
  .sheet-page .control-table td.count {
    display: none;
  }

  .sheet-page .control-table .unit,
  .sheet-page .control-table tbody td:nth-child(3) {
    left: 92px;
  }
}

@media (max-width: 900px) and (orientation: landscape),
       (orientation: landscape) and (max-height: 600px) and (hover: none) and (pointer: coarse) {
  .sheet-page .table-shell {
    --sheet-matrix-viewport-offset: 5rem;
    --sheet-matrix-viewport-offset: clamp(3rem, 16dvh, 6rem);
    --sheet-matrix-min-height: 12rem;
    --sheet-matrix-safe-gap: 2rem;
    height: calc(100vh - var(--sheet-matrix-viewport-offset));
    height: calc(100dvh - var(--sheet-matrix-viewport-offset));
    min-height: min(var(--sheet-matrix-min-height), calc(100vh - var(--sheet-matrix-safe-gap)));
    min-height: min(var(--sheet-matrix-min-height), calc(100dvh - var(--sheet-matrix-safe-gap)));
    max-height: calc(100vh - var(--sheet-matrix-safe-gap));
    max-height: calc(100dvh - var(--sheet-matrix-safe-gap));
    overflow-x: auto;
    overflow-y: auto;
  }

  .sheet-page .control-table tfoot th,
  .sheet-page .control-table tfoot td {
    position: static;
    top: auto;
    bottom: auto;
  }
}

@media (max-width: 760px) {
  .sheet-page .sheet-ai-ux-001b-dialog {
    inset: auto 0 0;
    width: calc(100% - 24px);
    max-width: none;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top));
    margin: 0 auto calc(12px + env(safe-area-inset-bottom));
    border-radius: 20px;
  }

  .sheet-page .sheet-ai-ux-001b-dialog-content {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 20px calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  }

  .sheet-page .sheet-ai-ux-001b-dialog-header {
    align-items: center;
  }

  .sheet-page .sheet-ai-ux-001b-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sheet-page .sheet-ai-ux-001b-microphone,
  .sheet-page .sheet-ai-ux-001b-close {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  .sheet-actions,
  .sheet-page .sheet-bidirectional-floating-navigation,
  .sheet-page .sheet-ai-ux-001b-dialog,
  .toggle,
  .date-popover,
  .progress-select,
  .extra-select {
    display: none !important;
  }

  .unit-report-link,
  .unit-report-actions {
    display: none !important;
  }

  .floor-report-link,
  .floor-report-actions {
    display: none !important;
  }

  .page {
    padding: 0;
    padding-bottom: 18mm;
  }

  .print-meta {
    display: block;
    margin: 0;
    font-weight: 800;
  }

  .print-date {
    position: fixed;
    top: 0;
    right: 0;
  }

  .print-maker {
    position: fixed;
    right: 0;
    bottom: 0;
  }

  .table-shell {
    height: auto;
    overflow: visible;
    border: 0;
  }

  .control-table {
    min-width: 0;
    width: 100%;
    font-size: 10px;
  }

  .control-table th,
  .control-table td,
  .control-table thead th,
  .control-table tbody td:nth-child(1),
  .control-table tbody td:nth-child(2),
  .control-table tbody td:nth-child(3),
  tfoot th,
  tfoot td {
    position: static !important;
    box-shadow: none !important;
  }

  .unit-row.hidden,
  .filtered-out {
    display: table-row !important;
  }

  .extra-input {
    border: 0;
    padding: 0;
    min-width: 0;
  }

  .unit-report-page {
    width: 100%;
    padding: 0;
  }

  .unit-report {
    gap: 10mm;
  }

  .unit-report-header {
    border: 1px solid #78918e;
    padding: 12mm;
    color: #102b29;
    background: #eef4f3;
  }

  .unit-report-header .unit-report-kicker,
  .unit-report-header .unit-report-subtitle {
    color: #415158;
  }

  .unit-report-card {
    box-shadow: none;
  }

  .unit-report-table-shell {
    overflow: visible;
  }

  .unit-report-table thead {
    display: table-header-group;
  }

  .unit-report-disclaimer,
  .unit-report-context-grid div,
  .unit-report-table tr {
    break-inside: avoid;
  }

  .floor-report-page {
    width: 100%;
    padding: 0;
  }

  .floor-report {
    gap: 10mm;
  }

  .floor-report-header {
    border: 1px solid #78918e;
    padding: 12mm;
    color: #102b29;
    background: #eef4f3;
  }

  .floor-report-header .floor-report-kicker,
  .floor-report-header .floor-report-subtitle {
    color: #415158;
  }

  .floor-report-card {
    box-shadow: none;
  }

  .floor-report-table-shell {
    overflow: visible;
  }

  .floor-report-table thead {
    display: table-header-group;
  }

  .floor-report-unit + .floor-report-unit {
    break-before: page;
  }

  .floor-report-disclaimer,
  .floor-report-context-grid div,
  .floor-report-table tr {
    break-inside: avoid;
  }
}

@media print {
  .crew-formal-cancel-btn,
  .crew-formal-cancellation-dialog,
  [data-testid="crew-work-entry-formal-approve-action"] {
    display: none !important;
  }
}

.progress-scroll{overflow:auto;margin:1rem 0}#progress-table,#progress-summary,#summary-preview-table{border-collapse:collapse;width:100%}#progress-table th,#progress-table td,#progress-summary th,#progress-summary td,#summary-preview-table td,#summary-preview-table th{border:1px solid #ccd3d7;padding:.45rem;text-align:left}#summary-fields label{display:inline-flex;gap:.25rem;align-items:center;margin:.4rem}#summary-fields input[type=checkbox]{width:auto}

/* r21 scoped native controls: readable/touch-operable within existing pages. */
:is(#entry-root,#progress-root,#sites-root,#membership-root,#pending-root,#member-action-root,[data-floor-period-app]) button { min-height:44px; touch-action:manipulation; }
:is(#pending-root,#member-action-root) input[type=checkbox] { width:1.35rem; height:1.35rem; min-height:1.35rem; display:inline-block; vertical-align:middle; margin-right:.5rem; }
:is(#entry-root,#progress-root,#sites-root,#membership-root,#pending-root,#member-action-root,[data-floor-period-app]) pre,
:is(#entry-root,#progress-root,[data-floor-period-app]) [aria-live] { white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:680px){
 #entry-fields,#schedule-fields { display:grid; grid-template-columns:minmax(0,1fr); gap:.6rem; }
 :is(#entry-root,#progress-root,#sites-root,#membership-root,#pending-root,#member-action-root,[data-floor-period-app]) { min-width:0; max-width:100%; }
 :is(#entry-root,#progress-root,#sites-root,#membership-root,#pending-root,#member-action-root,[data-floor-period-app]) :is(input:not([type=checkbox]),select,textarea) { min-height:44px; max-width:100%; box-sizing:border-box; }
 .progress-scroll { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
}
