* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --accent: #1f6f43;
  --accent-dark: #175534;
  --accent-soft: #e7f3ec;
  --line: #e3e6ea;
  --text: #22272e;
  --muted: #7a828c;
  --danger: #c0392b;
  --slot-h: 28px;
}
body { font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; color: var(--text); background: #f5f6f8; }

/* ---- 頂欄 ---- */
.topbar { display: flex; align-items: center; gap: 20px; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; white-space: nowrap; }
.brand-icon { font-size: 20px; }
.center-tabs { display: flex; gap: 6px; flex: 1; }
.center-tab { border: 1px solid var(--line); background: #fff; padding: 7px 18px; border-radius: 20px; font-size: 14px; cursor: pointer; color: var(--muted); font-family: inherit; white-space: nowrap; }
.center-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ---- 工具列 ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 4px; flex-wrap: wrap; gap: 8px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-label { font-weight: 700; font-size: 15px; }
.date-input { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: inherit; }
.hint { color: var(--muted); font-size: 13px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 14px; font-family: inherit; color: var(--text); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon { width: 34px; padding: 7px 0; font-size: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; color: #fff; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 時段表 ---- */
.grid-wrap { padding: 10px 20px 30px; overflow-x: auto; }
.grid { display: grid; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; min-width: 720px; }
.grid-head { padding: 10px 8px; text-align: center; font-weight: 700; font-size: 14px; border-bottom: 2px solid var(--line); border-left: 1px solid var(--line); background: #fafbfc; }
.grid-head .cap { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.time-col-head { border-left: none; background: #fafbfc; border-bottom: 2px solid var(--line); }
.time-cell { height: var(--slot-h); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; border-top: 1px solid transparent; transform: translateY(-7px); }
.room-col { position: relative; border-left: 1px solid var(--line); }
.slot { height: var(--slot-h); border-top: 1px solid #f0f1f3; cursor: pointer; }
.slot:nth-child(odd) { border-top: 1px solid var(--line); }
.slot:hover { background: var(--accent-soft); }
.slot.past { background: #f4f4f5; cursor: not-allowed; }
.slot.past:hover { background: #f4f4f5; }
.booking { position: absolute; left: 3px; right: 3px; background: var(--accent-soft); border: 1px solid var(--accent); border-left: 4px solid var(--accent); border-radius: 5px; padding: 3px 6px; font-size: 12px; overflow: hidden; cursor: pointer; z-index: 5; }
.booking:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.booking .b-subject { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .b-meta { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid #e74c3c; z-index: 6; pointer-events: none; }

/* ---- Modal ---- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,24,28,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.modal-head.ok { color: var(--accent); }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; font-size: 14px; line-height: 1.9; }

.form { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #444; font-weight: 600; }
.form input, .form select, .form textarea { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit; font-weight: 400; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.req { color: var(--danger); }
.chk-inline { flex-direction: row !important; align-items: center; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
/* 預約表單：加寬為兩欄式，縮短視窗高度 */
.modal-book { max-width: 920px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; align-items: start; }
.form-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.form-error { background: #fdeceb; color: var(--danger); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 18px 18px; }
.form .form-actions { padding: 4px 0 0; }

.cancel-code-box { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 15px; }
.cancel-code-box b { font-size: 20px; letter-spacing: 2px; color: var(--accent-dark); }
.small { font-size: 12px; color: var(--muted); }
.detail-agenda { margin-top: 8px; padding: 8px 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.8; }

/* 集團通訊錄挑選 */
.modal-wide { width: min(640px, 96vw); }
.dir-list { margin-top: 10px; max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.dir-section { font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 0 2px; position: sticky; top: 0; background: #fff; padding: 2px 0; }
.dir-item { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.dir-item:hover { background: #f4f8fb; }
.dir-item.sel { background: var(--accent-soft); border-color: var(--accent); }
.dir-item .dir-add { margin-left: auto; white-space: nowrap; color: var(--accent-dark); font-size: 12px; }
#dirSearch { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: inherit; font-size: 14px; }
.cancel-area { border-top: 1px solid var(--line); padding: 12px 18px 18px; }
.cancel-row { display: flex; gap: 8px; margin-top: 6px; }
.cancel-row input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: inherit; }
.my-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.my-item { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 8px 12px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .row3 { grid-template-columns: 1fr; }
}

/* ---- 手機版漢堡選單 ---- */
.m-menu-btn { display: none; font-size: 18px; }
.m-drawer-mask { position: fixed; inset: 0; background: rgba(20,24,28,.45); z-index: 60; }
.m-drawer-mask[hidden] { display: none; }
.m-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(260px, 78vw); background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,.15); display: flex; flex-direction: column; padding: 14px; gap: 4px; animation: drawerIn .2s ease; }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.m-drawer-head { font-weight: 700; padding: 10px 12px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.m-drawer-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; padding: 12px; border-radius: 8px; font-size: 15px; font-family: inherit; color: var(--text); cursor: pointer; text-decoration: none; }
.m-drawer-item:active, .m-drawer-item:hover { background: var(--accent-soft); }

/* ---- 手機專屬版型（清單式，非縮放自適應） ---- */
.grid.m-list { display: flex; flex-direction: column; gap: 12px; min-width: 0; border: none; background: transparent; border-radius: 0; overflow: visible; }
.m-room { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.m-room-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 700; font-size: 15px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.m-room-head .cap { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.m-book-btn { flex-shrink: 0; padding: 6px 14px; font-size: 13px; }
.m-slot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.m-slot:first-of-type { border-top: none; }
.m-slot:active { background: var(--accent-soft); }
.m-slot-time { color: var(--accent-dark); font-weight: 700; font-size: 13px; line-height: 1.5; white-space: nowrap; text-align: center; }
.m-slot-info { flex: 1; min-width: 0; line-height: 1.5; }
.m-slot-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-slot-arrow { color: var(--muted); font-size: 18px; }
.m-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .brand { flex: 1; }
  .brand-name { font-size: 16px; }
  .center-tabs { order: 5; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .center-tab { flex-shrink: 0; }
  .topbar .btn { padding: 7px 10px; font-size: 13px; }
  /* 次要動作收進漢堡選單，上排只留品牌＋預約＋☰ */
  #myBookingsBtn, #langBtn, .admin-link { display: none; }
  .m-menu-btn { display: inline-block; }
  .toolbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .toolbar .hint { width: 100%; }
  .grid-wrap { padding: 10px 12px 24px; }
  .form-actions { position: sticky; bottom: 0; background: #fff; padding-top: 10px; }
}
@media (max-width: 760px) {
  .form-cols { grid-template-columns: 1fr; } /* 窄螢幕（手機）維持單欄 */
}

/* ---- 管理後台 ---- */
.admin-link { text-decoration: none; font-size: 16px; }
.admin-login { display: flex; justify-content: center; padding: 80px 16px; }
.admin-login[hidden] { display: none; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.login-card h2 { font-size: 18px; }
.login-card input { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 14px; font-family: inherit; }
.admin-main { padding: 16px 20px 40px; max-width: 1100px; margin: 0 auto; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.panel h3 { font-size: 15px; margin-bottom: 8px; }
.panel-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; padding: 8px 10px; background: #fafbfc; border-bottom: 2px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: top; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.settings-grid { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #444; }
.settings-grid input:not([type=checkbox]) { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit; font-weight: 400; }
.settings-grid .chk, .chk { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 600; }
.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn-row input { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: inherit; }
.op-msg { border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-top: 8px; }
.op-msg.ok { background: var(--accent-soft); color: var(--accent-dark); }
.op-msg.err { background: #fdeceb; color: var(--danger); white-space: pre-wrap; }
.sep { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.center-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.center-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.center-box-head input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 14px; font-weight: 700; font-family: inherit; flex: 1; max-width: 280px; }
.room-row { display: flex; gap: 8px; margin-bottom: 4px; align-items: center; }
.room-row input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 14px; font-family: inherit; }
.room-row input:first-child { flex: 1; max-width: 240px; }
.room-zoom-row { display: flex; gap: 6px; align-items: center; margin: 0 0 12px 8px; }
.room-zoom-row input { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; font-family: inherit; }
.room-zoom-row input:nth-of-type(1) { width: 200px; }
.room-zoom-row input:nth-of-type(2) { flex: 1; max-width: 280px; }
code { background: #f0f1f3; border-radius: 4px; padding: 1px 5px; font-size: 12px; }
