:root {
    --navy: #16324f;
    --blue: #1769aa;
    --light: #eef4f8;
    --green: #19764b;
    --red: #b42318;
    --line: #d7e0e7;
    --text: #18212a;
    --muted: #60717f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
    background: #f5f7f9;
    color: var(--text);
    line-height: 1.6;
}

/* ---- ヘッダ ---- */
header {
    background: var(--navy);
    color: #fff;
    padding: 14px 20px;
}

.header-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

header a { color: #fff; text-decoration: none; }
.brand { font-size: 21px; font-weight: 700; }

nav { display: flex; flex-wrap: wrap; gap: 6px 14px; }
nav a { padding: 3px 4px; border-radius: 5px; }
nav a.active { background: rgba(255, 255, 255, .18); }
nav a:hover { text-decoration: underline; }

main { max-width: 1240px; margin: 22px auto; padding: 0 16px; }

h1 { font-size: 24px; margin: 0 0 18px; }
h2 { font-size: 19px; margin: 0 0 14px; }

/* ---- カード・グリッド ---- */
.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .04);
}

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

.metric { font-size: 27px; font-weight: 700; color: var(--navy); }
.muted { color: var(--muted); font-size: 14px; }

/* ---- フォーム ---- */
label { display: block; font-weight: 650; margin: 11px 0 5px; }

input, select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #aebbc5;
    border-radius: 6px;
    background: #fff;
    font: inherit;
}

input[type=checkbox] { width: auto; min-width: 0; transform: scale(1.2); }

button, .button {
    display: inline-block;
    border: 0;
    border-radius: 7px;
    padding: 10px 17px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover, .button:hover { filter: brightness(1.06); }
.button.secondary, button.secondary { background: #5b6872; }
.button.green, button.green { background: var(--green); }
.button.red, button.red { background: var(--red); }

.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.actions.compact { margin-top: 0; }

.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline > div { flex: 0 1 auto; }

/* ---- フラッシュ ---- */
.flash { padding: 12px 14px; border-radius: 7px; margin-bottom: 15px; }
.flash.ok { background: #d9f2e5; color: #0f5132; }
.flash.error { background: #f8d7da; color: #842029; }
.flash.info { background: #dbeafe; color: #1e3a8a; }

/* ---- テーブル ---- */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--light); font-size: 13px; }
.table-wrap { overflow: auto; }
td.nowrap, th.nowrap { white-space: nowrap; }

.badge {
    display: inline-block;
    border-radius: 99px;
    padding: 2px 9px;
    background: #e7edf2;
    font-size: 12px;
}
.badge.open { background: #fff0c2; color: #7a4b00; }
.badge.completed { background: #d9f2e5; color: #0f5132; }

/* ---- 打刻端末 ---- */
.terminal { max-width: 760px; margin: 0 auto; text-align: center; }
.clock { font-size: 38px; font-weight: 700; letter-spacing: 1px; margin-bottom: 4px; }
.punch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 16px; }
.punch-grid button { min-height: 68px; font-size: 20px; }
.default-punch-heading { margin-top: 26px; }
.default-punch-grid button { border: 3px solid rgba(255, 255, 255, .45); }

/* ---- ログイン ---- */
.login { max-width: 460px; margin: 40px auto; }

/* ---- 月間一括入力 ---- */
.manual-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.manual-heading h2 { margin-bottom: 4px; }

.monthly-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin: 0 0 18px;
}
.monthly-summary > div {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #f7fafc;
    padding: 12px 15px;
}
.monthly-summary span { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.monthly-summary strong { color: var(--navy); font-size: 25px; margin-right: 5px; }
.monthly-summary small { color: var(--muted); }

.manual-table th, .manual-table td { padding: 4px 5px; font-size: 13px; }
.manual-table input:not([type=checkbox]),
.manual-table select { padding: 4px 3px; min-width: 0; }
.manual-table input[type=time] { width: 64px; }
/* ブラウザの時計アイコンを消して幅を稼ぐ */
.manual-table input[type=time]::-webkit-calendar-picker-indicator { display: none; }
.manual-table input[type=time]::-webkit-inner-spin-button { display: none; }
.manual-table select { max-width: 130px; }
.monthly-manual .weekday { color: var(--muted); font-size: 12px; }
.monthly-manual tr.weekend td { background: #fffaf2; }
.monthly-manual .break-minutes-input { width: 56px; }
.manual-table .btn-default-row { padding: 3px 6px; font-size: 11px; margin-left: 3px; }
.manual-table thead th { position: sticky; top: 0; z-index: 2; }
.manual-table td[data-result] { font-variant-numeric: tabular-nums; color: var(--navy); font-weight: 650; }
tr.row-invalid td { background: #fff1f0 !important; }

/* ---- マイページ（従業員セルフ） ---- */
.me-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}
.me-summary > div {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    padding: 10px 12px;
}
.me-summary span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.me-summary strong { color: var(--navy); font-size: 20px; font-variant-numeric: tabular-nums; }
.me-summary small { color: var(--muted); margin-left: 3px; }

.time-pair { display: flex; align-items: center; gap: 8px; }
.time-pair input { width: auto; flex: 1 1 0; min-width: 0; }

.day-list { display: grid; gap: 6px; }
.day-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}
.day-row.is-holiday { background: #fffaf2; }
.day-row.is-review { border-left: 4px solid var(--blue); }
.day-row .d { min-width: 84px; font-weight: 700; }
.day-row .d .wd { color: var(--muted); font-weight: 400; font-size: 13px; }
.day-row .times { min-width: 150px; font-variant-numeric: tabular-nums; }
.day-row .st { min-width: 74px; }
.day-row .act { margin-left: auto; }
.day-row .act .button { padding: 7px 16px; }
.day-row .meta { flex-basis: 100%; font-size: 12px; color: var(--muted); }

@media (max-width: 560px) {
    .day-row .act { margin-left: 0; }
    .day-row .st { min-width: 0; }
}

/* ---- タイムカード ---- */
.timecard-sheet {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 20px;
}
.timecard-title { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.timecard-title h2, .timecard-title p { margin: 0 0 4px; }
.timecard-table th, .timecard-table td { padding: 4px 6px; font-size: 12px; white-space: nowrap; }
.timecard-table tr.weekend td { background: #fffaf2; }
.timecard-total th { background: var(--light); font-weight: 700; }
.timecard-sign { display: flex; justify-content: flex-end; gap: 60px; margin-top: 16px; font-size: 13px; }

@media (max-width: 760px) {
    .header-inner { display: block; }
    nav { margin-top: 10px; }
    .punch-grid { grid-template-columns: 1fr; }
    .clock { font-size: 30px; }
    .manual-heading { display: block; }
    .manual-heading button { margin-top: 10px; }
    .monthly-summary { grid-template-columns: repeat(2, 1fr); }
}
