:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dfe4ec;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.title-group h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-badges span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 12px;
  color: var(--muted);
}

.summary-badges strong {
  color: var(--text);
}

.summary-badges .pay-badge {
  background: var(--primary-soft);
  border-color: #bfdbfe;
}

.summary-badges .pay-badge strong {
  color: var(--primary);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
}

.pill input {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  outline: none;
}

.rate-pill input {
  width: 72px;
  text-align: right;
  color: var(--primary);
}

.unit {
  font-weight: 700;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 11px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--surface);
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 6px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Define Box */
.define-box {
  background: #f8faff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  max-height: 40vh;
  overflow-y: auto;
}

.define-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.define-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 8px;
}

.define-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto 48px 28px;
  gap: 6px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.define-item input,
.define-item select {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 7px;
  font: inherit;
  background: var(--surface);
  min-width: 0;
}

.define-item input {
  font-weight: 600;
}

.hours-tag {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--success);
  background: var(--success-soft);
  padding: 4px 5px;
  border-radius: 6px;
}

.hours-tag.is-error {
  color: var(--danger);
  background: var(--danger-soft);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.search-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 5px 10px;
}

.search-input-wrap input {
  border: none;
  outline: none;
  font: inherit;
  width: 190px;
  background: transparent;
}

.filter-bar select {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.pill-check {
  cursor: pointer;
  user-select: none;
  gap: 6px;
}

.pill-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.pill-check:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* Grid Table */
.table-wrap {
  flex: 1;
  overflow: auto;
  background: var(--surface);
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}

.grid th,
.grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  vertical-align: middle;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 15;
  background: #f1f5f9;
  border-bottom: 2px solid var(--border-strong);
  padding: 6px 4px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
}

.grid thead th.is-today {
  background: #dbeafe;
  color: #1e40af;
}

.grid thead th.is-weekend {
  background: #fef3c7;
  color: #92400e;
}

.day-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.85;
}

.day-lock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.3;
}

.day-lock-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
}

.day-lock-btn.is-locked {
  border-color: #334155;
  background: #334155;
  color: #fff;
}

.day-lock-btn.is-locked:hover {
  border-color: #1e293b;
  background: #1e293b;
  color: #fff;
}

.grid thead th.is-locked {
  background: #e2e8f0;
  color: #334155;
}

.sticky {
  position: sticky;
  z-index: 10;
  background: var(--surface);
}

thead th.sticky {
  z-index: 25;
}

.col-idx { width: 36px; left: 0; text-align: center; color: var(--muted); font-size: 11.5px; }
.col-name { width: 175px; left: 36px; }
.col-role { width: 100px; left: 211px; }
.col-hours { width: 76px; left: 311px; }
.col-pay { width: 112px; left: 387px; box-shadow: 3px 0 6px -2px rgba(15, 23, 42, 0.08); }
.col-day { width: 126px; }

.name-text {
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-text {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.del-emp-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  opacity: 0.7;
}

.del-emp-btn:hover {
  opacity: 1;
  color: var(--danger);
  background: var(--danger-soft);
}

.cell-hours,
.grid td.cell-hours {
  text-align: right;
  padding: 8px 10px;
  font-weight: 700;
  color: #0f766e;
  background: #f0fdfa;
}

.cell-pay,
.grid td.cell-pay {
  text-align: right;
  padding: 8px 10px;
  font-weight: 700;
  color: var(--primary);
  background: #f8faff;
}

.grid tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: #f8fafc;
  border-top: 2px solid var(--border-strong);
  padding: 6px 6px;
  font-weight: 700;
  font-size: 11.5px;
}

.grid tfoot td.sticky {
  z-index: 25;
  background: #f8fafc;
}

.foot-day-cell {
  text-align: center;
  line-height: 1.25;
}

.foot-day-hours {
  display: block;
  color: var(--success);
}

.foot-day-pay {
  display: block;
  color: var(--primary);
  font-size: 11px;
}

/* Clickable Day Cell */
.day-cell {
  height: 52px;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.1s;
}

.day-cell.is-today {
  background: #f0f7ff;
}

.day-cell.is-weekend {
  background: #fafafa;
}

.day-cell:hover {
  background: var(--primary-soft);
}

.day-cell.is-locked,
.day-cell.is-locked:hover {
  background: #f8fafc;
  cursor: not-allowed;
}

.day-cell.is-locked .day-empty-hint,
.day-cell.is-locked:hover .day-empty-hint {
  color: #94a3b8;
}

.day-cell-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  min-height: 48px;
  text-align: center;
}

.day-ranges {
  font-size: 11px;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}

.day-total-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  background: var(--success-soft);
  padding: 1px 6px;
  border-radius: 99px;
}

.day-total-pill.is-pending {
  color: #b45309;
  background: #fef3c7;
}

.day-total-pill.is-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.day-empty-hint {
  font-size: 12px;
  color: #cbd5e1;
}

.day-cell:hover .day-empty-hint {
  color: var(--primary);
}

