/* 管理画面の見た目。色は変数でまとめ、パートナーの基調の色は --primary を差し替える */
:root {
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, #ffffff);
  --primary-strong: color-mix(in srgb, var(--primary) 82%, #000000);
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --ink: #1d2530;
  --ink-2: #4a5568;
  --muted: #667085;
  --line: #dde3ea;
  --line-strong: #c4ccd6;
  --ok: #1a7f4b;
  --ok-bg: #e6f4ec;
  --warn: #9a5b00;
  --warn-bg: #fff4dc;
  --danger: #c0352b;
  --danger-bg: #fdecea;
  --info: #1d5fbf;
  --info-bg: #e8f0fc;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent);
  --topbar-h: 56px;
  --sidebar-w: 236px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.7; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.4; margin: 0 0 .6em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; margin-top: 1.2em; }
p { margin: 0 0 .8em; }
a { color: var(--primary-strong); }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; box-shadow: var(--shadow); }
.skip-link:focus { top: 8px; }
.boot, .noscript { padding: 40px; text-align: center; color: var(--muted); }

/* ---- 文字の補助 ---- */
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.pre-wrap { white-space: pre-wrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.mb-1 { margin-bottom: 6px; }

/* ---- 上の帯 ---- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); margin-right: 8px; vertical-align: 1px; }
.tenant-chip { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 6px 4px 12px; background: var(--primary-soft); border-radius: 999px; }
.tenant-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.account-link { color: var(--ink-2); text-decoration: none; font-size: .9rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-link:hover { color: var(--ink); text-decoration: underline; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.hamburger, .hamburger::before, .hamburger::after { display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: ""; }
.hamburger::before { position: absolute; top: -6px; }
.hamburger::after { position: absolute; top: 6px; }

/* 受付中のスイッチ */
.presence, .presence-big { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.presence-big { align-items: flex-start; gap: 14px; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch-input:checked + .switch { background: var(--ok); }
.switch-input:checked + .switch::after { transform: translateX(16px); }
.switch-input:focus-visible + .switch { box-shadow: var(--focus); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.is-online { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.is-paused { background: var(--warn); }
.presence-text { font-size: .86rem; color: var(--ink-2); }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); margin-right: 6px; vertical-align: 1px; }
.online-dot.is-online { background: var(--ok); }

/* お知らせのベル */
.bell-wrap { position: relative; }
.bell-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.bell-panel { position: absolute; right: 0; top: 46px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; }
.bell-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bell-items { list-style: none; margin: 0; padding: 0; }
.bell-items li { border-bottom: 1px solid var(--line); }
.bell-items li.is-unread { background: var(--primary-soft); }
.bell-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; color: var(--ink); text-decoration: none; }
a.bell-item:hover { background: var(--surface-2); }
.bell-title { font-weight: 600; }
.bell-body { font-size: .86rem; color: var(--ink-2); white-space: pre-wrap; }
.bell-time { font-size: .78rem; color: var(--muted); }
.bell-panel .empty { padding: 20px; }

/* ---- 左のメニュー ---- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); align-self: flex-start; flex: none; width: var(--sidebar-w); height: calc(100vh - var(--topbar-h));
  overflow-y: auto; padding: 14px 10px 40px; background: var(--surface); border-right: 1px solid var(--line);
}
.nav-group { margin-bottom: 14px; }
.nav-group-title { padding: 4px 10px; font-size: .76rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .93rem; }
.sidebar a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar a.is-active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }
.nav-badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px; }
.nav-backdrop { display: none; }
.main { flex: 1; min-width: 0; padding: 24px 28px 64px; outline: none; }
.view { max-width: 1180px; margin: 0 auto; }

/* ---- 見出し ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.page-head .lead { color: var(--ink-2); max-width: 780px; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; font-size: .9rem; text-decoration: none; }
.section { margin: 26px 0; }

/* ---- 箱・並べ方 ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.stack > .card { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card, .grid-2 > .stack { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.grid-wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.create-box summary { cursor: pointer; padding: 2px 0; }
.create-box[open] summary { margin-bottom: 12px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: .93rem; font-weight: 600; line-height: 1.3; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn-danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, #fff); }
.btn-danger-outline:hover { background: var(--danger-bg); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .86rem; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-primary.is-busy::after, .btn-danger.is-busy::after { border-color: #fff transparent #fff transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.btn-stack .btn { width: 100%; }

/* ---- 印・状態 ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.6; white-space: nowrap; border: 1px solid transparent; vertical-align: 1px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge-dark { background: #2b3440; color: #fff; }
.badge-xs { font-size: .7rem; padding: 0 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---- お知らせの帯 ---- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; }
.alert-danger { background: var(--danger-bg); color: #7a1f18; border-color: color-mix(in srgb, var(--danger) 25%, #fff); }
.alert-warn { background: var(--warn-bg); color: #6b4000; border-color: color-mix(in srgb, var(--warn) 25%, #fff); }
.alert-info { background: var(--info-bg); color: #163f7d; border-color: color-mix(in srgb, var(--info) 20%, #fff); }
.alert-ok { background: var(--ok-bg); color: #10522f; border-color: color-mix(in srgb, var(--ok) 20%, #fff); }
.hint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint .btn { margin-left: auto; }

/* ---- 空・読み込み中 ---- */
.empty { padding: 22px 12px; text-align: center; color: var(--muted); }
.empty p { margin: 0; }
.loading { display: flex; align-items: center; gap: 10px; padding: 30px 10px; color: var(--muted); justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- タブ ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; font-size: .93rem; }
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.is-active { color: var(--primary-strong); border-bottom-color: var(--primary); }
.tab-count { font-size: .76rem; background: var(--surface-2); border-radius: 999px; padding: 0 7px; color: var(--ink-2); }

/* ---- 入力 ---- */
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=date], input[type=time], input[type=month], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink);
  font: inherit; font-size: 16px; /* スマートフォンで拡大されない大きさ */
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); }
input[type=color] { width: 46px; height: 40px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; flex: none; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }
input[type=file] { font: inherit; max-width: 100%; }
.field { display: block; margin: 0 0 14px; min-width: 0; border: 0; padding: 0; }
fieldset.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 4px; font-size: .88rem; font-weight: 600; color: var(--ink-2); padding: 0; }
.check { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; cursor: pointer; }
.check.small { margin: 0; font-size: .82rem; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-2); }
.inline-field select, .inline-field input { width: auto; min-width: 140px; }
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=text] { max-width: 140px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; }
.form-inline .grow { flex: 1 1 280px; }
.form-inline .span-all, .form-inline h2 { flex-basis: 100%; margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; align-items: end; }
.form-grid .span-all, .form-grid h2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.narrow { max-width: 420px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.search-row input { flex: 1; min-width: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding-top: 14px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; justify-content: flex-end; }

/* ---- 一覧の部品 ---- */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; min-width: 0; }
.kv-tight { gap: 4px 16px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list > li:last-child { border-bottom: 0; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.compact { margin: 0; padding-left: 1.2em; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 10px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; }
.chip button { border: 0; background: transparent; cursor: pointer; width: 24px; height: 24px; border-radius: 50%; color: var(--ink-2); font-size: 14px; }
.chip button:hover { background: var(--line); }
.code { background: #10161f; color: #e7edf5; padding: 12px 14px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: .86rem; margin: 0 0 10px; }
.quote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--line-strong); background: var(--surface-2); border-radius: 0 6px 6px 0; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.quote-label { display: block; font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.mini-card { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.mini-card summary { cursor: pointer; font-weight: 600; }

/* ---- 表（狭い画面ではカードの形にする） ---- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { font-size: .8rem; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th { background: var(--surface-2); }
.src-title { font-weight: 600; overflow-wrap: anywhere; }
.usage-cell { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.status-sum { margin: 0 0 12px; }

/* ---- 数字のまとめ ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-wide { grid-column: span 2; }
.stat-label { font-size: .84rem; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-small { font-size: 1.15rem; }
.stat-unit { font-size: .9rem; font-weight: 500; color: var(--muted); }
.stat-note { font-size: .84rem; color: var(--muted); }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.meter span.is-warn { background: #e0a100; }
.meter span.is-danger { background: var(--danger); }
.meter-sm { height: 5px; margin: 2px 0; }
.wait-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.wait-card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.wait-card:hover { background: #fafbfd; }
.wait-count { grid-row: 1 / 3; font-size: 1.6rem; font-weight: 700; min-width: 2ch; text-align: center; color: var(--muted); }
.wait-title { font-weight: 600; }
.wait-note { font-size: .8rem; color: var(--muted); }
.wait-card.has-danger { border-left-color: var(--danger); } .wait-card.has-danger .wait-count { color: var(--danger); }
.wait-card.has-warn { border-left-color: #e0a100; } .wait-card.has-warn .wait-count { color: var(--warn); }
.wait-card.has-info { border-left-color: var(--primary); } .wait-card.has-info .wait-count { color: var(--primary-strong); }
.bar-list { list-style: none; margin: 0; padding: 0; }
.bar-list li { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 10px; padding: 5px 0; }
.bar-label { overflow-wrap: anywhere; font-size: .9rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.bar-n { font-size: .86rem; color: var(--ink-2); white-space: nowrap; }

/* グラフ */
.chart { margin: 8px 0 18px; }
.chart svg { width: 100%; height: auto; max-height: 260px; display: block; }
.chart .axis { stroke: var(--line-strong); }
.chart .bar-a { fill: #9aa8ba; }
.chart .bar-b { fill: var(--primary); }
.chart .val { font-size: 11px; fill: var(--ink-2); text-anchor: middle; }
.chart .lbl { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.chart figcaption { font-size: .82rem; color: var(--ink-2); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.key-a { background: #9aa8ba; }
.key-b { background: var(--primary); }

/* ---- 会話 ---- */
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; background: var(--surface); }
.conv-item:hover { border-color: var(--primary); background: #fafcff; }
.conv-top { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.conv-time { margin-left: auto; font-size: .8rem; color: var(--muted); }
.conv-q { margin-top: 6px; font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-summary { font-size: .86rem; color: var(--ink-2); margin: 4px 0 0; }
.conv-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.conv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.conv-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.conv-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.conv-head p { margin: 6px 0 0; }
.conv-side .card { margin-bottom: 12px; }
.transcript { height: min(62vh, 640px); overflow-y: auto; padding: 16px 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.msg-visitor { align-self: flex-start; border-top-left-radius: 4px; }
.msg-bot { align-self: flex-end; background: #f4f8ff; border-color: #d8e4f8; border-top-right-radius: 4px; }
.msg-staff { align-self: flex-end; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, #fff); border-top-right-radius: 4px; }
.msg-notice { background: #fbfbf6; border-style: dashed; }
.msg-system { align-self: center; max-width: 90%; background: transparent; border: 0; box-shadow: none; text-align: center; font-size: .84rem; color: var(--muted); }
.msg-head { display: flex; gap: 10px; justify-content: space-between; font-size: .76rem; color: var(--muted); margin-bottom: 2px; }
.msg-who { font-weight: 700; color: var(--ink-2); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { font-size: .74rem; color: var(--muted); }
.msg-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.msg-provider { font-size: .72rem; color: var(--muted); font-family: var(--mono); }
.msg-sources { margin-top: 6px; font-size: .8rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.msg-sources a { overflow-wrap: anywhere; }
.msg-actions { margin-top: 4px; text-align: right; }
.reply { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.reply textarea { min-height: 76px; }
.reply-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.brief-item { margin-bottom: 12px; }
.brief-item ul { margin: 0; padding-left: 1.2em; }
.brief-label { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.brief-warn { padding: 8px 10px; background: var(--warn-bg); border-radius: 8px; }
.draft { padding: 8px 10px; background: var(--surface-2); border-radius: 8px; margin-bottom: 6px; }
.presence-card { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; }
.presence-big .switch { margin-top: 3px; }
.presence-extra { flex: none; }

/* ---- 知識の項目 ---- */
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.item-title { overflow-wrap: anywhere; }
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.answer-form { margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.qa-q, .qa-a { display: grid; grid-template-columns: 26px 1fr; gap: 8px; margin-bottom: 8px; overflow-wrap: anywhere; }
.qa-q { font-weight: 600; }
.qa-mark { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: .78rem; font-weight: 700; background: var(--primary-soft); color: var(--primary-strong); }
.qa-a .qa-mark { background: var(--ok-bg); color: var(--ok); }
.fact-row { display: flex; gap: 12px; }
.fact-check { margin-top: 4px !important; width: 20px !important; height: 20px !important; }
.fact-main { flex: 1; min-width: 0; }
.fact-subject { font-size: .86rem; color: var(--ink-2); font-weight: 600; }
.fact-statement { font-size: 1.02rem; font-weight: 600; overflow-wrap: anywhere; }
.fact-cond { font-size: .9rem; color: var(--ink-2); }
.fact-edit { margin: 8px 0; }
.conflict-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-bottom: 10px; }
.policy { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.policy-main { flex: 1 1 220px; min-width: 0; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; padding: 0; margin: 0; }
.seg { position: relative; display: inline-flex; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { padding: 7px 12px; font-size: .88rem; font-weight: 600; color: var(--ink-2); border-left: 1px solid var(--line-strong); white-space: nowrap; }
.seg:first-of-type span { border-left: 0; }
.seg input:checked + span { background: var(--primary); color: #fff; }
.seg input:focus-visible + span { box-shadow: inset var(--focus); }
.segmented:disabled .seg { cursor: default; opacity: .85; }
.ccard .kv { grid-template-columns: minmax(110px, max-content) 1fr; }
.ccard-edit { margin: 10px 0; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.ccard details { margin: 8px 0; }
.job-list { list-style: none; margin: 0; padding: 0; }
.job-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.job-list li:last-child { border-bottom: 0; }
.job-list .text-danger { flex-basis: 100%; }
.coverage { list-style: none; margin: 0; padding: 0; }
.coverage li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.coverage li > div { flex: 1; min-width: 0; }
.cov-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.coverage li.is-yes .cov-mark { background: var(--ok-bg); color: var(--ok); }
.coverage li.is-no .cov-mark { background: var(--danger-bg); color: var(--danger); }
.suggestions { margin: 0; padding-left: 1.4em; }
.suggestions li { margin-bottom: 14px; }
.sg-target { font-weight: 700; }
.sg-problem { color: var(--ink-2); }
.try-frame iframe { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bh { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bh-row { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bh-day { font-weight: 700; padding-top: 8px; }
.bh-ranges { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.bh-range { display: inline-flex; align-items: center; gap: 4px; }
.bh-range input[type=time] { width: 116px; }

/* ---- ログイン ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 28px 26px; }
.login-card h1 { font-size: 1.3rem; }

/* ---- 確認の画面 ---- */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); color: var(--ink); }
.dialog-wide { width: min(720px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog-body { padding: 22px 22px 18px; }
.dialog-title { font-size: 1.12rem; margin-bottom: 12px; }
.dialog-message p { margin-bottom: .6em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---- トースト ---- */
#toasts { position: fixed; z-index: 1000; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); padding-bottom: env(safe-area-inset-bottom); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px 11px 14px; border-radius: 10px; background: #1f2937; color: #fff; box-shadow: var(--shadow-lg); font-size: .92rem; animation: toast-in .18s ease-out; }
.toast-ok { background: #14532d; }
.toast-warn { background: #7a4a00; }
.toast-danger { background: #8f2219; }
.toast-close { margin-left: auto; border: 0; background: transparent; color: inherit; opacity: .8; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- 狭い画面 ---- */
@media (max-width: 1080px) {
  .conv-layout { grid-template-columns: 1fr; }
  .grid-wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .main { padding: 18px 14px 80px; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; right: 0; width: auto; height: auto; max-height: calc(100vh - var(--topbar-h));
    z-index: 25; border-right: 0; border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
    transform: translateY(-110%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; align-content: start;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(16, 24, 40, .35); z-index: 20; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-wide { grid-column: auto; }
  .tenant-chip .btn { display: none; }
  .tenant-name { max-width: 30vw; }
  .presence-text, .account-link { display: none; }
  .brand { max-width: 34vw; }
}
@media (max-width: 720px) {
  h1 { font-size: 1.25rem; }
  .card { padding: 14px; }
  .sidebar { grid-template-columns: 1fr; }
  .tenant-chip { display: none; }
  .msg { max-width: 94%; }
  .transcript { height: 58vh; padding: 12px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.5rem; }
  .page-actions { width: 100%; }
  /* 表を縦に並んだカードにする */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td, .table tfoot, .table tfoot th { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 10px; background: var(--surface); }
  .table td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 8.5em 1fr; gap: 8px; text-align: left !important; white-space: normal !important; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; }
  .table td:not([data-label])::before { content: none; }
  .table td:not([data-label]) { grid-template-columns: 1fr; }
  .table tfoot tr { display: flex; justify-content: space-between; }
  .table tfoot th { width: auto; border: 0; background: transparent; }
  .bar-list li { grid-template-columns: 1fr auto; }
  .bar-list .bar { grid-column: 1 / -1; grid-row: 2; }
  .policy { align-items: stretch; }
  .segmented { width: 100%; }
  .seg { flex: 1; }
  .seg span { flex: 1; text-align: center; padding: 8px 4px; font-size: .82rem; white-space: normal; }
  .search-row { flex-wrap: wrap; }
  .dialog-actions .btn { flex: 1; }
  .reply-actions { flex-wrap: wrap; }
  .reply-actions .btn { width: 100%; }
  .bh-range input[type=time] { width: 104px; }
  .try-frame iframe { height: 480px; }
}

/* ---- 印刷（改善レポート） ---- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .sidebar, .nav-backdrop, #toasts, .print-hide, .page-actions, .skip-link { display: none !important; }
  .main { padding: 0; }
  .view { max-width: none; }
  .card, .stat { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  a { color: inherit; text-decoration: none; }
  .quote { background: #f3f3f3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ホワイトラベル: パートナーのロゴ */
.brand-logo { height: 26px; max-width: 120px; object-fit: contain; vertical-align: middle; margin-right: 8px; }
.brand:has(.brand-logo)::before { display: none; }
.login-logo { display: block; max-height: 48px; max-width: 220px; object-fit: contain; margin: 0 auto 10px; }
.login-product { text-align: center; font-weight: 700; font-size: 1.1rem; color: var(--primary); margin-bottom: 6px; }

/* ホームの「はじめにやること」 */
.setup { border-left: 4px solid var(--primary); }
.setup-count { font-weight: 600; color: var(--muted); white-space: nowrap; }
.setup-list { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: setup; }
.setup-item { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); counter-increment: setup; }
.setup-item:first-child { border-top: 0; }
.setup-mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.setup-mark:empty::before { content: counter(setup); }
.setup-item.is-next .setup-mark { border-color: var(--primary); color: var(--primary); }
.setup-item.is-done .setup-mark { border-color: var(--ok); background: var(--ok); color: #fff; }
.setup-item.is-done .setup-title { color: var(--muted); }
.setup-title { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 24px; }
.setup-note { margin: 4px 0 8px; color: var(--ink-2, var(--ink)); font-size: .92rem; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
