:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #63716b;
  --line: #d9dfda;
  --canvas: #edf1ed;
  --surface: #ffffff;
  --soft: #f6f8f5;
  --brand: #176b57;
  --brand-strong: #0f5746;
  --brand-soft: #dff1eb;
  --danger: #a13c3c;
  --danger-soft: #fff4f1;
  --warning: #845b20;
  --warning-soft: #fff8e9;
  --radius: 8px;
  --shadow: 0 12px 40px rgb(23 35 31 / 12%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 16px
    calc(24px + env(safe-area-inset-bottom));
}

.boot {
  min-height: 90vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand);
  font-size: 19px;
  font-weight: 800;
}

.start-screen {
  width: min(520px, 100%);
  margin: 7vh auto 0;
}

.start-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.start-title {
  font-size: 24px;
  font-weight: 800;
}

.start-copy,
.muted {
  color: var(--muted);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.start-card {
  padding: 22px;
}

.start-card h1 {
  margin: 0;
  font-size: 25px;
}

.start-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.form-stack {
  margin-top: 20px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #c8d0ca;
  border-radius: 7px;
  color: var(--ink);
  background: var(--soft);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(23 107 87 / 10%);
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font-weight: 680;
  white-space: nowrap;
}

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.button-primary {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.button-danger {
  color: var(--danger);
  border-color: #e3bcb9;
  background: white;
}

.button-soft {
  color: var(--brand-strong);
  border-color: #b9d8cb;
  background: #f2f9f5;
}

.button-warning {
  color: var(--warning);
  border-color: #e2c894;
  background: var(--warning-soft);
}

.button-wide {
  width: 100%;
}

.role-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.role-choices .button.active {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.claim-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.claim-button {
  min-width: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  text-align: left;
  white-space: normal;
  overflow: hidden;
}

.claim-button strong {
  font-size: 15px;
  max-width: 100%;
}

.claim-button span {
  color: var(--muted);
  font-size: 12px;
  max-width: 100%;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .brand-mark {
  width: 50px;
  height: 50px;
  font-size: 16px;
}

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

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

.account {
  text-align: right;
}

.account strong {
  display: block;
  font-size: 14px;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.month-nav {
  flex: 1;
  min-height: 44px;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.month-button {
  width: 38px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: var(--soft);
  font-size: 22px;
}

.month-title {
  font-weight: 760;
}

.tool-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--brand-strong);
  background: white;
  font-weight: 700;
}

.status-strip {
  margin-bottom: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #bddccf;
  border-radius: var(--radius);
  color: var(--brand-strong);
  background: #f0faf6;
  font-size: 13px;
}

.status-strip.warning {
  color: var(--warning);
  border-color: #ead0a2;
  background: var(--warning-soft);
}

.status-actions {
  display: flex;
  gap: 6px;
}

.status-actions .button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 12px;
  border-left: 1px solid var(--line);
}

.metric:first-child {
  border-left: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 23px;
}

.calendar {
  overflow: hidden;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  height: 34px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 700;
}

.weekday:last-child {
  border-right: 0;
}

.day-cell,
.day-blank {
  min-height: 78px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-cell:nth-child(7n),
.day-blank:nth-child(7n) {
  border-right: 0;
}

.day-blank {
  background: repeating-linear-gradient(
    -45deg,
    #fafbf9,
    #fafbf9 5px,
    #f6f8f5 5px,
    #f6f8f5 10px
  );
}

.day-cell {
  position: relative;
  padding: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  cursor: pointer;
}

.day-cell:hover {
  background: #f7fcfa;
}

.day-cell.past {
  background: #f4f6f3;
}

.day-cell.has-leave {
  background: #fbfdfc;
}

.day-cell.pending {
  background: #fffaf0;
}

.day-cell.selected {
  background: #eaf8f2;
  box-shadow: inset 0 0 0 2px var(--brand);
}

.day-cell.warning {
  box-shadow: inset 0 0 0 2px #c86455;
}

.day-cell.unavailable {
  color: #6f7773;
  background: #fbf8f5;
  cursor: not-allowed;
}

.day-cell.unavailable:hover {
  background: #fbf8f5;
}

.day-cell.rest-short {
  background: #fff5f1;
}

.day-cell.rest-short:hover {
  background: #fff5f1;
}

.day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
}

.day-number {
  font-size: 12px;
  font-weight: 800;
}

.day-tick {
  color: var(--brand);
  font-size: 14px;
  font-weight: 900;
}

.day-tag {
  padding: 0 4px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
}

.tag-leave {
  color: var(--danger);
  background: #f9e6e4;
}

.tag-pending {
  color: #94601b;
  background: #fff2d9;
}

.leave-name {
  margin-top: 5px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leave-shift,
.leave-cover {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.3;
}

.leave-cover {
  margin-top: auto;
  color: var(--brand-strong);
}

.leave-warning-text {
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.day-state {
  margin-top: auto;
  color: #8b9790;
  font-size: 9px;
}

.day-state.available {
  color: var(--brand);
  font-weight: 700;
}

.day-state.unavailable {
  color: #a34d3e;
  font-weight: 700;
  line-height: 1.35;
}

.legend {
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.dot-leave {
  background: #d98783;
}

.dot-pending {
  background: #d5a34f;
}

.dot-tick {
  color: var(--brand);
  font-weight: 900;
}

.panel {
  margin-top: 12px;
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-size: 16px;
  font-weight: 780;
}

.panel-copy {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.count-badge,
.quota-badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 700;
}

.count-badge.warning {
  color: var(--warning);
  background: #fff2d9;
}

.pending-list,
.staff-list,
.rules {
  padding: 0 14px;
}

.pending-row {
  padding: 12px 0;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.pending-batch-list {
  padding: 0 14px 6px;
  background: #f6faf7;
}

.pending-batch-row {
  padding: 10px 0;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.pending-batch-row:first-child {
  border-top: 0;
}

.pending-batch-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pending-batch-info strong {
  font-size: 13px;
}

.pending-batch-info span {
  color: var(--muted);
  font-size: 10px;
}

.pending-batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pending-batch-actions .button {
  flex: 1;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 11px;
}

.pending-row:first-child {
  border-top: 0;
}

.pending-row.warning {
  margin: 0 -14px;
  padding-right: 14px;
  padding-left: 14px;
  background: var(--danger-soft);
}

.pending-name {
  font-size: 14px;
  font-weight: 740;
}

.pending-line {
  color: var(--muted);
  font-size: 11px;
}

.pending-change {
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 700;
}

.pending-warning {
  color: var(--danger);
  font-size: 11px;
  line-height: 1.55;
  font-weight: 650;
}

.action-row {
  display: flex;
  gap: 6px;
}

.action-row .button {
  flex: 1;
  min-height: 34px;
  padding: 6px;
  font-size: 12px;
}

.my-leave {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.selected-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 700;
}

.empty-note {
  padding: 16px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.rule-row {
  min-height: 36px;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.rule-row:first-child {
  border-top: 0;
}

.boss-panel {
  border-color: #b9d8cb;
}

.staff-row {
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.staff-row:first-child {
  border-top: 0;
}

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

.staff-name {
  font-size: 14px;
  font-weight: 740;
}

.staff-meta,
.staff-shift {
  color: var(--muted);
  font-size: 10px;
}

.staff-shift {
  margin-top: 2px;
  color: var(--brand-strong);
}

.staff-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.staff-actions .button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 11px;
}

.my-shift-row {
  margin-top: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #cfe1d9;
  border-radius: 7px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 12px;
}

.my-shift-row strong {
  font-size: 13px;
}

.sub-panel {
  border-top: 1px solid var(--line);
  background: #f8faf7;
}

.sub-panel-head {
  padding: 12px 14px 6px;
}

.config-row {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #e2e7e3;
}

.config-row:first-child {
  border-top: 0;
}

.config-name {
  min-width: 104px;
  font-size: 12px;
  font-weight: 700;
}

.config-controls {
  flex: 1;
  display: flex;
  gap: 6px;
}

.config-controls .input,
.config-controls .select {
  min-height: 36px;
  padding: 5px 7px;
  font-size: 12px;
}

.schedule-zone {
  background: #f6faf7;
}

.schedule-list {
  padding: 2px 14px 8px;
}

.schedule-row {
  min-height: 58px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #e2e7e3;
}

.schedule-row:first-child {
  border-top: 0;
}

.schedule-person {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.schedule-person strong {
  font-size: 13px;
}

.schedule-person span {
  color: var(--muted);
  font-size: 10px;
}

.schedule-row .select {
  flex: 0 0 180px;
  min-height: 36px;
  padding: 5px 7px;
  font-size: 12px;
}

.schedule-save {
  padding: 8px 14px 14px;
}

.time-input {
  max-width: 110px;
}

.clear-zone {
  padding: 12px 14px;
}

.clear-actions {
  display: flex;
  gap: 8px;
}

.clear-actions .button {
  flex: 1;
}

.clear-person-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #e2e7e3;
}

.clear-person-row:first-child {
  border-top: 0;
}

.clear-person-row .button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(16 30 24 / 50%);
}

.modal {
  width: min(620px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 12px 12px 0 0;
  background: white;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.modal-copy {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.modal-close {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.modal-body {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  gap: 8px;
}

.modal-actions .button {
  flex: 1;
}

.modal-warning {
  padding: 10px 12px;
  border: 1px solid #edc9c3;
  border-radius: 7px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 24px;
  z-index: 80;
  margin: auto;
  max-width: 560px;
  padding: 11px 14px;
  border-radius: 7px;
  color: white;
  background: #182720;
  text-align: center;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: #8f3030;
}

.login-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.device-lock {
  padding: 18px;
  border: 1px solid #e3bcb9;
  border-radius: 8px;
  background: #fff8f7;
}

@media (min-width: 900px) {
  .app-shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
  }

  .dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.8fr);
    align-items: start;
    gap: 14px;
  }

  .calendar-column {
    min-width: 0;
  }

  .side-column {
    min-width: 0;
  }

  .day-cell,
  .day-blank {
    min-height: 96px;
  }

  .leave-name {
    font-size: 12px;
  }

  .leave-shift,
  .leave-cover,
  .day-state,
  .leave-warning-text {
    font-size: 10px;
  }
}

@media (max-width: 640px) {
  .schedule-row {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .schedule-row .select {
    flex-basis: auto;
    width: 100%;
  }

  .time-row {
    flex-wrap: wrap;
  }

  .time-row .config-name {
    min-width: 100%;
  }

  .time-row .config-controls {
    width: 100%;
  }

  .time-row .time-input {
    flex: 1;
    max-width: none;
  }
}
