/* ==== デザイントークン ====
   各テンプレートのTailwind任意値クラス（例: bg-[var(--brand)]）はここで定義した変数を参照する。
   ダークモードはbody[data-theme="dark"]で変数を上書きするだけで全画面に反映される。 */
:root {
  --brand: #1e3a5f;
  --brand-hover: #16304f;
  --danger: #b3403a;  --danger-bg: #fdf2f1;  --danger-border: #f3d2cf;
  --warn: #a06a1f;    --warn-bg: #fdf6ea;    --warn-border: #f0dfc0;
  --yellow: #8f7c22;  --yellow-bg: #fbf8e8;  --yellow-border: #eadfae;
  --ok: #2e6b3a;      --ok-bg: #edf6ef;      --ok-border: #cfe6d4;
  --info: #1a4d8f;    --info-bg: #eef4fb;    --info-border: #d5e3f3;
  --ink-1: #1a2734; --ink-2: #3d4c5a; --ink-3: #71818e;
  --line-1: #dde6ec; --line-2: #ecf1f5;
  --surface: #fff; --surface-2: #f6f9fb; --page-bg: #eef3f6;
  --hover-bg: #f8fbfd; --detail-bg: #fafcfe;
  --side-bg: #1e3a5f; --side-ink: rgba(255,255,255,.72); --side-ink-strong: #fff;
  --side-active: rgba(255,255,255,.13); --side-group: rgba(255,255,255,.42);
  --radius: 10px;
  --shadow-card: 0 1px 2px rgba(30,58,95,.06), 0 4px 12px rgba(30,58,95,.05);
}
html[data-theme="dark"] {
  --brand: #16304f;
  --danger: #e0897f; --danger-bg: #3a2422; --danger-border: #5c3833;
  --warn: #d9ab5e;   --warn-bg: #372c18;   --warn-border: #57451f;
  --yellow: #cfc06a; --yellow-bg: #33301a; --yellow-border: #524c26;
  --ok: #8cc79a;     --ok-bg: #1f3324;     --ok-border: #305239;
  --info: #8db8e8;   --info-bg: #1c2c40;   --info-border: #2d4763;
  --ink-1: #e8eef3; --ink-2: #c2ccd5; --ink-3: #8794a0;
  --line-1: #2b3844; --line-2: #232e39;
  --surface: #1a232c; --surface-2: #161e26; --page-bg: #10161c;
  --hover-bg: #202b35; --detail-bg: #171f28;
  --side-bg: #131c26;
  --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
}

body {
  background: var(--page-bg);
  transition: background-color .25s;
  /* 数字の桁を縦に揃える。文字には影響しないため全体にかけて問題ない */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ==== シェル：サイドバー＋コンテンツ ==== */
.shell { display: flex; min-height: 100vh; }
.sidenav {
  width: 216px; flex-shrink: 0; background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow: hidden; z-index: 60;
}
.side-brand {
  display: flex; align-items: center; gap: 9px; padding: 16px 16px 12px;
  color: var(--side-ink-strong); font-weight: 700; font-size: 15px; letter-spacing: .02em;
  white-space: nowrap; text-decoration: none;
}
.side-brand:hover { text-decoration: none; }
.side-cta-wrap { position: relative; padding: 4px 12px 12px; }
.side-cta {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; color: #1e3a5f; border: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 700; padding: 9px 0; cursor: pointer; font-family: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); white-space: nowrap;
}
.side-cta:hover { background: #eef4fb; }
.quick-menu {
  display: none; position: absolute; top: calc(100% - 6px); left: 12px; right: 12px; z-index: 90;
  background: var(--surface); border: 1px solid var(--line-1); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.22); overflow: hidden; padding: 5px;
}
.quick-menu.open { display: block; animation: fadein .14s ease; }
.quick-menu a {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink-1); white-space: nowrap; text-decoration: none;
}
.quick-menu a:hover { background: var(--info-bg); text-decoration: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 2px 8px; }
.side-group { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; color: var(--side-group); padding: 14px 10px 4px; white-space: nowrap; }
.side-nav a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px;
  color: var(--side-ink); font-size: 13.5px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.side-nav a:hover { color: var(--side-ink-strong); background: rgba(255,255,255,.06); text-decoration: none; }
.side-nav a.active { color: var(--side-ink-strong); background: var(--side-active); font-weight: 700; }
.side-foot { padding: 10px 8px 12px; border-top: 1px solid rgba(255,255,255,.12); }
.side-foot .settings-link {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px;
  color: var(--side-ink); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  cursor: pointer; background: none; border: none; width: 100%; text-align: left; font-family: inherit;
}
.side-foot .settings-link:hover { color: var(--side-ink-strong); background: rgba(255,255,255,.06); }
.side-role { padding: 7px 10px; font-size: 12px; color: var(--side-group); white-space: nowrap; }

