:root {
  color-scheme: light;
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  --ink: #1b1f24;
  --muted: #5d6673;
  --line: #c9d1dc;
  --line-strong: #8d99aa;
  --panel: #ffffff;
  --canvas: #f4f6f8;
  --brand: #17624f;
  --brand-dark: #0f4538;
  --accent: #d94836;
  --header: #d7e5f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--brand-dark);
  border-radius: 6px;
  color: #ffffff;
  background: var(--brand);
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.event-list button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent);
  border-color: #e4b2aa;
  background: #ffffff;
}

.secondary-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--brand);
  border-color: #b8d2ca;
  background: #ffffff;
}

.secondary-button:hover {
  color: #ffffff;
  background: var(--brand);
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

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

.login-panel {
  display: grid;
  width: min(460px, 100%);
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(35, 47, 62, 0.12);
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.stack {
  display: grid;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.muted,
.section-heading p,
.notice {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--accent);
}

.demo-account {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

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

.user-box button {
  min-width: 72px;
}

.workspace {
  display: grid;
  gap: 18px;
  padding: 18px 24px 32px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.view-tabs button {
  min-width: 96px;
  color: var(--brand);
  border-color: transparent;
  background: transparent;
}

.view-tabs button.active,
.view-tabs button:hover {
  color: #ffffff;
  border-color: var(--brand-dark);
  background: var(--brand);
}

.toolbar,
.editor-section,
.schedule-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 16px;
}

.toolbar label {
  width: 180px;
}

.notice {
  padding: 10px 12px;
  border-left: 4px solid var(--brand);
  background: #eef7f4;
}

.editor-section,
.schedule-section {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.event-form {
  display: grid;
  grid-template-columns: 160px 160px minmax(220px, 1fr) 110px;
  gap: 12px;
  align-items: end;
}

.store-form,
.manager-form {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr) 120px;
  gap: 10px;
  align-items: center;
}

.manager-form {
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 1.2fr) 140px 140px;
}

.store-admin-list,
.manager-admin-list {
  display: grid;
  gap: 10px;
}

.store-admin-row,
.manager-account-fields {
  display: grid;
  grid-template-columns: 100px minmax(220px, 1fr) 72px 64px 64px 64px 64px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.manager-account-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.manager-account-fields {
  grid-template-columns: minmax(120px, 1fr) minmax(220px, 1.3fr) 120px 72px 64px 64px;
  padding: 0;
  border: 0;
  background: transparent;
}

.manager-store-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid #b8d2ca;
  border-radius: 999px;
  color: var(--brand-dark);
  background: #eef7f4;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.inactive {
  color: var(--accent);
  border-color: #e4b2aa;
  background: #fffafa;
}

.store-admin-row button,
.manager-account-fields button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.event-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-list li {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  max-height: 72vh;
  border: 1px solid var(--line-strong);
  background: #ffffff;
}

.schedule-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 4700px;
  table-layout: fixed;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  width: 146px;
  height: 104px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: center;
  vertical-align: top;
  background: #ffffff;
}

.schedule-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 30px;
  color: #20252c;
  background: var(--header);
  font-weight: 700;
}

.schedule-table thead tr:nth-child(2) th {
  top: 30px;
}

.schedule-table .sticky {
  position: sticky;
  z-index: 4;
  background: #f2f5f8;
}

.schedule-table thead .sticky {
  z-index: 6;
  background: var(--header);
}

.title-col {
  left: 0;
  width: 72px !important;
}

.name-col {
  left: 150px;
  width: 108px !important;
}

.employee-col {
  left: 72px;
  width: 78px !important;
}

.category-col {
  left: 0;
  width: 72px !important;
}

.item-col {
  left: 72px;
  width: 108px !important;
}

.store-col {
  left: 0;
  width: 118px !important;
}

.store-title-col {
  left: 118px;
  width: 72px !important;
}

.store-name-col {
  left: 268px;
  width: 108px !important;
}

.store-employee-col {
  left: 190px;
  width: 78px !important;
}

.person-title,
.person-name {
  padding-top: 22px !important;
  color: #26313d;
}

