/* base.css
 * 凍結モック（案3_ソフトポータル調）の構成要素を部品化したもの。
 * 色は必ず tokens.css の変数を使う（生の色コード禁止）。
 *
 * 収録部品:
 *   レイアウトシェル(.app-shell / .sidebar / .topbar / .main)
 *   カード(.card)  ステップ進捗(.steps)  バッジ(.badge)  テーブル行(.rows)
 *   通知バッジ(.notif)  KPIタイル(.kpi)  ボタン(.btn)  フォーム(.field)
 */

/* ============ 基礎 ============ */
* { box-sizing: border-box; }
/* display を持つ部品（.notif / .badge 等）にも hidden を効かせる */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-blue-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); margin: 0; line-height: var(--lh-tight); }
.muted { color: var(--text-muted); }
.tnum { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ============ レイアウトシェル ============ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
  font-weight: 700; color: var(--text); font-size: var(--fs-h3);
}
.sidebar__brand small { display: block; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; letter-spacing: .12em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 11px var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-weight: 600;
  text-decoration: none;
}
.nav__item:hover { background: var(--surface); text-decoration: none; }
.nav__item.is-active { background: var(--primary-soft); color: var(--primary-strong); }
.nav__item .icon { width: 20px; height: 20px; flex: none; color: currentColor; }
.nav__item .notif { margin-left: auto; }
.sidebar__foot { margin-top: auto; }

.main {
  min-width: 0;
  padding: var(--sp-6) var(--sp-8) var(--sp-10);
  max-width: var(--content-max);
}

/* トップバー（会社名見出し＋右上のアクション） */
.topbar {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.topbar__title { font-size: var(--fs-display); font-weight: 700; letter-spacing: .01em; }
.topbar__lead { margin: 6px 0 0; color: var(--text-muted); font-size: var(--fs-body); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); }
.iconbtn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.iconbtn:hover { background: var(--surface); color: var(--text); }
.userchip {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  padding: 6px 14px 6px 6px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font-weight: 600;
}
.userchip__avatar {
  width: 30px; height: 30px; border-radius: var(--radius-pill);
  background: var(--primary-tint); color: var(--primary-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-sm);
}

/* ---- 狭い画面（スマホ・760px 以下）: シェルを縦積みにする（全ロール共通） ----
   固定サイドバー 232px のままだと 390px で必ず横スクロールが出るため、
   サイドバーを上部の横並びナビへ切り替える（折り返し式＝ページ幅を押し広げない）。
   1366px 以上の見た目は一切変わらない（この media 内だけの指定）。 */
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: var(--sp-3) var(--sp-4);
  }
  .sidebar__brand { padding: 0; font-size: var(--fs-body); }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; gap: var(--sp-2); }
  .nav__item { white-space: nowrap; padding: 8px var(--sp-3); }
  .sidebar__foot { margin-top: 0; margin-left: auto; }
  .sidebar__foot .btn { padding: 8px var(--sp-4); }
  .main { padding: var(--sp-4) var(--sp-4) 88px; max-width: 100%; }
  .topbar { flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
  .topbar__title { font-size: 24px; }
  .topbar__actions { margin-left: 0; width: 100%; min-width: 0; }
  .userchip { min-width: 0; overflow: hidden; }
  .userchip > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ============ カード ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
}
.card__head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.card__title { font-size: var(--fs-h2); font-weight: 700; }
.card__foot { margin-top: var(--sp-5); text-align: center; }
.card__link { font-weight: 600; color: var(--accent-blue-text); }

/* 見出し左のアイコンタイル */
.tile {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: var(--primary-tint); color: var(--primary-strong);
}
.tile--blue   { background: var(--accent-blue-tint);   color: var(--accent-blue-text); }
.tile--orange { background: var(--accent-orange-tint); color: var(--accent-orange-text); }
.tile--red    { background: var(--accent-red-soft);    color: var(--accent-red-text); }
.tile--sm { width: 32px; height: 32px; border-radius: var(--radius-sm); }

/* グリッド */
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
}

/* ============ 5段階ステップ進捗 ============ */
/* 使い方:
   <ol class="steps">
     <li class="step is-done"><span class="step__dot"><svg>チェック</svg></span><span class="step__label">依頼受付</span></li>
     <li class="step is-current step--orange"><span class="step__dot">3</span>…</li>
     <li class="step"><span class="step__dot">4</span>…</li>
   </ol>
   段階 = 依頼受付 / 計画承認済 / 作業中 / 確認待ち / 完了
   is-current の色は step--green / step--blue / step--orange / step--red で切り替える */
.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
}
.step {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.step::before, .step::after {
  content: ""; position: absolute; top: 13px; height: 2px;
  background: var(--line-strong);
}
.step::before { left: 0; right: 50%; }
.step::after  { left: 50%; right: 0; }
.step:first-child::before, .step:last-child::after { display: none; }
.step.is-done::after, .step.is-done + .step.is-done::before { background: var(--primary); }
.step.is-done + .step.is-current::before,
.step.is-done + .step.is-done::before { background: var(--primary); }
.step__dot {
  position: relative; z-index: 1;
  width: 28px; height: 28px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--muted-dot); color: var(--surface);
  font-size: var(--fs-sm); font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 4px var(--surface);
}
.step__label { font-size: var(--fs-xs); color: var(--text-muted); }
.step.is-done  .step__dot { background: var(--primary); }
.step.is-done  .step__label { color: var(--text-muted); }
.step.is-current .step__label { color: var(--text); font-weight: 700; }
.step.is-current .step__dot { background: var(--primary); }
.step--green  .step__dot { background: var(--primary); }
.step--blue   .step__dot { background: var(--accent-blue); }
.step--orange .step__dot { background: var(--accent-orange); }
.step--red    .step__dot { background: var(--accent-red); }

