/*
  医療入院カルテ・指示書 v1.0.3
  全ページ共通UI改善
  2026-07-05 JST

  目的：
  見やすさ、入力しやすさ、押しやすさを優先。
*/


:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --sub: #5f6b7a;
  --line: #d8dee9;
  --line-strong: #b9c3d1;
  --brand: #1f6feb;
  --brand-dark: #1557ba;
  --danger: #c62828;
  --ok: #1b7f3a;
  --warn: #8a5a00;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 1px 4px rgba(15, 23, 42, 0.06);
}


* {
  box-sizing: border-box;
}


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


body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  line-height: 1.75;
}


body,
input,
select,
textarea,
button {
  font-size: 16px;
}


a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}


a:hover {
  text-decoration: underline;
}


h1,
h2,
h3 {
  line-height: 1.35;
  margin: 0 0 14px;
  color: #111827;
}


h1 {
  font-size: 1.55rem;
  padding-bottom: 8px;
}


h2 {
  font-size: 1.25rem;
}


h3 {
  font-size: 1.1rem;
}


hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}


/* 上部ヘッダー */

header,
.header,
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}


body > h1,
body > .container,
main,
.page,
.content {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}


main,
.page,
.content {
  padding: 18px;
}


.user {
  background: #eef4ff;
  border: 1px solid #c9dcff;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 18px;
  color: #163b72;
  font-weight: 700;
}


/* ナビゲーション */

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}


nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  box-shadow: var(--shadow-soft);
}


nav a:hover {
  background: #eef4ff;
  border-color: #b9d1ff;
  text-decoration: none;
}


/* カード */

.card,
section,
fieldset {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 16px 18px;
}


.card + .card {
  margin-top: 20px;
}


.muted {
  color: var(--sub);
  font-size: 0.95rem;
}


/* フォーム */

form {
  margin: 0;
}


label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 700;
  color: #273244;
}


input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}


textarea {
  min-height: 120px;
  resize: vertical;
}


input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.16);
}


input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  transform: scale(1.2);
  margin-right: 8px;
}


input[type="date"],
input[type="number"] {
  max-width: 260px;
}


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


/* ボタン */

button,
.button,
a.button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  margin: 4px 4px 4px 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: #1f2937;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}


button:hover,
.button:hover,
a.button:hover,
input[type="submit"]:hover {
  background: #f2f6ff;
  text-decoration: none;
}


button.primary,
.primary,
input[type="submit"].primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}


button.primary:hover,
.primary:hover {
  background: var(--brand-dark);
}


button[type="submit"] {
  touch-action: manipulation;
}


button:focus,
.button:focus,
a:focus {
  outline: 3px solid rgba(31, 111, 235, 0.25);
  outline-offset: 2px;
}


/* 削除ボタン */

button[onclick*="削除"],
form[id^="delete-"] button,
form[id^="delete-nurse-"] + button {
  border-color: #efb4b4;
  background: #fff7f7;
  color: var(--danger);
}


button[onclick*="削除"]:hover {
  background: #ffecec;
}


/* テーブル */

table {
  width: calc(100% - 36px);
  margin: 16px 18px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}


table.list {
  display: block;
  overflow-x: auto;
  white-space: normal;
}


table.list thead,
table.list tbody,
table.list tr {
  width: 100%;
}


th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}


th {
  background: #eef2f7;
  color: #1f2937;
  font-weight: 800;
  white-space: nowrap;
}


tr:nth-child(even) td {
  background: #fbfcff;
}


tr:hover td {
  background: #f3f7ff;
}


td strong {
  font-size: 1.05rem;
}


.pre,
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}


/* 看護師ドラッグ並び替え */

#nurse-sort-body tr {
  transition: background 0.15s ease;
}


#nurse-sort-body tr.dragging {
  opacity: 0.55;
  background: #eaf2ff;
}


#nurse-sort-body td:first-child {
  width: 60px;
  text-align: center;
  font-weight: 800;
  color: var(--brand);
}


