:root {
  --canvas: #F7F8F5;
  --surface: #FFFFFF;
  --ink: #0F2A2E;
  --ink-muted: #5A6B6E;
  --line: #E4E7E2;
  --brand: #0E7C7B;
  --brand-strong: #0A5F5E;
  --brand-soft: #E6F1F0;
  --sage: #C8E0D8;
  --warn: #C2410C;
  --warn-soft: #FBEAE2;

  --radius: 1.25rem;
  --radius-sm: 0.75rem;
  --shadow-quiet: 0 1px 2px rgba(15,42,46,.04), 0 4px 12px rgba(15,42,46,.04);
  --shadow-soft:  0 2px 4px rgba(15,42,46,.05), 0 12px 32px rgba(15,42,46,.06);

  --font-display: "Noto Serif JP","Hiragino Mincho ProN",serif;
  --font-body: "Noto Sans JP","Hiragino Sans",system-ui,sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .auth { grid-template-columns: 1.1fr 1fr; } }

.auth__brand {
  display: none;
  position: relative;
  padding: 4rem;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 18% 8%, #EAF2EE 0%, transparent 55%),
    radial-gradient(80% 60% at 92% 92%, #DCEAE3 0%, transparent 60%),
    var(--canvas);
}
@media (min-width: 1024px) { .auth__brand { display: flex; } }

.auth__copy {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 2.4vw + 1rem, 2.75rem);
  line-height: 1.45;
  letter-spacing: -.01em;
  margin: 0;
}
.auth__lead { max-width: 28rem; margin: 1.75rem 0 0; font-size: .95rem; color: var(--ink-muted); }
.auth__breath { width: 12rem; height: auto; color: var(--brand); opacity: .55; margin-top: 3rem; display: block; }

.auth__footer { display: flex; justify-content: space-between; font-size: .75rem; color: var(--ink-muted); }
.auth__footer a { color: inherit; text-decoration: none; transition: color .2s var(--ease); }
.auth__footer a:hover { color: var(--ink); }

.auth__panel { display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--surface); }
@media (min-width: 640px) { .auth__panel { padding: 3rem; } }
.auth__form-wrap { width: 100%; max-width: 22rem; }

.auth__mark { display: inline-flex; align-items: center; gap: .625rem; text-decoration: none; color: var(--ink); }
.auth__mark-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--brand); transition: transform .3s var(--ease); }
.auth__mark:hover .auth__mark-dot { transform: scale(1.25); }
.auth__mark-name { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: -.01em; }

.auth__title { font-family: var(--font-display); font-size: 1.875rem; letter-spacing: -.01em; margin: 2rem 0 .5rem; }
.auth__sub { font-size: .875rem; color: var(--ink-muted); margin: 0 0 2.25rem; }

.field { margin-bottom: 1.25rem; }
.field__label {
  display: block; margin-bottom: .5rem;
  font-size: .7rem; font-weight: 500; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-muted);
}
.field__input {
  display: block; width: 100%; height: 3rem; padding: 0 1rem;
  background: var(--canvas); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: .95rem;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field__input::placeholder { color: rgba(90,107,110,.6); }
.field__input:focus {
  outline: none; background: var(--surface);
  border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,124,123,.15);
}

.field__row { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; gap: 1rem; }
.field__check { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--ink-muted); cursor: pointer; }
.field__check input { accent-color: var(--brand); width: 1rem; height: 1rem; }

.link-quiet { color: var(--brand); font-size: .8rem; text-decoration: none; transition: color .2s var(--ease); }
.link-quiet:hover { color: var(--brand-strong); }

.alert {
  margin: 0 0 1.25rem; padding: .75rem 1rem;
  background: var(--warn-soft); color: var(--warn);
  border-radius: var(--radius); font-size: .875rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; height: 2.875rem; padding: 0 1.25rem;
  background: var(--brand); color: var(--surface);
  border: 0; border-radius: var(--radius);
  font: 500 .9rem/1 var(--font-body); letter-spacing: .04em;
  box-shadow: var(--shadow-quiet);
  cursor: pointer;
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--brand-strong); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(14,124,123,.35); }
.btn[disabled] { background: rgba(14,124,123,.4); cursor: not-allowed; box-shadow: none; }

