/* Design notes (frontend-design pass, 2026-11-14)
   Subject: a crepe shop's back-of-house. Audience: owner and part-timers on phones.
   Palette, named after what is on the counter:
     whipped cream  #ffffff  every surface people read from
     steel counter  #eef1f6  the ground behind the surfaces (cool, not cream)
     blueberry      #1b2340  ink, and #2b3fa8 for anything you can press
     strawberry     #c2183a  reserved for "act now"; nothing decorative is red
     banana         #fff1c2  "this week"      mint  #0f7a5c  "fine"
   One typeface family: rounded gothic where the phone has one (iPhone), the
   universal-design gothic elsewhere. Nothing is set below 1rem; the text-size
   setting scales the root so every view grows together.
   The one loud element is the kitchen ticket at the top of ひとこと and the
   済 stamp on finished tasks; everything else stays quiet. Light only: the
   client finds dark dashboards hard to read. */
:root {
  color-scheme: light;
  --bg: #eef1f6;
  --surface: #ffffff;
  --ink: #1b2340;
  --ink-2: #4a5170;
  --line: #d3d9e6;
  --soft: #eef1f6;           /* chips, quiet fills */
  --brand: #2b3fa8;          /* shop name, active tab */
  --action: #2b3fa8;         /* buttons and links (8.6:1 on white) */
  --action-ink: #ffffff;
  --mark: #2a78d6;           /* data marks */
  --mark-soft: #b7d3f6;      /* de-emphasised marks */
  --track: #dfe5f2;          /* meter track */
  --bad: #a5132f;   --bad-bg: #fde8ec;   --bad-mark: #c2183a;
  --warn: #6f4a00;  --warn-bg: #fff1c2;  --warn-mark: #e0a100;
  --good: #0b5f47;  --good-bg: #e0f3ec;  --good-mark: #0f7a5c;
  --info: #24356f;  --info-bg: #e6ebfa;
  --stamp: #d8432b;          /* hanko vermilion, used only by the 済 stamp */
  --radius: 12px;
  --tap: 3rem;               /* minimum touch target */
  font-size: 100%;
}
:root.ts-l { font-size: 118.75%; }
:root.ts-xl { font-size: 137.5%; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 1.0625rem; line-height: 1.6; font-feature-settings: "palt";
  padding-bottom: calc(var(--tap) + 2rem + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.3; }
h2 { font-size: 1.25rem; line-height: 1.35; }
h3 { font-size: 1.0625rem; }
a { color: var(--action); }
.num, .big { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------ chrome */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .625rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;   /* above the tab bar (5), so the open menu is never covered */
}
.top-id { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.top-id strong { color: var(--brand); font-size: 1.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; min-height: var(--tap); min-width: var(--tap); padding: 0 .875rem;
  display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); width: min(22rem, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(27 35 64 / .22); padding: 1rem; display: grid; gap: 1rem;
  max-height: calc(100vh - 5.5rem); max-height: calc(100dvh - 5.5rem); overflow-y: auto; overscroll-behavior: contain;
}
.menu-panel h3 { margin-bottom: .375rem; }
.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .5rem 1rem; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line);
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; overflow-x: auto;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1 0 auto; min-height: calc(var(--tap) + .5rem); min-width: 2.75rem; padding: 0 .3125rem;
  display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 1rem;
  color: var(--ink-2); font-weight: 600; border-top: 4px solid transparent; white-space: nowrap;
}
.tabs a[aria-current="page"] { color: var(--brand); border-top-color: var(--brand); background: var(--soft); }
/* Wide screens: tabs move under the header instead of floating over the page. */
@media (min-width: 48rem) {
  body { display: flex; flex-direction: column; padding-bottom: 2rem; }
  .top { order: 0; position: relative; } .preview-bar { order: 1; }  /* relative, not static: z-index must still apply */
  .tabs { order: 2; position: sticky; top: 0; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); }
  .tabs a { flex: 0 0 auto; padding: 0 1.5rem; border-top: 0; border-bottom: 4px solid transparent; }
  .tabs a[aria-current="page"] { border-bottom-color: var(--brand); }
  body > main, body > .wall { order: 3; width: 100%; }
}
main { max-width: 44rem; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
main.wide { max-width: 72rem; }
.page-head { display: grid; gap: .25rem; }

/* ----------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap);
  padding: 0 1.125rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--mark); outline-offset: 2px;
}
label { font-weight: 600; display: grid; gap: .375rem; }
input[type="text"], input[type="password"], select, textarea {
  font: inherit; min-height: var(--tap); padding: .5rem .75rem; border: 1px solid #7c84a3; border-radius: 10px;
  background: var(--surface); color: var(--ink); width: 100%;
}
textarea { min-height: 5.5rem; resize: vertical; }
form.stack { display: grid; gap: .875rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.125rem; display: grid; gap: .625rem; align-content: start;
}
/* Only "act now" changes the card itself; the other states are carried by their pill. */
.card > *, main > * { min-width: 0; }  /* grid children may shrink, so wide tables scroll inside instead of widening the page */
.card.tone-bad { border: 2px solid var(--bad-mark); }

/* The kitchen ticket: torn top and bottom edges, dashed rules between lines. */
.ticket {
  border: 0; border-radius: 0; padding: 1.75rem 1.125rem 1.5rem;
  -webkit-mask: radial-gradient(circle at 7px 0, #0000 5.5px, #000 6px) -7px 0 / 14px 51% repeat-x,
                radial-gradient(circle at 7px 100%, #0000 5.5px, #000 6px) -7px 100% / 14px 51% repeat-x;
          mask: radial-gradient(circle at 7px 0, #0000 5.5px, #000 6px) -7px 0 / 14px 51% repeat-x,
                radial-gradient(circle at 7px 100%, #0000 5.5px, #000 6px) -7px 100% / 14px 51% repeat-x;
}
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.ticket .rows > li, .ticket .rows > li:first-child { border-top: 2px dashed var(--line); }
.pill {
  display: inline-flex; align-items: center; gap: .375rem; padding: .125rem .75rem .125rem .5rem;
  border-radius: 999px; font-weight: 700; width: fit-content;
}
.pill::before {
  content: attr(data-icon); display: inline-grid; place-items: center; width: 1.375rem; height: 1.375rem;
  border-radius: 50%; color: #fff; font-size: 1rem; line-height: 1;
}
.pill.bad { background: var(--bad-bg); color: var(--bad); }    .pill.bad::before { background: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.warn::before { background: var(--warn); }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.good::before { background: var(--good); }
.pill.info { background: var(--info-bg); color: var(--info); } .pill.info::before { background: var(--info); }
.lead { font-size: 1.3125rem; line-height: 1.55; font-weight: 500; }
.lead b { font-weight: 800; white-space: nowrap; }
.big { font-size: 2.75rem; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.chips li { padding: .25rem .75rem; border-radius: 8px; background: var(--soft); font-weight: 600; }
.notice { padding: .75rem 1rem; border-radius: 12px; background: var(--info-bg); color: var(--info); }
.notice.error { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--good-bg); color: var(--good); }

/* ------------------------------------------------------------- meters */
.meter { height: .875rem; border-radius: 999px; background: var(--track); position: relative; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--mark); min-width: .25rem; }
.meter.bad > i { background: var(--bad-mark); }
.meter.warn > i { background: var(--warn-mark); }
.meter.good > i { background: var(--good-mark); }
.meter-wrap { position: relative; padding-top: .25rem; }
.pace { position: absolute; top: 0; bottom: -.25rem; width: 3px; background: var(--ink); border-radius: 2px; }
.rows { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; }
.rows > li { padding: .75rem 0; border-top: 1px solid var(--line); display: grid; gap: .375rem; }
.rows > li:first-child { border-top: 0; }
.rows > li.split { display: flex; }
.split { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.split > :last-child { text-align: right; }
.name { font-weight: 700; font-size: 1.125rem; }

/* ------------------------------------------------------------- charts */
.bars { display: flex; align-items: flex-end; gap: .375rem; height: 11rem; position: relative; padding-top: 1.75rem; }
.bars .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; position: relative; }
.bars .bar { width: 72%; max-width: 3rem; background: var(--mark-soft); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .col.latest .bar { background: var(--mark); }
.bars .val { font-weight: 700; white-space: nowrap; line-height: 1.2; background: var(--surface); padding: 0 .25rem; position: relative; z-index: 1; }
.bars-x { display: flex; gap: .375rem; border-top: 1px solid var(--ink-2); padding-top: .25rem; }
.bars-x span { flex: 1; text-align: center; min-width: 0; }
.bars-x .latest { font-weight: 800; }
.avgline { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--ink-2); pointer-events: none; }
.spark { width: 100%; height: 3.5rem; display: block; }
.spark polyline { fill: none; stroke: var(--mark); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .5rem .5rem 0; border-top: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; } td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
details.more > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--action); font-weight: 600; }

/* ------------------------------------------------- data source diagram */
.schema { display: block; font-size: 1rem; }
.schema text { fill: var(--ink); font-size: 16px; }
.schema .col-head { font-weight: 800; font-size: 17px; }
.schema .node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.schema .node.source rect { fill: var(--info-bg); stroke: var(--action); }
.schema .node.app rect { fill: var(--soft); stroke-dasharray: 5 4; }
.schema .node-name { font-weight: 800; }
.schema .node-sub { fill: var(--ink-2); }
.schema .rule { stroke: var(--line); stroke-width: 1.5; }
.schema .col.key { font-weight: 800; }
.schema .origin { fill: var(--ink-2); font-weight: 400; }
a.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.schema .flow, .legend .flow { fill: none; stroke: var(--mark); stroke-width: 2; }
.schema .link, .legend .link { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 6 4; }
.arrow-flow { fill: var(--mark); } .arrow-link { fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: 0; margin: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: .5rem; }
details.more > summary { flex-wrap: wrap; column-gap: .75rem; padding: .25rem 0; }
details.more > summary strong { color: var(--ink); }
.wide-table { min-width: 68rem; } .mid-table { min-width: 44rem; }
.wide-table td, .wide-table th { padding-right: 1rem; }
.wide-table .r, .mid-table .r { white-space: nowrap; }
td a { display: inline-flex; align-items: center; min-height: var(--tap); min-width: var(--tap); }
.keymark { display: inline-block; padding: 0 .5rem; border-radius: 6px; background: var(--info-bg); color: var(--info); font-weight: 700; }

/* -------------------------------------------------------------- tasks */
.task { display: grid; grid-template-columns: auto 1fr; gap: .875rem; align-items: start; }
.task .tick {
  width: var(--tap); height: var(--tap); border-radius: 12px; border: 2px solid #5d6585; background: var(--surface);
  font-size: 1.5rem; font-weight: 800; color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
}
/* Finished: stamped 済, the way a slip is marked done in a Japanese shop. */
.task.done .tick {
  background: transparent; border: 3px solid var(--stamp); border-radius: 50%; color: var(--stamp);
  font-size: 1.375rem; transform: rotate(-9deg);
}
.task.done .task-text { color: var(--ink-2); text-decoration: line-through; }
.task-text strong { font-size: 1.1875rem; }
.done-by { color: var(--good); font-weight: 700; text-decoration: none; display: inline-block; }
.rows > li > .pill { margin-bottom: .125rem; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------- numbers grid */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 40rem) { .span-2 { grid-column: auto; } }
.tile .delta { font-weight: 700; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }

/* ------------------------------------------------------------ monitor */
body.monitor { padding-bottom: 0; }
body.monitor .top, body.monitor .tabs { display: none; }
.wall { min-height: 100vh; padding: 1.25rem; display: grid; gap: 1.25rem; grid-template-rows: auto 1fr; font-size: clamp(1.125rem, min(1.9vw, 2.5vh), 2.75rem); }  /* sized so one TV screen holds everything */
.wall-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.wall-head h1 { font-size: 1.6em; color: var(--brand); }
.wall-clock { font-size: 2.2em; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.wall-grid { display: grid; gap: 1.25rem; grid-template-columns: 1.25fr 1fr; align-items: start; }
.wall-side { display: grid; gap: 1.25rem; }
.wall .rows > li { padding: .45em 0; }
@media (max-width: 56rem) { .wall-grid { grid-template-columns: 1fr; } }
.wall .card { padding: 1.1em; gap: .6em; }
.wall h2 { font-size: 1.15em; }
.wall .big { font-size: 2.6em; }
.wall .name { font-size: 1.15em; }
.wall .pill::before { width: 1.3em; height: 1.3em; font-size: .85em; }

/* ------------------------------------------------------------ gallery */
/* Live, scaled-down previews of the real views on the vote page (not clickable). */
.preview { height: 13rem; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); position: relative; }
.preview iframe { width: 200%; height: 26rem; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; }
.preview-wide iframe { width: 400%; height: 52rem; transform: scale(.25); }
body.embed { padding-bottom: 0; }
body.embed .top, body.embed .tabs, body.embed .preview-bar { display: none; }
.btn.chosen { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: min(26rem, 100%); padding: 1.5rem; gap: 1rem; }