#nurse-sort-body td:nth-child(2) {
  width: 80px;
  text-align: center;
  font-size: 1.2rem;
  color: var(--sub);
  user-select: none;
}


/* メッセージ */

.flash,
.alert,
.success,
.error,
.notice {
  margin: 14px 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}


.success {
  border-color: #b7e2c2;
  background: #f0fff4;
  color: var(--ok);
}


.error {
  border-color: #f1b5b5;
  background: #fff5f5;
  color: var(--danger);
}


/* ログイン画面 */

form[action*="login"],
.login,
.login-card {
  max-width: 520px;
  margin: 32px auto;
}


form[action*="login"] input {
  font-size: 1.05rem;
}


/* 印刷時 */

@media print {
  nav,
  .user,
  button,
  .button,
  a.button {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .card,
  table {
    box-shadow: none;
    border-color: #999;
  }

  main,
  .page,
  .content {
    padding: 0;
  }
}


/* 小さい画面 */

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  nav {
    position: static;
    padding: 10px;
  }

  nav a {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    min-height: 46px;
  }

  .card,
  section,
  fieldset,
  table,
  .flash,
  .alert,
  .success,
  .error,
  .notice {
    margin-left: 10px;
    margin-right: 10px;
  }

  .card,
  section,
  fieldset {
    padding: 14px;
  }

  th,
  td {
    padding: 10px;
  }

  button,
  .button,
  a.button {
    width: 100%;
    margin-top: 6px;
  }

  input[type="date"],
  input[type="number"] {
    max-width: 100%;
  }
}


/* 横幅が広いPC */

@media (min-width: 1200px) {
  main,
  .page,
  .content {
    padding-left: 28px;
    padding-right: 28px;
  }

  .card,
  table {
    margin-left: 28px;
    margin-right: 28px;
  }

  table {
    width: calc(100% - 56px);
  }
}

/* ===== instruction-table-fix-202607050354 START ===== */

/*
  今日の指示などで、
  症状経過の長文により
  右側の操作欄が崩れる問題を修正。
*/

table.list {
  display: table;
  table-layout: fixed;
  width: calc(100% - 36px);
  max-width: calc(100% - 36px);
}

table.list thead {
  display: table-header-group;
  width: auto;
}

table.list tbody {
  display: table-row-group;
  width: auto;
}

table.list tr {
  display: table-row;
  width: auto;
}

