:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1c2330; --muted: #5b6676; --line: #d9dee6;
  --accent: #1f5fbf; --accent-text: #ffffff; --error-bg: #fdecec; --error: #a4161a; --warn-bg: #fff6dc; --warn: #6b4e00;
  --ok-bg: #e5f4ea; --ok: #1d5c30; --hover: #eef1f5; --info-bg: #e6eefb; --info: #1f4f99;
  --field: #7d8796; --accent-hover: #184c99; --ring: rgba(31, 95, 191, .28);
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1d2128; --text: #e7eaf0; --muted: #a8b2c0; --line: #3a414d;
    --accent: #7fb0ff; --accent-text: #0d1117; --error-bg: #3b1518; --error: #ffb3b6; --warn-bg: #3a3010; --warn: #ffe08a;
    --ok-bg: #12301c; --ok: #a6e6b8; --hover: #262b34; --info-bg: #182a45; --info: #a9c8ff;
    --field: #6f7989; --accent-hover: #a8c8ff; --ring: rgba(127, 176, 255, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
/* BIZ UDPGothic (on Windows since 2018) is drawn for legibility; Yu Gothic UI at normal weight
   renders thin there, so it only comes last. */
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", Meiryo, "Yu Gothic UI", sans-serif; }
/* Header: title, store search and the account on one line; the menu on a line of its own below,
   always a single row (on a narrow screen it scrolls sideways and admin.js brings the current
   page into view). */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 24px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
