:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --ink: #292522;
  --muted: #7a7169;
  --line: #ded5c9;
  --panel: #fffaf2;
  --soft: #ede5d8;
  --accent: #197a66;
  --accent-dark: #0f5f50;
  --warn: #b9493d;
  --gold: #b38130;
  --pending: #d98324;
  --approved: #197a66;
  --rejected: #b9493d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.9), rgba(247, 243, 236, 0.96)),
    radial-gradient(circle at 12% 0%, rgba(25, 122, 102, 0.16), transparent 28%),
    radial-gradient(circle at 96% 18%, rgba(179, 129, 48, 0.14), transparent 22%);
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.topbar,
.month-row,
.list-header,
.button-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px 18px;
}

.eyebrow,
.year-label,
.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.12;
}

.icon-button,
.round-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(55, 43, 30, 0.08);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-weight: 700;
}

.round-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 28px;
  line-height: 1;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin-bottom: 14px;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-button {
  height: 42px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 18px rgba(25, 122, 102, 0.22);
}

.calendar-panel,
.action-panel,
.list-panel {
  background: rgba(255, 250, 242, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 38px rgba(58, 45, 32, 0.09);
}

.calendar-panel {
  padding: 16px;
}

.month-row {
  justify-content: space-between;
  margin-bottom: 18px;
  text-align: center;
}

.month-row h2 {
  margin-top: 2px;
  font-size: 24px;
}

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

.week-grid {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.date-grid {
  min-height: 318px;
}

.date-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid transparent;
  font-weight: 700;
}

.date-cell.muted {
  color: #b6aaa0;
  background: rgba(255, 255, 255, 0.38);
}

.date-cell.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(25, 122, 102, 0.22);
}

.date-cell.today {
  background: #fff3d8;
}

.date-cell::after {
  content: "";
  position: absolute;
  bottom: 7px;
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: transparent;
}

.date-cell.pending::after {
  background: var(--pending);
}

.date-cell.approved::after {
  background: var(--approved);
}

.date-cell.rejected::after {
  background: var(--rejected);
}

.action-panel,
.list-panel {
  margin-top: 14px;
  padding: 14px;
}

.selected-card {
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selected-card h3 {
  margin-top: 4px;
  font-size: 20px;
}

.selected-card p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-row {
  margin-top: 12px;
}

.form-row label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 122, 102, 0.13);
}

.button-row {
  gap: 9px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.primary-button,
.danger-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  flex: 1 1 140px;
  background: var(--accent);
  color: white;
}

.primary-button.approve {
  background: var(--approved);
}

.danger-button {
  flex: 1 1 120px;
  background: var(--warn);
  color: white;
}

.ghost-button {
  flex: 0 0 auto;
  background: var(--soft);
  color: var(--ink);
}

.list-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.list-header h2 {
  font-size: 18px;
}

#syncBadge {
  padding: 5px 9px;
  border-radius: 999px;
  background: #eee6d8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.appointment-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.appointment-item strong {
  display: block;
  margin-bottom: 4px;
}

.appointment-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.status-pill {
  align-self: start;
  border-radius: 999px;
  padding: 5px 8px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.status-pending {
  background: var(--pending);
}

.status-approved {
  background: var(--approved);
}

.status-rejected {
  background: var(--rejected);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(41, 37, 34, 0.94);
  color: white;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (max-width: 380px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .calendar-panel,
  .action-panel,
  .list-panel {
    padding: 12px;
  }

  .week-grid,
  .date-grid {
    gap: 5px;
  }
}