.help { margin-top: 2.5rem; font-size: .75rem; color: var(--ink-muted); line-height: 1.7; }
.help a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; transition: text-decoration-color .2s var(--ease); }
.help a:hover { text-decoration-color: var(--brand); }

.preview-bar {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface);
  border-radius: 999px; padding: .5rem .25rem .5rem 1rem;
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .75rem; box-shadow: var(--shadow-soft); z-index: 50;
}
.preview-bar a {
  color: var(--surface); text-decoration: none;
  padding: .375rem .75rem; border-radius: 999px;
  opacity: .7; transition: background .2s var(--ease), opacity .2s var(--ease);
}
.preview-bar a.is-active, .preview-bar a:hover { background: rgba(255,255,255,.12); opacity: 1; }

/* ───── register / multi-section forms ───── */
/* プラン選択 select の文言(健康診断追加で長め)が省略されず収まる幅。狭いと末尾「(月額…)」が切れる */
.auth__form-wrap--wide { max-width: 44rem; }

.section { margin-top: 2rem; }
.section:first-of-type { margin-top: 0; }
.section__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--ink);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}

.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.field__hint { display: block; margin-top: .375rem; font-size: .72rem; color: var(--ink-muted); line-height: 1.6; }

.field__select-wrap { position: relative; }
.field__select-wrap::after {
  content: ""; position: absolute; right: 1.1rem; top: 50%;
  width: .5rem; height: .5rem;
  border-right: 1.5px solid var(--ink-muted);
  border-bottom: 1.5px solid var(--ink-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.field__select {
  display: block; width: 100%; height: 3rem; padding: 0 2.25rem 0 1rem;
  background: var(--canvas); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: .95rem;
  appearance: none;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field__select:focus {
  outline: none; background: var(--surface);
  border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,124,123,.15);
}

.consent { margin-top: 1.75rem; display: flex; flex-direction: column; gap: .75rem; }
.consent__row { display: flex; gap: .625rem; align-items: flex-start; font-size: .8rem; color: var(--ink-muted); line-height: 1.6; }
.consent__row input[type="checkbox"] { accent-color: var(--brand); width: 1.05rem; height: 1.05rem; margin-top: .15rem; flex-shrink: 0; }
.consent__row a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; transition: text-decoration-color .2s var(--ease); }
.consent__row a:hover { text-decoration-color: var(--brand); }

.auth__nav-back {
  display: inline-flex; align-items: center; gap: .375rem;
  margin-bottom: 1.5rem; font-size: .8rem; color: var(--ink-muted);
  text-decoration: none; transition: color .2s var(--ease);
}
.auth__nav-back:hover { color: var(--ink); }
.auth__nav-back::before { content: "←"; font-size: 1rem; }

.auth__email-readonly {
  display: inline-block; padding: .35rem .7rem;
  background: var(--brand-soft); color: var(--brand-strong);
  border-radius: 999px; font-size: .78rem; letter-spacing: .02em;
}

.btn--block { width: 100%; margin-top: 2rem; }

@media (min-width: 1024px) {
  .auth--scrollable .auth__panel { overflow-y: auto; max-height: 100vh; padding-top: 4rem; padding-bottom: 4rem; }
}

/* ═══════════════════════════════════════
   App Shell (ログイン後の共通レイアウト)
   ═══════════════════════════════════════ */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "side topbar"
    "side main";
  background: var(--canvas);
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .shell__side { display: none; }
}

.shell__side {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.5rem 0;
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.shell__brand {
  display: flex; align-items: center; gap: .625rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  text-decoration: none; color: var(--ink);
}
.shell__brand-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--brand); }
.shell__brand-name { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: -.01em; }

