:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f4ef;
  --ink: #17201a;
  --muted: #647067;
  --line: #d8dfd8;
  --primary: #1f7a4c;
  --primary-dark: #155d39;
  --accent: #1c6b8f;
  --danger: #b33636;
  --warning: #9a6417;
  --shadow: 0 16px 40px rgba(26, 40, 31, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(31, 122, 76, 0.08), rgba(28, 107, 143, 0.04) 42%, rgba(246, 247, 244, 1)),
    var(--bg);
  color: var(--ink);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.public-shell {
  width: min(720px, 100%);
  padding-bottom: 42px;
}

.admin-shell {
  width: min(1680px, 100%);
  padding: 28px 32px 36px;
}

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

.brand {
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #173e2b;
  color: #fff;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  line-height: 1.7;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.76);
  font-size: 13px;
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.booking-panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.field-full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  color: #344039;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d2ca;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 76, 0.13);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 12px;
}

.date-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.date-btn,
.slot-btn,
.secondary-btn,
.primary-btn,
.danger-btn,
.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: 0.16s ease;
}

.date-btn {
  min-height: 64px;
  background: #fff;
  color: var(--ink);
  padding: 8px 6px;
}

.date-btn strong,
.date-btn span,
.date-relative {
  display: block;
}

.date-btn strong {
  font-size: 17px;
}

.date-btn span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.date-relative {
  margin-top: 3px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.date-btn.active,
.slot-btn.active {
  border-color: var(--primary);
  background: #e7f2ea;
  color: var(--primary-dark);
}

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

.slot-btn {
  min-height: 46px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.slot-btn:disabled,
.date-btn:disabled {
  cursor: not-allowed;
  color: #9da7a0;
  background: #edf0ed;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 800;
}

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

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

.secondary-btn {
  color: var(--primary-dark);
  background: #eef6f0;
}

.ghost-btn {
  color: #344039;
  background: #fff;
}

.admin-entry {
  white-space: nowrap;
}

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

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.message {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.55;
  border: 1px solid transparent;
}

.message.ok {
  background: #e7f4ec;
  border-color: #b9dec7;
  color: #165330;
}

.message.error {
  background: #fff0f0;
  border-color: #efc7c7;
  color: #8d2424;
}

.success-box {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-top: 16px;
  background: #173e2b;
  color: #fff;
  border-radius: 8px;
}

.success-box .subtle {
  color: rgba(255, 255, 255, 0.76);
}

.my-booking {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #eef6f0;
  border: 1px solid #c8dfd0;
}

.my-booking p {
  margin-top: 4px;
}

.booking-limit {
  align-self: flex-start;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--primary-dark);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.admin-sidebar,
.admin-main {
  padding: 20px;
}

.admin-sidebar {
  position: sticky;
  top: 24px;
}

.admin-main {
  min-width: 0;
}

.admin-nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.admin-nav button {
  width: 100%;
  justify-content: flex-start;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-shell .toolbar {
  flex-wrap: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}

.stat strong {
  display: block;
  font-size: 30px;
  line-height: 1.05;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

.admin-main table {
  min-width: 1180px;
}

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

th {
  color: #344039;
  background: #eef3ee;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  background: #e7f2ea;
  color: var(--primary-dark);
}

.badge.warn {
  background: #fff3db;
  color: var(--warning);
}

.badge.off {
  background: #eef0ee;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-shell .settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.admin-shell .settings-grid .field-full {
  grid-column: 1 / -1;
}

.admin-shell textarea {
  min-height: 112px;
}

.admin-shell textarea[name="smartSheetSchema"] {
  min-height: 190px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.login-shell {
  width: min(420px, 100%);
  margin: 0 auto;
  padding-top: 9vh;
}

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

@media (max-width: 1280px) {
  .admin-shell {
    padding: 22px;
  }

  .admin-layout {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 16px;
  }

  .admin-sidebar,
  .admin-main {
    padding: 16px;
  }

  .admin-main table {
    min-width: 1040px;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .settings-grid,
  .admin-layout,
  .stats {
    grid-template-columns: 1fr;
  }

  .admin-shell .settings-grid {
    grid-template-columns: 1fr;
  }

  .admin-shell .toolbar {
    flex-wrap: wrap;
  }

  .admin-sidebar {
    position: static;
  }

  .date-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  body {
    background:
      linear-gradient(180deg, rgba(31, 122, 76, 0.07), rgba(246, 247, 244, 1) 34%),
      var(--bg);
  }

  .shell {
    padding: 10px;
  }

  .public-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 10px;
  }

  .public-shell .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .public-shell .brand {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
  }

  .public-shell .brand-mark {
    width: 30px;
    height: 30px;
    margin: 0;
    border-radius: 7px;
    font-size: 14px;
  }

  .public-shell h1 {
    font-size: 20px;
    line-height: 1.1;
  }

  .public-shell .brand .subtle,
  .public-shell .status-pill {
    display: none;
  }

  .public-shell .top-actions {
    width: auto;
    justify-content: flex-end;
  }

  .admin-entry {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .public-shell .booking-panel {
    min-height: 0;
  }

  .my-booking {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
    padding: 9px;
  }

  .my-booking h2 {
    font-size: 15px;
  }

  .my-booking p {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.35;
  }

  .booking-limit {
    justify-self: start;
    padding: 4px 8px;
    font-size: 11px;
  }

  .booking-panel,
  .admin-sidebar,
  .admin-main {
    padding: 10px;
  }

  .public-shell .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    height: 100%;
  }

  .public-shell .field-full {
    grid-column: 1 / -1;
  }

  .field {
    gap: 4px;
  }

  label {
    font-size: 12px;
  }

  input,
  select,
  textarea {
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 14px;
  }

  .date-row {
    display: flex;
    gap: 6px;
    margin: 0 -10px;
    padding: 0 10px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .date-row::-webkit-scrollbar {
    display: none;
  }

  .date-btn {
    flex: 0 0 58px;
    min-height: 50px;
    padding: 5px 4px;
  }

  .date-btn strong {
    font-size: 15px;
  }

  .date-btn span {
    font-size: 10px;
  }

  .date-relative {
    margin-top: 2px;
    font-size: 10px;
  }

  .slot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    max-height: min(24vh, 172px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .slot-btn {
    min-height: 36px;
    padding: 4px 2px;
    font-size: 12px;
    line-height: 1.15;
  }

  .section-head {
    margin: 4px 0 6px;
  }

  .section-head .subtle {
    display: none;
  }

  .public-shell .actions {
    position: sticky;
    bottom: 0;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    background: rgba(255, 255, 255, 0.96);
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn,
  .ghost-btn {
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 14px;
  }

  .public-shell .actions > * {
    flex: 1 1 0;
    width: auto;
  }

  .message {
    margin-top: 8px;
    padding: 9px;
    font-size: 13px;
  }

  .success-box {
    gap: 8px;
    padding: 12px;
    margin-top: 8px;
  }

  .admin-layout .actions > *,
  .settings-grid .actions > *,
  .login-shell .actions > * {
    width: 100%;
  }
}
