/* =========================================================================
   訪問看護スケジュール — 画面スタイル
   ========================================================================= */
:root {
  color-scheme: light;
  --bg:        #eef2f6;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --line:      #dbe3ec;
  --line-2:    #c3cedb;
  --text:      #0f172a;
  --muted:     #5b6b7f;
  --faint:     #8896a8;
  --accent:    #0f766e;
  --accent-d:  #115e59;
  --accent-l:  #ccfbf1;
  --danger:    #b91c1c;
  --danger-bg: #fef2f2;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --sat:       #1d4ed8;
  --sun:       #be123c;
  --radius:    10px;
  --shadow-1:  0 1px 2px rgba(15, 23, 42, .08);
  --shadow-2:  0 8px 28px rgba(15, 23, 42, .16);
  --font: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 起動中 ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 14px; color: var(--muted);
}
.boot-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ヘッダー ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; height: 52px;
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 6px rgba(15, 23, 42, .2);
  padding-top: env(safe-area-inset-top);
}
.appbar-title strong { font-size: 15px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.appbar-menu {
  display: none; width: 38px; height: 38px; margin-left: -6px;
  background: none; border: 0; padding: 9px 8px; cursor: pointer;
}
.appbar-menu span { display: block; height: 2px; background: #fff; border-radius: 2px; margin: 4px 0; }
.appbar-nav { display: flex; gap: 2px; margin-left: 10px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.appbar-nav::-webkit-scrollbar { display: none; }
.appbar-nav a {
  color: #d7f2ee; text-decoration: none; padding: 7px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.appbar-nav a:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.appbar-nav a.active { background: #fff; color: var(--accent-d); }
.appbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.btn-ghost {
  background: rgba(255, 255, 255, .14); border: 0; color: #fff;
  padding: 6px 11px; border-radius: 7px; cursor: pointer; font-size: 12px;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .26); }

.view { padding: 14px; max-width: 100%; }
.print-head { display: none; }

/* ---------- 汎用パーツ ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow-1);
}
.toolbar .spacer { flex: 1; }
.toolbar h2 { font-size: 15px; margin: 0; }
/* ツールバー内の入力は内容にあわせた幅にする（既定の 100% だと折り返してしまう） */
.toolbar input[type=date], .toolbar input[type=time], .toolbar input[type=search],
.toolbar input[type=text], .toolbar input[type=number], .toolbar select { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.danger { color: var(--danger); border-color: #f3c6c6; background: var(--danger-bg); }
.btn.danger:hover { background: #fde8e8; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn-icon {
  width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0;
  border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer;
}
.btn-icon:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .lbl { font-size: 12px; font-weight: 700; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=tel], input[type=number], input[type=search], select, textarea {
  padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 62px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.empty { padding: 30px 16px; text-align: center; color: var(--faint); font-size: 13px; }

/* ---------- 週グリッド ---------- */
.week-layout { display: flex; gap: 12px; align-items: flex-start; }
.grid-wrap {
  flex: 1; min-width: 0; overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
  max-height: calc(100vh - 150px);
}
.wgrid { display: grid; min-width: max-content; }
.wgrid > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.wg-corner {
  position: sticky; top: 0; left: 0; z-index: 6; background: var(--surface-2);
}
.wg-head {
  position: sticky; top: 0; z-index: 5; background: var(--surface-2);
  padding: 7px 8px; text-align: center; font-weight: 700; font-size: 13px;
  border-bottom: 2px solid var(--line-2) !important;
}
.wg-head .job { display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
.wg-head .bar { height: 3px; border-radius: 2px; margin: 4px auto 0; width: 70%; }

.wg-day {
  position: sticky; left: 0; z-index: 4; background: var(--surface-2);
  width: 62px; padding: 8px 4px; text-align: center;
  border-right: 2px solid var(--line-2) !important;
}
.wg-day .d { font-size: 17px; font-weight: 700; line-height: 1.1; }
.wg-day .w { font-size: 12px; color: var(--muted); }
.wg-day .m { font-size: 10px; color: var(--faint); }
.wg-day.sat .w, .wg-day.sat .d { color: var(--sat); }
.wg-day.sun .w, .wg-day.sun .d { color: var(--sun); }
.wg-day.today { background: var(--accent-l); }
.wg-day .cnt { font-size: 10px; color: var(--faint); margin-top: 2px; }

/* 1日の枠を午前・午後の2段に分ける（ホワイトボードの中央線にあたる） */
.wg-cell {
  min-height: 88px; padding: 0; display: grid; grid-template-rows: 1fr 1fr;
  background: var(--surface); position: relative;
}
.wg-half {
  display: flex; flex-direction: column; gap: 3px; padding: 3px;
  min-height: 42px; min-width: 0;
}
.wg-half.pm { border-top: 1px dashed var(--faint); }
.wg-half.drop-target { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-l); }
.wg-cell.today { background: #f2fbfa; }
.wg-cell.weekend { background: #fbfcfe; }
.wg-cell.off { background: repeating-linear-gradient(135deg, #f1f5f9 0 8px, #e8edf3 8px 16px); }
.wg-cell.drop-target { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-l); }
.wg-cell .off-label {
  font-size: 12px; font-weight: 700; color: var(--danger); text-align: center;
  padding: 6px 0; letter-spacing: .1em;
}
.wg-cell .add {
  opacity: 0; border: 1px dashed var(--line-2); border-radius: 6px; background: none;
  color: var(--faint); font-size: 11px; line-height: 1.3; padding: 1px; cursor: pointer; margin-top: auto;
}
.wg-half:hover .add { opacity: 1; }
.wg-cell.overflow { box-shadow: inset 0 0 0 2px #fbbf24; }

/* ---------- カード ---------- */
.card {
  display: block; width: 100%; text-align: left; position: relative;
  border: 1px solid var(--line-2); border-left: 5px solid var(--faint);
  border-radius: 6px; background: #fff; padding: 4px 6px 4px 7px;
  cursor: grab; box-shadow: var(--shadow-1); touch-action: manipulation;
}
.card:hover { border-color: var(--accent); }
.card .nm { font-size: 13px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.card .tm { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card .meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.card .chip {
  font-size: 10px; padding: 0 5px; border-radius: 999px; line-height: 15px;
  color: #fff; font-weight: 700; white-space: nowrap;
}
.card .comp { font-size: 10px; color: var(--muted); }
.card.status-cancelled { opacity: .62; background: #fafafa; }
.card.status-cancelled .nm { text-decoration: line-through; }
.card.status-hospitalized { background: #fff7ed; }
.card.status-suspended { background: #f5f3ff; }
.card.irregular { border-style: dashed; }
/* 同行の予定（担当者のカードの写し）。動かせないので掴む見た目にしない */
.card.mirror {
  background: linear-gradient(0deg, rgba(14, 165, 233, .08), rgba(14, 165, 233, .08)), #fff;
  border-color: #7dd3fc;
  cursor: pointer;
}
.card.mirror .nm { font-weight: 600; }
.card.conflict { box-shadow: 0 0 0 2px #f87171; }
.card.highlight { box-shadow: 0 0 0 3px #fde047; }
.card.dragging { opacity: .35; }

.drag-ghost {
  position: fixed; z-index: 200; pointer-events: none; width: 150px;
  transform: translate(-50%, -50%) rotate(-2deg); box-shadow: var(--shadow-2);
}

/* ---------- プール ---------- */
.pool { width: 216px; flex: none; display: flex; flex-direction: column; gap: 10px;
        max-height: calc(100vh - 150px); overflow: auto; }
.pool-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
            box-shadow: var(--shadow-1); overflow: hidden; }
.pool-box > h3 {
  margin: 0; padding: 7px 10px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.pool-box > h3 .n { color: var(--faint); font-weight: 600; }
.pool-list { padding: 6px; display: flex; flex-direction: column; gap: 4px; min-height: 46px; }
.pool-list.drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-l); }
.pool-list .none { color: var(--faint); font-size: 12px; text-align: center; padding: 8px 0; }
.pool-ref { font-size: 12px; padding: 3px 6px; border-radius: 5px; background: var(--surface-2); }
.pool-ref .d { color: var(--faint); font-size: 11px; }

/* ---------- 日別 / 自分の予定 ---------- */
.daylist { display: grid; gap: 10px; }
.daygroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
            box-shadow: var(--shadow-1); overflow: hidden; }
.daygroup > h3 {
  margin: 0; padding: 8px 12px; font-size: 13px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
.daygroup > h3 .bar { width: 4px; height: 15px; border-radius: 2px; }
.daygroup > h3 .n { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 600; }
.daygroup.sat > h3 { color: var(--sat); }
.daygroup.sun > h3 { color: var(--sun); }
.rows { display: flex; flex-direction: column; }
.vrow {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; width: 100%;
  border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
}
.daygroup .empty { padding: 10px 12px; text-align: left; }
.vrow:first-child { border-top: 0; }
.vrow:hover { background: var(--surface-2); }
.vrow .t { font-size: 14px; font-weight: 700; width: 46px; flex: none; font-variant-numeric: tabular-nums; }
.vrow .t.none { color: var(--faint); font-weight: 500; font-size: 12px; }
.vrow .b { flex: 1; min-width: 0; }
.vrow .n { font-size: 14px; font-weight: 700; }
.vrow .n .chip {
  display: inline-block; margin-left: 6px; vertical-align: 2px;
  font-size: 10px; font-weight: 700; color: #fff; padding: 0 6px; border-radius: 999px; line-height: 15px;
}
.vrow .s { font-size: 12px; color: var(--muted); }
.vrow .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.vrow.cancelled .n { text-decoration: line-through; color: var(--muted); }

/* ---------- テーブル ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { background: var(--surface-2); font-size: 12px; color: var(--muted); position: sticky; top: 0; z-index: 1; }
table.tbl tbody tr:hover { background: var(--surface-2); cursor: pointer; }
table.tbl td.wrap { white-space: normal; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--muted);
}
.badge.on  { background: var(--accent-l); border-color: #99f6e4; color: var(--accent-d); }
.badge.off { background: #f1f5f9; }
.badge.red { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.dot-color { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }

/* ---------- モーダル ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; animation: fade .12s ease;
}
@media (min-width: 720px) { .modal-back { align-items: center; padding: 24px; } }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh;
  border-radius: 14px 14px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-2);
}
@media (min-width: 720px) { .modal { border-radius: 14px; max-height: 88vh; } }
.modal.wide { max-width: 820px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 16px; overflow: auto; display: grid; gap: 13px; }
.modal-foot {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 14px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.modal-foot .spacer { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .row3 { grid-template-columns: 1fr 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600;
}
.seg button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.tagpick button {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 700;
}
.notice { font-size: 13px; padding: 9px 12px; border-radius: 8px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.notice.info { background: var(--accent-l); color: var(--accent-d); border: 1px solid #99f6e4; }
.notice.err  { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.pw-box {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 20px; font-weight: 700;
  letter-spacing: .12em; background: var(--surface-2); border: 1px dashed var(--line-2);
  border-radius: 8px; padding: 12px; text-align: center; user-select: all;
}

/* 利用者検索の候補 */
.picker { position: relative; }
.picker-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 10; margin-top: 3px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: var(--shadow-2); max-height: 230px; overflow: auto;
}
.picker-list button {
  display: block; width: 100%; text-align: left; padding: 8px 11px;
  border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; font-size: 13px;
}
.picker-list button:hover, .picker-list button.on { background: var(--accent-l); }
.picker-list .k { color: var(--faint); font-size: 11px; margin-left: 6px; }

/* ---------- ログイン ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
         background: linear-gradient(160deg, #0f766e, #134e4a); }
.login-card {
  background: #fff; border-radius: 14px; padding: 26px 24px 28px; width: 100%; max-width: 370px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .28); display: grid; gap: 6px;
}
.login-card h1 { font-size: 18px; margin: 0; text-align: center; }
.login-sub { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card label { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 8px; }
.login-card .check { margin-top: 14px; }
.login-warn { font-size: 11px; color: var(--faint); margin: 2px 0 0; }
.login-error { background: var(--danger-bg); color: var(--danger); border-radius: 8px;
               padding: 9px 12px; font-size: 13px; margin: 12px 0 0; }
.login-card button[type=submit] {
  margin-top: 16px; padding: 12px; border: 0; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; font-size: 15px;
}
.login-card button[type=submit]:hover { background: var(--accent-d); }

/* ---------- トースト ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw;
  pointer-events: none;
}
.toast {
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow-2); animation: pop .16s ease;
}
.toast.warn { background: #b45309; }
.toast.err  { background: #b91c1c; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 画面幅への対応 ---------- */
@media (max-width: 1080px) {
  .pool { width: 186px; }
}
@media (max-width: 860px) {
  .appbar-menu { display: block; }
  .appbar-nav {
    position: fixed; top: 52px; left: 0; right: 0; z-index: 39; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 6px;
    box-shadow: var(--shadow-2); display: none;
  }
  .appbar-nav.open { display: flex; }
  .appbar-nav a { color: var(--text); padding: 11px 12px; }
  .appbar-nav a.active { background: var(--accent-l); color: var(--accent-d); }
  .appbar-user span { display: none; }
  .view { padding: 10px; }
  .week-layout { flex-direction: column; }
  .pool { width: 100%; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .pool-box { flex: 1 1 210px; }
  .grid-wrap { max-height: none; }
}