table.list th,
table.list td {
  display: table-cell;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 入力欄が列幅を押し広げないようにする */
table.list input,
table.list select,
table.list textarea {
  max-width: 100%;
}

/* ボタンが極端に縦長にならないようにする */
table.list button,
table.list .button,
table.list a.button {
  white-space: nowrap;
  min-width: 72px;
}

/* 最後の操作列は必ず幅を確保 */
table.list th:last-child,
table.list td:last-child {
  width: 120px;
  min-width: 120px;
  white-space: normal;
}

/* 操作列のリンクとボタン */
table.list td:last-child a,
table.list td:last-child button {
  margin: 3px 3px 3px 0;
}

/*
  6列の指示一覧用。
  患者 / 症状経過 / 分類 / 指示 /
  看護師サイン / 操作
*/
@supports selector(table:has(th:nth-child(6))) {
  table.list:has(th:nth-child(6)) th:nth-child(1),
  table.list:has(th:nth-child(6)) td:nth-child(1) {
    width: 11%;
  }

  table.list:has(th:nth-child(6)) th:nth-child(2),
  table.list:has(th:nth-child(6)) td:nth-child(2) {
    width: 25%;
  }

  table.list:has(th:nth-child(6)) th:nth-child(3),
  table.list:has(th:nth-child(6)) td:nth-child(3) {
    width: 8%;
  }

  table.list:has(th:nth-child(6)) th:nth-child(4),
  table.list:has(th:nth-child(6)) td:nth-child(4) {
    width: 30%;
  }

  table.list:has(th:nth-child(6)) th:nth-child(5),
  table.list:has(th:nth-child(6)) td:nth-child(5) {
    width: 16%;
    min-width: 150px;
  }

  table.list:has(th:nth-child(6)) th:nth-child(6),
  table.list:has(th:nth-child(6)) td:nth-child(6) {
    width: 10%;
    min-width: 120px;
  }
}

/* 看護師サインのプルダウンを押しやすくする */
table.list td:nth-last-child(2) select {
  min-width: 130px;
}

/* スマホ・狭い画面では横スクロールを許可 */
@media (max-width: 900px) {
  table.list {
    display: block;
    overflow-x: auto;
    table-layout: auto;
    min-width: 900px;
    max-width: none;
  }
}

/* ===== instruction-table-fix-202607050354 END ===== */

/* ===== instruction-overflow-fix-202607050356 START ===== */

/*
  今日の指示テーブルの崩れ対策。
  症状経過が長文でも、
  右側の看護師サイン・操作欄を
  表の中に収める。
*/


/* まず表全体を画面内に収める */
table.list {
  width: calc(100vw - 80px) !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  table-layout: fixed !important;
  overflow: hidden !important;
}


/* セル内で必ず折り返す */
table.list th,
table.list td {
  box-sizing: border-box !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  white-space: normal !important;
}


/* 今日の指示：6列テーブル用 */
table.list th:nth-child(1),
table.list td:nth-child(1) {
  width: 11% !important;
}

table.list th:nth-child(2),
table.list td:nth-child(2) {
  width: 25% !important;
}

table.list th:nth-child(3),
table.list td:nth-child(3) {
  width: 8% !important;
}

table.list th:nth-child(4),
table.list td:nth-child(4) {
  width: 30% !important;
}

table.list th:nth-child(5),
table.list td:nth-child(5) {
  width: 16% !important;
  min-width: 150px !important;
}

table.list th:nth-child(6),
table.list td:nth-child(6) {
  width: 10% !important;
  min-width: 110px !important;
}


/* 操作列が右に飛び出さないようにする */
table.list td:nth-child(6) {
  text-align: center !important;
}

table.list td:nth-child(6) a,
table.list td:nth-child(6) button {
  display: block !important;
  width: 100% !important;
  max-width: 96px !important;
  margin: 4px auto !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}


/* 看護師サイン列のフォームを安定させる */
table.list td:nth-child(5) form {
  display: block !important;
  width: 100% !important;
}

table.list td:nth-child(5) select,
table.list td:nth-child(5) button {
  width: 100% !important;
  max-width: 150px !important;
  margin: 4px auto !important;
  display: block !important;
}


/* 症状経過・指示は読みやすく折り返す */
table.list td:nth-child(2),
table.list td:nth-child(4) {
  line-height: 1.75 !important;
}


/* 長文入力欄が表を横に押し広げないようにする */
table.list textarea,
table.list input,
table.list select {
  max-width: 100% !important;
}


/* 狭い画面では横スクロールに逃がす */
@media (max-width: 1050px) {
  table.list {
    width: 1050px !important;
    max-width: none !important;
    overflow-x: auto !important;
  }

  body {
    overflow-x: auto !important;
  }
}

/* ===== instruction-overflow-fix-202607050356 END ===== */

/* ===== instruction-table-final-fix-202607050357 START ===== */

/*
  今日の指示専用。
  長い症状経過で右側の
  看護師サイン・操作欄が崩れる問題を修正。
*/

table.instruction-list {
  display: table !important;
  table-layout: fixed !important;
  width: calc(100vw - 110px) !important;
  max-width: 1280px !important;
  min-width: 1120px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-collapse: separate !important;
  overflow: visible !important;
}

/* 列幅を固定 */
table.instruction-list col.col-patient {
  width: 120px !important;
}

table.instruction-list col.col-symptom {
  width: 340px !important;
}

table.instruction-list col.col-category {
  width: 80px !important;
}

table.instruction-list col.col-order {
  width: 400px !important;
}

table.instruction-list col.col-sign {
  width: 190px !important;
}

table.instruction-list col.col-action {
  width: 150px !important;
}

/* セル内で折り返す */
table.instruction-list th,
table.instruction-list td {
  display: table-cell !important;
  box-sizing: border-box !important;
  vertical-align: top !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  white-space: normal !important;
}

/* 症状経過と指示は読みやすく */
table.instruction-list td:nth-child(2),
table.instruction-list td:nth-child(4) {
  line-height: 1.8 !important;
}

/* 分類は細くても読めるように中央寄せしない */
table.instruction-list td:nth-child(3) {
  text-align: left !important;
}

/* 看護師サイン列 */
table.instruction-list td:nth-child(5) {
  width: 190px !important;
  min-width: 190px !important;
}

table.instruction-list td:nth-child(5) form {
  display: block !important;
  width: 100% !important;
}

table.instruction-list td:nth-child(5) select,
table.instruction-list td:nth-child(5) button {
  display: block !important;
  width: 100% !important;
  max-width: 160px !important;
  margin: 5px auto !important;
}

/* 操作列 */
table.instruction-list th:nth-child(6),
table.instruction-list td:nth-child(6) {
  width: 150px !important;
  min-width: 150px !important;
  text-align: center !important;
  overflow: visible !important;
}

/* 操作列の編集・非表示を表内に収める */
table.instruction-list td:nth-child(6) a,
table.instruction-list td:nth-child(6) button,
table.instruction-list td:nth-child(6) .button {
  display: block !important;
  width: 96px !important;
  max-width: 96px !important;
  min-width: 96px !important;
  margin: 6px auto !important;
  white-space: normal !important;
  line-height: 1.35 !important;
  text-align: center !important;
}

/* 画面が狭い場合は横スクロールで崩れを防ぐ */
@media (max-width: 1250px) {
  table.instruction-list {
    width: 1120px !important;
    max-width: none !important;
  }

  body {
    overflow-x: auto !important;
  }
}

/* ===== instruction-table-final-fix-202607050357 END ===== */

/* ===== instruction-js-class-fix-202607050402 START ===== */

/*
  JSで instruction-list を付けた後に効く最終調整。
  右側の看護師サイン・操作欄を表内に収める。
*/

table.instruction-list {
  width: 1180px !important;
  max-width: 1180px !important;
  min-width: 1180px !important;
  table-layout: fixed !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

table.instruction-list col.col-patient {
  width: 120px !important;
}

table.instruction-list col.col-symptom {
  width: 300px !important;
}

table.instruction-list col.col-category {
  width: 80px !important;
}

table.instruction-list col.col-order {
  width: 360px !important;
}

table.instruction-list col.col-sign {
  width: 180px !important;
}

table.instruction-list col.col-action {
  width: 140px !important;
}

table.instruction-list th,
table.instruction-list td {
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  white-space: normal !important;
  vertical-align: top !important;
}

table.instruction-list td:nth-child(5) select,
table.instruction-list td:nth-child(5) button {
  width: 150px !important;
  max-width: 150px !important;
  margin: 5px auto !important;
  display: block !important;
}

table.instruction-list td:nth-child(6) {
  width: 140px !important;
  min-width: 140px !important;
  text-align: center !important;
}

table.instruction-list td:nth-child(6) a,
table.instruction-list td:nth-child(6) button {
  display: block !important;
  width: 92px !important;
  max-width: 92px !important;
  min-width: 92px !important;
  margin: 6px auto !important;
  white-space: normal !important;
  text-align: center !important;
}

body {
  overflow-x: auto !important;
}

/* ===== instruction-js-class-fix-202607050402 END ===== */

/* ===== instruction-card-layout-202607050410 START ===== */

/*
  今日の指示をカード型に近い表示へ変更。
  症状経過が長くても、
  看護師サイン・操作欄が崩れないようにする。
*/

table.instruction-card-list {
  display: block !important;
  width: min(1280px, calc(100vw - 72px)) !important;
  min-width: 0 !important;
  max-width: 1280px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

table.instruction-card-list tbody {
  display: block !important;
  width: 100% !important;
}

table.instruction-card-list .instruction-card-header {
  display: none !important;
}

table.instruction-card-list .instruction-card-row {
  display: grid !important;
  grid-template-columns:
    150px
    minmax(260px, 1fr)
    minmax(320px, 1.15fr)
    210px
    130px;
  grid-template-areas:
    "patient symptom symptom sign action"
    "patient category order   sign action";
  width: 100% !important;
  margin: 14px 0 !important;
  border: 1px solid #d8dee9 !important;
  border-radius: 14px !important;
  background: #ffffff !important;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08) !important;
  overflow: hidden !important;
}

table.instruction-card-list .instruction-card-row > td {
  display: block !important;
  width: auto !important;
  min-width: 0 !important;
  border: 0 !important;
  border-right: 1px solid #d8dee9 !important;
  border-bottom: 1px solid #d8dee9 !important;
  padding: 14px !important;
  background: #ffffff !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  vertical-align: top !important;
}

table.instruction-card-list .instruction-card-row > td::before {
  display: block;
  content: attr(data-label);
  margin-bottom: 6px;
  color: #5f6b7a;
  font-size: 0.86rem;
  font-weight: 800;
}

table.instruction-card-list .cell-patient {
  grid-area: patient;
  font-weight: 700;
  background: #fbfcff !important;
}

table.instruction-card-list .cell-symptom {
  grid-area: symptom;
  line-height: 1.85 !important;
}

table.instruction-card-list .cell-category {
  grid-area: category;
  background: #fbfcff !important;
}

table.instruction-card-list .cell-order {
  grid-area: order;
  line-height: 1.85 !important;
  background: #fbfcff !important;
}

table.instruction-card-list .cell-sign {
  grid-area: sign;
  background: #ffffff !important;
}

table.instruction-card-list .cell-action {
  grid-area: action;
  text-align: center !important;
  background: #fbfcff !important;
  border-right: 0 !important;
}

table.instruction-card-list .cell-sign form {
  display: block !important;
  width: 100% !important;
}

table.instruction-card-list .cell-sign select,
table.instruction-card-list .cell-sign button {
  display: block !important;
  width: 100% !important;
  max-width: 180px !important;
  margin: 7px auto !important;
}

table.instruction-card-list .cell-action a,
table.instruction-card-list .cell-action button,
table.instruction-card-list .cell-action .button {
  display: block !important;
  width: 96px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  margin: 8px auto !important;
  text-align: center !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}

table.instruction-card-list input,
table.instruction-card-list select,
table.instruction-card-list textarea {
  max-width: 100% !important;
}

/* 画面幅が狭い場合 */
@media (max-width: 1100px) {
  table.instruction-card-list {
    width: calc(100vw - 28px) !important;
  }

  table.instruction-card-list .instruction-card-row {
    grid-template-columns: 140px 1fr 200px 120px;
    grid-template-areas:
      "patient symptom sign action"
      "patient category sign action"
      "patient order   sign action";
  }
}

/* iPad・スマホは縦積みにして崩れ防止 */
@media (max-width: 820px) {
  table.instruction-card-list .instruction-card-row {
    display: block !important;
  }

  table.instruction-card-list .instruction-card-row > td {
    border-right: 0 !important;
  }

  table.instruction-card-list .cell-action a,
  table.instruction-card-list .cell-action button,
  table.instruction-card-list .cell-action .button,
  table.instruction-card-list .cell-sign select,
  table.instruction-card-list .cell-sign button {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ===== instruction-card-layout-202607050410 END ===== */

/* ===== instruction-real-card-202607050413 START ===== */

/*
  今日の指示を table ではなく
  実カード表示に変換した後のCSS。
*/

.instruction-cards {
  width: min(1280px, calc(100vw - 72px));
  margin: 18px auto;
}

.instruction-real-card {
  display: grid;
  grid-template-columns: 150px minmax(280px, 1fr) minmax(320px, 1.1fr) 210px 140px;
  grid-template-areas:
    "patient symptom symptom sign action"
    "patient category order   sign action";
  background: #ffffff;
  border: 1px solid #d8dee9;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  margin: 14px 0;
  overflow: hidden;
}

.instruction-card-section {
  padding: 14px;
  border-right: 1px solid #d8dee9;
  border-bottom: 1px solid #d8dee9;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: #ffffff;
}

.instruction-card-label {
  color: #5f6b7a;
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.instruction-card-body {
  line-height: 1.8;
}

.section-patient {
  grid-area: patient;
  background: #fbfcff;
  font-weight: 700;
}

.section-symptom {
  grid-area: symptom;
}

.section-category {
  grid-area: category;
  background: #fbfcff;
}

.section-order {
  grid-area: order;
  background: #fbfcff;
}

.section-sign {
  grid-area: sign;
}

.section-action {
  grid-area: action;
  background: #fbfcff;
  border-right: 0;
  text-align: center;
}

.section-sign form {
  display: block;
  width: 100%;
}

.section-sign select,
.section-sign button {
  display: block !important;
  width: 100% !important;
  max-width: 180px !important;
  margin: 7px auto !important;
}

.section-action a,
.section-action button,
.section-action .button {
  display: block !important;
  width: 96px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  margin: 8px auto !important;
  text-align: center !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}

.section-action form {
  display: block !important;
  margin: 0 !important;
}

.instruction-real-card input,
.instruction-real-card select,
.instruction-real-card textarea {
  max-width: 100% !important;
}

/* 中くらいの画面 */
@media (max-width: 1150px) {
  .instruction-cards {
    width: calc(100vw - 28px);
  }

  .instruction-real-card {
    grid-template-columns: 135px minmax(240px, 1fr) 190px 130px;
    grid-template-areas:
      "patient symptom sign action"
      "patient category sign action"
      "patient order   sign action";
  }
}

/* iPad・スマホ */
@media (max-width: 820px) {
  .instruction-real-card {
    display: block;
  }

  .instruction-card-section {
    border-right: 0;
  }

  .section-sign select,
  .section-sign button,
  .section-action a,
  .section-action button,
  .section-action .button {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ===== instruction-real-card-202607050413 END ===== */

/* ===== instruction-card-polish-202607050415 START ===== */

/*
  今日の指示カードの最終調整。
  右側の看護師サイン・操作欄の
  縦長空白を減らし、操作しやすくする。
*/

.instruction-cards {
  width: min(1260px, calc(100vw - 64px)) !important;
}

.instruction-real-card {
  grid-template-columns:
    130px
    minmax(300px, 1.15fr)
    minmax(300px, 1fr)
    175px
    118px !important;

  grid-template-areas:
    "patient symptom symptom sign action"
    "patient category order   sign action" !important;

  align-items: start !important;
  margin: 12px 0 !important;
}

.instruction-card-section {
  padding: 12px 14px !important;
}

.instruction-card-label {
  margin-bottom: 4px !important;
}

/* 患者欄 */
.section-patient {
  min-height: 148px !important;
}

/* 症状経過 */
.section-symptom {
  min-height: 90px !important;
  max-height: none !important;
}

/* 分類・指示 */
.section-category,
.section-order {
  min-height: 86px !important;
}

/* 看護師サイン欄 */
.section-sign {
  min-height: 148px !important;
}

.section-sign .instruction-card-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  align-items: stretch !important;
}

.section-sign select,
.section-sign button {
  max-width: 150px !important;
  min-height: 42px !important;
  margin: 4px auto !important;
}

/* 操作欄 */
.section-action {
  min-height: 148px !important;
}

.section-action .instruction-card-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  align-items: center !important;
}

.section-action a,
.section-action button,
.section-action .button {
  width: 88px !important;
  min-width: 88px !important;
  max-width: 88px !important;
  min-height: 42px !important;
  margin: 3px auto !important;
  padding: 8px 10px !important;
}

/* 文字の密度を少し上げる */
.section-symptom .instruction-card-body,
.section-order .instruction-card-body {
  line-height: 1.7 !important;
}

/* 空の症状経過欄は高さを抑える */
.section-symptom .instruction-card-body:empty::after {
  content: " ";
  display: block;
  min-height: 24px;
}

/* 中くらいの画面 */
@media (max-width: 1150px) {
  .instruction-real-card {
    grid-template-columns:
      125px
      minmax(260px, 1fr)
      170px
      112px !important;

    grid-template-areas:
      "patient symptom sign action"
      "patient category sign action"
      "patient order   sign action" !important;
  }

  .section-sign,
  .section-action,
  .section-patient {
    min-height: 140px !important;
  }
}

/* ===== instruction-card-polish-202607050415 END ===== */

/* ===== instruction-patient-group-202607050424 START ===== */

/*
  今日の指示：
  同じ患者の複数指示を
  1つの患者カード内にまとめる。
*/

.instruction-patient-cards {
  width: min(1280px, calc(100vw - 64px));
  margin: 18px auto;
}

.instruction-patient-card {
  display: grid;
  grid-template-columns: 150px 1fr;
  grid-template-areas:
    "patient symptom"
    "patient items";
  gap: 14px;
  background: #ffffff;
  border: 1px solid #d8dee9;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  margin: 16px 0;
  padding: 16px;
}

.group-patient {
  grid-area: patient;
  background: #fbfcff;
}

.group-symptom {
  grid-area: symptom;
}

.group-instructions {
  grid-area: items;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instruction-item {
  display: grid;
  grid-template-columns: 120px minmax(280px, 1fr) 180px 120px;
  grid-template-areas:
    "category order sign action";
  gap: 12px;
  padding: 12px;
  border: 1px solid #d8dee9;
  border-radius: 14px;
  background: #fbfcff;
}

.instruction-card-section {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8dee9;
  border-radius: 12px;
  background: #ffffff;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.instruction-card-label {
  color: #5f6b7a;
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.instruction-card-body {
  line-height: 1.75;
}

.item-category {
  grid-area: category;
}

.item-order {
  grid-area: order;
}

.item-sign {
  grid-area: sign;
}

.item-action {
  grid-area: action;
  text-align: center;
}

.item-sign select,
.item-sign button,
.item-action select,
.item-action button,
.item-action a,
.item-action .button {
  display: block !important;
  width: 100% !important;
  max-width: 110px !important;
  min-height: 42px !important;
  margin: 6px auto !important;
  text-align: center !important;
  white-space: normal !important;
}

.item-action form,
.item-sign form {
  display: block !important;
  margin: 0 !important;
}

.item-action .danger,
button.danger {
  border-color: #efb4b4 !important;
  background: #fff7f7 !important;
  color: #c62828 !important;
}

.item-action .danger:hover,
button.danger:hover {
  background: #ffecec !important;
}

@media (max-width: 1100px) {
  .instruction-patient-card {
    grid-template-columns: 135px 1fr;
  }

  .instruction-item {
    grid-template-columns: 110px 1fr 165px 115px;
  }
}

@media (max-width: 820px) {
  .instruction-patient-card {
    display: block;
  }

  .instruction-item {
    display: block;
  }

  .instruction-card-section {
    margin: 10px 0;
  }

  .item-sign select,
  .item-sign button,
  .item-action select,
  .item-action button,
  .item-action a,
  .item-action .button {
    max-width: 100% !important;
  }
}

/* ===== instruction-patient-group-202607050424 END ===== */
