/* Ginza CRM. The look follows the Copilot CRM screens (Guestbook,
   Reservations): the same token names and values as branding.py's derived
   default palette (light, with dark when the phone or computer is in dark
   mode), and the same components: the 52px bar, the big top tabs, .hbtn and
   .hbtn-gold buttons, section bands, pills. Colours come only from tokens,
   so a later brand switch changes this file's :root and nothing else. */
:root {
  --ink:#FFFFFF; --ink-raised:#F0F0F0; --ink-high:#E0E0E0; --ink-line:#CCCCCC;
  --rice:#16181D; --rice-dim:#494B4F; --rice-faint:#646568;
  --kin:#2563EB; --kin-lo:#D8E3FB; --kin-deep:#2055CA; --kin-text:#2159D4; --accent-ink:#F3F3F4;
  --gold:#C9A64A; --gold-ink:#16181D; --gold-deep:#AD8F40; --gold-text:#6F5B29;
  --urushi:#DC2626; --urushi-lo:#F9D8D8; --urushi-text:#DC2626; --urushi-ink:#FFFFFF; --urushi-on-high:#BB2020;
  --matcha:#16A34A; --matcha-lo:#D5EEDE; --matcha-text:#12823B;
  --amber:#D97706; --amber-lo:#F8E7D2; --amber-text:#985304;
  --info:#2563EB; --info-lo:#D8E3FB; --info-text:#2159D4;
  --ui:"Helvetica Neue", Roboto, system-ui, -apple-system, sans-serif; --r:3px; --pad:10px;
  --scrim: rgba(10,7,5,.55);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink:#121212; --ink-raised:#202020; --ink-high:#2E2E2E; --ink-line:#414141;
    --rice:#FFFFFF; --rice-dim:#CBCBCB; --rice-faint:#A5A5A5;
    --kin:#2563EB; --kin-lo:#152139; --kin-deep:#2055CA; --kin-text:#719AF2; --accent-ink:#FFFFFF;
    --gold:#D9B968; --gold-ink:#16181D; --gold-deep:#C4A558; --gold-text:#D9B968;
    --urushi:#F87171; --urushi-lo:#3B2323; --urushi-text:#F87171; --urushi-ink:#16181D; --urushi-on-high:#F87171;
    --matcha:#4ADE80; --matcha-lo:#1C3726; --matcha-text:#4ADE80;
    --amber:#FBBF24; --amber-lo:#3A2E14; --amber-text:#FBBF24;
    --info:#60A5FA; --info-lo:#202C3C; --info-text:#60A5FA;
    --scrim: rgba(0,0,0,.65);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ink); color: var(--rice); font-family: var(--ui); font-size: 14px;
  line-height: 1.35; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--kin); outline-offset: 2px; }
[hidden] { display: none !important; }
.label { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--rice-dim); font-weight: 700; }
.muted { color: var(--rice-dim); }
.small { font-size: 12px; }
.error { color: var(--urushi-on-high); }
.gold-note { background: var(--ink-raised); border-left: 3px solid var(--gold); padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.field .gold-note { margin: 2px 0 0; }
.resv-deposit { margin-top: 8px; }
.done { color: var(--matcha-text); font-weight: 700; }

/* ---- the bar and the top tabs (Copilot header, CRM's .resv-toptabs) ---- */
.bar { display: flex; align-items: center; gap: 14px; padding: 0 12px; height: 52px;
  background: var(--ink-raised); border-bottom: 1px solid var(--ink-line); }
.brand { font-size: 13px; font-weight: 700; white-space: nowrap; }
.brand .lead { color: var(--rice-dim); }
.brand .crm { color: var(--kin-text); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--rice-dim); font-size: 12px; }
.link { border: 0; background: none; color: var(--kin-text); padding: 0; font-size: 12px; font-weight: 600; }
/* The gear (plan F2): a 44 px target with a 26 px ⚙, for every signed-in role; its menu opens under it, right-aligned,
   and stays inside the window at 384 px. Each item is a 44 px row. */
.who { position: relative; }
.gear { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 0; background: none; color: var(--kin-text); font-size: 26px; line-height: 1; opacity: .75; }
.gear:hover, .gear.on, .gear[aria-expanded=true] { opacity: 1; }
.menu { position: absolute; top: 100%; right: 0; z-index: 20; min-width: 200px; max-width: calc(100vw - 16px);
  display: flex; flex-direction: column; padding: 6px 0; border: 1px solid var(--ink-line); border-radius: 10px;
  background: var(--ink-raised); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.menu[hidden] { display: none; }
.menu-item { min-height: 44px; padding: 0 16px; border: 0; background: none; color: var(--rice); text-align: left;
  font-size: 15px; font-weight: 600; }
.menu-item[hidden] { display: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--ink-high); }
.subtabs { padding-top: 8px; }
.tabs { display: flex; gap: 8px; padding: 12px 12px 0; }
.tabs button { flex: 1; font-size: 16px; font-weight: 800; padding: 11px 10px; border-radius: 10px;
  border: 1px solid var(--ink-line); background: var(--ink-raised); color: var(--rice); position: relative; }