/* Bottom Bar */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.save-note {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.is-center {
  z-index: 140;
  backdrop-filter: blur(2px);
}

.modal-confirm {
  width: min(370px, 100%);
  border-radius: 16px;
}

.confirm-body {
  padding: 22px 20px 16px;
  text-align: center;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--primary-soft);
}

.confirm-icon.is-danger {
  background: var(--danger-soft);
}

.confirm-title {
  margin: 12px 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.confirm-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.confirm-actions.is-single {
  grid-template-columns: 1fr;
}

.confirm-actions .btn {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  text-align: center;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: min(480px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.preset-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.preset-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 56px 28px;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.slot-row select,
.slot-row input.time-input {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-weight: 600;
  background: var(--surface);
  width: 100%;
  min-width: 0;
  outline: none;
}

.slot-row input.time-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.slot-row input.time-input.is-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.slot-arrow {
  color: var(--muted);
  font-weight: 700;
}

.modal-total {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--success-soft);
  border-radius: 8px;
  color: var(--success);
  font-size: 13px;
  text-align: right;
}

.modal-total.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.mobile-top-actions,
.mobile-day-bar,
.mobile-day-summary,
.mobile-list-wrap,
.mobile-emp-meta {
  display: none;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Staff Management Modal */
.modal-staff {
  width: min(740px, 96vw);
  max-height: 88vh;
}

.staff-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.staff-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-emp-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.5fr) 128px 140px auto;
  gap: 8px;
  align-items: center;
}

.add-emp-form input,
.add-emp-form select,
.staff-input,
.staff-select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.add-emp-form input:focus,
.add-emp-form select:focus,
.staff-input:focus,
.staff-select:focus {
  border-color: var(--primary);
}

.staff-list-head {
  display: grid;
  grid-template-columns: 30px minmax(150px, 1.5fr) 128px 124px 36px;
  gap: 8px;
  padding: 0 8px 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.staff-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.staff-row {
  display: grid;
  grid-template-columns: 30px minmax(150px, 1.5fr) 128px 124px 36px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.staff-idx {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.staff-rate-input {
  text-align: right;
  font-weight: 600;
}

/* Report Modal */
.modal-report {
  width: min(1160px, 96vw);
  height: min(86vh, 820px);
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.report-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.report-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-grand-total {
  font-size: 12.5px;
  color: var(--muted);
}

.report-grand-total strong {
  color: var(--primary);
  font-size: 13.5px;
}

.report-table-wrap {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pinch-zoom;
  background: var(--surface);
}

.report-grid .r-sticky-name {
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--surface);
  font-weight: 700;
  width: 128px;
  min-width: 128px;
  max-width: 138px;
  padding: 6px 8px;
  box-shadow: 3px 0 6px -2px rgba(15, 23, 42, 0.1);
}

.report-grid thead th.r-sticky-name,
.report-grid tfoot td.r-sticky-name {
  z-index: 26;
  background: #f1f5f9;
}

.report-grid tfoot td.r-sticky-name {
  background: #f8fafc;
}

.report-grid td.r-cell-pad {
  padding: 6px 8px;
  white-space: nowrap;
}

.report-grid td.r-idx {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  width: 34px;
}

.report-grid td.r-rate {
  text-align: right;
  font-weight: 600;
}

.report-grid td.r-day-cell {
  min-width: 118px;
  height: 52px;
}

.empty-msg {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

@media (max-width: 768px) {
  .app {
    height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .title-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .title-group h1 {
    font-size: 13px;
    white-space: nowrap;
  }

  .mobile-top-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }

  .mobile-top-actions .btn-sm {
    padding: 5px 8px;
    font-size: 11.5px;
  }

  .mobile-top-actions .btn.is-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
  }

  .summary-badges {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .summary-badges span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 4px;
    font-size: 10.5px;
    white-space: nowrap;
  }

  .summary-badges strong {
    font-size: 12px;
  }

  /* Desktop controls hidden on mobile (mobile uses top-right action buttons) */
  .controls {
    display: none;
  }

  .search-input-wrap input,
  .add-emp-form input,
  .slot-row input.time-input,
  .field-block input {
    font-size: 16px;
  }

  .filter-bar select,
  .field-block select {
    font-size: 12.5px;
  }

  .mobile-date-select {
    font-size: 13.5px;
  }

  .define-box {
    padding: 10px 12px;
    max-height: 45dvh;
  }

  .define-head {
    flex-wrap: wrap;
  }

  .define-list {
    grid-template-columns: 1fr;
  }

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

  .define-item input[data-field="name"] {
    grid-column: 1 / -1;
  }

  .define-item .hours-tag {
    grid-column: 1 / 3;
  }

  .filter-bar {
    display: none;
    padding: 8px 12px;
  }

  .filter-bar.is-open {
    display: flex;
  }

  .filter-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .search-input-wrap {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-input-wrap input {
    width: 100%;
  }

  .filter-group .pill {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
    padding: 5px 7px;
    font-size: 11.5px;
  }

  .filter-group .pill select {
    flex: 1;
    min-width: 0;
    text-align: left;
  }

  #btnClearFilter {
    grid-column: 1 / -1;
    width: 100%;
    padding: 7px;
  }

  .pill-check {
    display: none;
  }

  /* Mobile Day Navigator + Card List */
  .table-wrap {
    display: none;
  }

  .mobile-day-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .mobile-day-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
    font-size: 12px;
    color: #1e40af;
    font-weight: 600;
  }

  .mobile-day-summary.is-locked {
    background: #f1f5f9;
    border-bottom-color: #cbd5e1;
    color: #334155;
  }

  .mobile-lock-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .mobile-lock-btn.is-locked {
    background: #334155;
    border-color: #334155;
    color: #fff;
  }

  .mobile-date-select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    border-radius: 8px;
    padding: 6px 8px;
    font: inherit;
    font-weight: 700;
    color: var(--text);
    text-align: center;
  }

  .mobile-list-wrap {
    display: block;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px;
  }

  .mobile-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .m-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 10px;
  }

  .m-card-info {
    flex: 1;
    min-width: 0;
  }

  .m-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-card-sub {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-card-sub strong {
    color: var(--primary);
  }

  .m-shift-btn {
    flex-shrink: 0;
    min-width: 96px;
    max-width: 145px;
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 9px;
    padding: 7px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
  }

  .m-shift-btn.has-shift {
    border-style: solid;
    border-color: #a7f3d0;
    background: var(--success-soft);
    color: var(--text);
  }

  .m-shift-btn.is-pending {
    border-style: solid;
    border-color: #fcd34d;
    background: #fffbeb;
    color: var(--text);
  }

  .m-shift-btn.is-pending .m-shift-hours {
    color: #b45309;
  }

  .m-shift-btn.is-error {
    border-style: solid;
    border-color: #fecaca;
    background: var(--danger-soft);
    color: var(--text);
  }

  .m-shift-btn.is-error .m-shift-hours {
    color: var(--danger);
  }

  .m-shift-btn.is-locked {
    cursor: not-allowed;
    opacity: 0.85;
    border-style: solid;
  }

  .m-shift-btn.is-locked:not(.has-shift):not(.is-pending):not(.is-error) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
  }

  .m-shift-hours {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--success);
  }

  .m-shift-range {
    display: block;
    font-size: 11px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Hide bottom bar completely on mobile (use + NV button in header) */
  .bottom-bar {
    display: none;
  }

  .modal-backdrop {
    bottom: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
    overflow: hidden;
  }

  .modal {
    width: 100%;
    min-height: 0;
    max-height: calc(100% - 12px);
    border-radius: 16px 16px 0 0;
  }

  .modal-backdrop.is-center {
    justify-content: center;
    padding: 16px;
  }

  .modal-confirm {
    width: min(360px, 100%);
    border-radius: 16px;
  }

  .modal-head,
  .modal-foot {
    flex-shrink: 0;
  }

  .modal-foot {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Let the browser scroll the document to focused fields when the keyboard opens. */
  body:has(> .editor-backdrop:not([hidden])) {
    height: auto;
  }

  body:has(> .editor-backdrop:not([hidden])) > .app {
    position: fixed;
    inset: 0;
  }

  .editor-backdrop {
    position: relative;
    inset: auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: max(12px, env(safe-area-inset-top));
    overflow: visible;
  }

  .editor-backdrop .modal {
    max-height: none;
    overflow: visible;
  }

  .editor-backdrop .modal-body {
    overflow: visible;
  }

  .editor-backdrop input {
    scroll-margin-block: 12px;
  }

  .preset-chip {
    padding: 8px 10px;
    font-size: 12.5px;
  }

  .slot-row {
    grid-template-columns: 1fr auto 1fr 48px 32px;
    gap: 5px;
    padding: 6px;
  }

  .slot-row input.time-input {
    padding: 7px 6px;
    text-align: center;
  }

  .modal-foot .btn {
    padding: 9px 14px;
  }

  .modal-report {
    width: 100%;
    height: 94%;
    max-height: 94%;
  }

  .modal-staff {
    width: 100%;
    max-height: none;
  }

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

  .add-emp-form #newEmpName,
  .add-emp-form button[type="submit"] {
    grid-column: 1 / -1;
  }

  .staff-list-head,
  .staff-idx {
    display: none;
  }

  .staff-row {
    grid-template-columns: 1fr 1fr 36px;
    gap: 6px;
    padding: 8px;
  }

  .staff-name-input {
    grid-column: 1 / 3;
  }

  .staff-row .del-emp-btn {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .staff-rate-input {
    grid-column: 2 / 4;
  }

  .report-toolbar {
    padding: 8px 12px;
  }

  .report-grid .r-sticky-name {
    width: 118px;
    min-width: 118px;
    max-width: 126px;
  }
}
