/* デザイン原則（青×黒 基調・抑制的な配色）:
   基調色は「黒×白×余白」のミニマル＋アクセントは青1色のみ。赤は基調色に使わない。
   → 近黒のサイドバー＋ニュートラルグレー＋アクセントは青のみ。
   原色の緑/橙/赤の多用・強い shadow・過剰な角丸は使わない。
   ステータスは原則「文字＋細いボーダー」で示し、色は意味のある最小限だけ（過不足など）。 */
:root {
  --ink: #1c1c1c;        /* 近黒（本文・見出し） */
  --ink-2: #44464b;
  --muted: #6b7280;
  --faint: #9aa0a8;
  --bg-sub: #f7f6f4;     /* 温かみのある淡灰 */
  --bg-active: #efeeea;
  --line: #e4e2dd;
  --line-strong: #cbc8c1;
  --sidebar: #1a1a1a;    /* サイドバー＝近黒（ミニマル） */
  --sidebar-dark: #111111;
  --accent: #2e5a8c;     /* 青（基調色）。唯一のアクセント、多用しない */
  --accent-dark: #1b3357; /* 濃紺 */
  --ok: #2f6b4f;         /* 深緑（確定/一致） */
  --warn: #b45309;       /* 琥珀（保留/過剰） */
  --bad: #b45309;        /* 琥珀（不足/差戻し）※赤は基調色に使わない */
}
* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #fdfcfa; color: var(--ink); display: flex; min-height: 100vh;
  font-size: 13px; line-height: 1.55;
}

