:root {
  --bg: #eef3f1;
  --surface: #ffffff;
  --ink: #1f2528;
  --muted: #687276;
  --line: #d8e0dc;
  --brand: #ad1f3a;
  --brand-dark: #7f1729;
  --green: #166b52;
  --blue: #2d5f9a;
  --amber: #9b6419;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(31, 37, 40, 0.1);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(173, 31, 58, 0.08), transparent 210px),
    var(--bg);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(169, 30, 51, 0.12);
}

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

.app-shell {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
}

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

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 22px;
  font-weight: 900;
}

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

h1 {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.1;
}

.table-page {
  display: grid;
  gap: 12px;
}

.shift-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}

label,
.date-field,
.employee-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.date-quick-tabs,
.area-tabs {
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.date-quick-tabs button,
.area-tabs button {
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.date-quick-tabs button.active,
.area-tabs button.active {
  color: #fff;
  background: var(--brand);
}

.date-input-hidden {
  display: none;
}

.date-input-hidden.show {
  display: block;
}

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

.area-tabs button {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 54px;
}

.area-tabs span {
  font-size: 12px;
  opacity: 0.8;
}

.board-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.board-heading p {
  color: var(--muted);
  font-size: 13px;
}

.board-heading h2 {
  margin-top: 3px;
  font-size: 21px;
}

.board-stats {
  display: flex;
  gap: 8px;
}

.board-stats span {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.board-stats strong {
  color: var(--brand);
  font-size: 18px;
}

.table-board {
  display: grid;
  gap: 12px;
}

.board-section {
  display: grid;
  gap: 9px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

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

.section-head h3 {
  margin-top: 1px;
  font-size: 17px;
}

.section-head strong {
  display: inline-grid;
  min-width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  color: var(--brand);
  background: #fff;
  box-shadow: 0 6px 16px rgba(31, 37, 40, 0.05);
}

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

.free-table-button {
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(22, 107, 82, 0.2);
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  box-shadow: 0 6px 14px rgba(31, 37, 40, 0.05);
  font-size: 20px;
  font-weight: 950;
}

.free-table-button:active {
  color: #fff;
  background: var(--green);
}

.booked-card-list {
  display: grid;
  gap: 9px;
}

.booked-empty {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5d1;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  font-size: 13px;
}

.booked-card {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 0;
  border: 1px solid rgba(173, 31, 58, 0.16);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.booked-card.arrived {
  border-color: rgba(22, 107, 82, 0.18);
}

.booked-table {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 118px;
  padding: 8px;
  color: #fff;
  background: var(--brand);
  text-align: center;
}

.booked-card.arrived .booked-table {
  background: var(--green);
}

.booked-table strong {
  max-width: 100%;
  font-size: 24px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booked-table span {
  font-size: 12px;
  font-weight: 900;
}

.booked-detail {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 10px 8px;
}

.booked-detail p,
.booked-detail a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-name {
  color: var(--ink) !important;
  font-size: 15px;
  font-weight: 900;
}

.phone-link {
  color: var(--brand);
  font-size: 16px;
  font-weight: 950;
  text-decoration: none;
  white-space: nowrap;
}

.employee-line {
  color: var(--green) !important;
  font-size: 13px;
  font-weight: 800;
}

.table-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--amber) !important;
  font-size: 13px;
  font-weight: 800;
  white-space: normal;
}

.booked-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid #edf0ef;
  background: #edf0ef;
}

.booked-actions button {
  min-height: 34px;
  border: 0;
  color: var(--ink);
  background: #fbfcfc;
  font-size: 13px;
  font-weight: 900;
}

.booked-actions button[data-action="cancel"] {
  color: var(--danger);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.sheet.open {
  display: block;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 37, 40, 0.42);
}

.sheet-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 12px);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-radius: 12px 12px 0 0;
  background: #fff;
  box-shadow: 0 -16px 44px rgba(31, 37, 40, 0.18);
  overflow-y: auto;
}

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

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

.sheet-head h2 {
  margin-top: 1px;
  font-size: 24px;
  line-height: 1.1;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f2f2;
  font-size: 24px;
  line-height: 1;
}

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

.fast-row {
  grid-template-columns: minmax(0, 1fr) 92px;
}

.employee-picker {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
}

.employee-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.employee-picker-head strong {
  color: var(--brand);
}

.employee-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.employee-options button {
  min-height: 36px;
  border: 1px solid #d7ddda;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.employee-options button.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.primary-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 17px;
  font-weight: 900;
}

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

.form-message {
  min-height: 16px;
  color: var(--green);
  font-size: 13px;
}

.form-message.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(92vw, 420px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(31, 37, 40, 0.92);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

.toast.error {
  background: rgba(180, 35, 24, 0.94);
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .shift-bar {
    grid-template-columns: 1fr;
  }

  .area-tabs {
    gap: 5px;
  }

  label,
  .date-field,
  .employee-picker {
    gap: 5px;
    font-size: 12px;
  }

  .area-tabs button {
    min-height: 50px;
  }

  .board-heading h2 {
    font-size: 20px;
  }

  .free-number-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .free-table-button {
    min-height: 46px;
    font-size: 19px;
  }
}

@media (max-width: 430px) {
  .sheet-panel {
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .free-number-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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