/* madobe 管理画面 — PWA と同じ窓辺の色で、運用の机として密度を上げる */
:root {
  --wall: #ebf3ff; /* ブルーホワイト */
  --pane: #ffffff;
  --pane-2: #f6faff;
  --ink: #101c36;
  --ink-2: #475569;
  --ink-3: #5f6b80;
  --line: #d9e5f4;
  --line-2: #e6effb;
  --sky: #0966d8;
  --sky-soft: #d6e8ff;
  --sun: #ffbb1c;
  --sun-ink: #8f5500;
  --sun-soft: #fff6d9;
  --leaf: #067a47;
  --leaf-soft: #e3f8ee;
  --danger: #d92d43;
  --danger-soft: #feecee;
  --font: "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  color-scheme: light;
}
/* data-theme はレイアウトの head と theme コントローラーが「ライト／ダーク／端末に合わせる」から決める */
:root[data-theme="dark"] {
  --wall: #0a1222; --pane: #101a2e; --pane-2: #142038; --ink: #eaf0f8; --ink-2: #a9b6cc; --ink-3: #8592ab;
  --line: #22314d; --line-2: #19253c; --sky: #5fb0ff; --sky-soft: #132a4d; --sun-ink: #ffd35e; --sun-soft: #2b2410;
  --leaf: #3fd28f; --leaf-soft: #15302a; --danger: #ff6b72; --danger-soft: #3a1b20;
  color-scheme: dark;
}
/* ダークではサイドバーを本文より一段明るい紺にして境目を出す */
:root[data-theme="dark"] .side { background: #0d1730; box-shadow: inset -1px 0 0 #22314d; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--wall); color: var(--ink); font: 14px/1.65 var(--font); font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.35; }

/* ---------- 骨組み ---------- */
.admin { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: #101c36; color: #c8d3e6; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.side .brand:hover { text-decoration: none; }
.mark { width: 30px; height: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 5px; border-radius: 9px; background: #1b2d55; flex: none; }
.mark i { border-radius: 2px; background: #2b4f8e; }
.mark i:first-child { background: var(--sun); }
.side .brand b { font-size: 17px; font-weight: 900; display: block; line-height: 1.1; }
.side .brand small { font-size: 11px; color: #8a9bbd; }
.side .group { font-size: 11.5px; color: #7286ad; padding: 14px 12px 4px; font-weight: 700; }
.side .nav { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px; color: #c8d3e6; font-size: 13.5px; }
.side .nav:hover { background: #1a2c52; color: #fff; text-decoration: none; }
.side .nav.on { background: #1f3a6e; color: #fff; font-weight: 700; box-shadow: inset 3px 0 0 var(--sun); }
.side .nav svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.side .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--sun); color: #3b2a00; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid #22355e; font-size: 12.5px; }
.side .me b { color: #fff; display: block; font-size: 13.5px; }
.side .me .roles { color: #8a9bbd; margin: 2px 0 8px; }
.side .me button { background: none; border: 1px solid #2c4a80; color: #c8d3e6; border-radius: 6px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.side .me button:hover { background: #1a2c52; }

.content { padding: 26px 32px 60px; max-width: 1240px; width: 100%; }
.page-title { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title h1 { font-size: 22px; font-weight: 900; }
.page-title .lead { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-title .actions { margin-left: auto; display: flex; gap: 8px; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .group, .side .me .roles { display: none; }
  .side .me { margin: 0; border: 0; padding: 7px 12px; }
  .content { padding: 18px 16px 40px; }
}

/* ---------- 部品 ---------- */
.card { background: var(--pane); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; font-weight: 900; margin-bottom: 4px; display: flex; align-items: baseline; gap: 10px; }
.card h2 small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.card .sub { color: var(--ink-3); font-size: 12.5px; margin: 0 0 12px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid > .card + .card { margin-top: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1080px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--pane); color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--wall); }
.btn.primary:hover { opacity: 0.9; }
.btn.sun { background: var(--sun); border-color: var(--sun); color: #3b2a00; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash.notice { background: var(--leaf-soft); color: var(--leaf); }
.flash.alert { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--ink-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--sky); font-weight: 700; }
.tabs .n { font-size: 11.5px; color: var(--ink-3); margin-left: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
  font: inherit; color: inherit; background: var(--pane); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
input[type="color"] { width: 48px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--pane); }

/* 表 */
.table-wrap { background: var(--pane); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list th { text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--pane-2); white-space: nowrap; }
.list td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list tr:hover td { background: var(--pane-2); }
.list td.r, .list th.r { text-align: right; }
.list .muted { color: var(--ink-3); font-size: 12.5px; }
.list .body { max-width: 520px; white-space: pre-wrap; overflow-wrap: anywhere; }
.list .row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.pill.warn { background: var(--sun-soft); color: var(--sun-ink); }
.pill.ok { background: var(--leaf-soft); color: var(--leaf); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--sky-soft); color: var(--sky); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ava img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ava { overflow: hidden; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; color: hsl(var(--h) 65% 26%); background: hsl(var(--h) 95% 89%); }

details.reveal summary { list-style: none; cursor: pointer; }
details.reveal summary::-webkit-details-marker { display: none; }
details.reveal[open] .reveal-body { margin-top: 8px; display: grid; gap: 6px; min-width: 260px; }

/* フォーム */
.form { display: grid; gap: 16px; max-width: 720px; }
.field label.l { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.field input:not([type="checkbox"]):not([type="color"]), .field select { width: 100%; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.field .req { color: var(--danger); margin-left: 3px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.errors { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 14px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.form-actions { display: flex; gap: 8px; padding-top: 4px; }

/* ---------- ダッシュボード ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--pane); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.kpi .value { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 3px; letter-spacing: 0; }
.kpi .note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.kpi.attention { border-color: color-mix(in srgb, var(--sun) 55%, var(--line)); background: linear-gradient(180deg, var(--sun-soft), var(--pane) 70%); }
.kpi a.value { color: var(--ink); display: block; }

/* 日別投稿数：1系列の棒（単色・角丸は上だけ・2px の隙間） */
.bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; align-items: end; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--line); position: relative; }
.bars .b { position: relative; height: 100%; display: flex; align-items: flex-end; }
.bars .b i { display: block; width: 100%; background: var(--sky); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b:hover i { background: color-mix(in srgb, var(--sky) 75%, var(--ink)); }
.bars .b .tip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--wall); font-size: 11.5px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.1s; z-index: 2; }
.bars .b:hover .tip { opacity: 1; }
.bars .peak { position: absolute; top: 0; right: 0; font-size: 11.5px; color: var(--ink-3); }
.bar-labels { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; font-size: 10.5px; color: var(--ink-3); text-align: center; margin-top: 4px; }

/* 事業部間の称賛：ヒートマップ（単色の濃淡、0 は空のまま） */
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; width: 100%; }
.heat th { font-weight: 700; color: var(--ink-3); padding: 4px 6px; white-space: nowrap; font-size: 11.5px; }
.heat thead th { writing-mode: vertical-rl; text-orientation: upright; height: 84px; vertical-align: bottom; letter-spacing: 0.05em; }
.heat tbody th { text-align: right; }
.heat td { text-align: center; height: 30px; min-width: 30px; border-radius: 5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.heat td.z { background: var(--line-2); color: transparent; }
.heat td.self { box-shadow: inset 0 0 0 1px var(--line); }
.heat td.hi { color: #fff; }
.legend-scale { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.legend-scale i { width: 18px; height: 10px; border-radius: 3px; display: inline-block; }

.meter { display: grid; grid-template-columns: minmax(0, 1fr) 120px 44px; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.meter + .meter { border-top: 1px solid var(--line-2); }
.meter .track { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.meter .track i { display: block; height: 100%; border-radius: 4px; background: var(--sky); }
.meter .track.sun i { background: var(--sun); }
.meter .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.points-flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.points-flow div { padding: 10px 12px; border-radius: 10px; background: var(--pane-2); }
.points-flow small { font-size: 11.5px; color: var(--ink-3); display: block; }
.points-flow b { font-size: 20px; font-weight: 900; }

/* ユーザー詳細 */
.profile { display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: center; }
.profile .ava { width: 64px; height: 64px; font-size: 26px; }
.profile h1 { font-size: 22px; font-weight: 900; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile .meta { color: var(--ink-3); font-size: 13px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 13.5px; }
dl.facts dt { color: var(--ink-3); }
dl.facts dd { margin: 0; }
.stats { display: flex; gap: 22px; }
.stats div small { display: block; font-size: 11.5px; color: var(--ink-3); }
.stats div b { font-size: 20px; font-weight: 900; }
.role-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ログイン */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #101c36; }
.login-card { width: min(440px, 100%); background: var(--pane); border-radius: 18px; padding: 30px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6); }
.login-card h1 { font-size: 20px; font-weight: 900; margin: 16px 0 4px; }
.login-card p { color: var(--ink-3); margin: 0 0 20px; font-size: 13px; }
.login-card .dev { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); }
.login-card .dev h2 { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.login-card .dev button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 10px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.login-card .dev button:hover { background: var(--line-2); }
.login-card .dev small { display: block; color: var(--ink-3); font-size: 11.5px; }

/* 表示テーマの切り替え（サイドバー下部） */
.theme-switch { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: #1a2c52; margin-bottom: 10px; }
.side .theme-switch button { flex: 1; border: 0; background: none; color: #8a9bbd; font: inherit; font-size: 11.5px; padding: 4px 0; border-radius: 6px; cursor: pointer; }
.side .theme-switch button:hover { color: #fff; }
.side .theme-switch button[aria-checked="true"] { background: #2c4a80; color: #fff; font-weight: 700; }

/* ---------- エンブレムの組み立て ---------- */
.emblem-thumb svg { display: block; }
.emblem-builder { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--pane-2); }
@media (max-width: 860px) { .emblem-builder { grid-template-columns: 1fr; } }
.emblem-stage { position: sticky; top: 16px; align-self: start; text-align: center; }
.emblem-enable { display: flex; gap: 8px; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 10px; cursor: pointer; }
.emblem-preview { width: 200px; height: 200px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, var(--pane), color-mix(in srgb, var(--sky) 8%, var(--pane-2))); transition: opacity .2s, filter .2s; }
.emblem-preview svg { width: 180px; height: 180px; }
.emblem-preview.off { opacity: .35; filter: grayscale(1); }
.emblem-controls { display: grid; gap: 14px; transition: opacity .2s; }
.emblem-controls.off { opacity: .45; pointer-events: none; }
.emblem-controls fieldset { border: 0; padding: 0; margin: 0; }
.emblem-controls legend { white-space: nowrap; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; display: flex; align-items: center; gap: 10px; width: 100%; }
.emblem-search { margin-left: auto; min-height: 28px !important; padding: 2px 10px !important; font-size: 12px; width: 160px; }
.emblem-options { display: flex; flex-wrap: wrap; gap: 6px; }
.emblem-option { position: relative; cursor: pointer; display: grid; justify-items: center; gap: 2px; }
.emblem-option input { position: absolute; opacity: 0; pointer-events: none; }
.emblem-option small { font-size: 10.5px; color: var(--ink-3); }
.emblem-option input:focus-visible + * { outline: 2px solid var(--sky); outline-offset: 2px; }
.emblem-tile { display: grid; justify-items: center; gap: 2px; padding: 6px 10px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--pane); }
.emblem-option input:checked + .emblem-tile { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
.emblem-tile small { font-size: 11px; font-weight: 700; color: var(--ink-2); }
.emblem-options.colors { gap: 10px; }
.emblem-swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--pane);
  background: radial-gradient(circle at 32% 28%, var(--light), var(--base) 58%, var(--dark)); box-shadow: 0 0 0 1.5px var(--line), inset 0 -2px 3px rgba(0,0,0,.2); }
.emblem-option input:checked + .emblem-swatch { box-shadow: 0 0 0 2.5px var(--sky), inset 0 -2px 3px rgba(0,0,0,.2); }
.emblem-switches { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.emblem-switches legend { margin-bottom: 4px; }
.emblem-switches .switch { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; cursor: pointer; }
.emblem-switches input[type=text] { width: 170px; }
.emblem-switches input[type=text]:disabled { opacity: .5; }
.emblem-options.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.emblem-options.icons .emblem-option[hidden] { display: none; }
.emblem-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; border: 1.5px solid var(--line); background: var(--pane); color: var(--ink-2); }
.emblem-option input:checked + .emblem-icon { border-color: var(--sky); color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }

.emblem-swatch.small { width: 26px; height: 26px; }
.emblem-swatch.white { background: radial-gradient(circle at 32% 28%, #fff, #eef1f6 60%, #c9d0dc); }
.emblem-swatch.black { background: radial-gradient(circle at 32% 28%, #5a6478, #1c2230 60%, #05070c); }
/* 自動：形の色に合わせることを、左右に塗り分けた丸で表す */
.emblem-swatch.auto { background: conic-gradient(from 200deg, #f5b70a 0 25%, #1a6fe8 0 50%, #e5203f 0 75%, #12b76a 0); }

.master-search select { min-width: 150px; }
.result-count { margin: -4px 0 10px; font-size: 13px; }
