/* HAKU Labo 管理画面（案B「すっきりノート」）
   こげ茶のヘッダー・メニュー × クリーム色の本文。OS のダークモード設定に関わらずこの配色で表示する。 */

/* ---------- 色・共通 ---------- */
:root {
  --bg: #f9f4e8;          /* 本文の背景（クリーム） */
  --surface: #fffdf8;     /* カード */
  --chrome: #2f2a24;      /* ヘッダー */
  --side: #3a332b;        /* メニュー */
  --side-ink: #e9dfc8;
  --cream-ink: #f6eedb;
  --text: #3b3328;        /* 文字（こげ茶） */
  --muted: #7d7060;
  --border: #e8dcc4;
  --primary: #3f7f6b;     /* ボタン・グラフ */
  --accent: #6b58c9;      /* 強調カード */
  --warn: #c98316;
  --danger: #c4513f;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
body.modal-open { overflow: hidden; }
a { color: var(--primary); }
h1, h2 { line-height: 1.35; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--primary); color: #fff; border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px; background: var(--chrome); color: var(--cream-ink);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--cream-ink); text-decoration: none; white-space: nowrap; }
.brand-name { font-weight: 600; }
.brand-sub { font-size: 14px; opacity: .9; }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.user { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(246, 238, 219, .18); white-space: nowrap; }
.app-header .button.ghost { color: var(--cream-ink); border-color: rgba(246, 238, 219, .45); }
.app-header .menu-toggle { display: none; width: 40px; height: 40px; align-items: center; justify-content: center; padding: 0; background: transparent; border: 0; cursor: pointer; }
.menu-toggle .bars, .menu-toggle .bars::before, .menu-toggle .bars::after { display: block; width: 22px; height: 2px; background: var(--cream-ink); border-radius: 2px; position: relative; content: ""; }
.menu-toggle .bars::before { position: absolute; top: -7px; }
.menu-toggle .bars::after { position: absolute; top: 7px; }

/* ---------- レイアウト・メニュー ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { flex: none; width: 220px; padding: 12px 0; background: var(--side); overflow-y: auto; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 2px 10px; padding: 0 12px;
  border-radius: 10px; color: var(--side-ink); text-decoration: none;
}
.sidebar a::before { width: 22px; text-align: center; font-size: 15px; opacity: .85; }
.sidebar a[data-nav=dashboard]::before { content: "◎"; }
.sidebar a[data-nav=orders]::before { content: "▤"; }
.sidebar a[data-nav=customers]::before { content: "☺"; }
.sidebar a[data-nav=products]::before { content: "♪"; }
.sidebar a[data-nav=finance]::before { content: "¥"; }
.sidebar a[data-nav=partners]::before { content: "✦"; }
.sidebar a[data-nav=reviews]::before { content: "★"; }
.sidebar a[data-nav=notifications]::before { content: "🔔"; font-size: 13px; }
.sidebar a[data-nav=data]::before { content: "⇅"; }
.sidebar a:hover:not([aria-current]) { background: rgba(255, 255, 255, .06); }
.sidebar a[aria-current] { background: var(--cream-ink); color: var(--chrome); font-weight: 700; }
.sidebar .count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px;
}
.backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .35); }
.main { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.main:focus { outline: none; }
.page > * + * { margin-top: 16px; }

/* ---------- 見出し・パネル ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head h2 { margin: 0; font-size: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; letter-spacing: .04em; color: #5b5145; }
.panel.error h2 { color: var(--danger); }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 901px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.muted { color: var(--muted); }
small.muted, .muted.block { font-size: 13px; }
.block { display: block; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.pre { white-space: pre-wrap; }
.neg { color: var(--danger); }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); }
.loading { color: var(--muted); }
.notice { padding: 10px 12px; border-radius: 8px; background: #e1f3ef; color: #1d6b58; }
.row, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row input, .row select, .page-head input, .page-head select { width: auto; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.back { font-size: 14px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; background: #f3ead6; padding: 1px 6px; border-radius: 6px; }

/* ---------- KPI カード ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.kpi-card.accent { border-left: 4px solid var(--accent); }
.kpi-card.warn { border-left: 4px solid var(--warn); }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { margin: 6px 0 4px; font-size: 26px; font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 13px; color: var(--muted); }

/* ---------- ボタン・入力 ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { filter: brightness(.97); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.ghost { background: transparent; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; font-size: 20px; cursor: pointer; }
.icon-button:hover { background: rgba(0, 0, 0, .05); }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; font-size: 16px; color: var(--text);
  background: #fffefa; border: 1px solid var(--border); border-radius: 8px;
}
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters input, .filters select { width: auto; flex: 1 1 160px; min-width: 140px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-weight: 600; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .actions, .form-grid .checks, .form-grid .field:has(textarea) { grid-column: 1 / -1; }
.items { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr auto; gap: 6px; align-items: center; }
.item-row > .check { grid-column: 1 / -1; }
.items-field { min-width: 0; margin: 8px 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.items-field legend { padding: 0 6px; font-size: 14px; font-weight: 600; }

/* ---------- 状態ラベル（淡い背景＋濃い文字で読みやすく） ---------- */
.badge { display: inline-block; padding: 2px 10px; border: 1px solid #d9cfbd; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; background: #ece7dc; color: var(--text); }
.badge.st-quoted { background: #e3ecfb; border-color: #c4d6f3; color: #284a86; }
.badge.st-in_production, .badge.pay-paid, .badge.accent, .badge.ps-active, .badge.rv-published { background: #e1f3ef; border-color: #bfe3da; color: #1d6b58; }
.badge.st-draft_review, .badge.pay-unpaid, .badge.warn, .badge.ps-preparing, .badge.rv-submitted { background: #fff1d6; border-color: #f1d79c; color: #8a5a00; }
.badge.st-awaiting_delivery { background: #ffe9d9; border-color: #f5c9a6; color: #8f4a12; }
.badge.st-delivered, .badge.st-completed { background: #e4f4e3; border-color: #c3e4c0; color: #2b6a2a; }
.badge.st-cancelled, .badge.pay-refunded, .badge.pay-partially_refunded, .badge.ps-paused, .badge.ps-retired { background: #f6e1de; border-color: #e8bdb6; color: #8e3326; }
.badge.rv-hidden { color: var(--muted); }

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { padding: 8px 12px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data .nowrap { white-space: nowrap; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; transition: background .15s; }
table.data tr.clickable:hover { background: rgba(63, 127, 107, .06); }
.biz { display: inline-flex; align-items: center; gap: 6px; }
i.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px; }

/* ---------- 概要・通知・進捗・グラフ ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 16px; }
.summary-grid > div { display: flex; flex-direction: column; min-width: 0; }
.summary-grid small { font-size: 12px; color: var(--muted); }
.summary-grid b, .summary-grid a { overflow-wrap: anywhere; }
.alert-list { margin: 0; padding-left: 20px; }
.alert-list li { margin: 4px 0; }
.alert-list.full { list-style: none; padding: 0; }
.alert-list.full .alert { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; margin: 8px 0; border-left: 4px solid var(--border); border-radius: 8px; background: var(--surface); }
.alert-list.full .sev-critical { border-left-color: var(--danger); }
.alert-list.full .sev-warning { border-left-color: var(--warn); }
.alert-list.full .sev-info { border-left-color: var(--primary); }
.alert small { display: block; color: var(--muted); }
.progress-row { display: grid; grid-template-columns: 9em 1fr auto; align-items: center; gap: 12px; margin: 6px 0; }
.progress-row progress { width: 100%; height: 10px; accent-color: var(--primary); }
.progress-row b { white-space: nowrap; }
.chart-wrap { margin: 0; }
svg.chart { width: 100%; height: auto; max-height: 280px; }
svg.chart .bar { fill: var(--primary); }
svg.chart .line { fill: none; stroke: var(--warn); stroke-width: 2.5; }
svg.chart .dot { fill: var(--warn); }
svg.chart .grid { stroke: var(--border); }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend .lg-bar::before, .legend .lg-line::before { content: ""; display: inline-block; vertical-align: middle; margin-right: 6px; }
.legend .lg-bar::before { width: 10px; height: 10px; border-radius: 2px; background: var(--primary); }
.legend .lg-line::before { width: 14px; height: 2px; background: var(--warn); }
.review-list { display: grid; gap: 12px; }
.review-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.scores { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.export-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.export-row > :first-child { flex: 1 1 240px; }
details summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.setting { border-bottom: 1px dashed var(--border); padding: 4px 0; }
ul.plain { margin: 0; padding-left: 20px; }

/* ---------- ダイアログ・トースト ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(30, 26, 20, .45); }
.dialog { display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: 90vh; background: var(--surface); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2); }
.dialog.wide { max-width: 860px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-body { padding: 16px; overflow-y: auto; }
.dialog-body .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: var(--chrome); color: var(--cream-ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast[data-kind=error] { background: var(--danger); color: #fff; }

/* ---------- タブレット・スマホ ---------- */
@media (max-width: 900px) {
  .app-header .menu-toggle { display: inline-flex; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: 56px; bottom: 0; left: 0; z-index: 30; width: min(280px, 85vw); box-shadow: 4px 0 20px rgba(0, 0, 0, .25); }
  .main { padding: 16px; }
}
@media (max-width: 600px) {
  .main { padding: 12px 12px 32px; }
  .brand-sub, .app-header .user { display: none; }
  .page-head h1 { font-size: 20px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-sub { font-size: 11px; }
  .progress-row { grid-template-columns: 1fr auto; }
  .progress-row progress { grid-column: 1 / -1; grid-row: 2; }
  /* 表はカード型に */
  table.data thead { display: none; }
  table.data tbody tr { display: block; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
  table.data td { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; text-align: right; }
  table.data td::before { content: attr(data-label); flex: none; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
  table.data td:last-child { border-bottom: 0; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row > select { grid-column: 1 / -1; }
  .dialog-wrap { align-items: flex-end; padding: 0; }
  .dialog, .dialog.wide { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .dialog-body .grid-2 { grid-template-columns: 1fr; }
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .button { width: 100%; }
  .alert-list.full .alert { flex-direction: column; }
}

/* ---------- 使いやすさの改善 ---------- */
/* クリックで一覧へ移動できる KPI カード */
a.kpi-card.link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.kpi-card.link:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(63, 127, 107, .12); transform: translateY(-1px); }
.kpi-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi-go { color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s, color .15s; }
a.kpi-card.link:hover .kpi-go { color: var(--primary); transform: translateX(2px); }
/* 金額入力の横に「¥11,000」表示 */
.yen-input { display: flex; align-items: center; gap: 10px; }
.yen-input input { flex: 1; min-width: 0; }
.yen-preview { flex: none; min-width: 6em; text-align: right; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
/* スマホ: 画面下に固定の「＋新規案件」 */
.fab { display: none; }
@media (max-width: 600px) {
  .fab {
    display: inline-flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: 20px; z-index: 20;
    min-height: 52px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--primary); color: #fff;
    font: inherit; font-weight: 700; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); cursor: pointer;
  }
  .page-head .button.primary { display: none; }   /* 上のボタンと重複させない */
  .main { padding-bottom: 96px; }
}

/* メール・リンク（2026-10-14） */
.sidebar a[data-nav=mail]::before { content: "✉"; }
.sidebar a[data-nav=links]::before { content: "⛓"; }
.mail-item { border-top: 1px solid var(--border); padding: 14px 0; }
.mail-item:first-of-type { border-top: 0; }
.mail-item.out { padding-left: 16px; border-left: 3px solid var(--primary); }
.mail-head { margin-bottom: 6px; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.75; margin: 0; max-height: 60vh; overflow: auto; }

.button.danger { color: var(--danger); border-color: var(--danger); }