.cell-event,
.cell-shift,
.brand-event {
  display: grid;
  min-height: 31px;
  place-items: center;
  padding: 3px;
  line-height: 1.25;
  word-break: break-word;
}

.cell-event {
  color: var(--accent);
  font-size: 12px;
  border-bottom: 1px solid #e5e9ef;
  background: #fffafa;
}

.brand-event {
  min-height: 63px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  background: #fffafa;
}

.brand-event span {
  display: block;
  width: 100%;
  padding: 2px;
  border-bottom: 1px solid #f1d7d3;
}

.store-order-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.store-filter-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

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

.store-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.store-filter-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

.store-filter-option input {
  width: auto;
  min-height: auto;
}

.staff-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}

.staff-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.staff-card h3 {
  margin: 0;
  font-size: 16px;
}

.staff-add-form,
.staff-row {
  display: grid;
  grid-template-columns: 86px 1fr 88px 64px 64px;
  gap: 8px;
  align-items: center;
}

.staff-add-form {
  grid-template-columns: 86px 1fr 88px 64px;
}

.staff-list {
  display: grid;
  gap: 8px;
}

.staff-row input,
.staff-add-form input {
  min-height: 34px;
  padding: 6px 8px;
}

.staff-row button,
.staff-add-form button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.ghost-danger {
  color: var(--accent);
  border-color: #e4b2aa;
  background: #ffffff;
}

.ghost-danger:hover {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.store-order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.store-order-item span {
  min-width: 140px;
  font-weight: 700;
}

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

.store-order-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.summary-card h3,
.summary-card p {
  margin: 0;
}

.summary-card h3 {
  font-size: 16px;
}

.summary-card span,
.summary-card li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.summary-card ul {
  display: grid;
  gap: 4px;
  margin: 4px 0 0;
  padding-left: 18px;
}

.save-status {
  min-height: 20px;
  margin: 0;
  color: var(--brand);
  font-weight: 700;
}

.store-name-cell {
  padding-top: 22px !important;
  color: #163d34;
  background: #eaf5f1 !important;
}

.store-group-start th,
.store-group-start td {
  border-top: 2px solid var(--line-strong);
}

.cell-shift {
  color: #1c2d3f;
  font-weight: 600;
  align-content: start;
}

.assignment-editor {
  display: grid;
  gap: 4px;
  width: 100%;
}

.leave-select,
.segment-row select,
.custom-text-input {
  min-height: 26px;
  padding: 2px 4px;
  font-size: 12px;
}

.segment-list {
  display: grid;
  gap: 4px;
}

.segment-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 22px;
  gap: 3px;
  align-items: center;
}

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

.mini-button,
.icon-button {
  min-height: 24px;
  padding: 0 6px;
  font-size: 12px;
}

.icon-button {
  min-width: 22px;
  color: var(--accent);
  border-color: #e4b2aa;
  background: #ffffff;
}

.leave-select:hover,
.leave-select:focus,
.custom-text-input:hover,
.custom-text-input:focus,
.segment-row select:hover,
.segment-row select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 2px rgba(23, 98, 79, 0.14);
}

.total-row th,
.total-row td,
.store-total-row th,
.store-total-row td,
.all-total-row th,
.all-total-row td {
  height: 42px;
  background: #eef7f4;
  font-weight: 700;
}

.all-total-row th,
.all-total-row td {
  background: #e6eef8;
}

.total-label {
  text-align: left !important;
  padding: 10px !important;
}

.total-hours {
  display: grid;
  min-height: 40px;
  place-items: center;
  color: var(--brand-dark);
}

.weekend {
  color: var(--accent) !important;
}

.schedule-table td.weekend {
  background: #fffdfd;
}

@media (max-width: 760px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
  }

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

  .store-form,
  .manager-form,
  .store-admin-row,
  .manager-account-fields {
    grid-template-columns: 1fr;
  }

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

  .staff-manager-grid,
  .staff-add-form,
  .staff-row {
    grid-template-columns: 1fr;
  }

  .toolbar label {
    width: 100%;
  }
}