.tabs button.on { background: var(--kin); border-color: var(--kin); color: var(--accent-ink); }
.pill { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; border-radius: 999px;
  padding: 3px 8px; background: var(--ink-high); color: var(--rice); display: inline-block; }
.tabs .count { margin-left: 6px; font-size: 11px; background: var(--urushi); color: var(--urushi-ink);
  border-radius: 999px; padding: 1px 7px; vertical-align: 2px; }
.tabs button.on .count { background: var(--accent-ink); color: var(--kin); }
.pill.all { background: var(--info-lo); color: var(--info-text); }
.pill.ginza { background: var(--kin-lo); color: var(--kin-text); }
.pill.deli { background: var(--amber-lo); color: var(--amber-text); }
.pill.live { background: var(--matcha-lo); color: var(--matcha-text); }
.pill.off { background: var(--ink-raised); color: var(--rice-faint); }
.pill.wait { background: var(--amber-lo); color: var(--amber-text); }
.pill.no { background: var(--urushi-lo); color: var(--urushi-text); }

/* ---- buttons (.hbtn / .hbtn-gold) and inputs (.search) ---- */
.hbtn { background: var(--ink); border: 1px solid var(--ink-line); border-radius: var(--r); padding: 8px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; min-height: 36px; }
.hbtn:hover { background: var(--ink-high); border-color: var(--rice-faint); }
.hbtn.warn { color: var(--urushi-text); }
.hbtn[disabled], .hbtn-gold[disabled] { opacity: .38; cursor: default; }
.hbtn-gold { background: var(--gold); border: none; color: var(--gold-ink); font-weight: 800; border-radius: var(--r);
  padding: 9px 16px; font-size: 13px; letter-spacing: .02em; min-height: 40px; }
.hbtn-gold:hover { background: var(--gold-deep); }
.wide { width: 100%; }
.search, .field input, .field select, .field textarea, textarea.search, select.search {
  background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--r); padding: 8px 10px;
  color: var(--rice); font-size: 13px; min-height: 36px; width: 100%; }
.search::placeholder, textarea::placeholder { color: var(--rice-faint); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > .label { color: var(--kin-text); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- sign-in and dialogs (Copilot .close-modal) ---- */
.login { flex: 1; display: grid; place-items: center; padding: 16px; }
.dialog { width: 420px; max-width: 100%; background: var(--ink-raised); border: 1px solid var(--ink-line);
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.dialog-head { padding: 14px 16px; border-bottom: 1px solid var(--ink-line); font-size: 15px; font-weight: 800; }
.dialog-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body p { margin: 0; }
.dialog-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--ink-line); }
.dialog-actions .hbtn, .dialog-actions .hbtn-gold { flex: 1; min-height: 42px; }
.overlay { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; z-index: 40; }
.steps { margin: 0; padding-left: 20px; }
.key { display: block; font: 700 16px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .05em;
  background: var(--ink); border: 1px dashed var(--ink-line); border-radius: var(--r); padding: 10px; word-break: break-all; }

/* ---- pages ---- */
.page { flex: 1; overflow: auto; padding: 12px; max-width: 980px; width: 100%; margin: 0 auto; }
.sec { border: 1px solid var(--ink-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: var(--ink-raised); }
.sec-head { display: flex; justify-content: space-between; align-items: center; background: var(--kin); color: var(--accent-ink);
  font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 9px 14px;
  margin: -12px -14px 10px; border-radius: 9px 9px 0 0; }
.sec-head.gold { background: var(--gold); color: var(--gold-ink); }
.empty { max-width: 560px; margin: 40px auto; color: var(--rice-dim); text-align: center; }
.empty h2 { color: var(--rice); font-size: 18px; }
.warning { background: var(--amber-lo); color: var(--amber-text); padding: 8px 14px; font-size: 13px; font-weight: 600; }

/* ---- teach ---- */
.teach { flex: 1; display: grid; grid-template-columns: 250px 1fr; min-height: 0; padding-top: 12px; }
.side { border-right: 1px solid var(--ink-line); padding: 0 12px 12px; overflow: auto; }
.sessions { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--ink-line); border-radius: 10px; overflow: hidden; }
.sessions button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--ink-line); background: var(--ink);
  padding: 9px 12px; font-size: 13px; font-weight: 500; }
