:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: #17211f;
  background: #f4f6f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --forest: #143a33;
  --green: #216b5b;
  --green-2: #3f8172;
  --ink: #17211f;
  --muted: #66726e;
  --line: #dfe5df;
  --paper: #ffffff;
  --cream: #f4f6f2;
  --danger: #a94335;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--cream); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
code { padding: 2px 6px; border-radius: 5px; background: #eef1ed; font-size: .9em; }

.center-screen, .auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 20%, rgba(72, 128, 112, .18), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(207, 164, 102, .16), transparent 25%),
    #edf1ec;
}
.center-screen { color: var(--muted); gap: 16px; align-content: center; }
.auth-card {
  width: min(440px, 100%);
  padding: 48px;
  border: 1px solid rgba(25, 55, 48, .12);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 24px 70px rgba(26, 55, 48, .12);
  text-align: center;
}
.auth-card h1 { margin: 10px 0 12px; font-size: 34px; letter-spacing: -.04em; }
.auth-card p { margin: 0 0 28px; color: var(--muted); line-height: 1.7; }
.auth-card small { display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted); margin-top: 20px; }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; background: var(--forest); position: relative; margin: 0 auto 24px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand-mark::before, .brand-mark::after, .brand-mark span::before, .brand-mark span::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.78); border-radius: 2px; }
.brand-mark::before { inset: 11px 26px 11px 11px; }
.brand-mark::after { inset: 11px 11px 11px 26px; }
.brand-mark span::before { left: 11px; right: 11px; top: 17px; }
.brand-mark span::after { left: 11px; right: 11px; bottom: 17px; }
.brand-mark.denied { background: #743d35; }
.brand-mark.compact { width: 38px; height: 38px; border-radius: 11px; margin: 0; transform: scale(.78); transform-origin: center; }
.eyebrow { display: inline-block; color: var(--green); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 750; }
.google-button { width: 100%; padding: 13px 18px; border: 1px solid #d8ded9; border-radius: 10px; color: var(--ink); background: #fff; font-weight: 700; display: flex; gap: 12px; align-items: center; justify-content: center; box-shadow: 0 3px 12px rgba(20,58,51,.06); }
.google-button:hover { border-color: #aebbb4; background: #fbfcfb; }
.google-g { color: #4285f4; font-size: 20px; font-weight: 800; font-family: Arial, sans-serif; }

.app-shell { min-height: 100vh; }
.topbar { height: 72px; padding: 0 clamp(20px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand-area, .topbar-actions, .profile-button { display: flex; align-items: center; }
.brand-area { gap: 4px; }
.brand-area > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.brand-area strong { font-size: 16px; letter-spacing: -.01em; }
.brand-area span { font-size: 11px; color: var(--muted); }
.topbar-actions { gap: 10px; }
.profile-button { gap: 9px; border: 0; background: transparent; padding: 5px 8px; text-align: left; }
.profile-button > span:last-child { display: flex; flex-direction: column; }
.profile-button strong { font-size: 13px; }
.profile-button small { color: var(--muted); font-size: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: white; background: var(--green); font-weight: 800; }
.avatar.small { width: 32px; height: 32px; font-size: 13px; flex: 0 0 auto; }
.demo-pill, .role-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.demo-pill { padding: 6px 10px; background: #f6ecd8; color: #805e26; }

.page-content { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 6px 0 4px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); }
.primary-button, .secondary-button, .danger-button, .text-button, .icon-button {
  border-radius: 9px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 720;
  transition: .18s ease;
}
.primary-button { padding: 10px 16px; color: white; background: var(--green); box-shadow: 0 5px 14px rgba(33,107,91,.15); }
.primary-button:hover { background: #185648; transform: translateY(-1px); }
.secondary-button { padding: 10px 15px; color: var(--ink); background: white; border-color: var(--line); }
.secondary-button:hover { border-color: #b9c4be; background: #f9faf9; }
.danger-button { padding: 10px 14px; color: var(--danger); background: #fff7f5; border-color: #eed8d3; }
.text-button { background: transparent; color: var(--green); padding: 7px 9px; }
.icon-button { width: 38px; height: 38px; background: transparent; color: #52615c; }
.icon-button:hover { background: #eff2ef; }
.large-button { padding: 12px 18px; }
.compact-button { padding: 8px 11px; font-size: 12px; }
.link-button { text-decoration: none; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stats-grid article { min-height: 100px; padding: 19px 20px; display: flex; align-items: center; gap: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.stats-grid article > div:last-child { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 7px; }
.stats-grid span { grid-column: 1 / 3; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.stats-grid strong { font-size: 29px; letter-spacing: -.04em; }
.stats-grid small { color: var(--muted); }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; }
.stat-icon.green { color: #1e6d5a; background: #e8f4ef; }
.stat-icon.amber { color: #8d642a; background: #f8efdc; }
.stat-icon.blue { color: #365f80; background: #e8f0f6; }
.stat-icon.slate { color: #5e6664; background: #ecefed; }

.calendar-card { padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 10px 40px rgba(32, 54, 48, .035); overflow: hidden; }
.calendar-card-header { display: flex; justify-content: space-between; gap: 24px; align-items: start; margin-bottom: 20px; }
.calendar-card h2 { margin: 0 0 5px; font-size: 20px; letter-spacing: -.02em; }
.calendar-card p { margin: 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }
.legend .mine { background: var(--green); }
.legend .others { background: var(--green-2); }
.legend .reserved { background: #b9623a; }
.calendar-wrap { position: relative; min-height: 620px; }
.calendar-wrap.is-loading::after { content: "更新中…"; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 4; padding: 6px 12px; border-radius: 999px; color: white; background: rgba(20,58,51,.88); font-size: 11px; }
.fc { --fc-border-color: #e4e9e5; --fc-neutral-bg-color: #f8faf8; --fc-page-bg-color: #fff; --fc-today-bg-color: #f3f8f5; color: #26322f; font-size: 13px; }
.fc .fc-toolbar-title { font-size: 17px; letter-spacing: -.02em; }
.fc .fc-button-primary { border: 1px solid #dce3de; color: #34423e; background: white; box-shadow: none; font-size: 12px; font-weight: 700; }
.fc .fc-button-primary:hover, .fc .fc-button-primary:not(:disabled).fc-button-active { border-color: var(--green); color: white; background: var(--green); }
.fc .fc-timegrid-slot { height: 2.35em; }
.fc .fc-timegrid-axis-cushion, .fc .fc-timegrid-slot-label-cushion { color: #7b8582; font-size: 11px; }
.fc .fc-col-header-cell-cushion { padding: 10px 4px; color: #45534f; text-decoration: none; font-weight: 720; }
.fc .fc-event { padding: 3px 5px; border-radius: 5px; box-shadow: 0 2px 5px rgba(20,58,51,.13); }
.fc .fc-event-title { font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(14, 31, 27, .48); backdrop-filter: blur(5px); }
.modal-card, .admin-panel { max-height: calc(100vh - 48px); overflow: auto; background: white; border-radius: 18px; box-shadow: 0 28px 90px rgba(9,26,22,.25); }
.modal-card { width: min(700px, 100%); }
.modal-header { padding: 24px 26px 18px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 5px 0 0; font-size: 23px; letter-spacing: -.03em; }
.booking-form { padding: 24px 26px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .section-label { color: #46534f; font-size: 12px; font-weight: 720; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d7ded9; border-radius: 8px; padding: 10px 11px; color: var(--ink); background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(63,129,114,.12); }
.field textarea { resize: vertical; }
.span-2 { grid-column: 1 / 3; }
.recurrence-block { padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: #fafbf9; }
.section-label { display: flex; align-items: center; gap: 7px; margin-bottom: 13px; }
.recurrence-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.compact-field input { width: 60px; }
.inline-control { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.weekday-picker { display: flex; gap: 7px; margin-top: 13px; }
.weekday-picker button { width: 34px; height: 34px; border: 1px solid #d7ded9; border-radius: 50%; background: white; color: #52605c; }
.weekday-picker button.selected { border-color: var(--green); color: white; background: var(--green); }
.form-error, .form-success { margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.form-error { color: #8b382d; background: #fff0ed; }
.form-success { color: #1c6956; background: #eaf6f1; }
.modal-actions { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.action-spacer { flex: 1; }

.admin-panel { width: min(980px, 100%); min-height: 650px; display: grid; grid-template-columns: 185px 1fr; grid-template-rows: auto 1fr; }
.admin-header { grid-column: 1 / 3; }
.admin-tabs { padding: 18px 12px; border-right: 1px solid var(--line); background: #f7f9f6; }
.admin-tabs button { width: 100%; margin-bottom: 5px; padding: 10px 11px; border: 0; border-radius: 8px; display: flex; align-items: center; gap: 9px; color: #53615d; background: transparent; text-align: left; font-weight: 700; }
.admin-tabs button.active { color: #fff; background: var(--green); }
.admin-content { padding: 26px; overflow: auto; }
.admin-content h3 { margin: 0 0 5px; font-size: 17px; }
.admin-content p { margin: 0; color: var(--muted); }
.section-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.user-form { display: grid; grid-template-columns: 1.4fr 1fr .7fr auto; gap: 11px; align-items: end; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.user-submit { height: 41px; }
.user-list-section { padding-top: 24px; }
.user-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.user-row { min-height: 59px; padding: 10px 13px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.user-info strong { font-size: 13px; }
.user-info span { color: var(--muted); font-size: 11px; }
.role-pill { padding: 4px 8px; }
.role-pill.admin { color: #77531f; background: #f7ecd8; }
.role-pill.coach { color: #1f6655; background: #e8f4ef; }
.audit-list { border-top: 1px solid var(--line); }
.audit-search { display: flex; gap: 8px; margin: 0 0 14px; }
.audit-search input { flex: 1; min-width: 0; border: 1px solid #d7ded9; border-radius: 8px; padding: 10px 11px; }
.audit-more { width: 100%; margin-top: 14px; }
.audit-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: start; padding: 18px 4px; border-bottom: 1px solid var(--line); }
.audit-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--green-2); }
.audit-row strong { font-size: 13px; }
.audit-row p, .audit-row time { font-size: 11px; color: var(--muted); }
.audit-row details { max-width: 300px; font-size: 12px; }
.audit-row pre { max-height: 180px; overflow: auto; padding: 9px; border-radius: 7px; background: #f4f6f4; white-space: pre-wrap; }
.export-section { min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 11px; }
.export-section > svg { color: var(--green); }
.export-section p { max-width: 460px; line-height: 1.65; margin-bottom: 9px; }

.toast { position: fixed; z-index: 120; right: 24px; bottom: 24px; max-width: min(520px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 10px; color: white; background: rgba(20,58,51,.95); box-shadow: 0 12px 35px rgba(10,30,25,.25); font-size: 13px; }

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-submit { align-self: end; }
}

@media (max-width: 720px) {
  .topbar { height: 64px; padding: 0 14px; }
  .compact-button, .profile-button > span:last-child, .demo-pill { display: none; }
  .page-content { width: min(100% - 24px, 1480px); padding-top: 24px; }
  .page-heading { align-items: start; flex-direction: column; }
  .large-button { width: 100%; }
  .stats-grid { gap: 9px; }
  .stats-grid article { min-height: 88px; padding: 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stats-grid strong { font-size: 23px; }
  .calendar-card { padding: 14px 10px; border-radius: 12px; }
  .calendar-card-header { flex-direction: column; gap: 12px; padding: 0 4px; }
  .calendar-wrap { overflow-x: hidden; }
  .fc { min-width: 0; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: 10px 6px; }
  .fc .fc-toolbar-chunk:nth-child(2) { width: 100%; order: -1; text-align: center; }
  .fc .fc-toolbar-title { font-size: 15px; }
  .modal-backdrop { padding: 8px; align-items: end; }
  .modal-card, .admin-panel { max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal-header { padding: 18px; }
  .booking-form { padding: 18px; grid-template-columns: 1fr; }
  .span-2 { grid-column: 1; }
  .recurrence-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-wrap: wrap; }
  .admin-panel { min-height: 88vh; display: block; }
  .admin-tabs { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-tabs button { width: auto; margin: 0 5px 0 0; white-space: nowrap; }
  .admin-content { padding: 18px; }
  .user-form { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 12px 1fr; }
  .audit-row details { grid-column: 2; max-width: 100%; }
  .audit-search { flex-wrap: wrap; }
  .audit-search input { flex-basis: 100%; }
  .auth-card { padding: 36px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid article { min-height: 76px; }
  .weekday-picker { justify-content: space-between; }
  .weekday-picker button { width: 32px; height: 32px; }
}

