:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #d9dee5;
  --text: #1c2430;
  --muted: #5f6b7a;
  --brand: #1f5aa6;
  --brand-dark: #16447f;
  --ok: #1a7f4b;
  --warn: #b06a00;
  --full: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

header.site {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

header.site h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
header.site .who { font-size: .85rem; opacity: .95; }
header.site a { color: #fff; }

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

section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 16px 0 8px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  min-height: 44px;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: #fff; color: var(--brand); }
button.danger { background: #fff; color: var(--full); border-color: var(--full); }
button.small { padding: 6px 10px; min-height: 36px; font-size: .85rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
.required::after { content: " *"; color: var(--full); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.msg { padding: 10px 12px; border-radius: 8px; margin: 12px 0; font-size: .9rem; }
.msg.error { background: #fdecea; color: #8c1d18; border: 1px solid #f3c3bf; }
.msg.ok { background: #e6f4ec; color: #10603a; border: 1px solid #b6ddc7; }
.msg.info { background: #eaf1fa; color: #16447f; border: 1px solid #c2d5ee; }
.hidden { display: none !important; }

/* --- カレンダー --- */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cal-head .month { font-weight: 700; font-size: 1.05rem; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .dow {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  padding: 4px 0;
}
.calendar .dow.sun { color: var(--full); }
.calendar .dow.sat { color: var(--brand); }

.day {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-height: 62px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  font: inherit;
  color: inherit;
  cursor: default;
}
.day.empty { border: none; background: transparent; }
.day .d { font-size: .85rem; font-weight: 600; }
.day .mark { font-size: 1.15rem; line-height: 1.1; }
.day .rest { font-size: .68rem; color: var(--muted); }
.day.open { cursor: pointer; border-color: #a8c6ea; }
.day.open:hover { background: #eef4fc; }
.day.open .mark { color: var(--ok); }
.day.few .mark { color: var(--warn); }
.day.full { background: #fbf0ef; }
.day.full .mark { color: var(--full); }
.day.closed { background: #f5f6f7; color: #9aa4b0; }
.day.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.day.selected { background: #dfeafa; border-color: var(--brand); }

.legend { font-size: .78rem; color: var(--muted); margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; }

/* --- 一覧 --- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; white-space: nowrap; }
th { background: #f0f3f7; font-weight: 600; color: var(--muted); }
td.wrap { white-space: normal; min-width: 160px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; }
.badge.confirmed { background: #e6f4ec; color: #10603a; }
.badge.cancelled { background: #f0f1f3; color: #6b7280; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
}
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 94vw);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .body { padding: 16px; }
dialog h2 { border-bottom: 1px solid var(--border); padding-bottom: 10px; }

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 16px; }
.login-wrap .card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.login-wrap h1 { font-size: 1.15rem; margin: 0 0 4px; }
.login-wrap p.lead { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }

.muted { color: var(--muted); font-size: .85rem; }
.weekly-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekly-grid label { text-align: center; margin: 0 0 2px; }
.weekly-grid input { text-align: center; padding: 8px 4px; }

@media (max-width: 480px) {
  main { padding: 10px; }
  section.card { padding: 12px; }
  .day { min-height: 56px; }
  th, td { padding: 6px 8px; }
}

/* 狭い画面では表を「1 件 = 1 カード」に組み替える（横スクロールを避ける） */
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #fff;
  }
  table.stack td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: none;
    padding: 3px 0;
    white-space: normal;
    text-align: right;
  }
  table.stack td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .8rem;
    text-align: left;
    flex: 0 0 auto;
  }
  table.stack td.cell-action { justify-content: flex-end; padding-top: 8px; }
  table.stack td:empty { display: none; }
}

/* --- v2 --- */
dialog.wide { width: min(720px, 96vw); max-height: 94vh; overflow-y: auto; }
label.inline { display: inline-flex; align-items: center; gap: 4px; margin: 0 14px 0 0; color: var(--text); font-size: .95rem; }
label.inline input { width: auto; }
.radio-row, .check-row { display: flex; flex-wrap: wrap; padding: 6px 0; }
.judge { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: #eef1f5; font-size: .9rem; }
.judge.good { background: #e6f4ec; color: #10603a; }
.judge.bad { background: #fdecea; color: #8c1d18; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0 4px; }

.office-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.office-tabs button { background: #fff; color: var(--muted); border-color: var(--border); }
.office-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.office-tabs button.own::after { content: " ★"; }
.readonly-note { background: #fff7e0; border: 1px solid #f0dca0; border-radius: 8px; padding: 8px 12px; font-size: .85rem; margin-bottom: 10px; }

.calendar.v2 .day { min-height: 92px; align-items: stretch; padding: 4px; }
.calendar.v2 .day .d { text-align: center; }
.calendar.v2 .day .hol { display: block; font-size: .62rem; color: var(--full); font-weight: 400; }
.slot-row {
  display: flex; justify-content: space-between; align-items: center; gap: 4px;
  font: inherit; font-size: .78rem; min-height: 26px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid transparent; background: #f3f5f8; color: var(--text); width: 100%;
}
button.slot-row { cursor: pointer; border-color: #a8c6ea; background: #fff; }
button.slot-row:hover { background: #eef4fc; }
.slot-row.open .m { color: var(--ok); font-weight: 700; }
.slot-row.few .m { color: var(--warn); font-weight: 700; }
.slot-row.full .m { color: var(--full); font-weight: 700; }
.slot-row.off { color: #9aa4b0; background: transparent; }
.day.off { background: #f5f6f7; color: #8b95a1; }
.day .stop { font-size: .72rem; color: var(--full); text-align: center; margin-top: 8px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.toolbar > * { flex: 0 1 auto; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.badge.doc { background: #e8eefb; color: #1f4fa0; }
.badge.nodoc { background: #fff1e0; color: #9a5a00; }
.btns { display: flex; gap: 4px; flex-wrap: wrap; }

.day-panel { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fafbfd; }
.day-panel h3 { margin-top: 0; }
.slot-box { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 10px; margin-top: 10px; }
.slot-box .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.slot-box .cap { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.slot-box .cap button { min-height: 32px; padding: 2px 10px; }
.slot-box ul { margin: 8px 0 0; padding-left: 18px; font-size: .88rem; }
.calendar.v2 .day.pick { cursor: pointer; }
.calendar.v2 .day.sel { outline: 2px solid var(--brand); outline-offset: -2px; background: #eef4fc; }
.cnt { font-size: .74rem; }
.cnt.over { color: var(--full); font-weight: 700; }

/* --- 10/16 打ち合わせ対応 --- */
.calendar.v2 .day.other { opacity: .62; background: #fafbfc; }
.calendar.v2 .day.other .d { color: var(--muted); font-weight: 500; }
.calendar.v2 .day.pick:hover { background: #f3f7fd; }
td.dates div { white-space: nowrap; }
.extra-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.extra-dates .chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #a8c6ea; background: #eef4fc; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: .85rem; }
.extra-dates .chip button { min-height: 0; padding: 0 6px; border: none; background: transparent; color: var(--full); cursor: pointer; font-size: 1rem; line-height: 1.3; }
.date-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.date-pills span { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 2px 8px; font-size: .85rem; }
.date-pills span.extra { border-color: #a8c6ea; background: #eef4fc; }

.req-note { margin: 0 0 6px; }
.req-mark { color: var(--full); font-weight: 700; margin-right: 2px; }
.unit-input { display: flex; align-items: center; gap: 6px; }
.unit-input input { flex: 1 1 auto; min-width: 0; }
.unit-input .unit { white-space: nowrap; color: var(--muted); font-size: .9rem; }