.sessions li:last-child button { border-bottom: 0; }
.sessions button.on { background: var(--ink-high); font-weight: 800; box-shadow: inset 4px 0 0 var(--kin); }
.sessions small { display: block; color: var(--rice-faint); font-weight: 400; font-size: 11px; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; overflow: auto; padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 720px; padding: 9px 12px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg.teacher { align-self: flex-end; background: var(--kin-lo); }
.msg.ai { align-self: flex-start; background: var(--ink-raised); border: 1px solid var(--ink-line); }
.msg small { display: block; color: var(--rice-dim); font-size: 11px; font-weight: 700; margin-bottom: 2px; }
.msg.upload { align-self: flex-end; background: none; border: 1px dashed var(--ink-line); color: var(--rice-dim); }
.msg.error { color: var(--urushi-text); }
.msg.guest { align-self: flex-end; background: var(--kin-lo); }
.msg.staff { align-self: flex-start; background: var(--ink-raised); border: 1px solid var(--kin); }
.msg .did { display: block; color: var(--rice-faint); font-size: 11px; font-style: italic; margin-top: 4px; }
.ib-thread { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ib-flag { display: inline-block; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px; margin-left: 6px;
  background: var(--urushi-text); color: var(--ink); }
.ib-flag.taken { background: var(--kin-lo); color: var(--rice); }
.ib-last { display: block; color: var(--rice-faint); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%; }
.gb-name.ib { flex-direction: column; align-items: flex-start; gap: 2px; }
.ib-boxes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.ib-box { display: inline-flex; align-items: center; gap: 2px; }
.ib-box.on { outline: 2px solid var(--kin-lo); }
.ib-count { opacity: .8; }
.ib-handoff { border: 1px solid var(--urushi-text); border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 13px; }
.composer { border-top: 1px solid var(--ink-line); padding: 10px 14px; background: var(--ink-raised); display: grid; gap: 8px; }
.composer .row { justify-content: flex-start; }
.composer #send { margin-left: auto; }
.file { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- lesson cards ---- */
.lesson { width: min(720px, 100%); border: 1px solid var(--ink-line); border-radius: 10px; background: var(--ink-raised);
  padding: 12px 14px; display: grid; gap: 8px; }
.log .lesson { align-self: flex-start; border-color: var(--gold); }
.lesson-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lesson-head b { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-text); margin-right: 4px; }
.lesson textarea { resize: vertical; }
.lesson.decided textarea, .lesson textarea[readonly] { border-color: transparent; background: transparent; resize: none; padding-left: 0; }
.lesson .why, .meta { font-size: 12px; color: var(--rice-dim); }
.lesson.off { opacity: .6; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.history { font-size: 12px; color: var(--rice-dim); margin: 0; padding-left: 18px; }
.tools { display: flex; gap: 8px; margin-bottom: 8px; }
.tools .search { flex: 1; }
.tools select.search { width: auto; flex: 0 0 auto; }

/* ---- users ---- */
table.users { width: 100%; border-collapse: collapse; background: var(--ink); border: 1px solid var(--ink-line); border-radius: 10px; overflow: hidden; }
table.users th, table.users td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--ink-line); vertical-align: top; font-size: 13px; }
table.users th { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--rice-faint); font-weight: 700; background: var(--ink-raised); }
table.users tr.off { opacity: .55; }
table.users .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

@media (max-width: 720px) {
  .bar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px 12px; }
  .who { font-size: 12px; }
  .who .role { display: none; }
  .tabs { overflow-x: auto; padding: 8px 8px 0; }
  .tabs button { font-size: 13px; padding: 9px 10px; flex: 0 0 auto; }
  .teach { grid-template-columns: 1fr; }
  .side { display: none; }
  table.users thead { display: none; }
  table.users tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--ink-line); }
  table.users td { border: 0; padding: 2px 10px; }
}
@media (min-width: 1200px) { .tabs button { font-size: 18px; } }

.gap-top { margin-top: 8px; }
.narrow-input { max-width: 260px; }
input[type=radio], input[type=checkbox] { accent-color: var(--kin); }
#settings-view label { display: inline-flex; gap: 6px; align-items: center; }
/* The booking page setup and the campaign links moved here from Reservations (25 Nov): their fields stay stacked. */
#resv-config label.field, #camp-box label.field { display: flex; align-items: stretch; gap: 5px; }

