:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --panel-strong: #edf3e8;
  --text: #1d2118;
  --muted: #66705d;
  --line: #dce1d2;
  --accent: #2f7d52;
  --accent-strong: #256741;
  --danger: #b94343;
  --shadow: 0 16px 40px rgba(35, 45, 25, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.submit-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 64px);
  background:
    radial-gradient(circle at 12% 12%, rgba(47, 125, 82, 0.14), transparent 34rem),
    linear-gradient(135deg, #f7f9f3 0%, #edf3e8 100%);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 440px);
  gap: clamp(36px, 8vw, 108px);
  align-items: center;
  width: min(1120px, 100%);
}

.auth-intro {
  max-width: 650px;
}

.auth-eyebrow {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.auth-intro h1 {
  max-width: 620px;
  font-size: clamp(36px, 5.2vw, 68px);
  letter-spacing: -0.04em;
}

.auth-intro > p {
  max-width: 590px;
  margin-top: 22px;
  font-size: 17px;
}

.auth-benefits {
  display: grid;
  gap: 14px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.auth-benefits li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  align-items: baseline;
}

.auth-benefits strong {
  color: var(--accent-strong);
}

.auth-benefits span {
  color: var(--muted);
}

.auth-card {
  width: 100%;
  padding: clamp(24px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 28px;
  padding: 4px;
  border-radius: 10px;
  background: var(--panel-strong);
}

.auth-tabs a {
  padding: 11px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.auth-tabs a.is-active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 3px 10px rgba(35, 45, 25, 0.08);
}

.auth-form-head {
  margin-bottom: 22px;
}

.auth-form-head h2 {
  margin-bottom: 7px;
  font-size: 24px;
}

.auth-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 14px;
}

.auth-assurance {
  margin-top: 2px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.auth-schedule-link {
  display: block;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.phone-shell {
  width: min(520px, 100%);
}

.form-card,
.qr-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-card {
  padding: 22px;
}

.form-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-dot {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

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

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: 1fr 1fr;
}

.field-grid.three {
  grid-template-columns: 0.9fr 1fr 1fr;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.form-section h2 {
  font-size: 15px;
}

.section-help {
  font-size: 12px;
  line-height: 1.5;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr 0.85fr);
  gap: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-field {
  position: relative;
}

.date-field input {
  cursor: pointer;
}

.date-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 72px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.date-picker-top,
.date-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.date-picker-top strong {
  color: var(--text);
  font-size: 15px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.date-weekdays,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-weekdays {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.date-grid {
  margin-top: 6px;
}

.date-day {
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  background: #f7faf4;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.date-day.is-muted {
  opacity: 0.35;
}

.date-day.is-selected {
  background: var(--accent);
  color: #fff;
}

.date-picker-actions {
  margin-top: 12px;
  justify-content: flex-end;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #86aa72;
  box-shadow: 0 0 0 3px rgba(47, 125, 82, 0.13);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

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

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

.ghost {
  background: #e7ebdf;
  color: var(--text);
}

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

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

.full {
  width: 100%;
}

.admin-page {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 38px;
}

.owner-page {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 38px;
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dashboard {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.owner-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.owner-summary article {
  display: grid;
  gap: 7px;
  padding: 16px;
  background: #fff;
}

.owner-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.owner-summary strong {
  color: var(--accent-strong);
  font-size: 26px;
  line-height: 1.1;
}

.owner-summary strong.is-negative {
  color: var(--danger);
}

.owner-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.owner-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.owner-form {
  padding: 16px;
}

.owner-table-wrap {
  overflow: auto;
}

.owner-table {
  min-width: 980px;
}

.owner-table td:first-child {
  min-width: 180px;
}

.owner-table td:first-child strong,
.owner-table td:first-child span {
  display: block;
}

.owner-table td:first-child span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.owner-table td {
  white-space: nowrap;
}

.owner-table td.is-negative {
  color: var(--danger);
  font-weight: 900;
}

.qr-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.qr-panel img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-panel p {
  word-break: break-all;
  font-size: 13px;
}

.save-panel {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.save-panel h2 {
  font-size: 16px;
}

.save-panel p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.save-slots {
  display: grid;
  gap: 8px;
}

.save-slot {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.save-slot strong,
.save-slot span {
  display: block;
}

.save-slot strong {
  font-size: 14px;
}

.save-slot span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.save-slot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.save-slot-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.table-panel {
  overflow: hidden;
}

.panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.month-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.month-summary article {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: #fff;
}

.month-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.month-summary strong {
  color: var(--accent-strong);
  font-size: 24px;
  line-height: 1.15;
}

.month-summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.month-summary small b {
  color: var(--accent-strong);
  font-weight: 900;
}

.month-summary strong.is-negative {
  color: var(--danger);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #dcebd8;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.live-pill.off {
  background: #f2dede;
  color: #9f3434;
}

.table-scroll {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.table-x-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.table-x-scroll-inner {
  height: 1px;
  min-width: 1940px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1940px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faf4;
  color: var(--muted);
  font-size: 12px;
}

th.row-index-sticky,
td.row-index-sticky {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  text-align: center;
  white-space: nowrap;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

th.row-index-sticky {
  z-index: 4;
  background: #f7faf4;
}

td.row-index-sticky {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

th.script-sticky,
td.script-sticky {
  position: sticky;
  left: 58px;
  z-index: 2;
  min-width: 180px;
  max-width: 240px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line), 8px 0 16px rgba(35, 45, 25, 0.06);
}

th.script-sticky {
  z-index: 3;
  background: #f7faf4;
}

td.script-sticky input {
  font-weight: 800;
}

td.row-total {
  min-width: 112px;
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 900;
}

td.row-total.is-negative {
  color: var(--danger);
}

td input,
td select {
  height: 36px;
  padding-inline: 8px;
}

.row-actions {
  display: flex;
  gap: 7px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 6px;
}

.compact-grid.two {
  grid-template-columns: repeat(2, minmax(74px, 1fr));
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.status.empty {
  background: #e9f4e4;
  color: #256741;
}

.status.full {
  background: #f4e6e2;
  color: #9f3434;
}

.status.none {
  background: #e8e8e8;
  color: #555;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(29, 33, 24, 0.92);
  color: #fff;
  font-size: 14px;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 33, 24, 0.46);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(24, 34, 20, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.icon-close {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: -22px;
  margin: 4px -22px -22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

@media (max-width: 860px) {
  .auth-page {
    place-items: start center;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 560px;
  }

  .auth-intro h1 {
    font-size: clamp(34px, 9vw, 52px);
  }

  .admin-header,
  .dashboard,
  .owner-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .qr-panel {
    max-width: 360px;
  }

  .month-summary {
    grid-template-columns: 1fr;
  }

  .owner-summary {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .auth-intro > p {
    font-size: 15px;
  }

  .auth-benefits li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .tier-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-card {
    padding: 18px;
  }

  .owner-summary {
    grid-template-columns: 1fr;
  }
}