/* ---- サイドバー（近黒。アクセントは左ボーダーのみ） ---- */
.sidebar {
  width: 210px; background: var(--sidebar); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar.admin { background: #161616; }
.sidebar.am { background: #232323; }
.brand { padding: 16px 14px 12px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 4px; }
.brand-sub { font-size: 10px; opacity: .7; line-height: 1.5; margin-top: 3px; }
.store-badge { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.14); }
.store-badge .sb-code { font-size: 11px; opacity: .65; letter-spacing: 1px; }
.store-badge .sb-name { font-size: 12.5px; font-weight: 600; margin-top: 1px; }
.sidebar nav { display: flex; flex-direction: column; padding: 8px 0; }
.sidebar nav a {
  color: rgba(255,255,255,.82); text-decoration: none; padding: 9px 14px; font-size: 12.5px;
  border-left: 3px solid transparent; display: flex; align-items: center; gap: 6px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { border-left-color: var(--accent); background: rgba(255,255,255,.06); color: #fff; font-weight: 600; }
.role-tag { padding: 6px 14px; font-size: 10.5px; color: rgba(255,255,255,.6); border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot { margin-top: auto; padding: 12px 14px; font-size: 10px; opacity: .75; line-height: 1.6; border-top: 1px solid rgba(255,255,255,.14); }
.logout { display: inline-block; margin-top: 8px; color: #fff; opacity: .8; text-decoration: underline; font-size: 11px; }

/* ---- コンテンツ ---- */
.content { flex: 1; padding: 18px 22px; max-width: 1280px; background: #fdfcfa; }
.foot { margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--faint); }

h1 { font-size: 18px; font-weight: 600; margin-bottom: 2px; letter-spacing: .02em; }
h1 .tag { font-size: 11px; font-weight: 400; color: var(--muted); border: 1px solid var(--line-strong); padding: 1px 7px; vertical-align: 2px; margin-left: 8px; }
.lead { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.lead a { color: var(--ink-2); }
h2 {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  margin: 24px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.empty { color: var(--muted); font-size: 12.5px; padding: 12px; border: 1px dashed var(--line-strong); background: var(--bg-sub); }
.empty a { color: var(--accent); }
.empty.ok-msg { color: var(--ink-2); border-color: var(--line-strong); background: var(--bg-sub); }
.muted { color: var(--faint); }

.toolbar { margin: 8px 0 12px; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.toolbar form { display: flex; align-items: center; gap: 6px; }
select, input[type=month], .btn { font-size: 12px; padding: 5px 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2); }
.btn { text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--bg-sub); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }

/* ---- KPIカード（白背景＋ボーダーのみ） ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.card { background: #fff; border: 1px solid var(--line); padding: 10px 12px; }
.card .label { font-size: 11px; color: var(--muted); }
.card .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.card .value small { font-size: 11px; font-weight: 400; color: var(--muted); }
.value.warn { color: var(--warn); } .value.bad { color: var(--bad); }

/* ---- テーブル ---- */
table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); font-size: 12.5px; background: #fff; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--bg-sub); font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
tr:hover td { background: #faf9f6; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-strong); }
td a:hover { text-decoration-color: var(--accent); color: var(--accent); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: 0; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* ---- 店舗ホームのアクションカード（色面を使わずボーダーで） ---- */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.action-card { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--line-strong); padding: 16px 18px; background: #fff; border-left: 3px solid var(--line-strong); }
.action-card:hover { border-left-color: var(--accent); }
.action-card.done { background: var(--bg-sub); border-left-color: var(--ink); }
.ac-label { font-size: 14px; font-weight: 600; }
.ac-status { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ac-cta { font-size: 12.5px; color: var(--accent); font-weight: 600; margin-top: 10px; }

/* ---- 入力フォーム（iPad最適化：大きめ・色は最小限） ---- */
.bigform { max-width: 560px; margin-top: 8px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.field .static-val { font-size: 16px; font-weight: 600; padding: 4px 0; }
.num-input, .field input[type=text] {
  width: 100%; font-size: 18px; padding: 11px 12px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); font-variant-numeric: tabular-nums;
}
.num-input { text-align: right; }
.num-input:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(46,90,140,.15); }
.num-input.big { font-size: 22px; padding: 14px 12px; }
.field input[type=text]:not(.num-input) { text-align: left; font-size: 15px; }

.calc-box { border: 1px solid var(--line); background: var(--bg-sub); padding: 10px 14px; margin: 10px 0; }
.calc-box.diff { background: #fff; border-color: var(--line-strong); border-left: 3px solid var(--line-strong); }
.calc-box > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.calc-box .cl { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.calc-box .cv { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-box .hint { font-size: 11px; color: var(--faint); margin-top: 3px; }

.submit-btn { width: 100%; font-size: 16px; padding: 14px; margin-top: 8px; }
.req { font-size: 10px; color: #fff; background: var(--muted); padding: 0 5px; vertical-align: 1px; }

/* ---- 釣り銭の金種テーブル ---- */
.denom-table { max-width: 560px; }
.denom-table .denom-label { font-weight: 600; font-size: 14px; }
.denom-table input.cnt { width: 110px; font-size: 17px; padding: 8px 10px; }
.denom-table .sub { font-size: 14px; color: var(--ink-2); }
.denom-table .total-row td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--bg-sub); }
/* チャネル別売上セクション（店舗入力フォーム） */
.channel-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.channel-section h2 { font-size: 15px; margin-bottom: 4px; }
.channel-table { max-width: 560px; width: 100%; }
.channel-table th, .channel-table td { padding: 6px 8px; }
.channel-table input.num-input { width: 130px; max-width: 100%; }

/* ---- 本部: 未提出チップ・2カラム ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: 11.5px; padding: 3px 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2); text-decoration: none; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.muted { color: var(--faint); border-style: dashed; }

/* ---- ログイン画面 ---- */
.login-body { display: flex; align-items: center; justify-content: center; background: var(--bg-sub); }
.login-card { width: 380px; max-width: 92vw; background: #fff; border: 1px solid var(--line); padding: 30px 28px 22px; }
.login-brand { font-size: 26px; font-weight: 700; letter-spacing: 5px; color: var(--ink); text-align: center; }
.login-sub { font-size: 12px; color: var(--muted); text-align: center; margin-top: 3px; margin-bottom: 20px; }
.login-card label { display: block; font-size: 12px; color: var(--ink-2); font-weight: 600; margin: 12px 0 4px; }
.login-card input { width: 100%; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line-strong); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(46,90,140,.15); }
.login-btn { width: 100%; margin-top: 18px; font-size: 16px; padding: 13px; }
.login-error { background: #f3f6fa; border: 1px solid #d7c4a8; color: var(--bad); font-size: 12px; padding: 8px 10px; margin-bottom: 4px; }
.login-hint { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); line-height: 1.8; }
.login-hint code { background: var(--bg-active); padding: 1px 5px; font-size: 11px; }

/* ---- 承認フロー・フォーム堅牢化・通知（抑制配色） ---- */
.toast { padding: 10px 14px; margin: 10px 0 4px; font-size: 13px; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); background: var(--bg-sub); color: var(--ink); }
.banner { padding: 10px 14px; margin: 8px 0; font-size: 12.5px; border: 1px solid var(--line-strong); border-left: 3px solid var(--line-strong); background: var(--bg-sub); }
.warn-banner { border-left-color: var(--warn); }
.err-banner { border-left-color: var(--bad); color: var(--bad); }
.field-err { color: var(--bad); font-size: 11.5px; margin-top: 4px; }
.tiny { font-size: 10.5px; color: var(--muted); }

/* ステータスバッジ（ボーダーのみ・小） */
.badge { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); } .badge.muted { color: var(--faint); }

/* 確認画面 */
.confirm-table { max-width: 560px; }
.confirm-table th { width: 42%; text-align: left; background: var(--bg-sub); }
.confirm-table tr.emph td, .confirm-table tr.emph th { font-weight: 700; }
.confirm-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; max-width: 560px; }
.confirm-actions .inline-form { flex: 1; }
.confirm-actions .submit-btn { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* 承認・ユーザー操作の行内フォーム */
.approve-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reason-input { font-size: 12px; padding: 5px 8px; border: 1px solid var(--line-strong); width: 180px; }
.btn.mini { font-size: 11.5px; padding: 4px 10px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: #f3f6fa; }
button[disabled], .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Excelライク グリッド */
.quick-filter { font-size: 12.5px; padding: 6px 10px; border: 1px solid var(--line-strong); min-width: 280px; }
#grid { width: 100%; margin-top: 8px; }

/* ユーザー管理 */
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 4px; max-width: 980px; }
.row-form input[type=text], .row-form input[type=password], .row-form select { font-size: 12.5px; padding: 7px 9px; border: 1px solid var(--line-strong); }
.row-form input[type=text], .row-form input[type=password] { min-width: 150px; }
.row-inactive td { opacity: .5; }

/* 入力フォームの補助フィールド・任意ラベル */
.sub-field { margin-top: -6px; padding-left: 12px; border-left: 2px solid var(--line); }
.opt { font-size: 10px; color: var(--muted); border: 1px solid var(--line-strong); padding: 0 5px; vertical-align: 1px; font-weight: 400; margin-left: 4px; }

/* 証憑写真（サムネイル） */
.photo-block { margin-top: 22px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.thumb { width: 160px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.thumb img { width: 100%; height: 108px; object-fit: cover; display: block; border: 1px solid var(--line); background: var(--bg-sub); }
.thumb figcaption { font-size: 11px; color: var(--ink-2); margin-top: 4px; line-height: 1.4; word-break: break-all; }
.thumb .inline-form { margin-top: 4px; }
.photo-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; padding: 12px; border: 1px dashed var(--line-strong); background: var(--bg-sub); max-width: 560px; }
.photo-upload input[type=file] { font-size: 12px; }

/* 督促送信フォーム */
.remind-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.remind-form select { font-size: 12px; }

/* 店舗作成直後の初期アカウント情報パネル（1回限り表示） */
.creds-panel { border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); background: #fbf7f2; padding: 12px 14px; margin: 10px 0; }
.creds-title { font-weight: 700; font-size: 13px; color: var(--ink); }
.creds-body { font-size: 13px; font-variant-numeric: tabular-nums; margin: 6px 0; word-break: break-all; }

/* 本社の代理操作（view-as）バナー（画面上部に固定して見落とし防止） */
.acting-banner { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 9px 14px; margin-bottom: 14px; background: #1b3357; color: #fff; border-left: 3px solid #fff; font-size: 12.5px; }
.acting-banner b { color: #fff; }
.acting-banner .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.acting-banner .btn:hover { background: rgba(255,255,255,.12); }

/* 本部ダッシュボードのグラフ */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; margin: 8px 0; }
.chart-card { background: #fff; border: 1px solid var(--line); padding: 12px 14px; }
.chart-card h3 { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.chart { display: block; }

/* 店舗管理: 行内編集の details */
td details summary { cursor: pointer; display: inline-block; list-style: none; }
td details summary::-webkit-details-marker { display: none; }

/* AG Grid を抑制配色に寄せる（アクセントは青） */
.ag-theme-quartz {
  --ag-active-color: #2e5a8c;
  --ag-range-selection-border-color: #2e5a8c;
  --ag-selected-row-background-color: #f7f6f4;
  --ag-row-hover-color: #faf9f6;
  --ag-header-background-color: #f3f1ec;
  --ag-header-foreground-color: #44464b;
  --ag-border-color: #e4e2dd;
  --ag-font-size: 12.5px;
  --ag-font-family: -apple-system, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

/* ---- コメント（本社⇔店舗の連絡） ---- */
.comment-thread { display: flex; flex-direction: column; gap: 8px; max-width: 760px; margin: 8px 0 14px; }
.comment { border: 1px solid var(--line); border-left: 3px solid var(--line-strong); background: #fff; padding: 8px 12px; }
.comment.from-hq { border-left-color: var(--accent); background: var(--bg-sub); }
.comment.from-store { border-left-color: var(--ok); }
.comment .c-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.comment .c-meta strong { color: var(--ink); font-size: 12.5px; }
.comment .c-body { font-size: 13px; color: var(--ink); white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; align-items: flex-start; max-width: 760px; }
.comment-form textarea { flex: 1; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line-strong); font-family: inherit; resize: vertical; }
.comment-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(46,90,140,.15); }

/* ---- 設定: 自動督促の店舗選択 ---- */
.radio-line { display: inline-block; margin-right: 16px; font-weight: 600; font-size: 13px; }
.store-pick { max-height: 240px; overflow-y: auto; border: 1px solid var(--line-strong); padding: 8px 10px; margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; background: #fff; }
.store-pick .pick { font-weight: 400; font-size: 12.5px; margin: 0; }

/* ============================================================
   レスポンシブ対応（iPad・スマートフォン）
   - サイドバーを上部の横スクロールナビへ
   - データテーブルは横スクロール
   - タッチしやすい入力・ボタン（iOSの自動ズーム防止に16px以上）
   ============================================================ */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar, .sidebar.admin, .sidebar.am {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 60;
    flex-direction: column;
  }
  .brand { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px 10px; }
  .brand-sub { display: none; }
  .store-badge { display: flex; gap: 8px; align-items: baseline; padding: 8px 14px; }
  .sidebar nav {
    flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0 4px; gap: 2px; border-top: 1px solid rgba(255,255,255,.12);
    scrollbar-width: thin;
  }
  .sidebar nav a {
    border-left: none; border-bottom: 3px solid transparent;
    white-space: nowrap; padding: 11px 13px;
  }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .role-tag, .sidebar-foot { display: none; }
  .logout { margin: 0; }
  .content { padding: 14px 14px; max-width: 100%; }
  /* データテーブルは横スクロール（金種表・確認表などのフォーム系は除く） */
  .content table:not(.denom-table):not(.confirm-table) {
    display: block; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  /* タッチターゲットと入力（16px以上でiOSズーム抑止） */
  select, input[type=month], input[type=text], input[type=password], .btn { font-size: 16px; }
  .btn { padding: 9px 14px; }
  .reason-input, .row-form input[type=text], .row-form input[type=password], .row-form select { font-size: 16px; }
  .btn.mini { font-size: 13px; padding: 7px 11px; }
  /* フォーム幅はビューポートに追従 */
  .bigform, .denom-table, .confirm-table, .confirm-actions, .photo-upload, .calc-box, .row-form { max-width: 100%; }
  .quick-filter { min-width: 0; width: 100%; }
}
@media (max-width: 480px) {
  body { font-size: 13.5px; }
  .content { padding: 12px 10px; }
  h1 { font-size: 19px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .num-input.big { font-size: 20px; }
  .denom-table input.cnt { width: 76px; font-size: 16px; }
  .confirm-actions { flex-direction: column; align-items: stretch; }
  .confirm-actions .btn { text-align: center; }
}
