:root {
  --ink: #1a1512;
  --muted: #6b5f56;
  --line: rgba(26, 21, 18, 0.1);
  --soft: #f6f1eb;
  --panel: #fffdf9;
  --lime: #c6f135;
  --accent: #2d6a4f;
  --accent-soft: #d8f3dc;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #166534;
  --radius: 16px;
  --font-display: "Avenir Next", "Segoe UI", "Helvetica Neue", "PingFang TC", "Noto Sans TC", sans-serif;
  --font-body: "PingFang TC", "Hiragino Sans GB", "Noto Sans TC", "Segoe UI", sans-serif;
  --shadow: 0 20px 48px rgba(26, 21, 18, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.th-foodie-crm {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--soft);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
button, input { font: inherit; }

/* ===== Login ===== */
body.th-foodie-crm-login { background: #14110f; color: #fff; }
.login-stage {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-visual {
  position: relative;
  overflow: hidden;
  padding: 56px clamp(28px, 5vw, 64px);
  background-color: #14110f;
  background-image:
    linear-gradient(180deg, rgba(20, 17, 15, 0.55) 0%, rgba(20, 17, 15, 0.25) 40%, rgba(20, 17, 15, 0.72) 100%),
    var(--login-hero);
  background-size: cover;
  background-position: center;
}
.visual-copy {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin-top: 16vh;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}
.visual-copy .eyebrow {
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--lime);
  margin: 0 0 12px;
}
.visual-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  margin: 0 0 14px;
  font-weight: 700;
}
.visual-lede {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  line-height: 1.55;
  max-width: 36em;
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: #faf7f2;
  color: var(--ink);
}
.login-card {
  width: min(100%, 400px);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
  border: 1px solid var(--line);
}
.login-logo { display: block; margin-bottom: 18px; height: auto; }
.login-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 22px;
}
.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.login-form label {
  display: block;
  margin-bottom: 14px;
}
.login-form label > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
}
.login-form .remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.login-form .remember input { width: auto; }
.btn-primary {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #000; }
.btn-primary:disabled { opacity: 0.65; cursor: wait; }
.form-msg {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}
.login-foot {
  margin: 18px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.login-foot a { color: var(--accent); text-decoration: underline; }

/* ===== App shell ===== */
body.th-foodie-crm-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #1a1512;
  color: #f5f0ea;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand img { display: block; filter: brightness(0) invert(1); height: auto; }
.side-project {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(198, 241, 53, 0.1);
  border: 1px solid rgba(198, 241, 53, 0.22);
}
.side-project-label {
  display: block;
  font-size: 11px;
  color: rgba(245, 240, 234, 0.55);
  margin-bottom: 2px;
}
.side-project strong {
  display: block;
  font-size: 14px;
  color: #fff;
}
.side-project-switch {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--lime);
  text-decoration: none;
}
.side-project-switch:hover { text-decoration: underline; }
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.project-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.project-card h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 17px;
}
.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.project-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar nav a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: rgba(245, 240, 234, 0.82);
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(198, 241, 53, 0.14);
  color: #fff;
}
.side-user {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side-user strong { display: block; font-size: 14px; }
.side-user span {
  display: block;
  font-size: 11.5px;
  color: rgba(245, 240, 234, 0.55);
  margin-top: 2px;
  word-break: break-all;
}
.btn-ghost {
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn-ghost:hover { border-color: var(--lime); color: var(--lime); }

.main { min-width: 0; }
.top {
  padding: 28px 28px 8px;
}
.top .eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent);
}
.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
}
.content { padding: 12px 28px 40px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 8px 28px rgba(26, 21, 18, 0.04);
}
.panel-head { margin-bottom: 16px; }
.panel-head.row-between {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-family: var(--font-display);
}
.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  max-width: 52em;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  background: #fff;
  color: var(--muted);
}
.chip.is-active,
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.btn-text {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  display: inline;
}
.btn-text:hover { color: var(--ink); }
.panel-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.btn-primary-inline {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
}
.btn-primary-inline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.empty {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.data-table th.th-sortable a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}
.data-table th.th-sortable a:hover {
  color: var(--accent);
}
.data-table th.th-sortable .sort-ind::after {
  content: "⇅";
  font-size: 11px;
  opacity: 0.35;
}
.data-table th.th-sortable.is-asc .sort-ind::after {
  content: "↑";
  opacity: 1;
  color: var(--accent);
}
.data-table th.th-sortable.is-desc .sort-ind::after {
  content: "↓";
  opacity: 1;
  color: var(--accent);
}
.data-table th.th-sortable.is-active a {
  color: var(--accent);
}
.data-table .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.social-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.col-social {
  min-width: 118px;
  max-width: 180px;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 12.5px;
  width: fit-content;
  max-width: 100%;
}
.social-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.social-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 9.5em;
}
.social-handle::before {
  content: "@";
  opacity: 0.55;
}
.social-empty {
  color: var(--muted);
  font-size: 13px;
}
.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex-shrink: 0;
}
.social-ig .social-icon {
  background: linear-gradient(135deg, #f58529, #dd2a7b 50%, #8134af);
  color: #fff;
}
.social-threads .social-icon {
  background: #1a1512;
  color: #fff;
}
.social-icon-at {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
}
.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 128px;
}
.btn-action {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
}
.btn-action:disabled {
  opacity: 0.6;
  cursor: wait;
}
.btn-approve {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-approve:hover { background: #245a43; }
.btn-reschedule {
  background: #fff;
  color: var(--accent);
  border-color: rgba(47, 109, 84, 0.4);
}
.btn-reschedule:hover { background: #eef7f2; }
.btn-reject {
  background: #fff;
  color: var(--danger);
  border-color: rgba(185, 28, 28, 0.35);
}
.btn-reject:hover { background: #fde8e8; }
.btn-pending {
  background: #fff;
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.35);
}
.btn-pending:hover { background: #fff4e0; }
.btn-detail {
  background: #fff;
  color: var(--muted);
  border-color: var(--line);
}
.btn-detail:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.detail-box {
  margin-top: 6px;
  padding: 10px;
  background: var(--soft);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 280px;
}
.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  background: #eee;
}
.status-pill.is-pending { background: #fff4e0; color: var(--warn); }
.status-pill.is-approved { background: #e7f6ea; color: var(--ok); }
.status-pill.is-rejected { background: #fde8e8; color: var(--danger); }
.status-pill.is-wa-sent { background: #e8f4ff; color: #1d4ed8; }
.status-pill.is-opt-in { background: #e7f6ea; color: var(--ok); }
.status-pill.is-opt-out { background: #f1f1f1; color: #666; }
.status-pill.is-fit-open { background: #e7f6ea; color: var(--ok); }
.status-pill.is-fit-full { background: #fff4e0; color: var(--warn); }
.status-pill.is-fit-none { background: #f1f1f1; color: #666; }

.col-session-fit .fit-dates {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
}
.col-session-fit .fit-dates li {
  margin: 0.15rem 0;
  line-height: 1.35;
}
.col-session-fit .fit-msg {
  margin-top: 0.25rem;
  font-weight: 600;
  font-size: 0.92em;
}
tr.is-fit-open td.col-session-fit {
  box-shadow: inset 3px 0 0 var(--ok);
}
tr.is-fit-full td.col-session-fit {
  box-shadow: inset 3px 0 0 var(--warn);
}
.wa-sent-badge { margin-top: 6px; }
.wa-sent-badge.is-empty { display: none; }
.wa-sent-badge:not([hidden]) { display: block; }

/* Approve modal */
body.th-modal-open { overflow: hidden; }
.th-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.th-modal[hidden] { display: none !important; }
.th-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 18, 0.45);
}
.th-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.th-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 0;
}
.th-modal-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-display);
}
.th-modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}
.th-modal-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.th-modal-close {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
}
.th-modal-close:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.th-modal-body { padding: 16px 20px; }
.th-modal-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.th-modal-error {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}
.th-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
  flex-wrap: wrap;
}
.approve-date-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.approve-date-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.approve-date-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.approve-date-option.is-disabled {
  opacity: 0.62;
  cursor: not-allowed;
  background: #f7f4ef;
}
.approve-date-option input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.approve-date-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.approve-date-main strong {
  font-size: 14px;
}
.approve-badge {
  display: inline-block;
  width: fit-content;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
}
.approve-badge.is-free {
  background: #e7f6ea;
  color: var(--ok);
}
.approve-badge.is-taken {
  background: #fde8e8;
  color: var(--danger);
}
.approve-badge.is-blocked {
  background: #fff4e0;
  color: var(--warn);
}
.approve-loading,
.approve-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.reject-reason-label {
  display: block;
  margin: 0 0 8px;
}
.reject-reason-label > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.reject-reason-label textarea {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  line-height: 1.45;
}
.reject-reason-label textarea:focus {
  outline: 2px solid rgba(45, 106, 79, 0.35);
  border-color: var(--accent);
}
.th-modal-char {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.btn-reject-confirm {
  background: #b91c1c !important;
  color: #fff !important;
  border-color: #b91c1c !important;
}
.btn-reject-confirm:disabled {
  opacity: 0.45;
}
.reject-reason-preview {
  margin-top: 4px;
  max-width: 14rem;
  color: var(--danger);
  line-height: 1.35;
}

/* ===== Public check page ===== */
body.th-foodie-check {
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(198, 241, 53, 0.18), transparent 55%),
    linear-gradient(165deg, #f7f2ea 0%, #efe6da 48%, #f4efe6 100%);
  min-height: 100vh;
}
.check-stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 40px;
}
.check-card {
  width: min(100%, 440px);
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
}
.check-eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
  color: #5a7a1f;
}
.check-card h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(22px, 4.5vw, 28px);
  line-height: 1.2;
}
.check-lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.check-form label {
  display: block;
  margin-bottom: 14px;
}
.check-form label > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.check-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.check-form input:focus {
  outline: 2px solid rgba(45, 106, 79, 0.3);
  border-color: var(--accent);
}
.check-form .btn-primary {
  width: 100%;
}
.check-msg {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.check-msg.is-error {
  background: #fde8e8;
  color: var(--danger);
}
.check-msg.is-empty {
  background: var(--soft);
  color: var(--muted);
}
.check-results {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}
.check-results-head {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.check-result {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 12px;
  background: #fff;
}
.check-result.is-rejected {
  border-color: rgba(185, 28, 28, 0.22);
  background: #fff8f8;
}
.check-result.is-approved {
  border-color: rgba(22, 101, 52, 0.22);
  background: #f5fbf6;
}
.check-result.is-pending {
  border-color: rgba(180, 83, 9, 0.22);
  background: #fffaf3;
}
.check-result-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.check-project {
  font-size: 13px;
  color: var(--muted);
}
.check-meta,
.check-slot {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.check-reason-label {
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  letter-spacing: 0.02em;
}
.check-message {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
}
.check-foot {
  margin: 22px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.check-foot a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Booking calendar ===== */
.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.cal-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
}
.cal-nav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.cal-month-label {
  margin: 0;
  min-width: 7.5em;
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}
.cal-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.cal-layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}
.cal-layout:has(.cal-detail[hidden]) {
  grid-template-columns: 1fr;
}
.cal-grid {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.cal-weekday {
  padding: 10px 4px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day {
  appearance: none;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  min-height: 92px;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  cursor: default;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-outside {
  background: #faf8f5;
  min-height: 92px;
  pointer-events: none;
}
.cal-day.has-booking {
  cursor: pointer;
  background: linear-gradient(180deg, #f3faf4 0%, #fff 55%);
}
.cal-day.is-session-day {
  cursor: pointer;
  background: linear-gradient(180deg, #fff8e8 0%, #fff 60%);
  box-shadow: inset 0 0 0 1px rgba(198, 146, 40, 0.28);
}
.cal-day.is-session-day.has-booking {
  background: linear-gradient(180deg, #eef9f0 0%, #fff8e8 45%, #fff 100%);
}
.cal-day.is-session-live {
  background: linear-gradient(180deg, #dff7e4 0%, #fff8e8 55%, #fff 100%);
  box-shadow: inset 0 0 0 2px rgba(46, 125, 50, 0.45);
}
.cal-day.is-session-day:hover,
.cal-day.is-session-day:focus-visible,
.cal-day.has-booking:hover,
.cal-day.has-booking:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}
.cal-session-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8a5a00;
  background: #ffe8b0;
  border-radius: 999px;
  padding: 1px 6px;
  width: fit-content;
}
.cal-day.is-session-live .cal-session-tag {
  color: #14532d;
  background: #bbf7d0;
}
.cal-capacity {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.cal-budget {
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cal-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid var(--line);
}
.cal-swatch.is-session { background: #fff8e8; border-color: #e0b34a; }
.cal-swatch.is-live { background: #dff7e4; border-color: #2e7d32; }
.cal-swatch.is-booked { background: #f3faf4; border-color: var(--accent); }
.cal-live-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #14532d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.cal-detail-meta,
.cal-detail-budget {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink);
}
.cal-detail-budget {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
}
.cal-day.is-today .cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}
.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.cal-event {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  min-width: 0;
}
.cal-event-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-time {
  font-size: 11px;
  color: var(--muted);
}
.cal-event-more {
  font-size: 11px;
  color: var(--muted);
  padding-left: 2px;
}
.cal-detail {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 8px 28px rgba(26, 21, 18, 0.04);
  position: sticky;
  top: 16px;
}
.cal-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-detail-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
}
.cal-detail .btn-ghost {
  border-color: var(--line);
  color: var(--ink);
  padding: 5px 12px;
  font-size: 12px;
}
.cal-detail .btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cal-detail-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
  margin-bottom: 10px;
}
.cal-detail-card:last-child { margin-bottom: 0; }
.cal-detail-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.cal-detail-card .sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  line-height: 1.45;
}
.cal-detail-empty {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}

@media (max-width: 900px) {
  .login-stage { grid-template-columns: 1fr; }
  .login-visual { min-height: 36vh; padding-top: 40px; }
  .visual-copy { margin-top: 4vh; }
  body.th-foodie-crm-app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .side-user { width: 100%; }
  .content, .top { padding-left: 16px; padding-right: 16px; }
  .cal-layout {
    grid-template-columns: 1fr;
  }
  .cal-day {
    min-height: 72px;
    padding: 6px 4px;
  }
  .cal-day.is-outside { min-height: 72px; }
  .cal-event-name { font-size: 11px; }
  .cal-detail {
    position: static;
  }
}