.nav { list-style: none; margin: 0; padding: 0 .75rem; display: flex; flex-direction: column; gap: .125rem; }
.nav__group { margin: 0; padding: 0; border: none; }
.nav__group-title {
  font-size: .65rem; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-muted);
  padding: 1rem 1rem .5rem;
}
summary.nav__group-title {
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  list-style: none;
  user-select: none;
  transition: color .15s var(--ease);
}
summary.nav__group-title::-webkit-details-marker { display: none; }
summary.nav__group-title:hover { color: var(--ink); }
summary.nav__group-title::after {
  content: '';
  width: .4rem; height: .4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s var(--ease);
  opacity: .6;
  margin-left: .5rem;
  flex-shrink: 0;
}
.nav__group[open] > summary.nav__group-title::after {
  transform: rotate(45deg);
}
.nav__item a {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem 1rem;
  border-radius: .75rem;
  font-size: .875rem; color: var(--ink);
  text-decoration: none;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav__item a:hover { background: var(--canvas); }
.nav__item--active a, .nav__item.is-active a { background: var(--brand-soft); color: var(--brand-strong); font-weight: 500; }
.nav__icon { width: 1rem; height: 1rem; flex-shrink: 0; opacity: .7; }
.nav__item--active .nav__icon, .nav__item.is-active .nav__icon { opacity: 1; }
.nav__badge {
  margin-left: auto;
  padding: .1rem .4rem;
  font-size: .65rem; letter-spacing: .04em;
  background: #fee2e2; color: #b91c1c;
  border-radius: 999px;
}

.shell__topbar {
  grid-area: topbar;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar__corp { font-size: .85rem; color: var(--ink-muted); display: flex; align-items: center; gap: .5rem; }
.topbar__corp strong { color: var(--ink); font-weight: 500; }
.topbar__chip { display: inline-flex; padding: .15rem .55rem; background: var(--brand-soft); color: var(--brand-strong); border-radius: 999px; font-size: .7rem; letter-spacing: .04em; }
.topbar__menu { display: flex; align-items: center; gap: 1rem; }
.topbar__user {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .375rem .875rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .8rem; color: var(--ink); text-decoration: none;
  transition: background .2s var(--ease);
}
.topbar__user:hover { background: var(--canvas); }
.topbar__avatar {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--sage); color: var(--brand-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 500;
}
.topbar__logout { font-size: .75rem; color: var(--ink-muted); text-decoration: none; }
.topbar__logout:hover { color: var(--ink); }

.shell__main { grid-area: main; padding: 2.5rem 2.5rem 4rem; max-width: 1800px; min-width: 0; }

.page__crumb { font-size: .75rem; color: var(--ink-muted); margin: 0 0 .75rem; letter-spacing: .04em; }
.page__crumb a { color: var(--brand); text-decoration: none; }
.page__crumb a:hover { color: var(--brand-strong); text-decoration: underline; }
.page__title-row { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap; }
.page__title { font-family: var(--font-display); font-size: 2rem; font-weight: 500; letter-spacing: -.01em; margin: 0; }
.page__lead { color: var(--ink-muted); margin: .25rem 0 0; font-size: .9rem; }
.page__actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ── KPI cards ─────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-quiet);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
  position: relative;
}
.kpi:hover { box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.kpi__label { font-size: .8rem; color: var(--ink-muted); margin: 0 0 .5rem; }
.kpi__value { font-family: var(--font-display); font-size: 2.25rem; font-weight: 500; letter-spacing: -.01em; line-height: 1; color: var(--ink); }
.kpi__unit { font-size: .85rem; color: var(--ink-muted); margin-left: .25rem; font-family: var(--font-body); }
.kpi__delta { display: inline-flex; align-items: center; gap: .25rem; margin-top: .75rem; font-size: .75rem; color: var(--ink-muted); }
.kpi__delta--up { color: var(--brand-strong); }
.kpi__delta--down { color: var(--warn); }
.kpi__accent { position: absolute; top: 1.25rem; right: 1.5rem; width: .75rem; height: .75rem; border-radius: 50%; background: var(--brand); opacity: .5; }
.kpi--brand .kpi__accent { background: var(--brand); }
.kpi--sage .kpi__accent { background: #8AB4A2; }
.kpi--warm .kpi__accent { background: #C2410C; opacity: .4; }
.kpi--info .kpi__accent { background: #6E8AA0; }
.kpi--neutral .kpi__accent { background: var(--ink-muted); opacity: .35; }

/* ── Card panel (for charts, tables, etc.) ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-quiet);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
/* 横スクロール可能なテーブル/コンテンツ用のラッパ。.panel に入れて使う */
.table-wrap { overflow-x: auto; }

/* スクリーンリーダー専用テキスト（視覚的には非表示） */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ローディングスピナー（Bootstrap 互換の最小実装） */
.spinner-border {
  display: inline-block;
  width: 2.5rem; height: 2.5rem;
  vertical-align: -0.125em;
  border: 0.25em solid var(--brand-soft, #d8e3df);
  border-right-color: var(--brand, #6b8b80);
  border-radius: 50%;
  animation: kirihare-spin .75s linear infinite;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}
@keyframes kirihare-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.panel__title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 500;
  margin: 0 0 .25rem;
  letter-spacing: .005em;
}
.panel__sub { color: var(--ink-muted); font-size: .8rem; margin: 0 0 1rem; }
.panel__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.panel__head > :first-child { min-width: 0; flex: 1 1 auto; }

/* ── Action bar (用 employee 一覧 等) ── */
.actionbar { display: flex; flex-wrap: wrap; gap: 1.5rem; padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.actionbar__group { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.actionbar__group-title { font-size: .68rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); }
.actionbar__row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actionbar__divider { width: 1px; background: var(--line); margin: 0 .5rem; align-self: stretch; }

/* ── small button variants ── */
.btn--ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--canvas); border-color: var(--ink-muted); box-shadow: var(--shadow-quiet); }
.btn--sm { width: auto; height: 2.25rem; padding: 0 .9rem; font-size: .8rem; border-radius: .75rem; }
.btn--icon { gap: .35rem; }

.file-pick {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem; border: 1px dashed var(--line);
  border-radius: .75rem; cursor: pointer;
  font-size: .8rem; color: var(--ink-muted);
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.file-pick:hover { border-color: var(--brand); color: var(--brand-strong); }
.file-pick input[type="file"] { display: none; }

.tag-status {
  display: inline-flex; padding: .15rem .55rem;
  border-radius: 999px; font-size: .7rem;
  background: var(--canvas); color: var(--ink-muted);
}

.empty-grid {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface);
  font-size: .85rem;
}

/* ── icon (inline SVG sizing) ── */
.icon { width: 1rem; height: 1rem; flex-shrink: 0; opacity: .65; }
.icon--lg { width: 1.125rem; height: 1.125rem; }
.nav__item a:hover .icon, .nav__item--active .icon { opacity: 1; }

/* ── command palette in topbar ── */
.topbar__search {
  position: relative;
  flex: 1; max-width: 32rem; margin: 0 2rem;
  display: flex; align-items: center; gap: .5rem;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .4rem .9rem;
  font-size: .8rem; color: var(--ink-muted);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.topbar__search:hover { border-color: var(--ink-muted); background: var(--surface); }
.topbar__search:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(14,124,123,.18);
}
.topbar__search-input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  font: inherit; color: var(--ink);
  padding: 0;
}
.topbar__search-input::placeholder { color: var(--ink-muted); }
.topbar__search-input::-webkit-search-cancel-button { display: none; }
.topbar__search-panel {
  position: absolute; top: calc(100% + .4rem); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow-soft);
  padding: .5rem;
  max-height: 24rem;
  overflow-y: auto;
  z-index: 100;
}
.topbar__search-result {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .7rem;
  border-radius: .5rem;
  font-size: .85rem; color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.topbar__search-result:hover,
.topbar__search-result.is-active {
  background: var(--brand-soft); color: var(--brand-strong);
}
.topbar__search-result__main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.topbar__search-result__label { line-height: 1.3; }
.topbar__search-result__sub { font-size: .72rem; color: var(--ink-muted); }
.topbar__search-result.is-active .topbar__search-result__sub { color: var(--brand-strong); opacity: .75; }
.topbar__search-result__group-label {
  margin-left: auto; font-size: .7rem; color: var(--ink-muted);
  letter-spacing: .04em; white-space: nowrap;
}
.topbar__search-result.is-active .topbar__search-result__group-label { color: var(--brand-strong); opacity: .7; }
.topbar__search-section-title {
  font-size: .7rem; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .08em;
  padding: .5rem .7rem .25rem;
}
.topbar__search-section-title:first-child { padding-top: .25rem; }
.topbar__search-empty {
  padding: 1rem; text-align: center;
  color: var(--ink-muted); font-size: .8rem;
}
.topbar__kbd {
  display: inline-flex; align-items: center; gap: .15rem;
  font-family: var(--font-body);
  font-size: .65rem; letter-spacing: .04em;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .375rem;
  padding: .075rem .35rem;
}
@media (max-width: 900px) { .topbar__search { display: none; } }

/* ── KPI sparkline + delta ── */
.kpi__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .25rem; gap: .75rem; }
.kpi__spark { width: 100%; height: 36px; margin-top: .75rem; display: block; }
.kpi__spark path { fill: none; stroke: currentColor; stroke-width: 1.5; }
.kpi__spark--brand { color: var(--brand); }
.kpi__spark--sage { color: #6e9b87; }
.kpi__spark--warm { color: #c2410c; }
.kpi__spark--info { color: #6e8aa0; }
.kpi__spark--neutral { color: var(--ink-muted); }
.kpi__spark-fill {
  fill: currentColor; opacity: .08;
}

.kpi__delta {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .75rem; color: var(--ink-muted);
  margin: 0;
}
.kpi__delta-arrow { font-size: .85em; }
.kpi__delta--up { color: #2e7d57; }
.kpi__delta--down { color: var(--warn); }

/* ── Table toolbar ── */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.toolbar__search {
  flex: 1; min-width: 14rem; max-width: 22rem;
  display: flex; align-items: center; gap: .5rem;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .45rem .75rem;
  font-size: .85rem;
}
.toolbar__search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  font: inherit; color: var(--ink);
}
.toolbar__search input::placeholder { color: var(--ink-muted); }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .78rem; color: var(--ink);
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.chip:hover { background: var(--canvas); border-color: var(--ink-muted); }
.chip--active { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.chip--dismiss::after { content: "×"; font-size: .9rem; opacity: .5; }
.chip--dismiss:hover::after { opacity: 1; }
.chip--static { cursor: default; }
.chip--static:hover { background: var(--surface); border-color: var(--line); }
.chip--static.chip--active:hover { background: var(--brand-soft); border-color: transparent; }

.toolbar__divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 .25rem; }
.toolbar__spacer { flex: 1; }
.toolbar__count { font-size: .75rem; color: var(--ink-muted); margin-right: .5rem; }

/* ── Status pill / health indicator ── */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .6rem; border-radius: 999px;
  font-size: .7rem; letter-spacing: .02em;
  background: var(--canvas); color: var(--ink-muted);
}
.pill__dot { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.pill--ok    { color: #2e7d57; background: #e7f3ec; }
.pill--watch { color: #b6841d; background: #faf1d9; }
.pill--alert { color: var(--warn); background: var(--warn-soft); }

/* ── Insight strip (alerts at top of dashboard) ── */
.insight {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.insight__body { flex: 1; font-size: .85rem; }
.insight__body strong { color: var(--ink); font-weight: 500; }
.insight__body p { margin: .1rem 0 0; color: var(--ink-muted); font-size: .78rem; }
.insight--alert { border-left-color: var(--warn); }
.insight--watch { border-left-color: #b6841d; }

/* ── Mobile improvements ── */
@media (max-width: 720px) {
  .shell__main { padding: 1.5rem; }
  .page__title { font-size: 1.5rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi__value { font-size: 1.75rem; }
  .actionbar { flex-direction: column; }
  .actionbar__divider { display: none; }
}

/* ═══════════════════════════════════════
   Fallbacks for legacy class names + extras
   （Agent が使った未定義 class への保険）
   ═══════════════════════════════════════ */

.panel__body { padding: 1.25rem 1.5rem; }
.panel--no-pad { padding: 0; }

.kpi__sub { font-size: .78rem; color: var(--ink-muted); margin: .25rem 0 0; line-height: 1.5; }
.kpi--wide { grid-column: 1 / -1; }
.kpi--compact { padding: 1rem 1.25rem; }
.kpi--compact .kpi__value { font-size: 1.6rem; }

.page__footnote { color: var(--ink-muted); font-size: .8rem; margin: 1rem 0 0; line-height: 1.65; }

/* generic table */
.data-table, .demo-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th, .demo-table th, .data-table td, .demo-table td {
  text-align: left; padding: .65rem .9rem;
  border-bottom: 1px solid var(--line);
}
.data-table thead th, .demo-table thead th {
  font-weight: 500; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted);
}
.data-table tbody tr:hover, .demo-table tbody tr:hover { background: var(--canvas); }
.data-table caption, .demo-table caption {
  caption-side: top; text-align: left; font-weight: 500;
  font-family: var(--font-display); font-size: 1rem;
  color: var(--ink); padding: 0 0 .5rem;
}

/* DataTables widgets を新デザインに馴染ませる（検索とページングのみ） */
.dataTables_wrapper { padding: 0; color: var(--ink); max-width: 100%; }
.dt-top { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.dt-bot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.dataTables_filter { font-size: .8rem; color: var(--ink-muted); }
.dataTables_filter input {
  padding: .4rem .75rem;
  border: 1px solid var(--line); border-radius: .5rem;
  font-size: .85rem; background: var(--surface); color: var(--ink);
  outline: none; transition: border-color .2s var(--ease);
}
.dataTables_filter input:focus { border-color: var(--brand); }
.dataTables_info { font-size: .8rem; color: var(--ink-muted); }
.dataTables_paginate {
  font-size: .8rem;
  display: flex; flex-wrap: wrap; justify-content: flex-end;
  gap: .15rem;
}
.dataTables_paginate .paginate_button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.875rem; height: 1.875rem;
  padding: 0 .6rem; margin: 0 .1rem;
  border: 1px solid var(--line); border-radius: .5rem;
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.dataTables_paginate .paginate_button:hover { background: var(--canvas); border-color: var(--ink-muted); }
.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
  background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand-soft);
}
.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
  opacity: .35; cursor: not-allowed; background: var(--surface); border-color: var(--line);
}
/* シンプルなアクションドロップダウン（自前実装、DataTables非依存） */
.action-dropdown { position: relative; display: inline-block; }
.action-dropdown__menu {
  position: absolute;
  top: calc(100% + .3rem);
  right: 0;
  display: none;
  min-width: 11rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .75rem;
  box-shadow: var(--shadow-quiet);
  padding: .375rem;
  z-index: 50;
}
.action-dropdown.is-open .action-dropdown__menu { display: block; }
.action-dropdown__item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .65rem;
  font-size: .85rem; color: var(--ink);
  border-radius: .5rem;
  cursor: pointer;
  user-select: none;
}
.action-dropdown__item:hover { background: var(--canvas); }
.action-dropdown__item input[type="checkbox"] {
  width: .9rem; height: .9rem; accent-color: var(--brand);
  margin: 0; cursor: pointer;
}

/* SmartAdmin legacy class fallbacks（旧テンプレが残してる場合の最低限の表示） */
.subheader { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.subheader-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; margin: 0; letter-spacing: -.005em; }
.subheader-icon { color: var(--brand); margin-right: .25rem; }
.page-breadcrumb { display: none; } /* 新 .page__crumb と重複するので非表示 */
.breadcrumb-item { font-size: .75rem; color: var(--ink-muted); }
.widget-body { padding: 1rem; }

/* 旧 Bootstrap btn-* class を ghost ボタンに寄せる */
.btn-primary:not([class*="btn--"]) {
  background: var(--brand); color: var(--surface);
  border: 0; border-radius: 1.25rem; padding: 0 1.25rem; height: 2.875rem;
  font: 500 .9rem/1 var(--font-body); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s var(--ease);
}
.btn-primary:not([class*="btn--"]):hover { background: var(--brand-strong); }
.btn-secondary:not([class*="btn--"]) {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 1.25rem; padding: 0 1.25rem; height: 2.875rem;
  font: 500 .9rem/1 var(--font-body); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-danger:not([class*="btn--"]) {
  background: var(--warn); color: var(--surface); border: 0;
  border-radius: 1.25rem; padding: 0 1.25rem; height: 2.875rem;
  font: 500 .9rem/1 var(--font-body); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Bootstrap d-* / col-* の最小ポリフィル（旧テンプレで残ってる場合用） */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }

.col-12 { width: 100%; }
.col-6 { width: 50%; }
.col-4 { width: calc(100% / 3); }
.col-3 { width: 25%; }
@media (min-width: 768px) {
  .col-md-12 { width: 100%; }
  .col-md-6 { width: 50%; }
  .col-md-4 { width: calc(100% / 3); }
}

.row { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem; } .mt-5 { margin-top: 1.5rem; }
.mr-1 { margin-right: .25rem; } .mr-2 { margin-right: .5rem; } .mr-3 { margin-right: .75rem; }
.ml-auto { margin-left: auto; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--ink-muted); }
.text-danger { color: var(--warn); }
.fw-300 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-700 { font-weight: 700; }

/* form-control を field__input に寄せる */
.form-control:not(.field__input) {
  display: block; width: 100%; height: 3rem; padding: 0 1rem;
  background: var(--canvas); color: var(--ink);
  border: 1px solid var(--line); border-radius: 1.25rem;
  font: inherit; font-size: .95rem;
  transition: border-color .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease);
}
.form-control:not(.field__input):focus {
  outline: none; background: var(--surface);
  border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,124,123,.15);
}
.form-group { margin-bottom: 1.25rem; }

/* 旧アラート類 → .alert スタイルにフォールバック */
.alert-danger { background: var(--warn-soft); color: var(--warn); padding: .75rem 1rem; border-radius: 1.25rem; font-size: .875rem; margin-bottom: 1rem; }
.alert-success { background: var(--brand-soft); color: var(--brand-strong); padding: .75rem 1rem; border-radius: 1.25rem; font-size: .875rem; margin-bottom: 1rem; }
.alert-info { background: var(--canvas); color: var(--ink); border: 1px solid var(--line); padding: .75rem 1rem; border-radius: 1.25rem; font-size: .875rem; margin-bottom: 1rem; }

/* ── Employee 画面 強化 (KPI + sticky 保存バー) ── */
.kpi-grid--employee { grid-template-columns: repeat(4, 1fr); margin-bottom: 1.5rem; }
@media (max-width: 900px) { .kpi-grid--employee { grid-template-columns: 1fr 1fr; } }
.kpi-grid--employee .kpi { padding: 1rem 1.25rem; }
.kpi-grid--employee .kpi__value { font-size: 1.6rem; }
.kpi-grid--employee .kpi__label { margin: 0 0 .35rem; }

.toolbar__search input[type="search"] {
  flex: 1; background: transparent; border: 0; outline: 0;
  font: inherit; font-size: .9rem; color: var(--ink);
  padding: 0;
}
.toolbar__search input[type="search"]::placeholder { color: var(--ink-muted); }

.commit-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: .85rem 1.5rem;
  margin: 1.5rem -2.5rem -4rem;
  box-shadow: 0 -8px 24px rgba(15,42,46,.06);
  z-index: 5;
}
.commit-bar__text {
  font-size: .8rem; color: var(--ink-muted);
  display: inline-flex; align-items: center; gap: .5rem;
}
.commit-bar__text strong { color: var(--ink); font-weight: 500; }
.commit-bar__text--dirty strong { color: var(--brand-strong); }
.commit-bar__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.employee__loginbadge {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .25rem .625rem;
  background: var(--brand-soft); color: var(--brand-strong);
  border-radius: 999px; font-size: .75rem;
}

.disclosure[hidden] { display: none !important; }
.disclosure__head {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .35rem .75rem;
  font-size: .8rem; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.disclosure__head:hover { background: var(--canvas); border-color: var(--ink-muted); }
.disclosure__head[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.disclosure__caret { transition: transform .2s var(--ease); }
.disclosure__head[aria-expanded="true"] .disclosure__caret { transform: rotate(180deg); }

/* trial period box の刷新（既存テンプレに inline style で残ってる場合の上書き） */
.trial-period-box {
  margin-top: 1rem !important;
  padding: 1.25rem 1.5rem !important;
  border: 1px solid var(--line) !important;
  border-left: 3px solid var(--brand) !important;
  border-radius: 1.25rem !important;
  background: var(--surface) !important;
  box-shadow: var(--shadow-quiet) !important;
  font-size: .875rem !important;
  color: var(--ink) !important;
}
.trial-period-box h2 { font-family: var(--font-display); font-size: 1.1rem !important; font-weight: 500; margin-bottom: .5rem !important; }
.trial-period-box .trial-info { color: var(--brand-strong); }
