/* High-frequency payroll and construction-log workspaces. */

:root {
  --work-surface-line: #d9e0e8;
  --work-surface-soft: #f6f8fa;
  --work-surface-ink: #1d2129;
  --work-surface-muted: #6e7681;
  --work-surface-blue: #0f3476;
  --work-surface-cyan: #2fa9a4;
}

/* Payroll: one task at a time, ledger or editor. */
.payroll-flow-workspace {
  width: min(100%, 1380px);
  margin-inline: auto;
  gap: 8px !important;
}

.payroll-flow-workspace > .panel,
.payroll-editor-workspace > .panel {
  margin: 0 !important;
}

.payroll-command-bar {
  min-height: 50px;
  display: grid;
  grid-template-columns: auto minmax(520px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--work-surface-line);
}

.payroll-command-title {
  min-width: 136px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.payroll-command-title strong {
  color: var(--work-surface-ink);
  font-size: 16px;
  line-height: 1.25;
}

.payroll-command-title span {
  color: var(--work-surface-muted);
  font-size: 12px;
}

.payroll-flow-workspace .payroll-command-bar .payroll-filters {
  min-width: 0;
  display: grid !important;
  grid-template-columns: 190px 160px minmax(220px, 1fr) !important;
  gap: 8px !important;
  padding: 0 !important;
}

.payroll-flow-workspace .payroll-command-bar .payroll-filters > label {
  min-width: 0;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 6px !important;
}

.payroll-flow-workspace .payroll-command-bar .payroll-filters > label > span {
  color: var(--work-surface-muted) !important;
  font-size: 12px !important;
  text-align: right !important;
  white-space: nowrap;
}

.payroll-flow-workspace .payroll-command-bar :is(input, select) {
  width: 100% !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 28px 0 8px !important;
  border: 1px solid #cfd6df !important;
  border-radius: 4px !important;
  color: var(--work-surface-ink) !important;
  background-color: #fff !important;
  font-size: 12px !important;
}

.payroll-command-actions,
.construction-log-entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.payroll-command-actions .table-action {
  min-height: 32px !important;
  padding: 5px 10px !important;
  white-space: nowrap;
}

.payroll-flow-workspace .payroll-kpi-strip {
  display: grid !important;
  grid-template-columns: 0.8fr 0.8fr repeat(3, 1fr) !important;
  gap: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.payroll-flow-workspace .payroll-kpi-strip > div {
  min-height: 58px !important;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 6px 10px !important;
  border: 0 !important;
  border-right: 1px solid #e3e8ee !important;
  background: transparent !important;
}

.payroll-flow-workspace .payroll-kpi-strip > div:last-child {
  border-right: 0 !important;
}

.payroll-flow-workspace .payroll-kpi-strip :is(span, small) {
  color: var(--work-surface-muted) !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
}

.payroll-flow-workspace .payroll-kpi-strip strong {
  color: #17365d !important;
  font-size: 16px !important;
  line-height: 1.25 !important;
  white-space: nowrap;
}

.payroll-ledger-workspace {
  min-height: 0;
  overflow: hidden;
}

.payroll-ledger-workspace > .data-table-shell {
  max-height: calc(100dvh - 300px);
  overflow: auto;
  border: 0 !important;
}

.payroll-ledger-workspace .data-table {
  width: 100%;
  min-width: 980px;
}

.payroll-ledger-workspace .data-table :is(th, td) {
  height: 34px !important;
  min-height: 34px !important;
  padding: 4px 7px !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
  white-space: nowrap;
}

.payroll-ledger-workspace .data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.payroll-editor-workspace {
  min-width: 0;
}

.payroll-editor-workspace .payroll-editor-panel > .panel-title {
  min-height: 42px !important;
  padding: 5px 10px !important;
}

.payroll-editor-workspace .payroll-editor-panel > .panel-title > div:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.payroll-editor-workspace .payroll-editor-panel > .panel-title span {
  overflow: hidden;
  color: var(--work-surface-muted) !important;
  font-size: 11px !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payroll-editor-workspace .payroll-sheet-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0 !important;
  padding: 0 !important;
  border-top: 1px solid var(--work-surface-line);
  border-left: 1px solid var(--work-surface-line);
}

.payroll-editor-workspace .payroll-sheet-meta > label {
  min-height: 36px;
  grid-template-columns: 96px minmax(0, 1fr) !important;
  gap: 0 !important;
  border-right: 1px solid var(--work-surface-line);
  border-bottom: 1px solid var(--work-surface-line);
}

.payroll-editor-workspace .payroll-sheet-meta > label > span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 8px;
  border-right: 1px solid #e5e9ee;
  font-size: 12px !important;
  font-weight: 600;
}

.payroll-editor-workspace .payroll-sheet-meta > label :is(input, select) {
  height: 35px !important;
  min-height: 35px !important;
  margin: 0 !important;
  padding: 0 8px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 12px !important;
}

.payroll-editor-workspace .payroll-sheet-meta > .payroll-note-field {
  grid-column: span 3 !important;
}

.payroll-editor-workspace .payroll-live-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  margin: 6px 0 !important;
  border-radius: 3px !important;
}

