/* EXPシフト 共通スタイル */

:root {
    --bg: #f4f4f2;
    --surface: #ffffff;
    --surface-sub: #f9f9f7;
    --border: #dcdcd7;
    --border-strong: #c4c4bd;
    --text: #1f2124;
    --text-sub: #5f6368;
    --text-faint: #8a8d91;
    --header: #24272b;
    --header-text: #f1f1ef;
    --accent: #b3262d;          /* ロゴの赤 */
    --accent-hover: #951e24;
    --accent-soft: #f8e9ea;
    --info: #2f5d8a;
    --info-soft: #e8eff6;
    --ok: #2e6b45;
    --ok-soft: #e6f1ea;
    --warn: #8a5a00;
    --warn-soft: #fbf1dc;
    --danger: #b3262d;
    --radius: 6px;
    --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--info); text-underline-offset: 2px; }
a:hover { color: #1f4366; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-sub); }
.small { font-size: 12px; }

/* ---------- ヘッダー ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header);
    color: var(--header-text);
}
.site-header__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 20px;
    min-height: 56px;
}
.site-header--wide .site-header__inner { max-width: none; }
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    flex-shrink: 0;
}
.brand img { height: 26px; width: auto; display: block; }
.brand__app {
    padding-left: 12px;
    border-left: 1px solid #4a4e54;
    font-size: 13px;
    color: #c9cbcd;
    white-space: nowrap;
}
.site-header__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}
.site-header__user .name { font-weight: 600; }
.site-header a { color: #d9dadb; text-decoration: none; }
.site-header a:hover { color: #fff; text-decoration: underline; }

.site-nav {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}
.site-nav a {
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    color: #c9cbcd;
}
.site-nav a:hover { background: #33373c; text-decoration: none; color: #fff; }
.site-nav a[aria-current="page"] { background: #3a3e44; color: #fff; }

/* ---------- レイアウト ---------- */

.page {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}
.page--narrow { max-width: 720px; }
.page--wide { max-width: none; }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 20px;
}
.page-head__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.site-footer {
    padding: 16px 20px;
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card__body { padding: 18px; }

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.stack > * + * { margin-top: 16px; }

/* ---------- ボタン・フォーム ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.btn:hover { background: var(--surface-sub); border-color: #a9a9a2; color: var(--text); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn--dark { background: var(--header); border-color: var(--header); color: #fff; }
.btn--dark:hover { background: #3a3e44; border-color: #3a3e44; color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: #e9e9e5; border-color: transparent; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--accent-soft); border-color: #e2b8ba; color: var(--danger); }
.btn--sm { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.btn--block { width: 100%; min-height: 42px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.field .hint { font-size: 12px; color: var(--text-faint); }

.input, .select {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
}
.input--time { width: 7.5em; }
.input--hhmm { width: 4.8em; text-align: center; font-family: var(--mono); padding: 4px 6px; min-height: 30px; }
.input--date { width: auto; }
.input--comment { min-width: 14em; min-height: 30px; padding: 4px 8px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form .select { width: auto; }

/* ---------- メッセージ ---------- */

.notice {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 13px;
}
.notice--error { background: var(--accent-soft); border-color: #e7c3c5; color: #7d1a1f; }
.notice--ok { background: var(--ok-soft); border-color: #bfdac9; color: var(--ok); }
.notice--warn { background: var(--warn-soft); border-color: #ecd5a6; color: var(--warn); }
.notice--info { background: var(--info-soft); border-color: #c4d5e6; color: var(--info); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    border-radius: var(--radius);
    background: var(--header);
    color: #fff;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
.toast--error { background: #7d1a1f; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
    background: #ececea;
    color: var(--text-sub);
}
.tag--confirmed { background: #2f3337; color: #fff; }
.tag--draft { background: #e3e3df; color: var(--text); }
.tag--request { background: var(--info-soft); color: var(--info); }
.tag--pending { background: var(--warn-soft); color: var(--warn); }
.tag--approved { background: var(--ok-soft); color: var(--ok); }
.tag--returned { background: var(--accent-soft); color: var(--danger); }
.tag--alert { background: var(--accent-soft); color: var(--danger); }

/* ---------- ログイン ---------- */

.login-body { background: var(--header); }
.login {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}
.login__brand { margin-bottom: 28px; text-align: center; color: #c9cbcd; }
.login__brand img { height: 40px; display: block; margin: 0 auto 10px; }
.login__brand span { font-size: 13px; letter-spacing: .08em; }
.login__card {
    width: 100%;
    max-width: 360px;
    padding: 28px;
    background: var(--surface);
    border-radius: 8px;
}
.login__card h1 { font-size: 17px; margin-bottom: 20px; }
.login__card .notice { margin-bottom: 16px; }
.login__card .btn--block { margin-top: 22px; }
.login__links { margin-top: 20px; font-size: 13px; text-align: center; }
.login__links a { color: #c9cbcd; }
.login .site-footer { color: #8a8d91; }

/* ---------- 月切り替え ---------- */

.month-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
}
.month-nav a, .month-nav span.disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
}
.month-nav a:hover { background: var(--surface-sub); }
.month-nav span.disabled { color: #c9c9c4; }
.month-nav strong { min-width: 8.5em; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- テーブル ---------- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-sub);
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fbfbfa; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { color: var(--text); text-decoration: underline; }
.table tr.is-muted td { color: var(--text-faint); }
.table tr.is-warn td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* ---------- エキスパート：シフト一覧 ---------- */

.control-banner { margin-bottom: 16px; }

.day-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.day {
    border-bottom: 1px solid var(--border);
}
.day:last-child { border-bottom: none; }
.day__summary {
    display: grid;
    grid-template-columns: 5.6em 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.day__summary:hover { background: var(--surface-sub); }
.day__date { font-weight: 600; font-variant-numeric: tabular-nums; }
.day__date .wd { margin-left: 2px; font-weight: 400; color: var(--text-sub); }
.day--sat .day__date .wd { color: var(--info); }
.day--sun .day__date .wd { color: var(--danger); }
.day--today .day__date { color: var(--accent); }
.day__status { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; min-width: 0; }
.day__shift { font-weight: 600; font-variant-numeric: tabular-nums; }
.day__req { color: var(--text-sub); font-size: 13px; font-variant-numeric: tabular-nums; }
.day__none { color: var(--text-faint); font-size: 13px; }
.day__chevron {
    width: 8px; height: 8px;
    border-right: 1.5px solid var(--text-faint);
    border-bottom: 1.5px solid var(--text-faint);
    transform: rotate(45deg);
    margin-right: 4px;
}
.day.is-open .day__chevron { transform: rotate(-135deg); }
.day__detail {
    padding: 4px 16px 16px calc(5.6em + 28px);
}
.shift-detail {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}
.shift-detail li {
    display: grid;
    grid-template-columns: 7em 1fr;
    gap: 2px 12px;
    padding: 8px 12px;
    background: var(--surface-sub);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.shift-detail li + li { margin-top: 6px; }
.shift-detail .time { font-weight: 600; font-variant-numeric: tabular-nums; }
.shift-detail .comment { grid-column: 2; color: var(--text-sub); font-size: 13px; }
.request-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.request-form .sep { color: var(--text-faint); }
.request-form .label { font-size: 13px; color: var(--text-sub); margin-right: 4px; }

.bulk-panel { margin-bottom: 16px; }
.weekday-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-picker label {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}
.weekday-picker input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-picker input:checked + span { color: #fff; }
.weekday-picker label:has(input:checked) { background: var(--header); border-color: var(--header); color: #fff; }
.weekday-picker label:has(input:focus-visible) { outline: 2px solid var(--info); outline-offset: 1px; }
.bulk-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-top: 16px; }

.user-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; font-size: 13px; }

/* ---------- 有給カレンダー ---------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.stat { padding: 12px 16px; background: var(--surface); }
.stat__label { font-size: 12px; color: var(--text-sub); }
.stat__value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: 12px; font-weight: 400; margin-left: 2px; color: var(--text-sub); }

.calendar {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.calendar th {
    padding: 8px 4px;
    background: var(--surface-sub);
    border-bottom: 1px solid var(--border);
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 600;
}
.calendar th:first-child { color: var(--danger); }
.calendar th:last-child { color: var(--info); }
.calendar td {
    height: 96px;
    padding: 0;
    border: 1px solid var(--border);
    vertical-align: top;
}
.cal-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    height: 100%;
    min-height: 96px;
    padding: 6px 8px;
    border: none;
    background: none;
    font: inherit;
    font-size: 12px;
    color: inherit;
    text-align: left;
}
button.cal-cell { cursor: pointer; }
button.cal-cell:hover { background: var(--surface-sub); }
.cal-cell[aria-pressed="true"] { background: var(--info-soft); box-shadow: inset 0 0 0 2px var(--info); }
.cal-cell__day { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell__work { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal-cell__time { font-variant-numeric: tabular-nums; }
.cal-cell .tag { margin-top: auto; align-self: flex-start; }
.calendar td.is-out { background: #f3f3f0; }
.calendar td.is-out .cal-cell { color: var(--text-faint); }

.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}
.action-bar .selected-info { margin-right: auto; color: var(--text-sub); font-size: 13px; }

/* ---------- 管理者：シフト作成 ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 14px;
}
.toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar__group + .toolbar__group { padding-left: 16px; border-left: 1px solid var(--border); }
.toolbar__label { font-size: 12px; color: var(--text-sub); font-weight: 600; }

.day-strip {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 4px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.day-strip a {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 38px;
    padding: 4px 0;
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.day-strip a small { font-size: 10px; color: var(--text-faint); }
.day-strip a.is-sat small { color: var(--info); }
.day-strip a.is-sun small { color: var(--danger); }
.day-strip a:hover { background: var(--surface-sub); }
.day-strip a[aria-current="date"] { background: var(--header); color: #fff; }
.day-strip a[aria-current="date"] small { color: #c9cbcd; }

.shift-table td { padding: 6px 8px; }
.shift-table tr.row--confirmed td { background: #f6f6f4; }
.shift-table tr.row--request td { background: #f7f9fc; }
.shift-table .col-actions, .shift-table .col-req { white-space: nowrap; }
.shift-table .col-actions .btn + .btn { margin-left: 2px; }
.shift-table .col-seq { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }
.shift-table .count-alert { color: var(--danger); font-weight: 600; }

.picker { position: relative; min-width: 11em; }
.picker__button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.picker__button:hover { border-color: #a9a9a2; }
.picker__button .placeholder { color: var(--text-faint); }
.picker__button::after {
    content: "";
    flex-shrink: 0;
    width: 6px; height: 6px;
    border-right: 1.5px solid var(--text-faint);
    border-bottom: 1.5px solid var(--text-faint);
    transform: rotate(45deg) translateY(-2px);
}
.picker__panel {
    position: fixed;   /* 表のスクロール領域で切れないよう画面基準で表示（位置はJSで設定） */
    z-index: 60;
    width: 260px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.picker__panel input {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid var(--border);
    font: inherit;
    border-radius: var(--radius) var(--radius) 0 0;
}
.picker__panel input:focus { outline: none; background: var(--surface-sub); }
.picker__panel ul { max-height: 320px; margin: 0; padding: 4px; overflow-y: auto; list-style: none; }
.picker__panel li {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.picker__panel li:hover, .picker__panel li.is-active { background: var(--info-soft); }
.picker__panel li .code { color: var(--text-faint); font-size: 11px; margin-left: 6px; font-family: var(--mono); }

.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text); }
.th-sort .arrow { font-size: 10px; margin-left: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-sub); }

/* ---------- ユーザー管理 ---------- */

.op-card .card__body { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.op-card .help { font-size: 12px; color: var(--text-sub); margin: 0; }
.op-card .btn { align-self: flex-start; }

/* ---------- エラー画面 ---------- */

.message-page { text-align: center; padding-top: 64px; }
.message-page .code { font-size: 13px; color: var(--text-faint); font-family: var(--mono); }
.message-page h1 { margin: 6px 0 12px; }
.message-page p { color: var(--text-sub); }

/* ---------- スマホ ---------- */

@media (max-width: 640px) {
    body { font-size: 15px; }
    .site-header__inner { padding: 8px 14px; gap: 10px; min-height: 50px; }
    .brand img { height: 22px; }
    .brand__app { display: none; }
    .site-header__user { gap: 12px; font-size: 13px; }
    .page { padding: 16px 12px 32px; }
    .page-head { margin-bottom: 14px; }
    .page-head__actions { margin-left: 0; width: 100%; }
    .day__summary { grid-template-columns: 4.8em 1fr auto; padding: 12px; gap: 10px; }
    .day__detail { padding: 0 12px 14px; }
    .shift-detail li { grid-template-columns: 1fr; }
    .weekday-picker { gap: 4px; }
    .weekday-picker label { width: calc((100% - 24px) / 7); min-width: 34px; }
    .shift-detail .comment { grid-column: 1; }
    .calendar td { height: 64px; }
    .cal-cell { min-height: 64px; padding: 4px; font-size: 10px; }
    .cal-cell__work { display: none; }
    .cal-cell .tag { font-size: 9px; padding: 0 4px; }
    .stat__value { font-size: 18px; }
}