header .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
header .brand img { display: block; }
header .brand span { color: var(--muted); font-weight: 400; }
header .find input { width: 280px; padding: 6px 12px; }
header form { display: flex; align-items: center; gap: 12px; margin: 0 0 0 auto; }
header form.find { margin: 0; }
header nav { order: 3; flex: 1 1 100%; display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; position: relative; margin: 0 -24px; padding: 2px 20px 0; scrollbar-width: thin; }
header nav a { flex: none; padding: 6px 12px 10px; color: var(--muted); text-decoration: none; box-shadow: inset 0 -3px 0 transparent; transition: color .15s, box-shadow .15s; }
header nav a:hover { color: var(--text); box-shadow: inset 0 -3px 0 var(--line); }
header nav a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }
/* Menu groups: stores, what is handed out, the setup tool itself, people. */
header nav .sep { flex: none; width: 1px; margin: 8px 8px 12px; background: var(--line); }
.who { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
a.who:hover { color: var(--accent); }
/* On a wide screen the e-mail address beside sign-out opens the account page instead. */
header nav a.account-link { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) {
  header { gap: 8px 12px; padding: 8px 16px 0; }
  /* Swiped on a touch screen, so no scroll bar over the current page's underline. */
  header nav { margin: 0 -16px; padding: 2px 12px 0; scrollbar-width: none; }
  header .who { display: none; }
  header nav a.account-link { display: inline; }
  /* Title and sign-out on the first line, the search across the second, the menu below. */
  header form:not(.find) { order: 1; margin: 0 0 0 auto; }
  header .find { order: 2; flex: 1 1 100%; }
  header .find input { width: 100%; }
}
main { max-width: 1200px; margin: 0 auto; padding: 16px 24px 48px; }
h1 { font-size: 28px; margin: 20px 0 16px; line-height: 1.4; }
h2 { font-size: 20px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); line-height: 1.4; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
::selection { background: var(--info-bg); color: var(--info); }
.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th { background: var(--bg); }
td a { text-decoration: none; }
td a:hover, tr.rowlink:hover td a { text-decoration: underline; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
tr.rowlink { cursor: pointer; }
/* The save button of a long form stays at the bottom of the window while the form is in view. */
.actions { position: sticky; bottom: 0; z-index: 1; margin: 0; padding: 12px 0; background: var(--bg); box-shadow: 0 -8px 8px -8px rgba(0, 0, 0, .15); width: 100%; }
/* Home: what needs attention, what is handed out, how much is registered. */
.todo, .status { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo a, .status a { display: grid; gap: 2px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: border-color .15s; }
.todo a { border-left: 4px solid var(--warn); }
.todo a strong { color: var(--accent); }
.todo a span { color: var(--muted); font-size: 15px; }
.status a { grid-template-columns: 6em 1fr; align-items: center; }
.todo a:hover, .status a:hover, .counts a:hover { border-color: var(--accent); }
.tiles.counts { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.tiles.counts a { justify-items: start; text-align: left; padding: 12px 16px; }
.tiles.counts a span { color: var(--muted); }
.counts a strong { font-size: 24px; line-height: 1.2; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { font-size: 14px; color: var(--muted); font-weight: 700; }
td small { color: var(--muted); }
td.ops form { display: inline-block; margin: 0 12px 0 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { padding: 8px 16px; border: 1px solid var(--field); border-radius: 6px; background: var(--panel); cursor: pointer; transition: background-color .15s, border-color .15s, box-shadow .15s; }
button:hover:not(:disabled) { background: var(--hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.link { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; }
/* Text-like buttons and row actions get a hit area larger than their letters, without moving them. */
button.link, td.ops a, td details summary { padding: 4px 6px; margin: -4px -6px; border-radius: 6px; }
button.link:hover, td.ops a:hover, td details summary:hover { background: var(--hover); }
button:disabled { opacity: .6; cursor: default; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--field); border-radius: 6px; background: var(--panel); max-width: 100%; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
/* Tick boxes big enough to see and hit, in the accent colour when ticked. */
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); vertical-align: middle; cursor: pointer; }
input.wide, textarea.wide { width: min(100%, 560px); }
form.row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
form.row label { display: grid; gap: 4px; font-size: 15px; font-weight: 700; color: var(--text); }
.msg { max-width: 48em; padding: 10px 14px; border-radius: 6px; border-left: 4px solid currentColor; }
.msg.error { background: var(--error-bg); color: var(--error); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.note, .lead { max-width: 48em; }
.note { color: var(--muted); font-size: 15px; }
.invite { padding: 4px 16px 8px; background: var(--panel); border: 2px solid var(--accent); border-radius: 8px; margin-bottom: 16px; }
.cards { list-style: none; padding: 0; display: grid; gap: 8px; }
.cards li { display: flex; justify-content: space-between; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
[hidden] { display: none !important; }
textarea { font: inherit; color: inherit; }
input.narrow { width: 72px; }
input.short { width: 120px; }
form.stack, div.stack { display: grid; gap: 12px; justify-items: start; }
form.stack label, div.stack label { display: grid; gap: 4px; font-size: 15px; font-weight: 700; color: var(--text); width: min(100%, 560px); }
label small, label .note { font-weight: 400; }
label.check { font-weight: 400; }
p.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
pre { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; font: 13px/1.5 Consolas, monospace; }
code { font-family: Consolas, monospace; }
.tiles { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.tiles a { display: grid; justify-items: center; gap: 8px; padding: 12px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s; text-decoration: none; color: var(--text); font-size: 14px; text-align: center; overflow-wrap: anywhere; }
.preview { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.swatch { display: flex; flex-wrap: wrap; align-items: end; gap: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.swatch.light { background: #ffffff; color: #1c2330; }
.swatch.dark { background: #1b1f27; color: #e7eaf0; }
.preview figure { margin: 0; display: grid; justify-items: center; gap: 4px; font-size: 13px; }
.desktop { grid-row: 1 / span 2; grid-column: 2; display: grid; place-items: center; min-width: 140px; padding: 16px; border-radius: 8px; background: linear-gradient(135deg, #2b5c9e, #4a8fcf); color: #ffffff; text-shadow: 0 1px 2px #000000; }
.desktop figcaption { max-width: 96px; text-align: center; overflow-wrap: anywhere; }
@media (max-width: 600px) { .preview { grid-template-columns: 1fr; } .desktop { grid-row: auto; grid-column: 1; } }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 6em; max-width: 420px; }
label small { color: var(--muted); overflow-wrap: anywhere; }
/* A small toggle inside a table row (publishing to chosen groups). */
td details { display: inline-block; vertical-align: top; margin-right: 12px; }
td details summary { cursor: pointer; color: var(--accent); text-decoration: underline; }
/* The smaller folds (詳しく, a choice inside a row) use the same chevron as the panels, smaller. */
details.more > summary, td details summary { list-style: none; }
details.more > summary::-webkit-details-marker, td details summary::-webkit-details-marker { display: none; }
details.more > summary::before, td details summary::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 8px 2px 1px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(-45deg); transition: transform .15s; }
details.more[open] > summary::before, td details[open] summary::before { transform: rotate(45deg); }
td details form { display: grid; gap: 4px; padding: 8px 0; }
/* Folded tasks: closed, a panel is one line; opened, it holds the form. */
details.panel { margin: 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.panel > summary { list-style: none; cursor: pointer; padding: 10px 16px; font-weight: 600; color: var(--accent); }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 12px 2px 2px; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(-45deg); transition: transform .15s; }
details.panel[open] > summary::before { transform: rotate(45deg); }
details.panel[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.panel > summary:hover { background: var(--hover); border-radius: var(--radius); }
details.panel[open] > summary:hover { border-radius: var(--radius) var(--radius) 0 0; }
details.panel > .panel-body { padding: 0 16px 12px; }
details.panel > .panel-body > :first-child { margin-top: 0; }
details.panel.danger > summary { color: var(--error); }
/* Background explanations, folded to one muted line. */
details.more { margin: 0 0 12px; }
details.more > summary { cursor: pointer; width: fit-content; color: var(--muted); font-size: 15px; }
details.more > .note { margin: 4px 0 0; }
details.more > .note p { margin: 0 0 4px; }
/* States, most important first: in effect (ok), limited (info), watch out (warn), inactive (muted). */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px 0 8px; border-radius: 999px; font-size: 14px; font-weight: 700; line-height: 1.8; white-space: nowrap; vertical-align: middle; background: var(--hover); color: var(--muted); }
.badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
h2 .badge { margin-left: 8px; }
.lead { margin: 0 0 4px; }
label.check { display: flex; gap: 6px; align-items: center; }
.drop { width: min(100%, 560px); padding: 4px 16px; background: var(--panel); border: 2px dashed var(--line); border-radius: 8px; }
.drop.over { border-color: var(--accent); background: var(--bg); }
.drop-result { display: grid; gap: 8px; width: min(100%, 560px); }
.drop-result p { margin: 0; }
.drop-result ul { list-style: none; margin: 0; padding: 0; }
.drop-result li { overflow-wrap: anywhere; }
.drop-result li.missing { color: var(--error); font-weight: 600; }

/* A table too wide for its frame (admin.js measures it) first lets its cells wrap ("fold"); if
   that is not enough it becomes one card per row ("stack", every cell labelled with its
   column), so no column, and no button in it, is off to the side. Tables that fit stay as they are. */
table.fold th, table.fold td { white-space: normal; overflow-wrap: break-word; }
table.fold td:first-child, table.fold td.tight, table.fold td.ops button, table.fold td.ops summary { white-space: nowrap; }
.scroll:has(> table.stack) { overflow: visible; }
table.stack, table.stack tbody, table.stack tr { display: block; }
table.stack thead { display: block; border-bottom: 1px solid var(--line); }
table.stack thead:not(:has(input)) { display: none; }
table.stack thead tr { display: flex; }
table.stack thead th { display: none; }
/* A header that holds a control ("select all") stays, with its purpose written out. */
table.stack thead th:has(input) { display: flex; align-items: center; gap: 8px; }
table.stack thead th:has(input)::after { content: "すべて選ぶ"; }
table.stack thead { background: var(--bg); }
table.stack thead th:has(input) { background: none; }
table.stack tbody tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.stack tbody tr:last-child { border-bottom: 0; }
table.stack tbody tr:hover td { background: none; }
/* The label sits in the cell's left padding, so whatever the cell holds (a line break, a
   second line in small print) flows together on the right. */
table.stack td { display: block; position: relative; padding: 4px 12px 4px calc(12px + 8em); border: 0; white-space: normal; overflow-wrap: anywhere; max-width: none; }
table.stack td::before { content: attr(data-label); position: absolute; left: 12px; width: 7.5em; color: var(--muted); font-size: 14px; line-height: 2; }
table.stack td:not([data-label]) { padding-left: 12px; }
table.stack td:not([data-label])::before { content: none; }
table.stack td:empty { display: none; }
table.stack td.ops { padding-left: 12px; }
table.stack td.ops::before { position: static; display: block; }
table.stack td.ops form, table.stack td.ops details { margin: 4px 16px 4px 0; }
table.stack td input:not([type="checkbox"]), table.stack td select { width: 100%; }

/* Key facts of one item (a store: last connection, what it receives) as label / value pairs. */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 16px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.facts dt { color: var(--muted); font-size: 15px; }
.facts dd { margin: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: 8px; } }

/* Sign-in and invitation: no menu, so the page is one card in the middle of the window. */
body.solo header { justify-content: center; padding-bottom: 10px; border-bottom: 0; background: none; }
body.solo main { max-width: 460px; margin: 6vh auto 48px; padding: 8px 32px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
body.solo main h1 { font-size: 24px; }
body.solo main button.primary { width: 100%; padding: 12px 16px; }
@media (max-width: 520px) { body.solo main { margin: 16px; padding: 4px 20px 20px; } }

@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; } }

/* Where a detail page sits, above its title: the list it belongs to. */
.crumbs { display: flex; align-items: center; gap: 8px; margin: 20px 0 -12px; font-size: 15px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { color: var(--muted); }
/* For the keyboard: the first Tab offers to skip the header. */
.skip { position: absolute; left: 16px; top: -48px; z-index: 10; padding: 8px 16px; background: var(--accent); color: var(--accent-text); border-radius: 6px; text-decoration: none; }
.skip:focus { top: 8px; color: var(--accent-text); }
/* Column headings that sort the list (admin.js adds the buttons). */
th button.sort { display: inline-flex; align-items: center; gap: 6px; margin: -4px -6px; padding: 4px 6px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; font-weight: inherit; }
th button.sort:hover:not(:disabled) { background: var(--hover); color: var(--text); }
th button.sort::after { content: ""; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; opacity: .25; }
th[aria-sort] button.sort { color: var(--text); }
th[aria-sort] button.sort::after { opacity: 1; }
th[aria-sort="ascending"] button.sort::after { border-top-color: transparent; border-bottom-color: currentColor; margin: 0 0 4px; }
/* The message after a change can be put away. */
.msg.ok[role="status"] { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.msg button.close { flex: none; padding: 0 8px; border: 0; background: none; color: inherit; font-size: 20px; line-height: 1.4; }
.msg button.close:hover:not(:disabled) { background: rgba(0, 0, 0, .06); }

/* A list without bullets inside a table cell or a fact (a store's PCs). */
ul.plain { list-style: none; margin: 4px 0 0; padding: 0; }
ul.plain li { margin: 2px 0; }