.payroll-editor-workspace .payroll-live-summary > div {
  min-height: 48px !important;
  padding: 5px 9px !important;
}

.payroll-editor-workspace .payroll-table-wrap {
  max-height: calc(100dvh - 390px);
  border: 1px solid var(--work-surface-line) !important;
}

.payroll-editor-workspace .payroll-table :is(input, select, textarea) {
  height: 30px !important;
  min-height: 30px !important;
  padding: 3px 6px !important;
  font-size: 12px !important;
}

.payroll-editor-workspace .payroll-table textarea {
  max-height: 64px !important;
  resize: vertical;
}

.payroll-editor-workspace .payroll-table thead th,
.payroll-editor-workspace .payroll-table tfoot th,
.payroll-editor-workspace .payroll-table tfoot td {
  position: sticky;
  z-index: 2;
}

.payroll-editor-workspace .payroll-table thead th {
  top: 0;
}

.payroll-editor-workspace .payroll-table thead tr:nth-child(2) th {
  top: 34px;
}

.payroll-editor-workspace .payroll-table tfoot :is(th, td) {
  bottom: 0;
}

.payroll-editor-workspace .payroll-editor-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  min-height: 44px !important;
  padding: 6px 10px !important;
  background: #fff;
}

/* Construction log: DingTalk-like daily entry, summary and history as separate views. */
.construction-log-document-workspace {
  gap: 8px !important;
}

.construction-log-view-tabs {
  min-height: 38px;
  display: flex;
  align-items: stretch;
  gap: 18px;
  padding: 0 12px;
  border-bottom: 1px solid var(--work-surface-line);
  background: #fff;
}

.construction-log-view-tabs button {
  position: relative;
  min-height: 38px;
  padding: 0 2px;
  border: 0;
  color: var(--work-surface-muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.construction-log-view-tabs button::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
}

.construction-log-view-tabs button:is(:hover, :focus-visible),
.construction-log-view-tabs button.is-active {
  color: var(--work-surface-blue);
  font-weight: 700;
}

.construction-log-view-tabs button.is-active::after {
  background: var(--work-surface-blue);
}

.construction-log-view-tabs button span {
  min-width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 3px;
  padding: 1px 5px;
  border-radius: 9px;
  color: #45627f;
  background: #edf2f7;
  font-size: 10px;
  font-weight: 600;
}

.construction-log-entry-workspace {
  min-width: 0;
  padding: 8px;
  background: var(--work-surface-soft);
}

.construction-log-day-rail {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px 48px;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px;
  border: 1px solid var(--work-surface-line);
  border-radius: 5px;
  background: #fff;
}

.construction-log-day-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(46px, 1fr));
  gap: 4px;
}

.construction-log-day,
.construction-log-day-shift,
.construction-log-today-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #4e5969;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.construction-log-day {
  position: relative;
  display: grid;
  place-content: center;
  gap: 1px;
}

.construction-log-day span {
  font-size: 12px;
  line-height: 1.2;
}

.construction-log-day strong {
  color: var(--work-surface-ink);
  font-size: 14px;
  line-height: 1.15;
}

.construction-log-day i {
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  transform: translateX(-50%);
}

.construction-log-day.has-log i {
  background: var(--work-surface-cyan);
}

.construction-log-day:is(:hover, :focus-visible),
.construction-log-day.is-today {
  border-color: #c9d7e6;
  background: #f3f7fb;
}

.construction-log-day.is-selected {
  border-color: var(--work-surface-blue);
  color: #fff;
  background: var(--work-surface-blue);
}

.construction-log-day.is-selected strong {
  color: #fff;
}

.construction-log-day.is-selected.has-log i {
  background: #fff;
}

.construction-log-day-shift {
  min-height: 48px;
  border-color: #d8e0e9;
  font-size: 18px;
}

.construction-log-today-button {
  min-height: 48px;
  border-color: #d8e0e9;
  font-size: 12px;
}

.construction-log-entry-workspace .construction-log-form {
  width: 100%;
  padding: 0 !important;
  border-radius: 5px !important;
  overflow: hidden;
}

.construction-log-entry-workspace .construction-log-form > .flow-section-title:first-of-type {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  min-height: 36px !important;
  padding: 5px 10px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--work-surface-line) !important;
}

