/* 勤怠管理 基本スタイル（デザインの作り込みは担当⑤）。スマホ優先・文字16px以上・ボタン高44px以上 */
:root {
  --c-primary: #1f6feb;
  --c-primary-d: #1558c0;
  --c-in: #1a7f37;
  --c-in-d: #136329;
  --c-out: #d9480f;
  --c-out-d: #b33a0b;
  --c-danger: #c62828;
  --c-warn-bg: #fff4e5;
  --c-warn: #8a4b00;
  --c-text: #1f2328;
  --c-sub: #59636e;
  --c-line: #d0d7de;
  --c-bg: #f6f8fa;
  --c-card: #ffffff;
  --c-sat: #eaf2ff;
  --c-off: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--c-bg); color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Yu Gothic", "Meiryo", Roboto, "Noto Sans JP", "BIZ UDPGothic", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px 14px 80px; outline: none; }
.loading { color: var(--c-sub); }
.muted { color: var(--c-sub); font-size: .9rem; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1 1 auto; }

/* ---- ヘッダ ---- */
.app-header { background: #fff; border-bottom: 1px solid var(--c-line); position: sticky; top: 0; z-index: 20; }
.header-inner { max-width: 1100px; margin: 0 auto; padding: 0 14px; display: flex; align-items: center; min-height: 52px; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: bold; color: var(--c-text); text-decoration: none; font-size: 1.1rem; }
.menu-toggle { margin-left: auto; width: 44px; height: 44px; border: 0; background: none; display: none; flex-direction: column; justify-content: center; gap: 5px; padding: 10px; cursor: pointer; }
.menu-toggle span { display: block; height: 2px; background: var(--c-text); border-radius: 2px; }
.nav { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.nav a, .nav button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; color: var(--c-text); text-decoration: none; border-radius: 8px; font-size: .95rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav a:hover, .nav button:hover { background: var(--c-bg); }
.nav a.active { color: var(--c-primary); font-weight: bold; }
.nav .sep { width: 1px; height: 22px; background: var(--c-line); margin: 0 4px; }
.nav .nav-group { font-size: .75rem; color: var(--c-sub); padding: 0 6px; }
.nav .user-name { font-size: .9rem; color: var(--c-sub); padding: 0 6px; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .45em; border-radius: 999px; background: var(--c-danger); color: #fff; font-size: .75rem; line-height: 1.5; text-align: center; margin-left: 4px; }
@media (max-width: 767px) {
  .menu-toggle { display: flex; }
  .nav {
    display: none; flex-direction: column; align-items: stretch; margin-left: 0;
    position: absolute; top: 100%; left: 0; right: 0; background: #fff;
    border-bottom: 1px solid var(--c-line); box-shadow: 0 8px 16px rgba(0,0,0,.12);
    padding: 4px 14px 10px; max-height: calc(100vh - 52px); overflow-y: auto;
  }
  .nav.open { display: flex; }
  .nav a, .nav button { width: 100%; justify-content: flex-start; }
  .nav .sep { display: none; }
  .nav .nav-group { width: 100%; margin-top: 6px; padding: 6px 6px 2px; font-weight: bold; border-top: 1px solid #eaeef2; }
  .nav .nav-group:first-child { border-top: 0; margin-top: 0; }
  .nav .user-name { width: 100%; padding: 8px 6px 2px; border-top: 1px solid #eaeef2; margin-top: 6px; }
}

/* ---- カード・ボタン・フォーム ---- */
.card { background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--c-line); background: #fff; color: var(--c-text); font-size: 16px; font-family: inherit; cursor: pointer; text-decoration: none; gap: 6px; }
.btn:hover { background: var(--c-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn.primary:hover { background: var(--c-primary-d); }
.btn.danger { background: #fff; border-color: var(--c-danger); color: var(--c-danger); }
.btn.danger.fill { background: var(--c-danger); color: #fff; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--c-primary); cursor: pointer; font-size: inherit; font-family: inherit; padding: 0; text-decoration: underline; min-height: 0; }
.form { max-width: 520px; }
.field { margin-bottom: 14px; }
.field > label, .field > .label { display: block; font-weight: bold; margin-bottom: 4px; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--c-sub); margin-top: 2px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--c-line); border-radius: 8px; font-size: 16px; font-family: inherit; background: #fff; color: var(--c-text);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid rgba(31, 111, 235, .35); outline-offset: 1px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; margin-right: 14px; }
.check input { width: 22px; height: 22px; }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields > .field { flex: 1 1 140px; }
.error-box { background: #fdecec; color: var(--c-danger); border: 1px solid #f3b7b7; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.warn-box { background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid #f3d29b; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.info-box { background: #eef5ff; color: #133d7a; border: 1px solid #c4dafc; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { min-height: 44px; padding: 0 14px; border: 0; background: none; font-size: 16px; font-family: inherit; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { border-bottom-color: var(--c-primary); color: var(--c-primary); font-weight: bold; }
@media (max-width: 767px) {
  .tabs { gap: 0; }
  .tabs button { padding: 0 8px; font-size: .92rem; flex: 1 1 auto; }
}

/* ---- 表 ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 8px 8px; border-bottom: 1px solid #eaeef2; text-align: left; vertical-align: middle; }
th { background: #f0f3f6; font-weight: bold; white-space: nowrap; font-size: .9rem; }
.table-wrap td { white-space: nowrap; }
.table-wrap td.remarks { white-space: normal; }
tr.sat td { background: var(--c-sat); }
tr.off td { background: var(--c-off); }
tr.today td { box-shadow: inset 3px 0 0 var(--c-primary); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f9ff; }
/* スマホでは全員の勤怠一覧を氏名・総労働・出勤日数だけに絞り、残りは行タップ（詳細画面）で見せる */
@media (max-width: 767px) {
  .table-wrap.summary-compact th:nth-child(n+4), .table-wrap.summary-compact td:nth-child(n+4) { display: none; }
}
/* スマホ幅では表を横スクロールしなくても操作ボタンに届くよう、最終列（操作）を右端に固定する */
@media (max-width: 767px) {
  .table-wrap.actions-sticky { position: relative; }
  .table-wrap.actions-sticky th:last-child, .table-wrap.actions-sticky td:last-child {
    position: sticky; right: 0; box-shadow: -6px 0 6px -6px rgba(0,0,0,.18);
  }
  .table-wrap.actions-sticky th:last-child { background: #f0f3f6; }
  .table-wrap.actions-sticky td:last-child { background: #fff; }
  .table-wrap.actions-sticky tr.sat td:last-child { background: var(--c-sat); }
  .table-wrap.actions-sticky tr.off td:last-child { background: var(--c-off); }
  .table-wrap.actions-sticky tr.clickable:hover td:last-child { background: #f5f9ff; }
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.time { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.inactive-row td { color: var(--c-sub); opacity: .65; }
.wd-sun, .wd-off { color: var(--c-danger); }
.wd-sat { color: var(--c-primary); }
.late { color: var(--c-danger); font-weight: bold; }
.remarks { font-size: .88rem; min-width: 160px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--c-line); background: #fff; white-space: nowrap; }
.pill.pending { background: #fff4e5; border-color: #f3d29b; color: var(--c-warn); }
.pill.approved, .pill.done, .pill.working { background: #e8f5ec; border-color: #a7d8b5; color: var(--c-in); }
.pill.rejected, .pill.error, .pill.missing { background: #fdecec; border-color: #f3b7b7; color: var(--c-danger); }
.pill.canceled, .pill.none { background: #f0f3f6; color: var(--c-sub); }
.pill.running { background: #eef5ff; border-color: #c4dafc; color: #133d7a; }
.pill.paid { background: #f3eefe; border-color: #cfc0f5; color: #5b3cc4; }

/* ---- 集計 ---- */
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.summary-grid .item { background: #fff; border: 1px solid var(--c-line); border-radius: 8px; padding: 8px 10px; }
.summary-grid .item .k { font-size: .8rem; color: var(--c-sub); }
.summary-grid .item .v { font-size: 1.15rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.summary-grid .item.main { background: #eef5ff; border-color: #c4dafc; }
@media (max-width: 767px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } .summary-grid .item.main { grid-column: span 2; } }
.summary-more { margin-bottom: 12px; }
.summary-more summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--c-primary); font-size: .9rem; padding: 4px 0; }

.period-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.period-nav .label { font-weight: bold; font-size: 1.05rem; }
.period-nav select { width: auto; }

/* ---- 打刻画面 ---- */
.punch { text-align: center; max-width: 560px; margin: 0 auto; }
.punch .date { font-size: 1.15rem; }
.punch .holiday { color: var(--c-danger); font-size: .95rem; }
.punch .clock { font-size: 3.4rem; font-weight: bold; font-variant-numeric: tabular-nums; letter-spacing: .03em; margin: 4px 0 8px; }
.punch .state { margin-bottom: 14px; }
.punch .state .pill { font-size: 1rem; padding: 4px 14px; }
.punch-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.btn-punch { min-height: 110px; border-radius: 16px; border: 0; color: #fff; font-size: 1.6rem; font-weight: bold; font-family: inherit; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.btn-punch.in { background: var(--c-in); }
.btn-punch.in:hover { background: var(--c-in-d); }
.btn-punch.out { background: var(--c-out); }
.btn-punch.out:hover { background: var(--c-out-d); }
.btn-punch:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn-punch small { display: block; font-size: .8rem; font-weight: normal; }
.punch .today-times { display: flex; justify-content: center; gap: 22px; font-size: 1.05rem; margin: 8px 0; flex-wrap: wrap; }
.punch .today-times b { font-variant-numeric: tabular-nums; font-size: 1.25rem; }
.punch .open-label { color: var(--c-out-d); font-size: .95rem; }
.punch .links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---- ログイン ---- */
.auth-box { max-width: 460px; margin: 20px auto; }
.user-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.user-list button { min-height: 52px; border: 1px solid var(--c-line); border-radius: 10px; background: #fff; font-size: 16px; font-family: inherit; cursor: pointer; padding: 6px; }
.user-list button.selected { border: 2px solid var(--c-primary); background: #eef5ff; font-weight: bold; }
.quick-punch { border-top: 1px dashed var(--c-line); margin-top: 18px; padding-top: 14px; }

/* ---- モーダル・トースト ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 20px 10px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 30px rgba(0,0,0,.25); margin: auto 0; }
.modal.wide { max-width: 860px; }
.modal-head { padding: 14px 16px; border-bottom: 1px solid var(--c-line); display: flex; align-items: center; gap: 8px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.modal-close { width: 44px; height: 44px; border: 0; background: none; font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 14px 16px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--c-line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); background: #1f2328; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 70; max-width: calc(100% - 24px); box-shadow: 0 6px 18px rgba(0,0,0,.25); text-align: center; }
.toast.error { background: var(--c-danger); }
.toast.success { background: var(--c-in); }

/* ---- 差分・履歴 ---- */
.diff td.changed { background: #fff4e5; font-weight: bold; }
.history-item { border-bottom: 1px solid #eaeef2; padding: 8px 0; font-size: .9rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: .9rem; }
.kv dt { color: var(--c-sub); }
.kv dd { margin: 0; }
pre.json { background: #f6f8fa; padding: 8px; border-radius: 6px; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ---- 休日カレンダー ---- */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.month { background: #fff; border: 1px solid var(--c-line); border-radius: 8px; padding: 8px; }
.month h3 { margin: 0 0 6px; font-size: .95rem; }
.month table { font-size: .85rem; }
.month th, .month td { padding: 3px 0; text-align: center; border: 0; background: none; }
.month td.off { background: var(--c-off); color: var(--c-danger); border-radius: 4px; }
.month td.sat { color: var(--c-primary); }
.month td.sat.off { background: var(--c-sat); color: var(--c-primary); }
.month td.company-work { background: #e8f5ec; color: var(--c-in); border-radius: 4px; }
.month td.closing { outline: 3px solid var(--c-out); outline-offset: -2px; border-radius: 4px; font-weight: bold; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; margin: 8px 0; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; border-radius: 3px; }
.legend .l-off::before { background: var(--c-off); }
.legend .l-work::before { background: #e8f5ec; }
.legend .l-closing::before { outline: 2px solid var(--c-out); outline-offset: -2px; }

/* ---- 管理ダッシュボード ---- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 12px; }
.dash-grid .card { margin: 0; }
.big-num { font-size: 2rem; font-weight: bold; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid #eaeef2; }
ul.plain li:last-child { border-bottom: 0; }