.content { flex: 1; min-width: 0; }

.menu-fab { display: none; }
@media (max-width: 760px) {
  .sidenav { position: fixed; left: 0; top: 0; z-index: 120; transform: translateX(-100%); transition: transform .25s ease; width: 232px; }
  .shell.mobile-open .sidenav { transform: none; }
  .menu-fab {
    display: grid; place-items: center; position: fixed; left: 14px; bottom: 14px; z-index: 110;
    width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  }
  .mobile-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 115; }
  .shell.mobile-open .mobile-backdrop { display: block; }
}

@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* ==== 設定シート（下からぬるっと・拡張で全画面） ==== */
.sheet { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.sheet .sheet-backdrop { position: absolute; inset: 0; background: rgba(10,18,26,.45); opacity: 0; transition: opacity .28s ease; }
.sheet .sheet-panel {
  position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 105%);
  width: min(860px, 96vw); height: min(72vh, 560px);
  background: var(--surface); border: 1px solid var(--line-1); border-bottom: none;
  border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.28);
  transition: transform .32s cubic-bezier(.32,.72,.33,1), width .28s cubic-bezier(.32,.72,.33,1),
    height .28s cubic-bezier(.32,.72,.33,1), border-radius .28s ease, top .28s cubic-bezier(.32,.72,.33,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translate(-50%, 0); }
.sheet.expanded .sheet-panel { width: 100vw; height: 100vh; top: 0; left: 50%; border-radius: 0; border: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.sheet-head h2 { font-size: 15px; font-weight: 700; color: var(--ink-1); margin: 0; }
.sheet-expand, .sheet-close {
  width: 28px; height: 28px; border-radius: 7px; border: none; background: var(--surface-2);
  color: var(--ink-3); cursor: pointer; font-size: 14px; display: grid; place-items: center;
}
.sheet-expand { margin-left: auto; }
.sheet-close { margin-left: 6px; }
.sheet-expand:hover, .sheet-close:hover { background: var(--line-2); color: var(--ink-1); }
.sheet-body { flex: 1; display: flex; min-height: 0; }
.sheet-side { width: 180px; flex-shrink: 0; border-right: 1px solid var(--line-2); padding: 12px 8px; background: var(--surface-2); }
.sheet-side a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2); text-decoration: none; cursor: pointer;
}
.sheet-side a:hover { background: var(--line-2); text-decoration: none; }
.sheet-side a.active { background: var(--info-bg); color: var(--info); font-weight: 700; }
.sheet-main { flex: 1; overflow-y: auto; padding: 20px 24px; }
.sheet-main h3 { font-size: 14px; font-weight: 700; color: var(--ink-1); margin: 0 0 14px; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.setting-row .stitle { font-size: 13.5px; font-weight: 600; color: var(--ink-1); }
.setting-row .sdesc { font-size: 12px; color: var(--ink-3); }
.setting-row .ctrl { margin-left: auto; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--line-1); transition: background-color .2s; cursor: pointer; }
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + .track { background: var(--info); }
.switch input:checked + .track::after { transform: translateX(18px); }
@media (max-width: 640px) { .sheet-side { width: 120px; } .sheet-main { padding: 16px; } }

/* ==== マスタ管理：ページ内2ペイン ==== */
.masters-layout { display: flex; gap: 22px; align-items: flex-start; }
.masters-side { width: 176px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--line-1); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 10px 8px; }
.masters-side .group { font-size: 10.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .05em; padding: 8px 10px 4px; }
.masters-side a { display: block; padding: 6px 10px; font-size: 13px; border-radius: 7px; color: var(--ink-2); text-decoration: none; }
.masters-side a:hover { background: var(--surface-2); text-decoration: none; }
.masters-side a.active { background: var(--info-bg); color: var(--info); font-weight: 700; }
.masters-main { flex: 1; min-width: 0; }
@media (max-width: 700px) { .masters-layout { flex-direction: column; } .masters-side { width: 100%; } }

/* ==== KPIカード ==== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line-1); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-card); }
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--ink-1); margin-top: 4px; }
.kpi-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.kpi.alert .kpi-value { color: var(--danger); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.ok .kpi-value { color: var(--ok); }

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.home-card { background: var(--surface); border: 1px solid var(--line-1); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 16px; display: flex; flex-direction: column; }
.home-card h2 { font-size: 14px; font-weight: 700; color: var(--ink-1); margin: 0 0 10px; }
.home-card .body { flex: 1; }
.home-card .links { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.home-card .links a { font-size: 13px; font-weight: 600; }
.home-card .links a.sub { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.mini-label { font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 6px; }
.badge-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ==== フラッシュ ==== */
#flash { display: flex; align-items: center; gap: 8px; }

/* ==== 登録ページの見出しラベル（サイドバーに項目を持たない代わりに現在地を示す） ==== */
.crumb { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .05em; margin-bottom: 2px; }