.construction-log-entry-workspace .flow-section-title small {
  color: var(--work-surface-muted);
  font-size: 11px;
  font-weight: 400;
}

.construction-log-entry-workspace .construction-log-form .form-grid.compact {
  border-top: 0 !important;
  border-left: 0 !important;
}

.construction-log-entry-workspace .construction-log-form .form-grid.compact > label:nth-child(odd) {
  border-left: 0 !important;
}

.construction-log-entry-workspace .construction-log-form .construction-log-field {
  min-height: 64px !important;
}

.construction-log-entry-workspace .construction-log-form .construction-log-field textarea {
  min-height: 63px !important;
}

.construction-log-entry-workspace .construction-log-form .form-actions {
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  margin: 0 !important;
  padding: 6px 8px !important;
  background: #fff;
}

.construction-log-summary-panel,
.construction-log-history {
  margin: 0 !important;
}

.construction-log-summary-panel .data-table-shell,
.construction-log-history .data-table-shell {
  width: 100% !important;
}

.construction-log-summary-panel .data-table,
.construction-log-history .data-table {
  width: 100% !important;
  min-width: 100% !important;
}

.construction-log-history > .data-table-shell {
  max-height: calc(100dvh - 260px) !important;
}

:root[data-color-scheme="dark"] :is(.payroll-command-bar, .payroll-ledger-workspace, .payroll-editor-workspace .payroll-editor-panel, .construction-log-view-tabs, .construction-log-day-rail, .construction-log-entry-workspace .construction-log-form) {
  color: #f2f4f7 !important;
  background: #18212d !important;
  border-color: #34404f !important;
}

:root[data-color-scheme="dark"] .payroll-command-title strong,
:root[data-color-scheme="dark"] .construction-log-day strong {
  color: #f2f4f7 !important;
}

:root[data-color-scheme="dark"] .payroll-flow-workspace .payroll-command-bar :is(input, select) {
  color: #f2f4f7 !important;
  background: #121923 !important;
  border-color: #445264 !important;
}

@media (max-width: 1100px) {
  .payroll-command-bar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .payroll-flow-workspace .payroll-command-bar .payroll-filters {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .payroll-command-actions {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 760px) {
  .payroll-flow-workspace {
    width: 100%;
    gap: 6px !important;
  }

  .payroll-command-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 6px;
  }

  .payroll-command-title {
    min-width: 0;
  }

  .payroll-command-title span {
    display: none;
  }

  .payroll-flow-workspace .payroll-command-bar .payroll-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .payroll-flow-workspace .payroll-command-bar .payroll-filters > label:last-child {
    grid-column: 1 / -1;
  }

  .payroll-flow-workspace .payroll-kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .payroll-flow-workspace .payroll-kpi-strip > div:nth-child(-n + 2) {
    display: none !important;
  }

  .payroll-flow-workspace .payroll-kpi-strip > div:last-child {
    grid-column: auto !important;
  }

  .payroll-editor-workspace .payroll-sheet-meta {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .payroll-editor-workspace .payroll-sheet-meta > .payroll-note-field {
    grid-column: auto !important;
  }

  .payroll-editor-workspace .payroll-table-wrap {
    max-height: calc(100dvh - 430px);
  }

  .construction-log-document-workspace .panel-title {
    gap: 6px !important;
  }

  .construction-log-view-tabs {
    gap: 16px;
    overflow-x: auto;
  }

  .construction-log-entry-workspace {
    padding: 6px;
  }

  .construction-log-day-rail {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    gap: 4px;
    padding: 4px;
  }

  .construction-log-day-list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .construction-log-day {
    min-width: 48px;
    scroll-snap-align: center;
  }

  .construction-log-day-list .construction-log-day:not(.is-selected):not(.is-today):nth-child(-n + 2) {
    display: none;
  }

  .construction-log-today-button {
    grid-column: 1 / -1;
    min-height: 36px;
  }

  .construction-log-entry-workspace .construction-log-form .form-grid.compact {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .construction-log-entry-workspace .construction-log-form .form-grid.compact > label,
  .construction-log-entry-workspace .construction-log-form .construction-log-upload-field {
    grid-template-columns: 78px minmax(0, 1fr) !important;
  }

  .construction-log-entry-workspace .construction-log-form .construction-log-field {
    min-height: 76px !important;
  }

  .construction-log-entry-workspace .construction-log-form .construction-log-field textarea {
    min-height: 75px !important;
    font-size: 14px !important;
  }

  .construction-log-entry-workspace .construction-log-form .form-actions {
    position: sticky;
    bottom: calc(58px + env(safe-area-inset-bottom));
    z-index: 3;
  }
}