/* 案件1行ぶんのブロック（アイコン＋名称＋ステップ） */
.projrow {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-row);
}
.projrow + .projrow { margin-top: var(--sp-3); }
.projrow__name { font-size: var(--fs-h3); font-weight: 700; color: var(--text); min-width: 8em; }
.projrow__steps { flex: 1; min-width: 260px; }

/* ============ ステータスバッジ ============ */
/* 5段階に対応: badge--recv/approved/working/review/done */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 84px; padding: 5px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunken); color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 700; white-space: nowrap;
}
.badge--recv     { background: var(--surface-sunken);      border-color: var(--line-strong);       color: var(--text-muted); }
.badge--approved { background: var(--accent-blue-soft);    border-color: var(--accent-blue-line);  color: var(--accent-blue-text); }
.badge--working  { background: var(--accent-orange-soft);  border-color: var(--accent-orange-line);color: var(--accent-orange-text); }
.badge--review   { background: var(--accent-red-soft);     border-color: var(--accent-red-line);   color: var(--accent-red-text); }
.badge--done     { background: var(--primary-soft);        border-color: var(--primary-line);      color: var(--primary-strong); }
/* 速報/確定ラベル */
.badge--sokuho   { background: var(--kpi-amber-chip); border-color: var(--accent-orange-line); color: var(--kpi-amber-text); min-width: 0; }
.badge--kakutei  { background: var(--primary-soft);   border-color: var(--primary-line);       color: var(--primary-strong); min-width: 0; }

/* ============ 通知バッジ ============ */
.notif {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--notify); color: #fff;
  font-size: var(--fs-xs); font-weight: 700; line-height: 1;
}
.notif--dot { min-width: 9px; height: 9px; padding: 0; }
.iconbtn .notif { position: absolute; top: 0; right: 0; }

/* ============ テーブル（案件×時間×単価×金額） ============ */
.rows { width: 100%; border-collapse: collapse; }
.rows th, .rows td { padding: var(--sp-4) var(--sp-3); text-align: left; vertical-align: middle; }
.rows thead th {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  padding-top: 0;
}
.rows tbody tr + tr td { border-top: 1px solid var(--line-soft); }
.rows tbody tr:hover { background: var(--surface-sunken); }
.rows td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rows td.amount { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.rows .cell-name { display: flex; align-items: center; gap: var(--sp-3); font-weight: 700; color: var(--text); }
.rows .chev { color: var(--text-faint); text-align: right; }

/* ============ 大きな数値 / KPI タイル ============ */
.stat { display: flex; align-items: center; gap: var(--sp-4); }
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat__value {
  font-size: var(--fs-hero); font-weight: 700; color: var(--text);
  letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat__value .unit { font-size: 20px; margin-left: 2px; }
.stat__underline { display: block; height: 5px; border-radius: var(--radius-pill); background: var(--accent-blue-line); margin-top: 6px; }
.stat__underline--green { background: var(--primary-line); }

.kpi {
  border-radius: var(--radius-lg);
  background: var(--kpi-green-bg);
  padding: var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-4);
}
.kpi--amber { background: var(--kpi-amber-bg); }
.kpi--pink  { background: var(--kpi-pink-bg); }
.kpi__value { font-size: var(--fs-hero); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.05; }
.kpi__value .unit { font-size: 20px; margin-left: 2px; }
.kpi__caption { font-size: var(--fs-sm); color: var(--text-muted); }
.kpi__chip {
  display: inline-block; margin-top: var(--sp-2);
  padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--kpi-green-chip); color: var(--text-body); font-size: var(--fs-sm); font-weight: 600;
}
.kpi--amber .kpi__chip { background: var(--kpi-amber-chip); color: var(--kpi-amber-text); }
.kpi--pink  .kpi__chip { background: var(--kpi-pink-chip); }

/* ============ ボタン ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 11px var(--sp-5);
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs-body); font-weight: 700;
  cursor: pointer;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-strong); }
.btn--ghost { background: var(--surface); color: var(--text-body); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-sunken); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ============ フォーム ============ */
.field { display: block; margin-bottom: var(--sp-4); }
.field__label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--text); margin-bottom: 6px; }
.field__input {
  width: 100%; padding: 12px var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text);
  font-family: inherit; font-size: var(--fs-body);
}
.field__input:focus {
  outline: none; background: var(--surface);
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.formnote { font-size: var(--fs-sm); color: var(--text-muted); }
.alert {
  padding: 10px var(--sp-4); border-radius: var(--radius-md);
  background: var(--accent-red-soft); border: 1px solid var(--accent-red-line);
  color: var(--accent-red-text); font-size: var(--fs-sm); font-weight: 600;
}

/* ============ ログイン画面 ============ */
.auth {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--sp-6);
  background:
    radial-gradient(760px 420px at 88% -8%, var(--hero-wash) 0%, rgba(182, 224, 225, 0) 62%),
    radial-gradient(620px 380px at -6% 108%, var(--primary-soft) 0%, rgba(232, 243, 239, 0) 60%),
    var(--bg);
}
.auth__card { width: min(420px, 100%); padding: var(--sp-8); }
.auth__brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.auth__title { font-size: 22px; font-weight: 700; }
.auth__lead { margin: 4px 0 var(--sp-6); color: var(--text-muted); font-size: var(--fs-sm); }
.auth__foot { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line-soft); }

/* ============ 要望メモ（右下・全ロール共通 / K1） ============ */
.wish-fab {
  position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 30;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 12px var(--sp-5); border: 0; border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text-body);
  box-shadow: var(--shadow-pop); font-family: inherit; font-weight: 700; cursor: pointer;
}
.wish-fab:hover { background: var(--primary-soft); color: var(--primary-strong); }
