* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
    font-size: 16px;
    line-height: 1.5;
}

h1 { font-size: 1.4rem; margin-bottom: 8px; }
h2 { font-size: 1.1rem; margin-top: 24px; }

.topbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.topbar a { color: #1a73e8; }

nav { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
nav a {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #f5f5f5;
    color: #1a1a1a;
    text-decoration: none;
    font-size: 14px;
}
nav a:active { background: #e0e0e0; }

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px;
}

table { border-collapse: collapse; width: 100%; }
td, th { border: 1px solid #ccc; padding: 6px 10px; text-align: left; font-size: 14px; white-space: nowrap; }
th { background: #f5f5f5; }

/* 横スクロール前提のテーブル（シフト一覧など）だけに最小幅を持たせる。
   結果表示・サマリー等の小さい表は、画面幅からはみ出さないようにする。 */
.table-scroll table { min-width: 480px; }

form.filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
form.filters label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    gap: 4px;
}
form.filters input,
form.filters select {
    font-size: 16px; /* iOSでフォーカス時に勝手に拡大されるのを防ぐ */
    padding: 8px;
}
button {
    font-size: 16px;
    padding: 10px 20px;
    cursor: pointer;
}

.btn-danger {
    background: #ea4335;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: bold;
}
.btn-danger:hover { background: #c5372c; }

.result-ok { background: #e6f4ea; border: 1px solid #34a853; padding: 12px; border-radius: 6px; }
.result-error { background: #fce8e6; border: 1px solid #ea4335; padding: 12px; border-radius: 6px; }
.status-error { color: #c62828; font-weight: bold; }
.status-success { color: #2e7d32; }
.count { color: #555; margin-top: 8px; }
.notice { color: #a05a00; background: #fff3e0; padding: 8px 12px; border-radius: 6px; }

@media (max-width: 600px) {
    body { padding: 12px; font-size: 15px; }
    form.filters { flex-direction: column; align-items: stretch; }
    form.filters label { width: 100%; }
    form.filters input,
    form.filters select { width: 100%; }
    button { width: 100%; }
    table { font-size: 13px; }
    td, th { padding: 5px 8px; }
}

/* ログイン・初回管理者アカウント作成など、認証系ページ共通のカードデザイン */
body.auth-page {
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 24px 16px;
    background: #1F2937;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
}
.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}
.auth-brand .mark {
    display: inline-block;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 0.03em;
    color: #1F2937;
    background: #F2DA34;
    padding: 4px 14px;
    border-radius: 6px;
}
.auth-brand .sub {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
}
.auth-card label {
    display: block;
    font-size: 13px;
    color: #444;
    margin-bottom: 6px;
}
.auth-card input[type="text"],
.auth-card input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    padding: 11px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 18px;
}
.auth-card input[type="text"]:focus,
.auth-card input[type="password"]:focus {
    outline: none;
    border-color: #F2DA34;
    background: #fff;
}
.auth-card button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    color: #1F2937;
    background: #F2DA34;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.auth-card button:active { background: #dcc52e; }
.auth-card .result-ok,
.auth-card .result-error,
.auth-card .notice {
    margin-bottom: 18px;
    font-size: 14px;
}
.auth-card .auth-link { text-align: center; margin-top: 4px; }
.auth-card .auth-link a { color: #1a73e8; }

/* ---- 第2版で追加 ---- */
.topbar { align-items: center; flex-wrap: wrap; }
.roster-status { font-size: 12px; padding: 1px 8px; border-radius: 10px; }
.roster-status.ok { background: #e6f4ea; color: #1e6b34; }
.roster-status.ng { background: #fff3e0; color: #a05a00; }
.card { border: 1px solid #ddd; border-radius: 10px; padding: 12px; margin: 8px 0 16px; background: #fff; }
.card label { display: inline-flex; flex-direction: column; font-size: 14px; gap: 4px; margin-right: 10px; }
.note { font-size: 13px; color: #555; }
.day-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
button.small { font-size: 13px; padding: 6px 10px; width: auto; }
button.danger { background: #ea4335; color: #fff; border: none; border-radius: 4px; }
button.secondary { background: #f5f5f5; border: 1px solid #bbb; border-radius: 4px; }
.del-cell { text-align: center; }

/* ---- 第3版：スマホで見やすく・押しやすく ---- */
:root { --ink: #1F2937; --accent: #F2DA34; --line: #e3e3e3; --muted: #666; --warn: #c25e00; --warn-bg: #fff4e5; }
body { font-size: 16px; color: #1a1a1a; background: #f6f7f9; }
body.has-tabbar { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.3rem; margin: 4px 0 12px; }

/* 上の帯：ロゴ・名簿の状態・ログイン中の人 */
.topbar { justify-content: flex-start; gap: 8px; font-size: 13px; margin: -4px 0 6px; }
.topbar .brand { font-weight: bold; background: var(--accent); color: var(--ink); padding: 1px 8px; border-radius: 5px; }
.topbar .who { margin-left: auto; color: var(--muted); }

/* 入力欄は16px以上（iPhoneが勝手に拡大しないように）、押せる所は指の大きさ以上 */
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="month"],
input[type="number"], select, textarea {
    font-size: 16px; min-height: 44px; padding: 8px 10px; border: 1px solid #bbb; border-radius: 8px; background: #fff; color: #1a1a1a;
}
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 48px; font-size: 16px; padding: 10px 18px; border-radius: 10px;
    border: 1px solid #bbb; background: #fff; color: #1a1a1a; text-decoration: none; cursor: pointer; font-weight: bold;
}
button.primary, .btn.primary { background: var(--accent); border-color: #d9c22b; color: var(--ink); }
button.danger, .btn.danger { background: #fff; border: 1px solid #ea4335; color: #c62828; }
button.small, .btn.small { min-height: 44px; font-size: 15px; padding: 8px 14px; }
.card { border-radius: 12px; padding: 14px; border-color: var(--line); }
.card label:not(.chip), .plan-card form label:not(.chip), .field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #444; margin: 0 0 12px; }
.card label > input, .card label > select, .plan-card form label > select, .field > input, .field > select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.actions.inline { flex-direction: row; flex-wrap: wrap; }

/* 画面の下に固定するボタン */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; margin: 0; gap: 0;
    background: #fff; border-top: 1px solid #ddd; padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 62px; padding: 6px 2px; font-size: 12px; color: #555; text-decoration: none; border: none; background: none; border-radius: 0;
}
.tabbar a .ti { font-size: 22px; line-height: 1; }
.tabbar a.on { color: var(--ink); font-weight: bold; box-shadow: inset 0 3px 0 var(--accent); }

/* 日付の切りかえ（大きな ◀ ▶） */
.datebar { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; align-items: center; margin-bottom: 10px; }
.datebar .btn { min-height: 52px; padding: 0; font-size: 20px; }
.datebar .label { text-align: center; font-weight: bold; font-size: 18px; }
.datebar .label input { width: 100%; text-align: center; }
.sticky { position: sticky; top: 0; z-index: 20; background: #f6f7f9; padding: 8px 0 6px; }

/* 予定のカード */
.day-head { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 6px; padding: 4px 2px; font-weight: bold; font-size: 17px; border-bottom: 2px solid var(--ink); }
.day-head.sun { color: #c00; } .day-head.sat { color: #0040c0; }
.day-head.today { color: var(--ink); }
.day-head .tag { font-size: 12px; background: var(--accent); color: var(--ink); padding: 1px 8px; border-radius: 10px; }
.day-head .cnt { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: normal; }
a.shift-card, .shift-card {
    display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 10px; align-items: center;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 8px;
    color: #1a1a1a; text-decoration: none;
}
a.shift-card:active { background: #fffbe0; }
.shift-card .t { grid-row: 1 / span 2; font-variant-numeric: tabular-nums; font-weight: bold; font-size: 17px; line-height: 1.25; }
.shift-card .t small { display: block; font-weight: normal; color: var(--muted); font-size: 14px; }
.shift-card .t { grid-column: 1; }
.shift-card .u { grid-column: 2; grid-row: 1; font-size: 17px; font-weight: bold; min-width: 0; }
.shift-card .hp { grid-column: 2; grid-row: 2; font-size: 15px; color: #444; min-width: 0; }
.shift-card .ty { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-size: 13px; background: #eef1f5; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.shift-card .warn { grid-column: 1 / -1; margin-top: 6px; font-size: 13px; color: var(--warn); background: var(--warn-bg); padding: 4px 8px; border-radius: 6px; }
.shift-card.has-warn { border-color: #f0a24a; }
.shift-card .nt { grid-column: 1 / -1; margin-top: 6px; font-size: 14px; color: #333; background: #f6f7f9; padding: 5px 8px;
                  border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px; border: 1px solid #bbb; border-radius: 10px; resize: vertical; }
.empty { color: var(--muted); background: #fff; border: 1px dashed #ccc; border-radius: 12px; padding: 16px; text-align: center; }

/* 曜日・週目を選ぶ大きなボタン（チェック欄の代わり） */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 12px; }
.chips label { margin: 0; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 44px; padding: 0 8px;
              border: 1px solid #bbb; border-radius: 22px; background: #fff; font-size: 16px; color: #333; }
.chips input:checked + span { background: var(--ink); color: var(--accent); border-color: var(--ink); font-weight: bold; }
.chips input:focus-visible + span { outline: 2px solid #1a73e8; }

/* 計画のまとまり */
.plan-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; color: #1a1a1a; text-decoration: none; }
.plan-card .days { font-size: 18px; font-weight: bold; }
.plan-card .weeks { font-size: 13px; color: var(--muted); margin-left: 6px; font-weight: normal; }
.plan-card .line2 { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 15px; }
.plan-card.open { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
details.add { margin: 8px 0 16px; }
details.add > summary { list-style: none; }
details.add > summary::-webkit-details-marker { display: none; }

@media (max-width: 600px) {
    body { font-size: 16px; }
    button { width: auto; }
    .card button, .actions button, .actions .btn { width: 100%; }
    .filters input, .filters select { width: 100%; }
}

/* 週ごとに曜日が違う計画の選び方（週×曜日のマス目） */
.week-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 4px; align-items: center; margin: 0 0 4px; }
.week-grid .wk { font-size: 13px; color: #444; }
.week-grid label { margin: 0 !important; display: block !important; }
.week-grid input { position: absolute; opacity: 0; pointer-events: none; }
.week-grid span { display: flex; align-items: center; justify-content: center; height: 40px; border: 1px solid #bbb; border-radius: 8px; background: #fff; font-size: 15px; }
.week-grid input:checked + span { background: var(--ink); color: var(--accent); border-color: var(--ink); font-weight: bold; }
.roster-status.ng a { color: inherit; text-decoration: underline; }

/* 第3版：1人分の予定のカレンダー表示と、表示の切り替えタブ */
.viewtabs { display: flex; gap: 0; margin: 8px 0; border: 1px solid #d1d5db; border-radius: 10px; overflow: hidden; background: #fff; }
.viewtabs a { flex: 1; text-align: center; padding: 10px 4px; min-height: 44px; box-sizing: border-box; color: var(--ink); text-decoration: none; font-weight: bold; }
.viewtabs a + a { border-left: 1px solid #d1d5db; }
.viewtabs a.on { background: var(--ink); color: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 4px; }
.cal .wd { text-align: center; font-size: 12px; color: #6b7280; padding: 2px 0; }
.cal .wd.sun, .cday.sun .dn { color: #dc2626; }
.cal .wd.sat, .cday.sat .dn { color: #2563eb; }
button.cday { min-height: 54px; margin: 0; padding: 4px 0; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; font-size: 15px; color: var(--ink); font-weight: normal; }
button.cday .mk { min-width: 22px; padding: 0 5px; border-radius: 11px; background: var(--accent); color: var(--ink); font-size: 12px; font-weight: bold; line-height: 20px; }
button.cday.has { border-color: #c9b21a; }
button.cday.today { border: 2px solid var(--ink); }
button.cday.sel { background: var(--ink); border-color: var(--ink); }
button.cday.sel .dn { color: #fff; }
.dayview { margin-top: 12px; }
