/* v2 共有スタイル: シェル(2アプリ) + ダッシュボード + ボード + 画面共通ヘルパ。
 * 読込順: theme.css → ui.css → app2.css。theme の :root トークンを使用。 */

/* ---- アプリシェル / トップナビ ---- */
.app-shell { min-height: 100vh; background: var(--bg, #eef1f5); }
.topnav {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--brand, #1f3a5f); color: #fff;
  position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 6px rgba(0,0,0,.18);
}
.topnav.is-staff { background: #2a6048; } /* 従業員アプリは緑系で識別 */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; background: #fff; color: var(--brand, #1f3a5f); border-radius: 7px; font-weight: 800; }
.topnav.is-staff .brand-mark { color: #2a6048; }
.brand-name { font-size: 15px; }
.brand-badge { font-size: 10px; font-weight: 700; background: rgba(255,255,255,.2); color: #fff; padding: 2px 7px; border-radius: 999px; }
.brand-switch { font-size: 11px; color: #dfe7f1; text-decoration: none; margin-left: 4px; border: 1px solid rgba(255,255,255,.3); padding: 2px 8px; border-radius: 999px; }
.brand-switch:hover { background: rgba(255,255,255,.14); }
.nav-items { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topnav .nav-item { background: transparent; color: #dfe7f1; border: 0; cursor: pointer; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; min-height: 40px; white-space: nowrap; }
.topnav .nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.topnav .nav-item.active { background: #fff; color: var(--brand, #1f3a5f); }
.topnav.is-staff .nav-item.active { color: #2a6048; }
.nav-now { font-size: 12px; color: #cdd8e6; white-space: nowrap; }
.nav-user { display: flex; align-items: center; gap: 6px; }
.nav-user-ic { width: 26px; height: 26px; border-radius: 50%; background: #fff; color: #2a6048; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.nav-user-sel { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 6px 8px; font-size: 12px; max-width: 180px; }
.nav-user-sel option { color: #1f2937; }

/* ---- ページ ---- */
.page { padding: 20px; max-width: 1280px; margin: 0 auto; }
.page-head { margin-bottom: 14px; }
.page-head h1 { font-size: 20px; margin: 0 0 4px; color: var(--text, #1f2937); }
.page-head .sub { margin: 0; color: var(--muted, #5b6573); font-size: 13px; line-height: 1.6; }

/* ---- KPI ---- */
.grid.kpis4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.grid.kpis2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface, #fff); border: 1px solid var(--line, #d3d9e2); border-left: 4px solid var(--neutral, #5b6573); border-radius: var(--radius, 10px); padding: 12px 14px; }
.kpi.is-ok { border-left-color: var(--ok, #1e7d46); }
.kpi.is-warn { border-left-color: var(--warn, #b15c00); }
.kpi.is-danger { border-left-color: var(--danger, #c2261b); }
.kpi.is-muted { border-left-color: var(--neutral, #5b6573); }
.kpi-label { font-size: 12px; color: var(--muted, #5b6573); }
.kpi-num { font-size: 24px; font-weight: 800; color: var(--text, #1f2937); line-height: 1.2; margin: 2px 0; }
.kpi-sub { font-size: 11px; color: var(--muted, #5b6573); }

/* ---- カード / 共通ヘルパ ---- */
.card { background: var(--surface, #fff); border: 1px solid var(--line, #d3d9e2); border-radius: var(--radius, 10px); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; color: var(--text, #1f2937); margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.muted { color: var(--muted, #5b6573); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.note, .help { color: var(--muted, #5b6573); font-size: 13px; line-height: 1.7; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted, #5b6573); font-weight: 600; }

/* ---- 出勤ボード（日: 現場カード） ---- */
.board-sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.site-card { margin: 0; }
.site-card.has-short { border-color: #f0c2bd; }
.site-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line, #eef1f5); }
.site-name { font-weight: 700; color: var(--text, #1f2937); display: block; }
.site-client { font-size: 12px; color: var(--muted, #5b6573); }
.post-row { padding: 6px 0; border-top: 1px dashed #eef1f5; }
.post-row:first-of-type { border-top: 0; }
.post-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.post-name { font-weight: 600; font-size: 13px; color: var(--text, #1f2937); }
.post-time { font-size: 12px; color: var(--muted, #5b6573); }
.post-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; background: #f4f7fb; border: 1px solid var(--line, #d3d9e2); border-radius: 999px; padding: 3px 9px; }
.slot-t { color: var(--muted, #5b6573); font-size: 11px; }

/* ---- 週テーブル ---- */
.wk-table th.wk-site, .wk-table td.wk-site { text-align: left; min-width: 150px; position: sticky; left: 0; background: var(--surface, #fff); z-index: 1; }
.wk-client { display: block; font-size: 11px; color: var(--muted, #5b6573); font-weight: 400; }
.wk-day { cursor: pointer; white-space: nowrap; }
.wk-day:hover { background: #e9eef5; }
.wk-cell { text-align: center; font-size: 12px; font-weight: 600; }
.wk-cell.heat-ok { background: #e7f4ec; color: var(--ok, #1e7d46); }
.wk-cell.heat-warn { background: #fdf0e0; color: var(--warn, #b15c00); }
.wk-cell.heat-danger { background: #fae4e2; color: var(--danger, #c2261b); }
.wk-cell.wk-none, .wk-none { color: #c2c8d2; text-align: center; }
.mini-row.is-short { background: #fdf3f2; border-color: #f0c2bd; }

/* ---- ランチャー ---- */
.launch { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #1f3a5f, #2a6048); padding: 24px; }
.launch-box { background: #fff; border-radius: 16px; padding: 32px; max-width: 720px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.launch-box h1 { margin: 0 0 4px; font-size: 22px; }
.launch-box .sub { color: var(--muted, #5b6573); margin: 0 0 22px; }
.launch-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.launch-card { display: block; text-decoration: none; color: inherit; border: 2px solid var(--line, #d3d9e2); border-radius: 12px; padding: 22px; transition: .12s; }
.launch-card:hover { border-color: var(--brand, #1f3a5f); box-shadow: 0 8px 24px rgba(31,58,95,.16); transform: translateY(-2px); }
.launch-card.staff:hover { border-color: #2a6048; }
.launch-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff; background: var(--brand, #1f3a5f); margin-bottom: 12px; }
.launch-card.staff .launch-ic { background: #2a6048; }
.launch-card h2 { margin: 0 0 6px; font-size: 17px; }
.launch-card p { margin: 0; color: var(--muted, #5b6573); font-size: 13px; line-height: 1.6; }

/* ---- マイスケジュール 週ビュー（レイアウトのみ・色は既存トークン/status-dot） ---- */
.sched-week { display: flex; flex-direction: column; gap: 8px; }
.sched-day { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: start; border: 1px solid var(--line, #d3d9e2); border-radius: var(--radius, 10px); padding: 10px 12px; }
.sched-day.is-off { background: #f7f9fc; }
.sched-day.is-today { border-color: var(--brand, #1f3a5f); box-shadow: inset 3px 0 0 var(--brand, #1f3a5f); }
.sched-date { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding-top: 2px; }
.sched-dnum { font-weight: 700; color: var(--text, #1f2937); font-size: 14px; white-space: nowrap; }
.sched-jobs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sched-none { font-size: 13px; padding: 4px 2px; }
.sched-job { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: #f6f8fb; border: 1px solid var(--line, #d3d9e2); border-radius: 9px; padding: 8px 10px; cursor: pointer; font: inherit; transition: .12s; }
.sched-job:hover { border-color: var(--brand, #1f3a5f); background: #eef3f9; }
.sched-job-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sched-site { font-weight: 600; color: var(--text, #1f2937); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-time { font-size: 12px; color: var(--muted, #5b6573); }
.sched-st { color: var(--text, #1f2937); font-weight: 600; }
.sched-go { color: var(--muted, #5b6573); font-weight: 700; font-size: 16px; }
.cal-mini { font-size: 10px; color: var(--muted, #5b6573); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1024px) { .grid.kpis4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .grid.kpis4, .grid.kpis2 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .launch-cards { grid-template-columns: 1fr; }
  .nav-now { display: none; }
  .nav-items { order: 3; flex-basis: 100%; }
  .sched-day { grid-template-columns: 1fr; gap: 6px; }
}
