/* Tsumugi 共通スタイル。色は :root の変数で管理する(設計書 2節) */
:root {
	--bg: #f4f5f7;
	--surface: #ffffff;
	--ink: #1f2933;
	--sub: #5f6b7a;
	--line: #dde1e7;
	--brand: #3b5b8c;
	--brand-ink: #ffffff;
	--header-bg: #24344d;
	--header-ink: #e8edf5;

	/* 状態バッジ(設計書 17節: 灰=未着手系、青=進行中・中、緑=完了系、黄=保留、赤=未対応・高) */
	--gray: #6b7280;
	--gray-bg: #eef0f3;
	--blue: #1d5fbf;
	--blue-bg: #e3edfb;
	--green: #1f7a4d;
	--green-bg: #e2f4ea;
	--yellow: #8a6100;
	--yellow-bg: #fdf3d6;
	--red: #b42318;
	--red-bg: #fde7e5;

	--radius: 8px;
	--font: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.6; }
a { color: var(--brand); }
h1 { font-size: 1.4rem; margin: 0 0 16px; }
.muted { color: var(--sub); }

/* 共通ヘッダー */
.app-header {
	display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
	padding: 10px 20px; background: var(--header-bg); color: var(--header-ink);
}
.brand { color: #fff; font-weight: 700; font-size: 1.25rem; text-decoration: none; letter-spacing: .04em; }
.menu { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.menu a {
	color: var(--header-ink); text-decoration: none; font-size: .9rem;
	padding: 5px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px;
}
.menu a:hover { background: rgba(255,255,255,.1); }
.menu a.active { background: #fff; color: var(--header-bg); border-color: #fff; font-weight: 600; }
.user-area { display: flex; align-items: center; gap: 12px; }
.user-card { display: flex; align-items: center; gap: 8px; }
.avatar {
	display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
	background: #e8edf5; color: var(--header-bg); font-weight: 700; font-size: .9rem;
}
.user-name { font-size: .9rem; }
.role-tag { font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.15); }
.role-SYSTEM_ADMIN { background: #f2c94c; color: #3d2e00; }
.role-ADMIN { background: #9cc3f5; color: #0d2b55; }
.user-area form { margin: 0; }

/* ボタン */
.btn {
	display: inline-block; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
	padding: 7px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-logout { background: #c0392b; border-color: #c0392b; color: #fff; padding: 5px 12px; }
.btn-block { width: 100%; }

/* 本文 */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }

/* 処理結果の枠 */
.message { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.message-success { background: var(--green-bg); border-color: #a6dcbf; color: var(--green); }
.message-error { background: var(--red-bg); border-color: #f5b5ae; color: var(--red); }

/* フォーム */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--sub); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
	font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3f5; border-color: var(--brand); }
.field-error { color: var(--red); font-size: .85rem; }

/* ログイン画面(SC-06、ヘッダーなし) */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box {
	width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
	border-radius: 12px; padding: 32px 28px; box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.login-title { text-align: center; font-size: 2rem; margin: 0; color: var(--header-bg); letter-spacing: .06em; }
.catchphrase { text-align: center; color: var(--sub); margin: 4px 0 24px; }

/* 見出し行(タイトル+ボタン) */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.count { font-size: .9rem; font-weight: 400; color: var(--sub); margin-left: 8px; }
.container.narrow { max-width: 720px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 20px; color: var(--sub); text-align: center; }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "Courier New", monospace; }

/* 表 */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8f9fb; color: var(--sub); font-weight: 600; font-size: .82rem; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions > * { margin-left: 4px; }
form.inline { display: inline; margin: 0; }

/* バッジ */
.badge { display: inline-block; font-size: .75rem; padding: 1px 9px; border-radius: 999px; background: var(--gray-bg); color: var(--gray); white-space: nowrap; vertical-align: middle; }
.badge-sales { background: #fff0e0; color: #9a4d00; margin-left: 4px; }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-role-SYSTEM_ADMIN { background: #fdf0c4; color: #6b4e00; }
.badge-role-ADMIN { background: var(--blue-bg); color: var(--blue); }
.badge-role-WORKER { background: var(--gray-bg); color: var(--gray); }
.dept { display: inline-block; margin-right: 8px; }

/* ボタンの追加 */
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-danger-outline { color: var(--red); border-color: #f0b4ae; background: #fff; }

/* フォームの追加 */
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.req { font-size: .7rem; font-weight: 600; color: #fff; background: var(--red); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: middle; }
.hint { font-size: .8rem; color: var(--sub); }
.row { display: flex; align-items: center; gap: 8px; }
.row input { width: auto; }
input.short { max-width: 140px; }
input.readonly, input[readonly] { background: #f1f3f6; color: var(--sub); }
fieldset.field { border: 0; padding: 0; margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: auto; }

/* 見出し・区切り */
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.section { margin: 24px 0; }
.sub-head { font-size: .95rem; color: var(--sub); margin: 0 0 8px; }
.section .page-head { margin-bottom: 10px; }
.actions { display: flex; gap: 8px; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.num { text-align: right; white-space: nowrap; }
th.num { text-align: right; }

/* 集計カード */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.3; }
.stat-label { font-size: .8rem; color: var(--sub); }

/* 2表の横並び(広い画面のみ) */
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 960px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* 絞り込み */
.filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; background: var(--surface);
	border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.filter .field { min-width: 140px; }
.filter-actions { display: flex; gap: 6px; }
.btn-link { border-color: transparent; background: transparent; color: var(--brand); }

/* メッセージの追加 */
.message-warning { background: var(--yellow-bg); border-color: #f0d68a; color: var(--yellow); }
.message-info { background: var(--blue-bg); border-color: #b5cdf3; color: var(--blue); }

/* 行クリックで詳細へ */
.table-hover tbody tr[data-href] { cursor: pointer; }
.table-hover tbody tr[data-href]:hover { background: #f3f7fd; }

/* 状態バッジの色(設計書 17節) */
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-member { background: #eef2f8; color: var(--brand); margin: 0 4px 4px 0; }

/* 進捗バー(横棒+数値) */
.progress { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-track { flex: 1; height: 8px; background: #e6e9ee; border-radius: 999px; overflow: hidden; min-width: 70px; }
.progress-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.progress-value { font-size: .82rem; color: var(--sub); min-width: 3em; text-align: right; }

/* 詳細の情報欄 */
.info { margin-bottom: 8px; }
.description { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; margin: 0; }
.info-grid dt { font-size: .8rem; color: var(--sub); font-weight: 600; }
.info-grid dd { margin: 2px 0 0; }
.info-grid .wide { grid-column: 1 / -1; }

/* 入力の追加 */
.toolbar { display: flex; gap: 4px; }
textarea { resize: vertical; }
textarea.autogrow { overflow: hidden; min-height: 80px; }
.checks-column { flex-direction: column; gap: 6px; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input.short-date { max-width: 200px; }

/* 勤怠 */
.container.wide { max-width: 1400px; }
.month-nav, .year-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.month-nav input[type=month], .month-nav select { width: auto; }
input.year-input { width: 110px; }
.summary { margin-bottom: 16px; }
.summary h2 { margin-bottom: 10px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 20px; margin: 0 0 12px; }
.summary-grid dt { font-size: .78rem; color: var(--sub); font-weight: 600; }
.summary-grid dd { margin: 2px 0 0; font-weight: 600; }
.attendance-table td, .attendance-table th { padding: 7px 10px; }
.attendance-table tr.is-holiday td { background: #fbf3f2; }
.attendance-table tr.is-today td { box-shadow: inset 0 2px 0 var(--brand), inset 0 -2px 0 var(--brand); }
.attendance-table tr.is-today td:first-child { font-weight: 700; color: var(--brand); }
.lines { font-size: .82rem; color: var(--sub); }
.note { font-size: .82rem; color: var(--sub); margin-top: 10px; }
.error-list { margin: 0 0 8px; padding-left: 1.2em; }
.row-fields.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.lines-table select { min-width: 200px; }
.summary-grid .span2 { grid-column: span 2; }
.over { color: var(--red); font-weight: 700; }
.workload { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
#results.loading { opacity: .45; pointer-events: none; transition: opacity .15s; }
[hidden] { display: none !important; }

/* 勤怠入力の合計表示 */
.totals { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; background: #f8f9fb; border: 1px solid var(--line);
	border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; font-size: .92rem; }
.ok { color: var(--green); font-weight: 700; }

/* 狭い画面: ヘッダーのメニューを畳む */
.menu-toggle { display: none; }
@media (max-width: 760px) {
	.app-header { padding: 10px 14px; gap: 10px; }
	.menu-toggle { display: inline-block; margin-left: auto; font: inherit; font-size: .85rem; color: #fff;
		background: transparent; border: 1px solid rgba(255,255,255,.4); border-radius: var(--radius); padding: 4px 12px; }
	.menu { display: none; order: 3; flex-basis: 100%; flex-direction: column; }
	.menu.open { display: flex; }
	.menu a { border-radius: var(--radius); }
	.user-area { order: 2; flex-basis: 100%; justify-content: space-between; }
	.container { padding: 16px 14px 40px; }
	.row-fields { grid-template-columns: 1fr; }
}

/* ログイン画面のデモ用アカウント */
.demo-accounts { margin-top: 20px; padding: 12px 14px; background: #f8f9fb; border: 1px dashed var(--line); border-radius: var(--radius); font-size: .85rem; }
.demo-title { margin: 0 0 6px; font-weight: 600; }
.demo-accounts table { border-collapse: collapse; }
.demo-accounts td { padding: 2px 10px 2px 0; }
.demo-accounts .hint { margin: 6px 0 0; }

/* 勤怠の表は列が多いため、狭い画面では表の中で横スクロールする(列が潰れて縦に伸びないように) */
.attendance-table { min-width: 1080px; }
.attendance-table .lines { min-width: 260px; }

/* 公開デモの案内 */
.demo-banner { flex-basis: 100%; order: 10; margin: 0; padding: 4px 10px; font-size: .78rem; color: #3d2e00;
	background: #f2c94c; border-radius: 6px; }
