/* ====================================
   DigiMaster - スタイルシート
   プロフェッショナル医療システムデザイン
==================================== */

/* Google Fonts読み込み */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');

/* リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* メインカラー - M3風の落ち着いた緑 */
  --primary: #2E7D32;
  --primary-light: #388E3C;
  --primary-dark: #1B5E20;
  --primary-gradient: linear-gradient(180deg, #2E7D32 0%, #1B5E20 100%);

  /* アクセントカラー */
  --accent: #3C8DBC;
  --accent-light: #5DADE2;

  /* ニュートラル */
  --gray-900: #1a1a1a;
  --gray-800: #2d2d2d;
  --gray-700: #404040;
  --gray-600: #525252;
  --gray-500: #737373;
  --gray-400: #a3a3a3;
  --gray-300: #d4d4d4;
  --gray-200: #e5e5e5;
  --gray-100: #f5f5f5;
  --gray-50: #fafafa;
  --white: #ffffff;

  /* セマンティック */
  --danger: #b91c1c;
  --warning: #d97706;
  --success: #15803d;
  --info: #0369a1;

  /* シャドウ */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ====================================
   ログイン画面
==================================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
  position: relative;
}

.login-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2300A65A' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-container {
  background: var(--white);
  padding: 60px 50px;
  border-radius: 4px;
  box-shadow: var(--shadow-xl);
  width: 420px;
  text-align: center;
  position: relative;
  border: 1px solid rgba(0,0,0,0.08);
}

.login-logo {
  margin-bottom: 45px;
}

.logo-icon {
  margin-bottom: 20px;
}

.logo-icon i {
  font-size: 56px;
  color: var(--primary);
  filter: drop-shadow(0 2px 4px rgba(46,125,50,0.3));
}

.logo-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.logo-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-500);
  letter-spacing: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form input {
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: all 0.2s ease;
}

.login-form input::placeholder {
  color: var(--gray-400);
  font-weight: 400;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  border-radius: 3px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(46,125,50,0.3);
}

.login-btn:hover {
  background: linear-gradient(180deg, #1B5E20 0%, #145214 100%);
  box-shadow: 0 6px 16px rgba(46,125,50,0.4);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
}

.forgot-link {
  display: block;
  margin-top: 25px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 12px;
  font-weight: 400;
  transition: color 0.2s;
}

.forgot-link:hover {
  color: var(--primary);
}

.login-account-message {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #d48d87;
  border-radius: 4px;
  background: #fff3f1;
  color: #922e28;
  font-size: 13px;
  line-height: 1.5;
}

/* ====================================
   メイン画面
==================================== */
.main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ヘッダー */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 42px;
  background: #f5f5f0;
  border-bottom: 1px solid #ddd;
  box-shadow: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-back {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-back:hover {
  background: var(--primary-dark);
}

.patient-selector {
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  color: var(--white);
  font-size: 13px;
  font-family: inherit;
  min-width: 220px;
  cursor: pointer;
}

.patient-selector option {
  color: var(--gray-800);
  background: var(--white);
}

.header-patient-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #333;
}

.patient-id-text {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.patient-name {
  font-size: 18px;
  font-weight: 700;
  color: #212529;
  letter-spacing: 2px;
}

.patient-kana {
  font-size: 14px;
  color: #495057;
  letter-spacing: 1px;
}

.patient-age {
  font-size: 14px;
  color: #333;
}

.patient-gender-badge {
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.patient-gender-badge.male {
  background: var(--primary);
}

.patient-gender-badge.female {
  background: #e91e63;
}

.patient-calendar-icon {
  color: var(--primary);
  font-size: 16px;
  cursor: pointer;
}

.patient-calendar-icon:hover {
  color: var(--primary-dark);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-icons {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  border-radius: 3px;
  font-size: 15px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #e8f5e9;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
}

.btn-logout {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: var(--white);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.6);
}

/* ====================================
   メインボディ（3カラム）
==================================== */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--primary-gradient);
  color: var(--white);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.btn-edit-small {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.btn-edit-small:hover {
  opacity: 1;
}

/* 左パネル */
.panel-left {
  width: 300px;
  min-width: 280px;
}

/* タブコンテナ */
.tab-container {
  padding: 8px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.tab-container.secondary {
  background: var(--gray-50);
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.tab-row:last-child {
  margin-bottom: 0;
}

.tab {
  padding: 6px 10px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--gray-600);
  transition: all 0.2s;
}

.tab:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.tab.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* タブコンテンツ */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.info-section {
  padding: 5px 0;
}

.info-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 12px 0 8px;
}

.info-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.info-label {
  width: 70px;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 500;
}

.info-value {
  flex: 1;
  font-size: 12px;
  color: var(--gray-800);
}

.no-data {
  color: var(--gray-400);
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

/* 患者メモ */
.patient-memo {
  padding: 12px;
  background: #fffbeb;
  border-top: 1px solid var(--gray-200);
}

.memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-700);
}

.patient-memo textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  background: var(--white);
}

.patient-memo textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* 中央パネル（カルテ） */
.panel-center {
  flex: 1;
  min-width: 500px;
}

.karte-header {
  padding: 12px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.karte-date {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
}

.date-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
}

.date-input:focus {
  outline: none;
  border-color: var(--primary);
}

.karte-status {
  padding: 5px 14px;
  background: var(--primary);
  color: var(--white);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.karte-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-600);
}

.select-small {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  background: var(--white);
}

.select-small:focus {
  outline: none;
  border-color: var(--primary);
}

.karte-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--gray-50);
}

.karte-section {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-700);
}

.text-tools {
  display: flex;
  gap: 4px;
}

.tool-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 3px;
  font-weight: 700;
  font-size: 13px;
  transition: all 0.2s;
}

.tool-btn:hover {
  background: var(--gray-100);
}

.tool-btn.text-red {
  color: #dc2626;
}

.tool-btn.text-blue {
  color: #2563eb;
}

.font-size-select {
  padding: 6px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
}

.karte-editor {
  flex: 1;
  padding: 20px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
  overflow-y: auto;
  font-size: 14px;
  line-height: 2;
  min-height: 400px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.karte-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05), 0 0 0 3px rgba(46,125,50,0.1);
}

.karte-editor p {
  margin-bottom: 6px;
}

.karte-editor strong {
  color: var(--primary-dark);
}

.karte-footer {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
}

.footer-right {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* 右パネル（メニュー） */
.panel-right {
  width: 280px;
  min-width: 250px;
}

.menu-tabs {
  padding: 8px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.menu-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 3px;
}

.menu-tab {
  flex: 1;
  min-width: 38px;
  padding: 5px 6px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  text-align: center;
  color: var(--gray-600);
  transition: all 0.2s;
}

.menu-tab:hover {
  background: var(--gray-50);
}

.menu-tab.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.menu-search {
  padding: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  background: var(--gray-50);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
}

.search-input::placeholder {
  color: var(--gray-400);
}

.menu-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--white);
}

.menu-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.menu-item.selected {
  background: #ecfdf5;
  border-color: var(--primary);
}

.item-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--white);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 10px;
}

.item-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
}

.item-points {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}

.selected-items {
  border-top: 2px solid var(--primary);
  background: var(--gray-50);
}

.selected-header {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  background: var(--gray-100);
  color: var(--gray-700);
}

.total-points {
  color: var(--primary);
  font-weight: 700;
}

.selected-list {
  max-height: 150px;
  overflow-y: auto;
  padding: 8px;
}

.menu-footer {
  display: flex;
  padding: 10px;
  background: var(--primary-gradient);
  gap: 6px;
}

.footer-icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  cursor: pointer;
  border-radius: 3px;
  font-size: 15px;
  transition: all 0.2s;
}

.footer-icon-btn:hover {
  background: rgba(255,255,255,0.22);
}

.footer-spacer {
  flex: 1;
}

/* ====================================
   ボタン
==================================== */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(46,125,50,0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 8px rgba(46,125,50,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-600);
  color: var(--white);
}

.btn-secondary:hover {
  background: var(--gray-700);
}

.btn-outline {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-small {
  padding: 6px 12px;
  font-size: 11px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}

.btn-small:hover {
  background: var(--gray-200);
}

.login-facility-context {
  width: 100%;
  min-height: 72px;
  margin: 0 auto 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #b7c8b8;
  border-radius: 4px;
  background: #f5faf5;
  color: #234b26;
}

.login-facility-context.is-loading {
  color: var(--gray-600);
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.login-facility-context.is-error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff7f7;
}

.login-facility-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--primary-dark);
  background: #dcebdc;
  font-size: 18px;
}

.login-facility-context span,
.login-facility-context strong,
.login-facility-context small {
  display: block;
}

.login-facility-context strong {
  margin-top: 1px;
  font-size: 16px;
}

.login-facility-context small {
  color: var(--gray-600);
}

.login-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.facility-certificate-revoke {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #efcaca;
  border-radius: 3px;
  background: #fff0f0;
  color: #d04444;
  font-family: inherit;
  cursor: pointer;
}

.facility-certificate-revoke:hover {
  background: #ffe3e3;
}

.btn-sm {
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.2;
}

/* ====================================
   モーダル
==================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: var(--white);
  border-radius: 4px;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-large {
  width: 520px;
}

.modal-patient-file-name {
  width: min(520px, calc(100vw - 40px));
  max-height: none;
}

.modal-patient-file-name .modal-body {
  padding: 28px 32px;
}

.modal-patient-file-name .form-input {
  width: 100%;
}

.modal-patient-file-name textarea.form-input {
  min-height: 82px;
  resize: vertical;
}

.patient-file-name-footer {
  justify-content: space-between;
  align-items: center;
}

.patient-file-name-actions {
  display: flex;
  gap: 12px;
}

.modal-print-menu {
  width: min(560px, calc(100vw - 40px));
  max-height: none;
}

.print-menu-popover {
  position: fixed;
  z-index: 10050;
  width: 188px;
  padding: 0;
  background: #fff;
  border: 1px solid #bcc9c6;
  border-radius: 2px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.22);
}

.print-menu-popover.hidden {
  display: none;
}

.print-menu-popover .print-menu-list {
  padding: 0;
  background: #fff;
}

.print-menu-header {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 32px;
  border-bottom: 1px solid #d7e1dc;
  background: #f8fbfa;
}

.print-menu-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border: 0;
  border-right: 1px solid #d7e1dc;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
}

.print-menu-back:hover,
.print-menu-back:focus {
  outline: none;
  background: #eaf6ef;
}

.print-menu-title {
  min-width: 0;
  padding: 0 10px;
  color: #12351f;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print-menu-option {
  display: block;
  width: 100%;
  min-height: 31px;
  padding: 6px 14px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #1f2937;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.print-menu-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-menu-mode-option i {
  width: 16px;
  color: #0b5a2a;
  text-align: center;
}

.print-menu-option:hover,
.print-menu-option:focus {
  outline: 2px solid #38a5ff;
  outline-offset: -2px;
  background: #f7fbff;
}

.print-menu-list {
  padding: 14px;
  background: #f8fbfa;
}

.print-menu-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid #d9e5df;
  border-bottom: none;
  background: #fff;
}

.print-menu-row:first-child {
  border-radius: 4px 4px 0 0;
}

.print-menu-row:last-child {
  border-bottom: 1px solid #d9e5df;
  border-radius: 0 0 4px 4px;
}

.print-menu-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #12351f;
  font-size: 14px;
  font-weight: 700;
}

.print-menu-name i {
  width: 20px;
  text-align: center;
  color: var(--primary);
}

.print-menu-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-karte-context {
  width: min(1024px, 94vw);
  border-radius: 0;
  max-height: 88vh;
}

.karte-context-body {
  padding: 0;
  background: #f4f7f5;
}

.karte-context-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid #d5ded9;
}

.karte-context-row-with-amount {
  grid-template-columns: 180px minmax(0, 1fr) 128px;
}

.karte-context-row > label:first-child,
.karte-context-section-title,
.karte-context-section-row span:first-child {
  padding: 0 20px;
  color: #1f3328;
  font-size: 14px;
}

.karte-context-section-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 128px;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid #d5ded9;
}

.karte-context-section-row span:last-child {
  grid-column: 2 / 4;
  justify-self: end;
  padding-right: 18px;
  color: #1f3328;
  font-size: 14px;
  font-weight: 600;
}

.karte-context-row select,
.karte-context-row input[type="text"] {
  width: min(502px, 100%);
  height: 30px;
  border: 1px solid #c7d4ce;
  border-radius: 4px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  padding: 0 8px;
}

.karte-context-amount {
  justify-self: end;
  padding-right: 18px;
  color: #0f172a;
  font-size: 14px;
}

.karte-context-section-title {
  display: flex;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid #d5ded9;
  color: #0b5a1b;
  font-weight: 600;
}

.karte-context-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.karte-context-checkbox input {
  width: 16px;
  height: 16px;
}

.karte-context-footer {
  justify-content: flex-end;
  padding: 10px 12px 14px;
  border-top: 1px solid #d5ded9;
  background: #f4f7f5;
}

.karte-context-footer .btn-primary {
  min-width: 90px;
  background: #0f5b18;
  border-color: #0f5b18;
}

.modal-karte-add {
  width: min(1028px, calc(100vw - 160px));
  border: 2px solid #111;
  border-radius: 4px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
  max-height: none;
}

.karte-add-header {
  min-height: 42px;
  padding: 0 14px;
  background: #0b5312;
}

.karte-add-header h3 {
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.karte-add-close {
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.karte-add-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.karte-add-body {
  padding: 10px 12px 0;
}

.karte-add-footer {
  min-height: 48px;
  padding: 8px 10px 6px;
  justify-content: center;
}

.karte-add-footer .btn-primary {
  min-width: 90px;
  height: 36px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 15px;
}

.modal-reception-edit {
  width: min(1080px, calc(100vw - 64px));
  aspect-ratio: 1.618 / 1;
  max-height: calc(100vh - 24px);
}

@media (max-width: 900px), (max-height: 650px) {
  .modal-reception-edit {
    width: 94vw;
    height: auto;
    aspect-ratio: auto;
    max-height: 94vh;
  }
}

.modal-reception-edit .karte-context-row {
  grid-template-columns: 180px minmax(0, 1fr);
}

.modal-reception-edit .karte-context-row-with-amount,
.modal-reception-edit .karte-context-section-row {
  grid-template-columns: 180px minmax(0, 1fr) 250px;
}

.modal-reception-edit .karte-context-row > select {
  width: min(528px, 100%);
}

.reception-edit-static-row span {
  color: #0f172a;
  font-size: 14px;
}

.reception-edit-select-control {
  display: flex;
  align-items: center;
  gap: 4px;
  width: min(560px, 100%);
}

.reception-edit-select-control select {
  flex: 1;
  width: 100%;
}

.reception-edit-mini-btn,
.reception-edit-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #c7d4ce;
  border-radius: 4px;
  background: #fff;
  color: #0f5b18;
  font-size: 16px;
  cursor: pointer;
}

.reception-edit-mini-btn {
  flex: 0 0 32px;
  font-size: 13px;
}

.reception-edit-plus {
  margin-left: 0;
  color: #1f3328;
}

.modal-reception-edit .reception-edit-add-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-reception-edit .reception-edit-add-label .reception-edit-plus {
  flex: 0 0 32px;
}

.reception-edit-labor-add-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 44px;
}

.modal-reception-edit .reception-edit-add-label .reception-edit-labor-menu-button {
  width: 44px;
  flex: 0 0 44px;
  gap: 2px;
  font-size: 16px;
}

.reception-edit-labor-menu-button > span {
  font-size: 9px;
  line-height: 1;
}

.reception-edit-labor-add-menu {
  position: absolute;
  z-index: 1300;
  top: 36px;
  left: 0;
  width: 160px;
  padding: 6px 0;
  border: 1px solid #c7d4ce;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.reception-edit-labor-add-menu button {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 16px;
  border: 0;
  background: #fff;
  color: #111827;
  text-align: left;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.reception-edit-labor-add-menu button:hover,
.reception-edit-labor-add-menu button:focus-visible {
  background: #eef5f0;
  outline: none;
}

.reception-edit-mini-btn:hover,
.reception-edit-plus:hover {
  background: #eef7ef;
  border-color: #0f5b18;
}

.reception-edit-amount-input {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-right: 18px;
  color: #0f172a;
  font-size: 14px;
}

.reception-edit-amount-input input {
  width: 205px;
  height: 30px;
  border: 1px solid #c7d4ce;
  border-radius: 4px;
  background: #fff;
  padding: 0 8px;
  font: inherit;
  text-align: left;
}

.reception-edit-checks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.reception-edit-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #1f3328;
  font-size: 14px;
  white-space: nowrap;
}

.reception-edit-checks input {
  width: 15px;
  height: 15px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--primary-gradient);
  color: var(--white);
  border-radius: 4px 4px 0 0;
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.form-row {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.required {
  display: inline-block;
  padding: 2px 8px;
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  margin-right: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
  color: var(--gray-800);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,93,26,0.1);
}

.radio-group {
  display: flex;
  gap: 24px;
  padding: 10px 0;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-inputs input {
  width: 90px;
  text-align: center;
}

.date-inputs span {
  color: var(--gray-400);
}

.form-section-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  letter-spacing: 0.5px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 24px;
  background: var(--gray-50);
  border-radius: 0 0 4px 4px;
  border-top: 1px solid var(--gray-200);
}

.app-confirm-modal {
  z-index: 11000;
}

.app-confirm-box {
  width: min(420px, calc(100vw - 40px));
  max-height: none;
}

.app-confirm-body {
  padding: 20px 24px;
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.6;
}

.app-confirm-body p {
  margin: 0;
  white-space: pre-line;
}

.app-confirm-footer {
  padding: 12px 16px;
  gap: 8px;
}

.app-confirm-footer .btn {
  min-width: 88px;
  padding: 8px 16px;
}

.receipt-submission-confirm-modal {
  z-index: 11100;
}

.receipt-submission-confirm-box {
  width: min(600px, calc(100vw - 48px));
  background: #fff;
  border: 1px solid #cfd6d2;
  border-radius: 2px;
  box-shadow: none;
  padding: 14px 32px 16px;
  color: #111827;
  font-size: 14px;
  line-height: 1.55;
}

.receipt-submission-confirm-box p {
  margin: 0;
  white-space: pre-line;
}

.receipt-submission-confirm-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.receipt-submission-confirm-footer .btn {
  min-width: 92px;
  height: 38px;
  padding: 7px 18px;
}

/* ====================================
   患者登録モーダル（M3 DigiKar風）
==================================== */
.modal-patient {
  width: 960px;
  max-width: 95vw;
}

.modal-body-patient {
  padding: 0;
}

/* フォーム行 */
.form-row-patient {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--gray-200);
  min-height: 38px;
}

.form-row-patient:last-child {
  border-bottom: none;
}

/* ラベル列 */
.form-label-patient {
  width: 90px;
  min-width: 90px;
  padding: 10px 14px;
  background: var(--gray-50);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  border-right: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}

/* 入力エリア */
.form-input-area {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 住所セクション */
.form-input-area.address-section {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 10px;
}

/* 必須バッジ */
.required-badge {
  display: inline-block;
  padding: 2px 6px;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 2px;
  flex-shrink: 0;
}

/* 入力フィールド共通 */
.modal-patient input,
.modal-patient select {
  padding: 6px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 2px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  height: 30px;
}

.modal-patient input:focus,
.modal-patient select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.modal-patient input.patient-field-invalid,
.modal-patient select.patient-field-invalid {
  border-color: #dc2626;
}

.modal-patient input.patient-field-invalid:focus,
.modal-patient select.patient-field-invalid:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.16);
}

.radio-group-patient.patient-field-invalid {
  border: 1px solid #dc2626;
  border-radius: 3px;
  padding: 3px 8px;
}

.patient-field-error {
  flex-basis: 100%;
  margin-left: 42px;
  color: #dc2626;
  font-size: 12px;
  line-height: 1.35;
}

.address-section .patient-field-error {
  margin-left: 0;
}

/* 入力フィールドサイズ */
.input-medium {
  width: 280px;
}

.input-wide {
  flex: 1;
  min-width: 400px;
}

.input-year {
  width: 160px;
}

.input-month {
  width: 70px;
}

.input-day {
  width: 70px;
}

.input-postal {
  width: 140px;
}

/* 郵便番号行 */
.postal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.btn-postal-search {
  padding: 8px 14px;
  background: var(--primary);
  border: none;
  border-radius: 3px;
  color: var(--white);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-postal-search:hover {
  background: var(--primary-dark);
}

.btn-postal-search i {
  margin-right: 4px;
}

.input-address {
  width: 100%;
}

.select-prefecture {
  width: 200px;
}

.select-facility {
  width: 100%;
}

/* 日付入力 */
.date-inputs-patient {
  display: flex;
  align-items: center;
  gap: 7px;
}

.birth-date-segment {
  flex: 0 0 auto;
  padding: 0 8px;
  text-align: left;
}

.date-separator {
  font-size: 13px;
  color: var(--gray-600);
  padding: 0 2px;
}

/* カスタムコンボボックス */
.combobox {
  position: relative;
  display: inline-flex;
}

.combobox-input {
  border-right: none !important;
  border-radius: 3px 0 0 3px !important;
}

.combobox-btn {
  width: 24px;
  padding: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-left: none;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  transition: all 0.15s;
}

.combobox-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.combobox.open .combobox-btn {
  background: var(--gray-100);
}

.combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-top: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  display: none;
}

.combobox.open .combobox-dropdown {
  display: block;
}

.combobox-option {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.combobox-option:last-child {
  border-bottom: none;
}

.combobox-option:hover,
.combobox-option.highlighted {
  background: #fff3cd;
}

.combobox-option.selected {
  background: #e8f5e9;
  font-weight: 500;
}

/* ラジオボタン */
.radio-group-patient {
  display: flex;
  align-items: center;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* オンライン資格確認ボタン */
.btn-online-check {
  padding: 6px 12px;
  background: var(--white);
  border: 1px solid var(--gray-400);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-online-check:hover {
  background: var(--gray-100);
  border-color: var(--gray-500);
}

/* フッター */
.modal-footer-patient {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}

.btn-cancel-patient {
  padding: 6px 16px;
  background: var(--white);
  border: 1px solid var(--gray-400);
  color: var(--gray-700);
  font-size: 12px;
}

.btn-cancel-patient:hover {
  background: var(--gray-100);
}

.btn-register {
  padding: 6px 20px;
  background: var(--primary);
  border: none;
  color: var(--white);
  font-size: 12px;
}

.btn-register:hover {
  background: var(--primary-dark);
}

.btn-register-checkin {
  padding: 6px 16px;
  background: var(--primary-dark);
  border: none;
  color: var(--white);
  font-size: 12px;
}

.btn-register-checkin:hover {
  background: #0a2e0a;
}

/* ====================================
   履歴リスト
==================================== */
.history-search {
  margin-bottom: 12px;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--white);
  transition: all 0.2s;
}

.history-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.history-date {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-date-text {
  font-weight: 600;
  color: var(--primary);
  font-size: 13px;
}

.history-status {
  padding: 3px 10px;
  background: var(--primary);
  color: var(--white);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}

.history-content {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* ====================================
   スクロールバー
==================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

/* ====================================
   レスポンシブ
==================================== */
@media (max-width: 1200px) {
  .panel-left {
    width: 260px;
  }
  .panel-right {
    width: 250px;
  }
}

/* ====================================
   カルテ画面 新レイアウト
==================================== */

/* ヘッダー調整 */
.app-header {
  height: 42px;
  padding: 0 12px;
}

.header-left {
  gap: 8px;
}

.btn-back {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-patient-info {
  gap: 8px;
  font-size: 13px;
}

.patient-id-text {
  font-weight: 600;
}

.patient-name {
  font-size: 15px;
  font-weight: 600;
}

.patient-kana {
  font-size: 12px;
  opacity: 0.9;
}

.header-icons-left {
  display: flex;
  gap: 2px;
  margin-left: 12px;
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  border-radius: 3px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn-sm:hover {
  background: #e8f5e9;
}

.icon-btn-sm.has-badge {
  position: relative;
}

.icon-btn-sm .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: white;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
}

/* タブバー */
.karte-tabs-bar {
  display: flex;
  align-items: center;
  padding: 0 8px;
  height: 36px;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;
}

.karte-tabs-bar.secondary {
  height: 32px;
  background: #fff;
  border-bottom: 1px solid #e9ecef;
}

.karte-tabs-left {
  display: flex;
  gap: 2px;
}

.karte-tabs-center {
  display: flex;
  align-items: center;
  margin-left: auto;
  margin-right: auto;
}

.karte-tabs-right {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.karte-tab {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.karte-tab:hover {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.karte-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

.karte-tab-sm {
  padding: 4px 10px;
  background: transparent;
  border: none;
  font-size: 11px;
  font-family: inherit;
  color: var(--gray-600);
  cursor: pointer;
}

.karte-tab-sm:hover {
  color: var(--primary);
}

.karte-tab-sm.active {
  color: var(--primary);
  font-weight: 600;
}

.date-tab {
  padding: 4px 16px;
  background: var(--primary);
  color: var(--white);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
}

.date-tab-add {
  width: 24px;
  height: 24px;
  margin-left: 4px;
  background: var(--gray-200);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  color: var(--gray-600);
}

.date-tab-add:hover {
  background: var(--gray-300);
}

.karte-action-btn {
  padding: 4px 10px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  color: var(--gray-700);
  cursor: pointer;
}

.karte-action-btn:hover {
  background: var(--gray-100);
}

.karte-status-info {
  font-size: 11px;
  color: var(--gray-600);
}

.status-label {
  background: var(--gray-200);
  padding: 2px 8px;
  border-radius: 2px;
  margin-right: 8px;
}

.fax-label {
  font-size: 11px;
  margin-left: 16px;
}

.fax-select {
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--gray-300);
  border-radius: 2px;
  margin-left: 4px;
}

/* カテゴリタブバー */
.category-tabs-bar {
  display: flex;
  padding: 6px 8px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  gap: 4px;
  flex-wrap: wrap;
}

.category-tab {
  padding: 5px 14px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  transition: all 0.15s;
}

.category-tab:hover {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.category-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

/* 3カラムボディ - 比率 4:4:6 */
.app-body-karte {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--gray-100);
}

.karte-panel {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  overflow: hidden;
}

/* 左: 患者情報/診療履歴 = 4 */
.karte-panel-left {
  flex: 4;
  min-width: 240px;
  overflow-y: auto;
}

/* 中央: カルテ = 4 */
.karte-panel-center {
  flex: 4;
  min-width: 300px;
  display: flex;
  flex-direction: column;
}

/* 右: 算定エリア = 6 (4+2) */
.karte-panel-right {
  flex: 6;
  min-width: 350px;
  border-right: none;
}

/* ====================================
   左パネル: 診療履歴
==================================== */
.history-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.history-search i {
  color: var(--gray-400);
  font-size: 12px;
}

.history-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 12px;
  outline: none;
}

.history-search-actions {
  display: flex;
  gap: 4px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
}

/* 診療履歴カード - M3風 */
.history-card {
  border-bottom: 1px solid #e9ecef;
}

.history-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background 0.15s;
}

.history-card-header:hover {
  background: #e9ecef;
}

.history-card.active .history-card-header {
  background: #c8e6c9;
  border-left: 3px solid var(--primary);
}

.history-card-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.history-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}

.history-insurance {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.history-card-info {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--gray-600);
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
}

.questionnaire-response-card {
  border-bottom: 1px solid #e9ecef;
  background: var(--white);
}

.questionnaire-response-card .history-card-header {
  cursor: default;
}

.questionnaire-response-card .m3-patient-table {
  padding: 8px 10px 12px;
}

.history-card-body {
  display: none;
}

.history-card.expanded .history-card-body {
  display: block;
}

/* 2カラムレイアウト */
.history-columns {
  display: flex;
  border-top: 1px solid var(--gray-100);
}

.history-col-left {
  flex: 1;
  border-right: 1px solid var(--gray-100);
}

.history-col-right {
  flex: 1;
}

.history-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

.history-col-header i {
  font-size: 10px;
  color: var(--gray-400);
}

.history-copy-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--primary-green);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-copy-btn:hover {
  background: rgba(0, 100, 45, 0.1);
}

.history-copy-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.history-copy-btn i {
  color: inherit;
}

.history-soap-content {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--gray-700);
  line-height: 1.6;
}

.history-soap-content p {
  margin: 0 0 4px 0;
}

.history-soap-content strong {
  color: var(--gray-600);
}

/* 算定リスト */
.history-billing-list {
  padding: 4px 0;
}

.billing-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
}

.billing-row:hover {
  background: var(--gray-50);
}

.billing-row[data-history-copy-item-record-id],
.history-prescription-row[data-history-copy-item-record-id] {
  cursor: pointer;
}

.billing-row[data-history-copy-item-record-id]:hover,
.history-prescription-row[data-history-copy-item-record-id]:hover {
  background: #eef9f2;
}

.billing-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.billing-icon-green {
  background: #dcfce7;
  color: #166534;
}

.billing-icon-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.billing-icon-yellow {
  background: #fef3c7;
  color: #d97706;
}

.billing-icon-purple {
  background: #f3e8ff;
  color: #7c3aed;
}

.billing-icon-orange {
  background: #ffedd5;
  color: #c2410c;
}

.billing-name {
  flex: 1;
  color: var(--gray-700);
}

.billing-qty {
  color: var(--gray-500);
  font-size: 10px;
  min-width: 40px;
  text-align: right;
}

.billing-count {
  color: var(--gray-400);
  font-size: 10px;
  min-width: 30px;
  text-align: right;
}

/* 旧スタイル互換 */
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
}

.history-item-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.history-item-icon.shinsatsu {
  background: #dbeafe;
  color: #1d4ed8;
}

.history-item-name {
  flex: 1;
  color: var(--gray-700);
}

.history-item-points {
  color: var(--gray-500);
  font-size: 10px;
}

/* 左パネルセクション */
.panel-section {
  border-bottom: 1px solid var(--gray-200);
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
}

.panel-section-actions {
  display: flex;
  gap: 4px;
}

.btn-icon-xs {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-xs:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.patient-info-table {
  padding: 0;
}

.info-row-karte {
  display: flex;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
}

.info-label-karte {
  width: 70px;
  padding: 8px 10px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 500;
}

.info-value-karte {
  flex: 1;
  padding: 8px 10px;
  color: var(--gray-800);
}

.name-kana {
  font-size: 11px;
  color: var(--gray-500);
}

.name-kanji {
  font-weight: 500;
}

.memo-content textarea {
  width: 100%;
  border: none;
  padding: 10px;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  min-height: 80px;
}

.memo-content textarea:focus {
  outline: none;
}

.panel-section-body {
  padding: 10px;
}

.text-muted {
  font-size: 11px;
  color: var(--gray-400);
}

/* 中央パネル - カルテエディタ */
.karte-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.editor-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}

.editor-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn-sm {
  width: 24px;
  height: 24px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
}

.tool-btn-sm:hover {
  background: var(--gray-100);
}

.tool-btn-sm.text-red { color: #dc2626; }
.tool-btn-sm.text-blue { color: #2563eb; }

.tool-separator {
  color: var(--gray-300);
  margin: 0 4px;
}

.font-size-display {
  font-size: 12px;
  min-width: 20px;
  text-align: center;
}

.karte-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--white);
}

.karte-editor {
  min-height: 100%;
  font-size: 14px;
  line-height: 1.8;
  outline: none;
}

.karte-editor p {
  margin-bottom: 4px;
}

.karte-editor strong {
  color: var(--gray-700);
}

.karte-editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.btn-karte-action {
  padding: 6px 14px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  color: var(--gray-700);
  cursor: pointer;
}

.btn-karte-action:hover {
  background: var(--gray-100);
}

.btn-karte-action.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  margin-left: auto;
}

.btn-karte-action.primary:hover {
  background: var(--primary-dark);
}

.checkbox-label-sm {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--gray-600);
}

/* 右パネル */
.right-panel-split {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 算定 = 4 */
.procedure-list-panel {
  flex: 4;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.procedure-header {
  padding: 8px 12px;
  background: var(--gray-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
}

.procedure-items {
  flex: 1;
  overflow-y: auto;
}

.procedure-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s;
}

.procedure-item:hover {
  background: var(--gray-50);
}

.procedure-item.selected {
  background: #ecfdf5;
}

.proc-checkbox {
  width: 20px;
  color: var(--primary);
}

.proc-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--white);
  border-radius: 2px;
  font-size: 9px;
  font-weight: 600;
  margin-right: 6px;
}

.proc-name {
  flex: 1;
  color: var(--gray-700);
}

.proc-points {
  color: var(--gray-500);
  font-weight: 500;
}

/* 算定メニュー = 2 */
.keyword-tree-panel {
  flex: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.keyword-search {
  padding: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.keyword-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
}

.keyword-input:focus {
  outline: none;
  border-color: var(--primary);
}

.category-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.tree-item {
  user-select: none;
}

.tree-header {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--gray-700);
}

.tree-header:hover {
  background: var(--gray-100);
}

.tree-header i {
  width: 16px;
  font-size: 10px;
  color: var(--gray-500);
}

.tree-header.sub {
  padding-left: 24px;
  font-size: 11px;
}

.tree-actions {
  margin-left: auto;
  display: none;
  gap: 2px;
}

.tree-header:hover .tree-actions {
  display: flex;
}

.tree-children {
  display: none;
}

.tree-item.expanded > .tree-children {
  display: block;
}

.tree-leaf {
  padding: 5px 8px 5px 48px;
  font-size: 11px;
  color: var(--gray-600);
  cursor: pointer;
}

.tree-leaf:hover {
  background: var(--gray-100);
}

/* 右下フッター - M3風 */
.right-panel-footer {
  display: flex;
  padding: 10px 12px;
  background: linear-gradient(180deg, #2E7D32 0%, #1B5E20 100%);
  gap: 8px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.footer-btn-lg {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-direction: column;
  gap: 2px;
}

.footer-btn-lg:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

.footer-btn-lg.primary {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.3);
}

.footer-btn-lg.success {
  background: #4CAF50;
  font-weight: 600;
}

.footer-btn-lg.success:hover {
  background: #43A047;
}

/* ====================================
   受付一覧画面
==================================== */
.reception-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--gray-100);
}

/* 受付ヘッダー */
.reception-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 42px;
  background: var(--primary-gradient);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.reception-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ロゴマーク */
.clinic-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s;
}

.clinic-logo:hover {
  background: rgba(255,255,255,0.25);
}

.logo-mark {
  color: var(--white);
  font-size: 18px;
}

.clinic-info {
  display: flex;
  align-items: center;
}

.clinic-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.reception-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reception-header-right .header-icons {
  display: flex;
  gap: 2px;
}

.reception-header-right .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.system-announcement-button {
  position: relative;
}

.system-announcement-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 2px solid #2f7e3d;
  border-radius: 999px;
  background: #d93636;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  box-sizing: border-box;
}

.system-announcement-modal {
  z-index: 10060;
}

.system-announcement-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
}

.system-announcement-header {
  align-items: flex-start;
  background: #0b5518;
  color: #fff;
}

.system-announcement-header h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 18px;
}

.system-announcement-header p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.system-announcement-header .modal-close {
  color: #fff;
}

.system-announcement-body {
  min-height: 260px;
  padding: 0;
  overflow-y: auto;
  background: #f7f9f7;
}

.system-announcement-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  color: #65726c;
  text-align: center;
}

.system-announcement-item {
  position: relative;
  padding: 18px 22px 17px 28px;
  border-bottom: 1px solid #dfe6e1;
  background: #fff;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.system-announcement-item.unread {
  background: #f2faf3;
  cursor: pointer;
}

.system-announcement-item.unread:hover,
.system-announcement-item.unread:focus-visible {
  background: #e7f6ea;
  box-shadow: inset 3px 0 0 #2c8a3d;
  outline: none;
}

.system-announcement-item.is-saving {
  cursor: wait;
  opacity: 0.72;
}

.system-announcement-item.unread::before {
  content: '';
  position: absolute;
  top: 23px;
  left: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c8a3d;
}

.system-announcement-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: #6b756f;
  font-size: 11px;
}

.system-announcement-category {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #9fc3a5;
  border-radius: 999px;
  background: #edf7ef;
  color: #146224;
  font-weight: 700;
}

.system-announcement-read-status {
  margin-left: auto;
  color: #66736b;
  font-size: 11px;
  font-weight: 600;
}

.system-announcement-item.unread .system-announcement-read-status {
  color: #147028;
}

.system-announcement-item h4 {
  margin: 0 0 8px;
  color: #15241b;
  font-size: 15px;
  line-height: 1.5;
}

.system-announcement-details {
  display: grid;
  gap: 8px;
  margin: 0;
}

.system-announcement-details > div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.system-announcement-details dt {
  color: #526158;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
}

.system-announcement-details dd {
  margin: 0;
  color: #26382d;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
}

.system-announcement-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: #176a2a;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.system-announcement-source:hover {
  text-decoration: underline;
}

.system-announcement-read-hint {
  display: block;
  margin-top: 11px;
  color: #758078;
  font-size: 11px;
  text-align: right;
}

.system-announcement-item.unread .system-announcement-read-hint {
  color: #176a2a;
  font-weight: 600;
}

@media (max-width: 640px) {
  .system-announcement-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
  }

  .system-announcement-item {
    padding-right: 16px;
  }

  .system-announcement-details > div {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
  }
}

/* 「全て」は小ボタンではなく、右端セル全体をクリック領域にする */
#main-screen .m3-all-btn-wrap {
  flex: 0 0 54px;
  width: 54px;
  height: 100%;
  padding: 0 !important;
  align-items: stretch;
  justify-content: stretch;
  box-sizing: border-box;
}

#main-screen .m3-all-btn-wrap .m3-all-btn,
#main-screen .m3-all-btn-wrap .m3-all-btn:hover,
#main-screen .m3-all-btn-wrap .m3-all-btn:focus,
#main-screen .m3-all-btn-wrap .m3-all-btn:focus-visible,
#main-screen .m3-all-btn-wrap .m3-all-btn:active {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-sizing: border-box;
}

.icon-text {
  font-size: 10px;
  font-weight: 600;
}

/* ヘッダー検索ボックス */
.header-search-box {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0 10px;
  height: 28px;
}

.header-search-box i {
  font-size: 12px;
  opacity: 0.8;
  margin-right: 6px;
}

.header-search-input {
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 12px;
  width: 120px;
  outline: none;
}

.header-search-input::placeholder {
  color: rgba(255,255,255,0.7);
}

/* ユーザードロップダウン */
.user-dropdown {
  position: relative;
}

.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--primary);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.user-dropdown-btn:hover {
  background: var(--primary-dark);
}

.user-dropdown-btn i {
  font-size: 12px;
  transition: transform 0.2s;
}

.user-dropdown.open .user-dropdown-btn i {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--white);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s;
  z-index: 1000;
}

.user-dropdown.open .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--gray-100);
}

.dropdown-item i {
  width: 16px;
  color: var(--gray-500);
  text-align: center;
}

.office-report-dropdown-item {
  justify-content: flex-start;
  gap: 0;
  min-height: 34px;
  padding: 8px 14px;
  color: #1f2933;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}

.office-report-dropdown-item:hover {
  background: #eef5f1;
  color: var(--primary-dark);
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 0;
}

/* 受付ツールバー */
.reception-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-nav-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #dee2e6;
  background: #fff;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  color: #495057;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-nav-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.toolbar-date-input {
  padding: 7px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--gray-800);
}

.toolbar-date-input:focus {
  outline: none;
  border-color: var(--primary);
}

.toolbar-date-display {
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #212529;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
}

.toolbar-date-display:hover {
  border-color: var(--primary);
}

.reception-date-picker { position: relative; }
.reception-calendar {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 100;
  width: 270px;
  max-width: calc(100vw - 24px);
  padding: 12px;
  background: #fff;
  border: 1px solid #cbd5d1;
  border-radius: 4px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .18);
}
.reception-calendar-header { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 4px; text-align: center; font-weight: 600; }
.reception-calendar button { font: inherit; cursor: pointer; border: 1px solid #d8dfdc; border-radius: 3px; background: #fff; color: #26362b; }
.reception-calendar-header button { height: 28px; }
.reception-calendar-weekdays, .reception-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.reception-calendar-weekdays { margin-top: 8px; color: #666; font-size: 12px; }
.reception-calendar-weekdays span:first-child, .reception-calendar-days .sunday { color: #e44747; }
.reception-calendar-weekdays span:last-child, .reception-calendar-days .saturday { color: #3181d1; }
.reception-calendar-days { gap: 3px; margin-top: 5px; }
.reception-calendar-days button { height: 30px; border-color: transparent; font-size: 14px; }
.reception-calendar-days .outside-month { opacity: .55; }
.reception-calendar-days button:hover { background: #edf5ee; }
.reception-calendar-days .selected { background: #185923; color: #fff; opacity: 1; }
.reception-calendar-days .selected:hover { background: #185923; }
.reception-calendar button:focus-visible { outline: 2px solid #185923; outline-offset: 1px; }
.reception-calendar-footer { display: flex; justify-content: space-between; margin-top: 10px; }
.reception-calendar-footer button { padding: 5px 12px; }
.reception-calendar-days.month-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.reception-calendar-days.month-options button { height: 54px; }
.reception-calendar-days.year-options { grid-template-columns: 1fr; max-height: 260px; overflow-y: auto; }
.reception-calendar-days.year-options button { min-height: 42px; }

.patient-count {
  padding: 5px 12px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #495057;
}

.toolbar-btn {
  padding: 7px 14px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--gray-700);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.filter-btn {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.filter-btn:hover {
  background: var(--primary-dark);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  transition: all 0.2s;
}

.toolbar-icon-btn:hover {
  background: var(--gray-100);
}

.office-report-menu {
  position: relative;
}

.office-report-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 4px 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
  z-index: 4100;
}

.office-report-menu.open .office-report-menu-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.office-report-menu.open .office-report-menu-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* 患者テーブル */
.reception-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.patient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--white);
}

.patient-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.patient-table th {
  padding: 8px 6px;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-left: none;
  text-align: center;
  font-weight: 600;
  color: #495057;
  font-size: 12px;
  white-space: nowrap;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.patient-table th:first-child {
  border-left: 1px solid #dee2e6;
}

.patient-table th:hover {
  background: linear-gradient(180deg, #e9ecef 0%, #dee2e6 100%);
}

.patient-table th:last-child {
  border-right: none;
}

.rme-daily-report-modal {
  z-index: 3600;
}

.rme-daily-report-dialog {
  width: min(1220px, calc(100vw - 48px));
  height: min(690px, calc(100vh - 44px));
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  border-radius: 2px;
  background: #f4f8f6;
  overflow: hidden;
}

.rme-daily-report-header {
  height: 42px;
  min-height: 42px;
  padding: 0 13px;
  border-radius: 2px 2px 0 0;
  background: #0b5012;
}

.rme-daily-report-header h3 {
  font-size: 18px;
  letter-spacing: 0;
}

.rme-daily-report-header .modal-close {
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  opacity: 1;
}

.rme-daily-toolbar {
  height: 43px;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid #cfdbd6;
  background: #f6faf8;
}

.rme-date-nav {
  width: 32px;
  height: 32px;
  border: 1px solid #cfd8d4;
  border-radius: 3px;
  background: #fff;
  color: #10251a;
  cursor: pointer;
  font-family: inherit;
}

.rme-date-nav:hover {
  background: #eef5f1;
}

.rme-date-display {
  min-width: 140px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfd8d4;
  border-radius: 3px;
  background: #fff;
  color: #10251a;
  font-size: 18px;
}

.rme-daily-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 0;
  overflow: hidden;
}

.rme-dashboard-banner {
  min-height: 45px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 1px solid #d7e0db;
  background: #fff;
  color: #10251a;
  font-size: 14px;
}

.rme-dashboard-banner.hidden {
  display: none;
}

.rme-dashboard-banner .btn {
  background: #07520f;
  border-color: #07520f;
}

.rme-banner-close {
  width: 31px;
  height: 31px;
  margin-left: auto;
  border: 0;
  border-radius: 2px;
  background: #e8eeeb;
  color: #0b5012;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
}

.rme-filter-chips {
  min-height: 36px;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.rme-filter-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #d3dcd8;
  border-radius: 14px;
  background: #fff;
  color: #10251a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.rme-filter-chip.active {
  background: #0b5012;
  border-color: #0b5012;
  color: #fff;
  box-shadow: none;
}

.rme-filter-count {
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #d62f2f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.rme-filter-chip.active .rme-filter-count {
  background: #fff;
  color: #0b5012;
}

.rme-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid #cad6d0;
  border-top: 0;
  background: #fff;
}

.rme-daily-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  color: #10251a;
  font-size: 14px;
}

.rme-daily-table th,
.rme-daily-table td {
  border-top: 1px solid #d4dfda;
  border-right: 1px solid #d4dfda;
  padding: 6px 7px;
  text-align: left;
  vertical-align: middle;
}

.rme-daily-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  background: #f3f8f5;
  font-weight: 400;
  white-space: nowrap;
}

.rme-daily-table th:nth-child(1) { width: 68px; }
.rme-daily-table th:nth-child(2) { width: 140px; }
.rme-daily-table th:nth-child(3) { width: 40px; text-align: right; }
.rme-daily-table th:nth-child(4) { width: 370px; }
.rme-daily-table th:nth-child(6) { width: 78px; }

.rme-daily-table td:nth-child(3) {
  text-align: right;
}

.rme-patient-cell {
  min-width: 130px;
}

.rme-patient-kana,
.rme-patient-name {
  display: block;
  line-height: 1.25;
}

.rme-patient-kana {
  color: #10251a;
  font-size: 13px;
}

.rme-patient-name {
  font-size: 15px;
  font-weight: 500;
}

.rme-patient-name.male {
  color: #1e5aa7;
}

.rme-patient-name.female {
  color: #d73535;
}

.rme-actions {
  text-align: center;
  white-space: nowrap;
}

.rme-row-btn {
  width: 31px;
  height: 31px;
  margin-left: 4px;
  border: 1px solid #d6dedb;
  border-radius: 3px;
  background: #fff;
  color: #1f3328;
  cursor: pointer;
}

.rme-row-btn:hover {
  background: #eef5f1;
  color: #0b5012;
}

.rme-empty {
  height: 72px;
  color: #5f6f68;
  text-align: center;
}

.rme-daily-footer {
  height: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 13px;
  border-top: 1px solid #cfdbd6;
  background: #f6faf8;
  color: #61736b;
  font-size: 12px;
}

.rme-help-link {
  border: 0;
  background: transparent;
  color: #2f70d8;
  cursor: pointer;
  font: inherit;
}

.rme-help-link:hover {
  text-decoration: underline;
}

@media (max-width: 860px) {
  .rme-daily-report-dialog {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
  }

  .rme-dashboard-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .rme-banner-close {
    position: absolute;
    right: 20px;
  }
}

/* ソート矢印アイコン */
.patient-table th .sort-icon {
  margin-left: 2px;
  font-size: 9px;
  color: #adb5bd;
}

.patient-table th:hover .sort-icon {
  color: #6c757d;
}

.patient-table th.sort-asc .sort-icon,
.patient-table th.sort-desc .sort-icon {
  color: var(--primary);
}

.patient-table th[data-reception-sort] {
  cursor: pointer;
  user-select: none;
}

.patient-table th[data-reception-sort]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.patient-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #dee2e6;
  border-right: 1px solid #f1f3f4;
  vertical-align: middle;
  font-size: 13px;
}

.patient-table td:first-child {
  border-left: 1px solid #f1f3f4;
}

.patient-table td:last-child {
  border-right: none;
}

.patient-table tbody tr {
  cursor: default;
  transition: background 0.15s;
}

.patient-table tbody tr:hover {
  background: #f7faf8;
}

.patient-table tbody tr:active {
  background: #f7faf8;
}

.patient-table tbody tr.selected {
  background: #c8e6c9;
}

/* テーブルカラム幅 */
.col-num { width: 45px; text-align: center; font-weight: 500; color: #495057; }
.col-appointment { width: 55px; text-align: center; }
.col-time { width: 55px; text-align: center; }
.col-status { width: 80px; text-align: center; }
.col-patient-id { width: 75px; }
.col-patient-name { min-width: 150px; }
.col-birth-date { width: 90px; text-align: center; }
.col-age { width: 40px; text-align: center; }
.col-insurance { width: 110px; }
.col-department { width: 100px; }
.col-doctor { width: 92px; }
.col-last-visit { width: 90px; }
.col-patient-memo { min-width: 160px; max-width: 240px; text-align: left; }
.col-reception-memo { min-width: 160px; max-width: 240px; }
.col-action-icon { width: 28px; text-align: center; font-size: 11px; }
.col-actions { width: 28px; text-align: center; }

.first-visit-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #ffffff;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.first-visit-indicator.is-first {
  background: #e8f5e9;
  border-color: #2e7d32;
  color: #1b5e20;
}

/* 患者名セル */
.patient-name-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.patient-name-cell .patient-kana {
  font-size: 11px;
  line-height: 1.25;
  color: #6c757d;
}

.patient-name-cell .patient-kanji {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #212529;
}

.reception-cell-link,
.reception-name-link,
.reception-edit-cell {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.reception-cell-link {
  color: #0f172a;
  min-height: 22px;
}

.reception-cell-link:hover,
.reception-name-link:hover .patient-kanji {
  color: #0f6b3a;
  text-decoration: none;
}

.reception-name-link {
  align-items: flex-start;
  width: 100%;
  text-align: left;
}

.reception-name-link .patient-kana {
  color: #111827;
}

.reception-name-link .patient-kanji {
  color: #111827;
  font-weight: 600;
}

.reception-name-link.patient-name-gender-male .patient-kana,
.reception-name-link.patient-name-gender-male:hover .patient-kana {
  color: #111827;
}

.reception-name-link.patient-name-gender-male .patient-kanji,
.reception-name-link.patient-name-gender-male:hover .patient-kanji {
  color: #1565c0;
}

.reception-name-link.patient-name-gender-female .patient-kana,
.reception-name-link.patient-name-gender-female:hover .patient-kana {
  color: #111827;
}

.reception-name-link.patient-name-gender-female .patient-kanji,
.reception-name-link.patient-name-gender-female:hover .patient-kanji {
  color: #d81b60;
}

.reception-edit-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  width: 100%;
  min-height: 24px;
  text-align: left;
  white-space: nowrap;
}

.reception-edit-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-reception-memo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reception-memo-cell {
  width: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.reception-memo-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reception-memo-cell.active {
  font-weight: 500;
}

.patient-memo-cell {
  width: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.patient-memo-cell span {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.patient-memo-cell.active {
  font-weight: 500;
}

.reception-edit-cell,
.patient-memo-cell,
.reception-memo-cell {
  position: relative;
  padding-right: 18px;
}

.reception-edit-indicator {
  position: absolute;
  right: 1px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  color: #0f6b3a;
  font-size: 12px;
  line-height: 12px;
  opacity: 0;
  pointer-events: none;
}

.patient-table tbody tr:hover .reception-edit-indicator,
.patient-table tbody tr:focus-within .reception-edit-indicator {
  opacity: 1;
}

@media (hover: none) {
  .reception-edit-indicator {
    opacity: 1;
  }
}

.action-label {
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 10px;
}

.text-warning {
  color: #f59e0b;
}

.memo-icon.warning {
  color: #f59e0b;
}

/* ステータスボタン（M3風ドロップダウン） */
.status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  min-width: 65px;
  transition: filter 0.2s;
}

.status-btn:hover {
  filter: brightness(0.95);
}

/* ステータスメニュー */
.status-menu {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  min-width: 100px;
}

.status-menu-item {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s;
}

.status-menu-item:first-child {
  border-radius: 4px 4px 0 0;
}

.status-menu-item:last-child {
  border-radius: 0 0 4px 4px;
}

.status-menu-item:hover {
  filter: brightness(0.95);
}

/* ステータスバッジ（後方互換性） */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.status-reserved {
  background: #f59e0b;
  color: white;
}

.status-checkedin {
  background: #3b82f6;
  color: white;
}

.status-in-exam {
  background: #22c55e;
  color: white;
}

.status-waiting-payment {
  background: #a855f7;
  color: white;
}

.status-completed {
  background: var(--gray-400);
  color: white;
}

/* 患者検索モーダル */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 2000;
}

.search-modal-content {
  background: var(--white);
  border-radius: 6px;
  box-shadow: var(--shadow-xl);
  width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--primary-gradient);
  color: var(--white);
  border-radius: 6px 6px 0 0;
}

.search-modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.search-form {
  margin-bottom: 20px;
}

.search-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.search-row label {
  width: 80px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.search-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.search-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.search-results {
  border-top: 1px solid var(--gray-200);
  padding-top: 16px;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.search-result-item:hover {
  background: var(--gray-50);
  border-color: var(--primary);
}

.search-result-info {
  flex: 1;
}

.search-result-name {
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.search-result-detail {
  font-size: 11px;
  color: var(--gray-500);
}

.search-result-action {
  display: flex;
  gap: 6px;
}

.search-no-result {
  text-align: center;
  padding: 30px;
  color: var(--gray-400);
}

/* 患者名 */
.patient-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.patient-kana {
  font-size: 10px;
  color: var(--gray-500);
}

.patient-kanji {
  font-weight: 500;
  color: var(--primary);
}

/* アクションボタン */
.action-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 3px;
  font-size: 10px;
  font-family: inherit;
  color: var(--gray-600);
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.action-btn.primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.action-btn.primary:hover {
  background: var(--primary-dark);
}

/* メモアイコン */
.memo-icons {
  display: flex;
  gap: 4px;
}

.memo-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
}

.memo-icon:hover {
  background: var(--gray-200);
}

.memo-icon.active {
  background: #fef3c7;
}

.memo-icon.patient-memo-open {
  border: 0;
  padding: 0;
  color: #334155;
}

.memo-icon.patient-memo-open.active {
  color: #92400e;
}

.modal-patient-memo {
  width: min(600px, calc(100vw - 72px));
  max-height: min(580px, calc(100vh - 72px));
  border-radius: 0;
}

.modal-patient-memo .modal-header {
  height: 42px;
  padding: 0 14px;
  background: #005511;
  border-radius: 0;
}

.modal-patient-memo .modal-header h3 {
  font-size: 17px;
}

.modal-patient-memo .modal-close {
  font-size: 32px;
  font-weight: 700;
}

.patient-memo-form {
  background: #f8fbfa;
}

.patient-memo-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid #d4dedb;
}

.patient-memo-row label {
  color: #111827;
  font-size: 14px;
}

#patient-memo-facility {
  width: 100%;
  height: 30px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  padding: 0 8px;
  font: inherit;
}

#patient-memo-text {
  width: 100%;
  min-height: 420px;
  display: block;
  border: 0;
  border-top: 2px solid #38a7d4;
  border-bottom: 2px solid #38a7d4;
  background: #fff;
  padding: 18px 16px;
  resize: vertical;
  font: inherit;
  line-height: 1.7;
}

#patient-memo-text:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px #38a7d4;
}

.patient-memo-footer {
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fbfa;
  border-top: 1px solid #d4dedb;
}

.modal-patient-summary {
  width: min(600px, calc(100vw - 72px));
  max-height: min(580px, calc(100vh - 72px));
  border-radius: 0;
}

.modal-patient-summary .modal-header {
  height: 42px;
  padding: 0 14px;
  background: #005511;
  border-radius: 0;
}

.modal-patient-summary .modal-header h3 {
  font-size: 17px;
}

.modal-patient-summary .modal-close {
  font-size: 32px;
  font-weight: 700;
}

.patient-summary-form {
  padding: 4px;
  background: #f8fbfa;
}

#patient-summary-text {
  width: 100%;
  min-height: 420px;
  display: block;
  border: 1px solid #b9d1df;
  background: #fff;
  padding: 14px 12px;
  resize: vertical;
  font: inherit;
  line-height: 1.7;
}

#patient-summary-text:focus {
  outline: none;
  border-color: #38a7d4;
  box-shadow: 0 0 0 1px #38a7d4;
}

.patient-summary-footer {
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fbfa;
  border-top: 1px solid #d4dedb;
}

.modal-reception-memo {
  width: min(600px, calc(100vw - 72px));
  max-height: min(580px, calc(100vh - 72px));
  border-radius: 0;
}

.modal-reception-memo .modal-header {
  height: 42px;
  padding: 0 14px;
  background: #005511;
  border-radius: 0;
}

.modal-reception-memo .modal-header h3 {
  font-size: 17px;
}

.modal-reception-memo .modal-close {
  font-size: 32px;
  font-weight: 700;
}

.reception-memo-form {
  background: #f8fbfa;
}

.reception-memo-label-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid #d4dedb;
}

#reception-memo-label {
  width: 100%;
  height: 30px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  padding: 0 8px;
  font: inherit;
}

.reception-memo-label-add {
  width: 34px;
  height: 30px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.reception-memo-label-add:hover {
  border-color: #0f6b3a;
  color: #0f6b3a;
}

#reception-memo-text {
  width: 100%;
  min-height: 420px;
  display: block;
  border: 0;
  border-top: 2px solid #38a7d4;
  border-bottom: 2px solid #38a7d4;
  background: #fff;
  padding: 18px 16px;
  resize: vertical;
  font: inherit;
  line-height: 1.7;
}

#reception-memo-text:focus,
#reception-memo-label:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px #38a7d4;
}

.reception-memo-footer {
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fbfa;
  border-top: 1px solid #d4dedb;
}

/* 患者なし表示 */
.no-patients {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--gray-500);
}

.no-patients.show {
  display: flex;
}

.no-patients-icon {
  font-size: 48px;
  margin-bottom: 20px;
  color: var(--gray-300);
}

.no-patients p {
  margin-bottom: 20px;
  font-size: 14px;
}

/* Font Awesome アイコン調整 */
.clinic-info i {
  font-size: 18px;
  margin-right: 8px;
}

.btn i,
.toolbar-btn i {
  margin-right: 4px;
}

.icon-btn i,
.toolbar-icon-btn i,
.toolbar-nav-btn i,
.footer-icon-btn i {
  font-size: 14px;
}

.memo-icon i {
  font-size: 11px;
}

.action-btn i {
  font-size: 12px;
}

.panel-header i {
  margin-right: 6px;
}

.memo-header i {
  margin-right: 4px;
}

/* 受付フッター */
.reception-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}

/* ====================================
   患者検索画面（M3風フルスクリーン）
==================================== */
.patient-search-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gray-100);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.patient-search-screen.hidden {
  display: none !important;
}

.patient-search-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 検索ヘッダー */
.patient-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #4a5568;
  color: var(--white);
}

.patient-search-header h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.search-close-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
}

.search-close-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* 検索バー */
.patient-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--gray-50);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 0 12px;
  height: 40px;
}

.search-input-wrapper i {
  color: var(--gray-400);
  font-size: 14px;
  margin-right: 10px;
}

.search-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  outline: none;
}

.search-input-wrapper input::placeholder {
  color: var(--gray-400);
}

.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26, 93, 26, 0.1);
}

/* ヘッダー虫眼鏡アイコン */
.search-icon-btn {
  background: rgba(255,255,255,0.15) !important;
  border: none;
}

.search-icon-btn:hover {
  background: rgba(255,255,255,0.25) !important;
}

/* 検索結果エリア */
.patient-search-results {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: var(--white);
}

/* 検索結果テーブル */
.search-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.search-results-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-results-table th {
  padding: 10px 12px;
  background: var(--gray-100);
  border-bottom: 2px solid var(--gray-300);
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  font-size: 12px;
  white-space: nowrap;
}

.search-results-table td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.search-results-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.search-results-table tbody tr:hover {
  background: #f0f9f0;
}

/* テーブルカラム幅 */
.search-results-table .col-patient-no { width: 90px; }
.search-results-table .col-kana { width: 120px; }
.search-results-table .col-name { width: 120px; }
.search-results-table .col-gender { width: 40px; text-align: center; }
.search-results-table .col-birth { width: 140px; }
.search-results-table .col-age { width: 50px; text-align: center; }
.search-results-table .col-last { width: 100px; }
.search-results-table .col-memo { min-width: 120px; }
.search-results-table td.col-memo {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.search-results-table .col-actions { width: 200px; }

/* アクションボタン */
.search-action-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.search-action-btn {
  width: 100%;
  min-width: 0;
  padding: 5px 12px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  color: var(--gray-700);
  transition: all 0.15s;
}

.search-action-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.search-action-btn.primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.search-action-btn.primary:hover {
  background: var(--primary-dark);
}

.search-action-btn i {
  font-size: 11px;
}

/* 結果なし表示 */
.search-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--gray-400);
}

.search-no-results i {
  font-size: 48px;
  margin-bottom: 16px;
}

.search-no-results p {
  font-size: 14px;
}

.search-no-results.hidden {
  display: none;
}

/* 検索フッター */
.patient-search-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}

/* 性別表示 */
.gender-badge {
  display: inline;
  width: auto;
  height: auto;
  line-height: inherit;
  text-align: center;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.gender-badge.male {
  color: #1e40af;
}

.gender-badge.female {
  color: #be185d;
}

.patient-name-gender.male {
  color: #1e40af;
}

.patient-name-gender.female {
  color: #be185d;
}

/* 患者メモアイコン */
.memo-indicator {
  display: flex;
  gap: 4px;
}

.memo-indicator i {
  font-size: 12px;
  color: var(--gray-400);
}

.memo-indicator i.active {
  color: #f59e0b;
}

/* ====================================
   ステータスボタン
==================================== */
.status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: filter 0.15s;
}

.status-btn:hover {
  filter: brightness(0.95);
}

/* ステータスメニュー */
.status-menu {
  min-width: 100px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn 0.15s ease;
  z-index: 1000;
  padding: 4px;
}

.status-menu-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  margin: 2px 0;
  transition: filter 0.1s;
  text-align: center;
}

.status-menu-item:hover {
  filter: brightness(0.92);
}

/* ====================================
   ローディングオーバーレイ
==================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====================================
   トースト通知
==================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
}

.toast > span {
  white-space: pre-line;
}

.toast.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.toast.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.toast.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fbbf24;
}

.toast.info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.toast i {
  font-size: 16px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-100px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ====================================
   処方アイテム
==================================== */
.prescription-section,
.billing-section {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}

.prescription-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}

.rx-icon {
  background: #fef3c7;
  color: #d97706;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.rx-name {
  flex: 1;
  font-weight: 500;
}

.rx-detail {
  font-size: 11px;
  color: var(--gray-500);
}

.rx-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.rx-remove:hover {
  color: var(--danger);
}

/* ====================================
   M3風 カルテ画面スタイル
==================================== */

/* M3風 日付・アクションバー */
.m3-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
}

.m3-action-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* M3風 タブバー行 */
.m3-tabbar-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
}

.m3-tabbar-row.secondary {
  background: #f8f9fa;
}

/* M3風 3ゾーン構造 */
.m3-zone {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  border-right: 1px solid #dee2e6;
}

.m3-zone:last-child {
  border-right: none;
}

/* 患者情報ゾーン（左パネル対応） */
.m3-zone-patient {
  flex: 4;
  min-width: 220px;
}

/* カルテゾーン（中央2パネル対応） */
.m3-zone-karte {
  flex: 8.5;
  min-width: 560px;
  gap: 6px;
}

/* オーダーゾーン（右パネル対応） */
.m3-zone-order {
  flex: 3.5;
  min-width: 220px;
  justify-content: center;
}

/* ゾーン内セパレータ */
.m3-zone-sep {
  width: 1px;
  height: 20px;
  background: #dee2e6;
  margin: 0 8px;
}

/* 中央情報 */
.m3-center-date {
  padding: 3px 10px;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}

.m3-center-info {
  font-size: 12px;
  color: #495057;
}

.m3-center-doctor {
  font-size: 12px;
  font-weight: 500;
  color: #212529;
}

.m3-center-tag {
  padding: 2px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.m3-center-close,
.m3-center-dropdown {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 4px;
}

.m3-center-close:hover,
.m3-center-dropdown:hover {
  color: #212529;
}

/* SOAP部分 */
.m3-soap-label {
  font-size: 12px;
  font-weight: 500;
  color: #495057;
}

/* M3風 検索ボックス（タブバー内） */
.m3-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
}

.m3-search-box i {
  color: #6c757d;
  font-size: 12px;
}

.m3-search-box input {
  border: none;
  outline: none;
  font-size: 11px;
  width: 140px;
}

/* M3風 オーダータブボタン */
.m3-order-tab-btn {
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-order-tab-btn:hover {
  background: #e8f5e9;
  border-color: var(--primary);
}

.m3-order-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.m3-tab-green {
  padding: 5px 14px;
  background: var(--primary);
  border: none;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.m3-tab-green:hover {
  background: var(--primary-dark);
}

.m3-tab-green.active {
  background: var(--primary);
}

.m3-tab-white {
  padding: 5px 14px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  transition: all 0.15s;
}

.m3-tab-white:hover {
  background: #e8f5e9;
  border-color: var(--primary);
}

.m3-tabbar-center {
  display: flex;
  align-items: center;
  margin-left: auto;
  margin-right: auto;
  gap: 8px;
}

.m3-date-display {
  padding: 5px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
}

.m3-date-add {
  width: 26px;
  height: 26px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  color: #495057;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m3-date-add:hover {
  background: #e9ecef;
}

.m3-tabbar-right {
  display: flex;
  gap: 6px;
}

.m3-action-btn {
  padding: 5px 12px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-action-btn:hover {
  background: #e9ecef;
}

/* M3風 タブバー右側情報 */
.m3-tabbar-right-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 12px;
}

.m3-info-dept {
  padding: 3px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-weight: 600;
}

.m3-info-doctor {
  font-weight: 500;
  color: #212529;
}

.m3-info-insurance {
  padding: 3px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-weight: 500;
}

.m3-info-time {
  color: var(--primary);
  font-weight: 500;
}

.m3-info-state {
  padding: 3px 8px;
  background: #fff3e0;
  color: #f57c00;
  border-radius: 3px;
  font-weight: 500;
}

/* M3風 3ゾーンボディ */
.m3-karte-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: #d0d0d0;
  gap: 1px;
}

/* パネル内タブラッパー */
.m3-panel-tabs-wrapper {
  background: #fff;
}

.m3-panel-tabs-row {
  display: flex;
  border-bottom: 1px solid #dee2e6;
}

.m3-panel-tabs-row .m3-panel-tab {
  flex: 1;
  padding: 6px 4px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  border: none;
  border-right: 1px solid #dee2e6;
  border-radius: 0;
  cursor: pointer;
  background: #fff;
  color: #495057;
  font-weight: 500;
}

.m3-panel-tabs-row .m3-panel-tab:last-child {
  border-right: none;
}

.m3-panel-tabs-row .m3-panel-tab:hover {
  background: #f8f9fa;
  color: var(--primary);
}

.m3-panel-tabs-row .m3-panel-tab.active {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 600 !important;
  border-color: var(--primary) !important;
}

/* M3風 共通ヘッダーバー */
.m3-common-header {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  min-height: 56px;
}

.m3-header-zone {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #dee2e6;
}

.m3-header-zone:last-child {
  border-right: none;
}

.m3-header-zone-patient {
  min-width: 300px;
}

.m3-header-zone-patient .m3-panel-tabs-wrapper {
  height: 100%;
}

.m3-header-zone-karte {
  min-width: 400px;
  padding: 4px 8px;
  justify-content: center;
}

.m3-header-zone-order {
  min-width: 200px;
}

.m3-header-zone-order .m3-panel-tabs-wrapper {
  height: 100%;
}

.m3-header-zone-all {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  background: #fff;
  border-left: 1px solid #dee2e6;
}

.m3-all-btn {
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-all-btn:hover {
  background: #e8f5e9;
  color: var(--primary);
}

/* ゾーン比率を統一（全レイヤー共通：3ゾーン均等配分） */
/* 患者情報ゾーン */
.m3-panel-left,
.m3-header-zone-patient,
.m3-subheader-patient {
  flex: 1 !important;
}

/* カルテゾーン */
.m3-zone-karte-wrapper,
.m3-header-zone-karte,
.m3-subheader-karte {
  flex: 2 !important;
}

/* オーダーゾーン（全てボタン含む） */
.m3-panel-right,
.m3-header-zone-order,
.m3-subheader-order {
  flex: 1 !important;
}

/* 全てボタンをオーダーゾーン内に統合 */
.m3-header-zone-all,
.m3-subheader-all {
  display: none !important;
}

/* サブヘッダーカルテ内部 */
.m3-subheader-karte-inner {
  display: flex;
  width: 100%;
  height: 100%;
}

.m3-subheader-soap-part {
  flex: 3.5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-right: 1px solid #dee2e6;
}

.m3-subheader-proc-part {
  flex: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

/* M3風 サブヘッダーバー */
.m3-sub-header {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  height: 32px;
}

.m3-subheader-zone {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-right: 1px solid #dee2e6;
}

.m3-subheader-zone:last-child {
  border-right: none;
}


.m3-subheader-order {
  flex: 3.5;
  min-width: 180px;
  gap: 2px;
}

.m3-subheader-search {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  background: #fff;
}

.m3-subheader-title {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

/* カルテヘッダー行 */
.m3-karte-header-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #dee2e6;
  margin-bottom: 4px;
}

.m3-karte-header-row2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: #495057;
}

.m3-header-status {
  color: var(--primary);
  font-weight: 500;
}

.m3-header-status-icon {
  color: var(--primary);
}

.m3-tag-add {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 2px 4px;
}

/* 2カラム（患者情報ゾーン内） */
.m3-history-columns {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: #fff;
}

.m3-history-col-left,
.m3-history-col-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.m3-history-col-left {
  border-right: 1px solid #dee2e6;
}

.m3-history-col-body {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.5;
  color: #212529;
}

.m3-history-col-body p {
  margin: 0 0 2px 0;
}

/* 処置・行為アイテム */
.m3-history-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid #f1f3f4;
}

.m3-history-item.sub {
  padding-left: 24px;
  color: #6c757d;
}

.m3-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.m3-item-icon.orange {
  background: #f57c00;
}

.m3-item-icon.blue {
  background: #1976d2;
}

.m3-item-icon.purple {
  background: #7b1fa2;
}

.m3-item-label {
  color: var(--primary);
  font-weight: 500;
  font-size: 10px;
}

.m3-item-count,
.m3-item-qty {
  margin-left: auto;
  color: #6c757d;
  font-size: 10px;
  flex-shrink: 0;
}

/* カルテゾーンラッパー */
.m3-zone-karte-wrapper {
  flex: 8.5;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 560px;
}

/* カルテゾーンヘッダー */
.m3-karte-header {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 6px 10px;
}

.m3-karte-header-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.m3-karte-date {
  padding: 4px 12px;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.m3-karte-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.m3-karte-tag {
  padding: 3px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.m3-tag-close,
.m3-tag-dropdown {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
}

.m3-tag-close:hover,
.m3-tag-dropdown:hover {
  color: #212529;
}

.m3-karte-header-row2 {
  display: flex;
  align-items: center;
  gap: 16px;
}

.m3-header-value {
  font-size: 12px;
  font-weight: 500;
  color: #212529;
}

.m3-header-value.dept {
  color: var(--primary);
  font-weight: 600;
}

.m3-header-value.insurance {
  padding: 2px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
}

/* カルテパネルコンテナ（横並び・高さ揃え） */
.m3-karte-panels {
  display: flex;
  flex: 1;
  gap: 1px;
  background: #d0d0d0;
  overflow: hidden;
}

.m3-karte-panels .m3-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.m3-karte-panels .m3-panel-soap {
  flex: 3.5;
}

.m3-karte-panels .m3-panel-procedure {
  flex: 5;
}

.m3-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.m3-panel-left {
  flex: 4;
  min-width: 220px;
}

.m3-panel-left .m3-history-columns {
  flex: 1;
  height: 100%;
}

.m3-panel-soap {
  flex: 3.5;
  min-width: 260px;
}

.m3-panel-procedure {
  flex: 5;
  min-width: 300px;
}

.m3-panel-right {
  flex: 3.5;
  min-width: 220px;
}

.m3-panel-right .m3-panel-content {
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0 0;
}

/* M3風 パネルヘッダー（緑色） */
.m3-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.m3-panel-header i {
  font-size: 16px;
}

/* M3風 パネルタブ */
.m3-panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.m3-panel-tab {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-panel-tab:hover {
  background: #e8f5e9;
}

.m3-panel-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* M3風 パネルコンテンツ */
.m3-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* M3風 患者情報 */
.m3-patient-info {
  margin-bottom: 16px;
}

.m3-info-row {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f1f3f4;
}

.m3-info-label {
  width: 80px;
  color: #6c757d;
  font-size: 11px;
  font-weight: 500;
}

.m3-info-value {
  flex: 1;
  font-size: 12px;
  color: #212529;
}

/* M3風 診療履歴セクション */
.m3-history-section {
  border-top: 2px solid var(--primary);
  margin-top: 12px;
}

.m3-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.m3-icon-btn {
  width: 24px;
  height: 24px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  color: #6c757d;
}

.m3-history-list {
  max-height: 300px;
  overflow-y: auto;
}

/* M3風 カルテエディタ */
.m3-karte-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.m3-editor-title {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.m3-editor-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.m3-tool-btn {
  width: 26px;
  height: 26px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.m3-tool-btn:hover {
  background: #e9ecef;
}

.m3-tool-size-btn {
  min-width: 16px;
  height: 22px;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.m3-tool-size-btn:hover {
  color: #111827;
  background: #e9ecef;
  border-radius: 3px;
}

.m3-tool-btn.text-red {
  color: #dc3545;
}

.m3-tool-btn.text-blue {
  color: #0d6efd;
}

.m3-tool-sep {
  color: #dee2e6;
  margin: 0 4px;
}

.m3-font-size {
  font-size: 11px;
  color: #495057;
  min-width: 20px;
  text-align: center;
}

.m3-karte-editor {
  flex: 1;
  padding: 16px;
  min-height: 350px;
  font-size: 14px;
  line-height: 1.8;
  outline: none;
  overflow-y: auto;
}

.m3-karte-editor:focus {
  background: #fafffe;
}

.m3-karte-editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.m3-karte-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-karte-btn:hover {
  background: #e9ecef;
}

.m3-karte-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.m3-karte-btn.primary:hover {
  background: var(--primary-dark);
}

.m3-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #495057;
}

/* M3風 オーダータブ */
.m3-order-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.m3-order-tab {
  padding: 5px 12px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.m3-order-tab:hover {
  background: #e8f5e9;
}

.m3-order-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* M3風 オーダー検索 */
.m3-order-search {
  margin-bottom: 12px;
}

.m3-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 12px;
}

.m3-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* M3風 オーダーリスト */
.m3-order-list {
  margin: 0;
  border: none;
  border-radius: 0;
  max-height: none;
  overflow: visible;
}

.m3-order-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f3f4;
  cursor: pointer;
}

.m3-order-item:last-child {
  border-bottom: none;
}

.m3-order-item:hover {
  background: #e8f5e9;
  cursor: pointer;
}

.m3-order-item:active {
  background: #c8e6c9;
}

.m3-order-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.m3-order-name {
  flex: 1;
  font-size: 11px;
  color: #212529;
}

.m3-order-points {
  font-size: 11px;
  font-weight: 600;
  color: #6c757d;
}

/* M3風 セットツリー */
.m3-set-tree {
  border: none;
  border-radius: 0;
  overflow: visible;
}

.m3-tree-item {
  border-bottom: 1px solid #f1f3f4;
}

.m3-tree-item:last-child {
  border-bottom: none;
}

.m3-tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #212529;
}

.m3-tree-header:hover {
  background: #f8f9fa;
}

.m3-tree-header i {
  color: #6c757d;
  font-size: 10px;
  width: 12px;
}

.m3-tree-children {
  display: none;
  padding-left: 24px;
  background: #fafafa;
}

.m3-tree-item.expanded > .m3-tree-children {
  display: block;
}

.m3-tree-leaf {
  padding: 6px 10px;
  font-size: 11px;
  color: #495057;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
}

.m3-tree-leaf:hover {
  background: #e8f5e9;
}

.m3-tree-leaf:last-child {
  border-bottom: none;
}

.karte-set-header {
  justify-content: space-between;
}

.karte-set-header i {
  color: #0b6b35;
}

.karte-set-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.karte-set-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.karte-set-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #d5dadd;
  border-radius: 4px;
  background: #fff;
  color: #1f2a30;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.karte-set-action-btn:hover {
  background: #f1f5f4;
  border-color: #bfc7c4;
}

.karte-set-action-btn.danger:hover {
  background: #fff1f1;
  border-color: #efb6b6;
  color: #b42318;
}

.karte-set-action-btn i {
  width: auto;
  color: inherit;
  font-size: 12px;
}

/* M3風 下部アクションバー（オーダーゾーン内） */
.m3-order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: transparent;
  border-top: 1px solid #dee2e6;
  margin-top: auto;
}

.m3-footer-group {
  display: flex;
  gap: 4px;
}

.m3-footer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.m3-footer-btn:hover {
  background: var(--primary-dark);
}

.m3-footer-btn i {
  font-size: 16px;
  color: #fff;
}

/* M3風 医師情報バー */
.m3-doctor-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  font-size: 12px;
}

/* M3風 主訴・所見パネル */
.m3-soap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  height: 32px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  box-sizing: border-box;
}

.m3-soap-title {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.m3-soap-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.m3-soap-editor {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  overflow-y: auto;
  outline: none;
}

.m3-soap-editor:focus {
  background: #fafffe;
}

.m3-soap-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

.karte-late-entry {
  display: flex;
  align-items: center;
  gap: 6px;
}

.karte-late-entry-details {
  display: flex;
  align-items: center;
  gap: 6px;
}

.karte-late-entry-details.hidden {
  display: none;
}

.karte-late-entry-details input {
  height: 26px;
  box-sizing: border-box;
  border: 1px solid #b9c8c2;
  border-radius: 2px;
  background: #fff;
  font-size: 12px;
}

#karte-late-entry-reason {
  width: min(220px, 20vw);
  padding: 0 6px;
}

.karte-late-entry-details label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
}

#karte-late-entry-recorded-at {
  width: 174px;
  padding: 0 4px;
}

.karte-schema-picker-content {
  width: min(640px, calc(100vw - 64px));
  max-height: min(620px, calc(100vh - 64px));
  border-radius: 0;
}

.karte-schema-picker-content .modal-header,
.karte-schema-editor-content .modal-header {
  height: 28px;
  padding: 0 8px;
  background: #005511;
  border-radius: 0;
}

.karte-schema-picker-content .modal-header h3,
.karte-schema-editor-content .modal-header h3 {
  font-size: 13px;
  font-weight: 600;
}

.karte-schema-picker-content .modal-close,
.karte-schema-editor-content .modal-close {
  font-size: 20px;
  font-weight: 700;
}

.karte-schema-template-grid {
  max-height: 410px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  background: #f5f5f5;
}

.karte-schema-template {
  min-height: 122px;
  padding: 5px;
  border: 1px solid #d8dfdc;
  background: #fff;
  color: #111827;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.karte-schema-template:hover,
.karte-schema-template:focus {
  border-color: #0f6b3a;
  outline: none;
  background: #eef8f1;
}

.karte-schema-template-name {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.karte-schema-template img {
  width: 100%;
  height: 88px;
  display: block;
  object-fit: contain;
  background: #fff;
}

.karte-schema-picker-footer,
.karte-schema-editor-footer {
  justify-content: flex-end;
  padding: 8px;
  border-top: 1px solid #d4dedb;
  background: #f8fbfa;
}

.karte-schema-editor-content {
  width: min(690px, calc(100vw - 64px));
  max-height: min(620px, calc(100vh - 64px));
  border-radius: 0;
}

.karte-schema-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  padding: 8px;
  background: #f5f5f5;
}

.karte-schema-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  border: 1px solid #bfcac5;
  background: #fff;
  overflow: hidden;
}

.karte-schema-canvas-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#karte-schema-draw-canvas {
  cursor: crosshair;
  touch-action: none;
}

.karte-schema-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  background: #eee;
}

.karte-schema-color-list {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  gap: 5px;
}

.karte-schema-color,
.karte-schema-tool-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  cursor: pointer;
}

.karte-schema-color {
  width: 18px;
  height: 18px;
}

.karte-schema-color[data-schema-color="#ffffff"] {
  box-shadow: inset 0 0 0 1px #ddd;
}

.karte-schema-color.active,
.karte-schema-tool-btn.active {
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18);
}

.karte-schema-line-width {
  width: 32px;
  height: 24px;
  border: 1px solid #cbd5d1;
  background: #fff;
  font-size: 12px;
}

.karte-schema-block {
  display: inline-block;
  max-width: 100%;
  margin: 6px 0 8px;
  border: 1px solid #d5dfdc;
  background: #fff;
  vertical-align: top;
}

.karte-schema-image {
  width: min(280px, 100%);
  height: auto;
  display: block;
}

.karte-soap-section-body {
  min-height: 1em;
}

.history-soap-text .karte-schema-block {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 4px 0;
}

.history-soap-text .karte-schema-image {
  width: min(160px, 100%);
}

/* M3風 処置・行為パネル */
.m3-procedure-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  height: 32px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-size: 12px;
  font-weight: 600;
  color: #495057;
  box-sizing: border-box;
}

.m3-procedure-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.m3-proc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #f1f3f4;
  font-size: 11px;
}

.m3-proc-item:hover {
  background: #f8f9fa;
}

.m3-proc-item.highlight {
  background: #fff8e1;
}

.m3-proc-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.m3-proc-icon.orange {
  background: #ff9800;
}

.m3-proc-icon.blue {
  background: #2196f3;
}

.m3-proc-icon.purple {
  background: #9c27b0;
}

.m3-proc-name {
  flex: 1;
  color: #212529;
}

.m3-proc-pts {
  font-weight: 600;
  color: #6c757d;
  min-width: 50px;
  text-align: right;
}

/* オーダーゾーンヘッダー内部レイアウト（タブ + 全てボタン） */
.m3-order-header-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 100%;
}

.m3-order-header-wrap .m3-panel-tabs-wrapper {
  flex: 1;
}

.m3-all-btn-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-left: 1px solid #dee2e6;
  background: #fff;
}

.m3-all-btn-wrap .m3-all-btn {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ====================================
   M3風 診療履歴画面スタイル
==================================== */

/* 日付・タグバー */
.m3-history-date-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
}

.m3-history-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

.m3-history-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.m3-history-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.m3-icon-btn-sm {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  cursor: pointer;
  color: #6c757d;
  font-size: 11px;
}

.m3-icon-btn-sm:hover {
  background: #f8f9fa;
  color: var(--primary);
}

/* 情報行 */
.m3-history-info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  font-size: 12px;
  color: #495057;
}

.m3-history-status {
  margin-left: auto;
  color: var(--primary);
  font-weight: 500;
}

/* カラムヘッダー */
.m3-history-col-headers {
  display: flex;
  border-bottom: 1px solid #dee2e6;
  background: #f8f9fa;
}

.m3-history-col-header {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #495057;
}

.m3-history-col-header:first-child {
  border-right: 1px solid #dee2e6;
}

.m3-col-arrow {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 10px;
}

.m3-col-arrow:hover {
  color: var(--primary-dark);
}

/* アウトラインアイコン */
.m3-item-icon-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.m3-item-icon-outline.blue {
  border-color: #1976d2;
  color: #1976d2;
}

/* 理由テキスト */
.m3-history-item.reason {
  background: #f8f9fa;
  padding-left: 30px;
  color: #666;
  font-size: 10px;
  line-height: 1.4;
}

/* ====================================
   M3風 患者情報画面スタイル
==================================== */

/* タブコンテンツ */
.m3-tab-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

/* 患者情報セクション */
.m3-patient-section {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.m3-patient-section.gray-bg {
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  margin-top: 16px;
}

.m3-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.m3-patient-section.gray-bg .m3-section-header {
  background: #f5f5f5;
  border-bottom: none;
}

.m3-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.m3-section-actions {
  display: flex;
  gap: 8px;
}

/* 患者情報テーブル */
.m3-patient-table {
  background: #fff;
}

.m3-patient-row {
  display: flex;
  padding: 10px 16px;
  border-bottom: 1px solid #e8e8e8;
  background: #fff;
}

.m3-patient-row:last-child {
  border-bottom: none;
}

.m3-patient-label {
  width: 70px;
  font-size: 12px;
  color: #666;
  flex-shrink: 0;
}

.m3-patient-value {
  flex: 1;
  font-size: 13px;
  color: #333;
  padding-left: 40px;
}

.m3-patient-value .m3-patient-kana {
  display: block;
  font-size: 12px;
  color: #495057;
  margin-bottom: 2px;
}

.m3-patient-value .m3-patient-kanji {
  display: block;
  font-weight: 500;
  color: var(--primary);
}

/* 患者メモ */
.m3-memo-content {
  padding: 16px 20px;
  background: #fff;
  font-size: 13px;
  color: #333;
  line-height: 1.7;
}

.m3-memo-content p {
  margin: 0;
}

.m3-memo-content.empty {
  color: #888;
}

.m3-patient-section.gray-bg .m3-memo-content {
  background: #f5f5f5;
}

.clinical-profile-section {
  margin: 0;
  background: #f3f6f5;
  border-bottom: 1px solid #cbd9d5;
}

.clinical-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 37px;
  padding: 0 12px;
  border-bottom: 1px solid #cbd9d5;
  background: #f3f6f5;
}

.clinical-profile-title {
  color: #111827;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

.clinical-profile-actions {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

.clinical-profile-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.clinical-profile-icon-btn:hover,
.clinical-profile-icon-btn:focus {
  background: #e8f2ec;
  color: #06451f;
  outline: none;
}

.clinical-profile-list,
.m3-allergy-list {
  background: #fff;
}

.clinical-profile-empty {
  min-height: 31px;
  padding: 5px 12px;
  border-bottom: 1px solid #cbd9d5;
  color: #111827;
  font-size: 13px;
  line-height: 20px;
}

.clinical-profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 31px;
  padding: 5px 8px 5px 12px;
  border-bottom: 1px solid #cbd9d5;
  color: #111827;
  font-size: 13px;
}

.clinical-profile-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clinical-profile-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
  font-size: 14px;
}

.clinical-profile-delete:hover,
.clinical-profile-delete:focus {
  color: #b91c1c;
  outline: none;
}

.allergy-add-modal {
  align-items: flex-start;
  justify-content: center;
  padding-top: 132px;
}

.allergy-add-dialog {
  width: min(600px, calc(100vw - 48px));
  max-height: min(528px, calc(100vh - 160px));
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.allergy-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 14px;
  background: #0b5312;
  color: #fff;
}

.allergy-add-header h3 {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.allergy-add-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.allergy-add-close:hover,
.allergy-add-close:focus {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.allergy-add-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px 12px 12px;
  background: #fff;
}

.allergy-add-search {
  width: 100%;
  height: 32px;
  padding: 3px 8px;
  border: 1px solid #1c9bd1;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(28, 155, 209, 0.2);
  color: #0f172a;
  font: inherit;
}

.allergy-candidate-list {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  border-top: 1px solid #d5dfdc;
  overflow-y: auto;
}

.allergy-candidate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid #d5dfdc;
  background: #fff;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  text-align: left;
}

.allergy-candidate-row:hover,
.allergy-candidate-row:focus,
.allergy-candidate-row.selected {
  background: #f1f6f4;
  outline: none;
}

.allergy-candidate-selected {
  margin-left: 12px;
  color: #0b5a2a;
  font-size: 12px;
}

.allergy-candidate-empty {
  padding: 14px 12px;
  color: #7b8580;
  font-size: 14px;
}

.m3-memo-date {
  color: var(--primary);
}

.m3-memo-highlight {
  color: var(--primary);
}

/* ====================================
   処方入力モーダル
==================================== */
.modal-prescription {
  width: 900px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-body-prescription {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 薬剤検索セクション */
.prescription-search-section {
  padding: 16px;
  background: #f8fdf8;
  border-bottom: 1px solid var(--gray-200);
}

.prescription-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 10px 14px;
}

.prescription-search-box i {
  color: var(--gray-400);
}

.prescription-search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

.drug-search-results {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--white);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

.drug-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.15s;
}

.drug-result-item:hover {
  background: #e8f5e9;
}

.drug-result-item:last-child {
  border-bottom: none;
}

.drug-result-name {
  font-weight: 500;
  color: var(--gray-800);
}

.drug-result-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--gray-500);
}

.drug-hit-hint {
  min-width: 0;
  color: #315142;
}

/* 処方履歴セクション */
.prescription-history-section {
  border-bottom: 1px solid var(--gray-200);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.section-title i {
  margin-right: 6px;
  color: var(--primary);
}

.btn-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px 8px;
}

.prescription-history-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 16px;
}

.prescription-history-list.collapsed {
  display: none;
}

.rx-history-group {
  margin-bottom: 12px;
}

.rx-history-date {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 6px;
}

.rx-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--gray-50);
  border-radius: 4px;
  margin-bottom: 4px;
}

.rx-history-item .rx-name {
  flex: 1;
  font-weight: 500;
}

.rx-history-item .rx-detail {
  font-size: 11px;
  color: var(--gray-500);
}

.btn-do-rx {
  padding: 4px 10px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-do-rx:hover {
  background: var(--primary-dark);
}

/* 現在の処方リスト */
.current-prescription-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.rp-count {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.current-prescription-list {
  flex: 1;
  padding: 0;
  background: var(--white);
  overflow-y: auto;
}

.prescription-remarks-section {
  margin-top: 12px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
}

.prescription-remarks-header {
  margin-bottom: 8px;
}

.btn-prescription-remark-template {
  padding: 5px 12px;
  font-size: 12px;
}

.prescription-remarks-input {
  width: 100%;
  min-height: 72px;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}

.prescription-remarks-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.14);
}

.no-prescription-message {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.no-prescription-message i {
  font-size: 32px;
  margin-bottom: 12px;
}

.current-rx-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

.rx-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rp-number {
  background: var(--primary);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.rx-drug-name {
  flex: 1;
  font-weight: 600;
  color: var(--gray-800);
}

.btn-remove-rx {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
}

.btn-remove-rx:hover {
  color: var(--danger);
}

.rx-item-details {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-600);
}

.rx-total {
  color: var(--primary);
  font-weight: 500;
}

.generic-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.rx-note {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fffde7;
  border-radius: 3px;
  font-size: 11px;
  color: #6d4c41;
}

.current-rx-compact-group {
  border-bottom: 1px solid #d7e2de;
  background: var(--white);
  cursor: pointer;
}

.current-rx-compact-group:hover .current-rx-drug-line,
.current-rx-compact-group:hover .current-rx-usage-line {
  background: #f6faf7;
}

.current-rx-compact-group.is-group-anchor-selected {
  background: #eef9f2;
  box-shadow: inset 0 0 0 2px #8fd2d9;
}

.current-rx-compact-group.is-group-anchor-selected .current-rx-drug-line,
.current-rx-compact-group.is-group-anchor-selected .current-rx-usage-line {
  background: #eef9f2;
}

.current-rx-drug-line {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 30px;
  padding: 6px 30px 2px 4px;
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
}

.current-rx-drug-line:hover {
  background: #f6faf7;
}

.current-rx-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: #a177d2;
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.current-rx-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.current-rx-dose {
  flex: 0 0 auto;
  max-width: 78px;
  color: #111827;
  white-space: normal;
}

.current-rx-usage-line {
  min-height: 25px;
  padding: 0 30px 6px 32px;
  color: #111827;
  font-size: 13px;
  line-height: 1.45;
}

.current-rx-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: #94a3a0;
  cursor: pointer;
  opacity: 0;
}

.current-rx-compact-group:hover .current-rx-remove,
.current-rx-drug-line:focus-within .current-rx-remove {
  opacity: 1;
}

.current-rx-remove:hover {
  background: #fee2e2;
  color: var(--danger);
}

.current-rx-note {
  margin: 0 30px 6px 32px;
  padding: 4px 6px;
  background: #fffde7;
  color: #6d4c41;
  font-size: 11px;
  line-height: 1.4;
}

/* 薬剤詳細パネル */
.drug-detail-panel {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  z-index: 10;
}

.drug-detail-header {
  padding: 12px 16px;
  background: var(--primary);
  color: var(--white);
  border-radius: 8px 8px 0 0;
}

.drug-detail-header .drug-name {
  font-weight: 600;
  display: block;
}

.drug-detail-header .drug-unit {
  font-size: 12px;
  opacity: 0.8;
}

.drug-detail-form {
  padding: 16px;
}

.drug-detail-form .form-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.drug-detail-form label {
  width: 80px;
  font-size: 12px;
  color: var(--gray-600);
}

.drug-detail-form .input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drug-detail-form input[type="number"],
.drug-detail-form input[data-numeric-pad] {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.drug-detail-form select {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--white);
}

.drug-detail-form input[type="text"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.drug-detail-form input[data-numeric-pad] {
  flex: 0 0 80px;
}

.unit-label {
  font-size: 12px;
  color: var(--gray-600);
}

.calculated-total {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}

.drug-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: 0 0 8px 8px;
}

/* 処方モーダルフッター */
.modal-footer-prescription {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.footer-left {
  display: flex;
  gap: 16px;
}

.footer-right {
  display: flex;
  gap: 10px;
}

/* ====================================
   会計モーダル
==================================== */
#billing-modal {
  z-index: 5000;
}

#billing-operation-modal {
  z-index: 5100;
}

.modal-billing {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  height: min(900px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body-billing {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(128px, 1fr) auto auto;
  overflow: hidden;
  padding: 0;
}

/* 患者情報 */
.billing-patient-info {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 46px;
  padding: 9px 20px;
  background: #e8f5e9;
  border-bottom: 1px solid #c8e6c9;
}

.billing-patient-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.billing-patient-id,
.billing-insurance-info {
  font-size: 12px;
  color: var(--gray-600);
}

/* 明細テーブル */
.billing-details-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.billing-details-table-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.billing-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.billing-details-table th {
  padding: 8px 12px;
  background: var(--gray-100);
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
}

.billing-details-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
}

.billing-details-table .col-category {
  width: 50px;
  text-align: center;
}

.billing-details-table .col-points,
.billing-details-table .col-qty,
.billing-details-table .col-subtotal {
  width: 70px;
  text-align: right;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: var(--white);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.category-badge.home {
  background: #c49a4a;
}

.category-badge.green {
  background: #4caf50;
}

/* 計算結果 */
.billing-calculation-section {
  padding: 11px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.calc-label {
  font-size: 13px;
  color: var(--gray-600);
}

.calc-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
}

.calc-divider {
  height: 1px;
  background: var(--gray-300);
  margin: 6px 0;
}

.calc-row.highlight {
  padding: 7px 0;
}

.calc-row.highlight .calc-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.calc-row.highlight .calc-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* 支払いセクション */
.billing-payment-section {
  padding: 0;
}

#billing-modal.billing-view-mode .billing-calculation-section {
  border-color: #9fc9a9;
}

.payment-method-tabs {
  display: flex;
  gap: 0;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.payment-tab {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-family: inherit;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.payment-tab:hover {
  color: var(--gray-700);
  background: var(--gray-50);
}

.payment-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--white);
  font-weight: 600;
}

.payment-form {
  padding: 12px 20px;
}

.payment-form .form-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.payment-form label {
  width: 100px;
  font-size: 12px;
  color: var(--gray-600);
}

.payment-form .input-group {
  display: flex;
  align-items: center;
  flex: 1;
}

.payment-form .input-prefix {
  padding: 8px 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-right: none;
  border-radius: 4px 0 0 4px;
  font-size: 14px;
  color: var(--gray-600);
}

.payment-form input[type="number"],
.payment-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 0 4px 4px 0;
  font-size: 16px;
  font-family: inherit;
}

.payment-form select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--white);
}

.quick-amount-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  padding-left: 100px;
}

.quick-btn {
  padding: 8px 16px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}

.quick-btn:hover {
  background: #e8f5e9;
  border-color: var(--primary);
}

.change-row .change-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.change-amount.negative {
  color: var(--danger);
}

.billing-operation-dialog {
  width: min(940px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.business-report-modal .billing-operation-dialog {
  width: min(1080px, 96vw);
}

.business-report-description {
  margin-bottom: 14px;
  color: var(--gray-700);
  font-size: 13px;
}

.business-report-output-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 13px;
}

.business-report-output-label {
  min-width: 105px;
  font-weight: 600;
}

.business-report-date-label input {
  width: 160px;
  max-width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font: inherit;
}

.business-report-memo-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
}

.business-report-range-message {
  margin: 5px 0 0 114px;
  color: var(--gray-600);
  font-size: 11px;
}

.business-report-section-title {
  margin: 5px 0 10px;
  font-size: 15px;
}

.business-report-table-wrap {
  overflow-x: auto;
}

.business-report-history-table {
  margin-top: 0;
  min-width: 850px;
}

.business-report-history-table th,
.business-report-history-table td {
  text-align: center;
  white-space: nowrap;
}

.business-report-more {
  margin-top: 10px;
}

@media (max-width: 700px) {
  .business-report-output-label {
    flex-basis: 100%;
  }

  .business-report-date-label input {
    width: 140px;
  }

  .business-report-range-message {
    margin-left: 0;
  }
}

.billing-operation-body {
  flex: 0 0 auto;
  padding: 14px 18px;
  overflow: visible;
  border-bottom: 1px solid var(--gray-200);
}

.billing-operation-result {
  flex: 1 1 auto;
  padding: 0 18px 16px;
  min-height: 0;
  overflow: auto;
}

.billing-operation-form {
  display: grid;
  gap: 12px;
}

.billing-operation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.billing-operation-field {
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: var(--gray-700);
}

.billing-operation-field.full {
  grid-column: 1 / -1;
}

.billing-operation-field input,
.billing-operation-field select,
.billing-operation-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font: inherit;
  background: var(--white);
}

.billing-operation-field textarea {
  min-height: 72px;
  resize: vertical;
}

.billing-operation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.billing-operation-result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 8px;
}

.billing-operation-section-title {
  margin: 14px 0 2px;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 700;
}

.billing-operation-note {
  padding: 9px 10px;
  border: 1px solid #d5dedb;
  background: #f6faf8;
  color: var(--gray-700);
  font-size: 13px;
}

.billing-operation-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.billing-operation-table th,
.billing-operation-table td {
  border: 1px solid var(--gray-200);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.billing-operation-table th {
  background: #f4f7f6;
  font-weight: 600;
}

.billing-operation-table .amount {
  text-align: right;
  white-space: nowrap;
}

.monthly-report-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
  margin: 12px 0 8px;
  font-size: 12px;
}

.monthly-report-heading::before {
  content: '';
}

.monthly-report-heading > :last-child {
  text-align: right;
  line-height: 1.7;
}

.monthly-report-heading strong {
  font-size: 18px;
}

.monthly-report-title {
  font-size: 20px;
  text-align: center;
}

.monthly-report-table {
  min-width: 900px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.monthly-report-table th,
.monthly-report-table td {
  padding: 4px 6px;
  text-align: center;
  line-height: 1.2;
}

.monthly-report-table tbody tr:nth-child(odd) {
  background: #f1f1f1;
}

.monthly-report-table tfoot th {
  border-top: 2px solid var(--gray-700);
  border-bottom: 2px solid var(--gray-700);
  background: var(--white);
}

.insurance-summary-table {
  margin-top: 12px;
}

.insurance-summary-table td:first-child {
  text-align: left;
}

.generic-usage-report {
  width: min(100%, 790px);
  margin: 0 auto;
  padding: 4px 8px 18px;
  color: #1f2933;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.generic-usage-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  margin: 6px 0 28px;
}

.generic-usage-heading::before {
  content: '';
}

.generic-usage-title {
  font-size: 20px;
  text-align: center;
}

.generic-usage-meta {
  text-align: right;
  line-height: 1.8;
  white-space: nowrap;
}

.generic-usage-table {
  width: 100%;
  margin: 0 0 26px;
  border-collapse: collapse;
}

.generic-usage-table th,
.generic-usage-table td {
  height: 40px;
  padding: 4px 7px;
  border: 0;
  border-bottom: 1px solid #5d6164;
  text-align: right;
  white-space: nowrap;
  box-sizing: border-box;
}

.generic-usage-table thead th {
  height: 32px;
  border-bottom-width: 2px;
  font-weight: 700;
}

.generic-usage-table thead th:first-child,
.generic-usage-table tbody th {
  width: 61%;
  text-align: left;
}

.generic-usage-table tbody th {
  font-weight: 400;
  white-space: normal;
}

.generic-usage-table tbody tr:nth-child(even) {
  background: #f1f1f1;
}

.generic-usage-table tbody tr:last-child th,
.generic-usage-table tbody tr:last-child td {
  border-bottom-width: 2px;
}

.generic-usage-subtitle {
  margin: 0 7px 3px;
  font-weight: 700;
}

.generic-usage-notes {
  display: grid;
  gap: 5px;
  margin-top: -10px;
  font-size: 12px;
  line-height: 1.7;
}

.generic-usage-facility {
  margin-top: 22px;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 760px) {
  .generic-usage-heading {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .generic-usage-heading::before {
    display: none;
  }

  .generic-usage-meta {
    text-align: center;
  }

  .generic-usage-table {
    min-width: 700px;
  }
}

.psychotropic-report {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 4px 6px 18px;
  color: #1f2933;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.psychotropic-report-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  margin: 6px 0 12px;
}

.psychotropic-report-heading::before {
  content: '';
}

.psychotropic-report-title {
  font-size: 20px;
  text-align: center;
}

.psychotropic-report-meta {
  text-align: right;
  line-height: 1.8;
  white-space: nowrap;
}

.psychotropic-report-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.psychotropic-report-table th,
.psychotropic-report-table td {
  height: 24px;
  padding: 3px 5px;
  border: 0;
  text-align: center;
  line-height: 1.15;
}

.psychotropic-report-table thead th {
  border-bottom: 2px solid #5d6164;
  vertical-align: bottom;
  white-space: normal;
}

.psychotropic-report-table tbody tr:nth-child(odd) {
  background: #f0f0f0;
}

.psychotropic-report-table .patient-name {
  text-align: left;
  white-space: nowrap;
}

.psychotropic-report-table th:nth-child(1) { width: 42px; }
.psychotropic-report-table th:nth-child(2) { width: 86px; }
.psychotropic-report-table th:nth-child(3) { width: 150px; }
.psychotropic-report-table th:nth-child(4) { width: 120px; }
.psychotropic-report-table th:nth-child(5) { width: 86px; }
.psychotropic-report-table th:nth-child(n+6) { width: 55px; }

.psychotropic-summary-title {
  margin-top: 18px;
  padding-bottom: 4px;
  border-bottom: 2px solid #5d6164;
  font-weight: 700;
}

.psychotropic-summary-table {
  width: 100%;
  max-width: 560px;
  border-collapse: collapse;
}

.psychotropic-summary-table th,
.psychotropic-summary-table td {
  height: 25px;
  padding: 2px 0;
  border: 0;
  font-weight: 400;
  text-align: left;
}

.psychotropic-summary-table td {
  width: 70px;
  text-align: right;
  white-space: nowrap;
}

.psychotropic-summary-table .psychotropic-summary-spacer th,
.psychotropic-summary-table .psychotropic-summary-spacer td {
  height: 12px;
}

@media (max-width: 760px) {
  .psychotropic-report-heading {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .psychotropic-report-heading::before {
    display: none;
  }

  .psychotropic-report-meta {
    text-align: center;
  }
}

.monthly-report-facility {
  margin: 28px 2px 10px;
  font-weight: 700;
}

.billing-operation-empty,
.billing-operation-error {
  padding: 10px;
  color: var(--gray-600);
  background: #f7f8f8;
  border: 1px solid var(--gray-200);
}

.billing-operation-error {
  color: var(--danger);
  background: #fff6f5;
}

/* 会計モーダルフッター */
.modal-footer-billing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.modal-footer-billing .footer-left {
  flex-wrap: wrap;
  gap: 8px;
}

.modal-footer-billing .billing-pdf-selection {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-footer-billing .billing-pdf-selection label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gray-800);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.modal-footer-billing .billing-pdf-selection input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #2563eb;
}

.modal-footer-billing .footer-right {
  margin-left: auto;
}

.modal-footer-billing .btn {
  white-space: nowrap;
}

/* 参照画面に合わせたコンパクト会計ダイアログ */
#billing-modal .modal-billing {
  width: min(600px, calc(100vw - 20px));
  height: auto;
  max-height: calc(100vh - 20px);
  background: #f4f6f5;
  border-radius: 0;
}

#billing-modal .modal-header {
  min-height: 43px;
  padding: 8px 14px;
  background: #0f581c;
  border-bottom: 0;
}

#billing-modal .modal-header h3,
#billing-modal .modal-close {
  color: #fff;
}

#billing-modal .modal-header h3 {
  font-size: 18px;
  font-weight: 500;
}

#billing-modal .modal-close {
  font-size: 28px;
}

#billing-modal .modal-body-billing {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  padding: 11px 15px 0;
  overflow-y: auto;
  background: #f4f6f5;
}

#billing-modal .billing-patient-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  min-height: 27px;
  padding: 0;
  background: transparent;
  border: 0;
  color: #111;
  font-size: 14px;
}

#billing-modal .billing-patient-info strong {
  font-weight: 400;
}

.billing-insurance-card {
  position: relative;
  min-height: 72px;
  margin: 0 0 25px;
  padding: 5px 108px 5px 7px;
  background: #fff;
  border: 1px solid #cbd5d0;
}

.billing-insurance-lines > div {
  min-height: 32px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #111;
}

.billing-insurance-lines > div + div {
  border-top: 1px solid #d8dfdc;
}

.billing-content-check {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 27px;
  padding: 3px 8px;
  border: 1px solid #edcaca;
  border-radius: 4px;
  background: #fdeaea;
  color: #c43c3c;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.billing-summary-grid {
  display: grid;
  grid-template-columns: 222px minmax(0, 1fr);
  align-items: start;
  gap: 15px;
  margin-bottom: 18px;
}

.billing-total-card {
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 7px;
  background: #fff;
  border: 1px solid #cbd5d0;
  font-size: 14px;
}

.billing-total-label {
  align-self: start;
  white-space: nowrap;
}

.billing-total-values {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.billing-total-values strong,
#billing-modal .billing-calculation-section strong {
  font-weight: 400;
}

#billing-modal .billing-calculation-section {
  padding: 5px 6px;
  background: #fff;
  border: 1px solid #cbd5d0;
}

#billing-modal .calc-row {
  min-height: 27px;
  padding: 2px 0;
  color: #111;
  font-size: 14px;
}

#billing-modal .calc-divider {
  margin: 1px 0;
  background: #cbd5d0;
}

#billing-modal .billing-charge-row {
  min-height: 30px;
}

#billing-modal .billing-input-row input {
  width: 94px;
  height: 29px;
  padding: 3px 8px;
  border: 1px solid #cbd5d0;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font: inherit;
  text-align: right;
}

.billing-carryover-option {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  font-size: 12px;
  color: #111;
}

.billing-carryover-option input {
  width: 15px;
  height: 15px;
  margin: 0;
}

#billing-modal .quick-amount-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
}

#billing-modal .quick-btn {
  padding: 4px 7px;
  border-radius: 3px;
  font-size: 11px;
}

#billing-modal .change-amount {
  color: #111;
  font-size: 14px;
  font-weight: 400;
}

#billing-modal .change-amount.negative {
  color: var(--danger);
}

.billing-payment-guidance {
  padding: 0 0 13px;
  color: #1769d3;
  font-size: 14px;
}

#billing-modal .billing-payment-section {
  display: none;
}

#billing-modal .payment-method-tabs {
  justify-content: flex-start;
  gap: 20px;
  background: transparent;
  border: 0;
}

#billing-modal .payment-tab {
  flex: 0 0 auto;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111;
  font-size: 13px;
}

#billing-modal .payment-tab:hover,
#billing-modal .payment-tab.active {
  border: 0;
  background: transparent;
  color: #111;
  font-weight: 400;
}

#billing-modal .payment-radio {
  width: 15px;
  height: 15px;
  border: 2px solid #c7ced0;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 3px #fff;
}

#billing-modal .payment-tab.active .payment-radio {
  border-color: #a9bff8;
  background: #a9bff8;
}

#billing-modal .payment-form {
  padding: 8px 0 0;
}

#billing-modal .payment-cash-form:empty {
  display: none;
}

#billing-modal .payment-form .form-row {
  margin: 5px 0;
}

#billing-modal .billing-details-retained {
  display: none;
}

.billing-document-selection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 15px;
  background: #f4f6f5;
  border-top: 1px solid #ccd5d1;
  border-bottom: 1px solid #ccd5d1;
}

.billing-document-selection label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #111;
  font-size: 13px;
  white-space: nowrap;
}

.billing-document-selection input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #3478eb;
}

#billing-modal .modal-footer-billing {
  min-height: 50px;
  padding: 7px 11px;
  background: #f4f6f5;
}

#billing-modal .modal-footer-billing .footer-left {
  display: flex;
}

#billing-modal .modal-footer-billing .btn {
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 3px;
  font-size: 14px;
}

#billing-modal #btn-billing-complete {
  min-width: 90px;
}

@media (max-width: 620px) {
  .billing-summary-grid {
    grid-template-columns: 1fr;
  }

  .billing-total-card {
    grid-template-columns: 1fr auto;
  }
}

/* ====================================
   レセプト作成モーダル
==================================== */
.receipt-claim-open-btn {
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.modal-receipt-claim {
  position: relative;
  width: min(1026px, calc(100vw - 28px));
  height: min(680px, calc(100vh - 28px));
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  background: #f7faf8;
  overflow: hidden;
}

.receipt-claim-loading {
  position: absolute;
  top: 42px;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(247, 250, 248, 0.9);
  backdrop-filter: blur(1px);
}

.receipt-claim-loading[hidden] {
  display: none;
}

.receipt-claim-loading-box {
  min-width: min(360px, calc(100% - 32px));
  padding: 26px 32px 24px;
  border: 1px solid #b8cbbd;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(9, 54, 19, 0.16);
  color: #10251a;
  text-align: center;
}

.receipt-claim-loading-spinner {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 4px solid #dbe8df;
  border-top-color: #0b5012;
  border-radius: 50%;
  animation: receipt-claim-loading-spin 0.8s linear infinite;
}

.receipt-claim-loading-box strong,
.receipt-claim-loading-note {
  display: block;
}

.receipt-claim-loading-box strong {
  font-size: 16px;
  line-height: 1.5;
}

.receipt-claim-loading-note {
  margin-top: 6px;
  color: #5c6d62;
  font-size: 12px;
}

@keyframes receipt-claim-loading-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .receipt-claim-loading-spinner {
    animation-duration: 1.8s;
  }
}

.modal-receipt-claim .modal-header {
  min-height: 42px;
  padding: 9px 14px;
  background: #0b5012;
  color: #fff;
}

.modal-receipt-claim .modal-header h3 {
  font-size: 17px;
}

.modal-receipt-claim .modal-close {
  color: #fff;
  opacity: 1;
}

.receipt-claim-tabs {
  display: grid;
  grid-template-columns: repeat(3, 140px) 1fr;
  height: 32px;
  border-bottom: 1px solid #cbd8d1;
  background: #eef3f0;
}

.receipt-claim-tab {
  border: 0;
  border-right: 1px solid #cbd8d1;
  background: #dce6e1;
  color: #0f2b18;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.receipt-claim-tab.active {
  background: #0b5012;
  color: #fff;
  font-weight: 700;
}

.receipt-claim-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #f7faf8;
}

.receipt-claim-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.receipt-claim-controls {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.receipt-claim-field-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.receipt-claim-scope-select {
  width: 136px;
  height: 31px;
  border: 1px solid #b7c9bd;
  border-radius: 4px;
  background: #fff;
  color: #10251a;
  font-family: inherit;
  font-size: 13px;
}

.receipt-claim-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #10251a;
  font-size: 14px;
  white-space: nowrap;
}

.receipt-claim-field input {
  height: 31px;
  border: 1px solid #c3d0ca;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 16px;
  background: #fff;
}

#receipt-claim-month {
  width: 82px;
}

#receipt-claim-bill-date {
  width: 166px;
}

.receipt-claim-picker {
  position: fixed;
  width: 278px;
  padding: 10px 12px 12px;
  background: #fff;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 4300;
}

.receipt-claim-picker.hidden {
  display: none;
}

.receipt-claim-picker-header {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
}

.receipt-claim-picker-nav,
.receipt-claim-picker-footer button {
  height: 30px;
  border: 1px solid #d6dedb;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  font-family: inherit;
}

.receipt-claim-picker-nav {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.receipt-claim-picker-nav:hover,
.receipt-claim-picker-footer button:hover,
.receipt-claim-month-option:hover,
.receipt-claim-date-day:hover {
  background: #eef6f0;
}

.receipt-claim-picker-title {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d6dedb;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
}

.receipt-claim-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 18px;
  padding: 6px 6px 4px;
}

.receipt-claim-month-option {
  height: 52px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #2f3337;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
}

.receipt-claim-month-option.selected {
  background: #176928;
  color: #fff;
  font-weight: 700;
}

.receipt-claim-date-weekdays,
.receipt-claim-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

.receipt-claim-date-weekdays {
  margin-bottom: 5px;
  color: #666;
  font-size: 14px;
  font-weight: 600;
}

.receipt-claim-date-weekdays span {
  height: 22px;
  line-height: 22px;
}

.receipt-claim-date-weekdays .sunday,
.receipt-claim-date-day.sunday {
  color: #ef4444;
}

.receipt-claim-date-weekdays .saturday,
.receipt-claim-date-day.saturday {
  color: #2563eb;
}

.receipt-claim-date-day {
  width: 34px;
  height: 34px;
  margin: 0 auto 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #2f3337;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
}

.receipt-claim-date-day.outside {
  color: #b4b9bd;
}

.receipt-claim-date-day.selected {
  background: #176928;
  color: #fff;
  font-weight: 700;
}

.receipt-claim-date-day.today:not(.selected) {
  border: 1px solid #176928;
}

.receipt-claim-picker-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.receipt-claim-picker-footer button {
  min-width: 56px;
  padding: 0 12px;
  font-size: 13px;
}

.receipt-claim-check-label {
  font-size: 14px;
  font-weight: 700;
  color: #10251a;
}

.receipt-claim-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  font-size: 14px;
  color: #10251a;
  white-space: nowrap;
}

.receipt-claim-check input {
  width: 16px;
  height: 16px;
  accent-color: #2f7f32;
}

.receipt-claim-medical-only.is-hidden {
  display: none;
}

.receipt-claim-result-card {
  min-height: 68px;
  margin-bottom: 18px;
  border: 1px solid #cad8d1;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 10px 22px;
  color: #10251a;
}

.receipt-claim-result-empty {
  font-size: 14px;
}

.receipt-claim-result-ready {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.receipt-claim-result-main {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.receipt-claim-result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.receipt-claim-result-icon {
  color: #17611f;
  font-size: 28px;
}

.receipt-claim-result-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
}

.receipt-claim-result-meta {
  font-size: 12px;
  color: #34453a;
}

.receipt-claim-section {
  margin-bottom: 16px;
}

.receipt-claim-section-header {
  width: 100%;
  height: 33px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #10251a;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.receipt-claim-section-header i {
  width: 14px;
  text-align: center;
  color: #0b5012;
  font-size: 11px;
  transition: transform 0.15s ease;
}

.receipt-claim-section:not(.receipt-claim-section-open) .receipt-claim-section-header i {
  transform: rotate(-90deg);
}

.receipt-claim-section:not(.receipt-claim-section-open) .receipt-claim-section-body {
  display: none;
}

.receipt-claim-review-section {
  margin-top: 4px;
}

.receipt-claim-review-body {
  padding: 2px 28px 12px;
}

.receipt-claim-review-body p {
  margin: 0 0 8px;
  color: #253a2d;
  font-size: 13px;
  line-height: 1.5;
}

.receipt-claim-section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 6px;
}

.receipt-claim-table-wrap {
  border: 1px solid #cbd8d1;
  background: #fff;
  overflow: auto;
}

.receipt-claim-table {
  width: 100%;
  border-collapse: collapse;
  color: #10251a;
  font-size: 14px;
}

.receipt-claim-table th {
  height: 36px;
  padding: 7px 7px;
  text-align: left;
  background: #f4f8f6;
  color: #10251a;
  border-right: 1px solid #cbd8d1;
  border-bottom: 1px solid #cbd8d1;
  font-weight: 400;
  white-space: nowrap;
}

.receipt-claim-table th:last-child {
  border-right: 0;
}

.receipt-claim-table td {
  height: 36px;
  padding: 5px 7px;
  border-right: 1px solid #d7e1dc;
  border-bottom: 1px solid #d7e1dc;
  vertical-align: middle;
}

.receipt-claim-table td:last-child {
  border-right: 0;
}

.receipt-claim-table tr.has-warning {
  background: #fff7ed;
}

.receipt-claim-table tr.is-nonclaim {
  background: #f8fafc;
  color: #64748b;
}

.receipt-claim-table .number {
  text-align: right;
  white-space: nowrap;
}

.receipt-claim-warning-chip,
.receipt-claim-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 24px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.receipt-claim-warning-chip {
  border: 1px solid #f59e0b;
  color: #9a3412;
  background: #fff7ed;
  cursor: pointer;
  font-family: inherit;
  gap: 4px;
}

.receipt-claim-status-chip.include {
  color: var(--primary-dark);
  background: #e8f5e9;
}

.receipt-claim-status-chip.exclude,
.receipt-claim-status-chip.month_delay,
.receipt-claim-status-chip.return_hold {
  color: #475569;
  background: #e2e8f0;
}

.receipt-claim-status-chip.resubmit {
  color: #0f4f6b;
  background: #e0f2fe;
}

.receipt-claim-status-cell,
.receipt-claim-warning-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.receipt-claim-status-select,
.receipt-return-status-select {
  height: 30px;
  min-width: 84px;
  border: 1px solid #bfd0c7;
  border-radius: 4px;
  background: var(--white);
  color: #1f2933;
  font-size: 14px;
  font-family: inherit;
}

.receipt-claim-muted {
  color: var(--gray-400);
  font-size: 12px;
}

.receipt-claim-row-actions,
.receipt-return-preview-modal {
  z-index: 4000;
}

.receipt-return-preview-content {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}

.receipt-return-preview-summary {
  padding: 12px 16px;
  overflow-wrap: anywhere;
  border-bottom: 1px solid #cbd9d5;
}

.receipt-return-preview-body {
  overflow: auto;
  min-height: 0;
}

.receipt-return-preview-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.receipt-return-preview-table th,
.receipt-return-preview-table td {
  padding: 9px 10px;
  border: 1px solid #cbd9d5;
  vertical-align: top;
}

.receipt-return-preview-table th {
  position: sticky;
  top: 0;
  background: #f3f6f5;
  text-align: left;
  white-space: nowrap;
}

.receipt-return-preview-table td:last-child {
  width: 36%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.receipt-return-actions {
  text-align: center;
  white-space: nowrap;
  width: 62px;
}

.receipt-claim-open-karte-btn {
  color: var(--primary-dark);
}

.receipt-claim-empty {
  padding: 14px;
  color: #10251a;
  text-align: left;
}

.receipt-claim-footer-split {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

@media (max-width: 900px) {
  .modal-receipt-claim {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
  }

  .receipt-claim-tabs {
    grid-template-columns: repeat(3, minmax(88px, 1fr));
  }

  .receipt-claim-top {
    display: grid;
    gap: 10px;
  }

  .receipt-claim-result-ready {
    align-items: flex-start;
    flex-direction: column;
  }

  .receipt-claim-table {
    min-width: 760px;
  }

  .receipt-claim-field input {
    font-size: 14px;
  }

  .modal-receipt-claim .modal-footer .footer-right {
    flex-wrap: wrap;
  }
}

/* ====================================
   共通: ローディング・通知
==================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--gray-500);
}

.no-data,
.no-results {
  padding: 20px;
  text-align: center;
  color: var(--gray-400);
}

/* ====================================
   フィルターメニュー
==================================== */
.filter-menu {
  background: var(--white);
  border: 1px solid #cfd5d9;
  border-radius: 3px;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.28);
  z-index: 1300;
  overflow: visible;
  color: #263238;
}

.reception-filter-arrow {
  position: absolute;
  top: -8px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-left: 1px solid #cfd5d9;
  border-top: 1px solid #cfd5d9;
  transform: rotate(45deg);
}

.reception-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.08fr;
  gap: 12px;
  padding: 10px 12px 8px;
}

.reception-filter-section {
  min-width: 0;
}

.reception-filter-title {
  margin: 0 0 6px;
  color: #202124;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
}

.reception-filter-links {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px;
  border: 1px solid #dde2e6;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  background: #fff;
}

.reception-filter-links button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #2d73d2;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.reception-filter-links button:hover {
  text-decoration: underline;
}

.reception-filter-options {
  height: 318px;
  padding: 4px 8px 8px;
  border: 1px solid #dde2e6;
  border-radius: 0 0 3px 3px;
  background: #fff;
  overflow: hidden;
}

.reception-filter-options.scrollable {
  overflow-y: auto;
  scrollbar-color: #8b8b8b #f2f2f2;
  scrollbar-width: thin;
}

.reception-filter-options.scrollable::-webkit-scrollbar {
  width: 12px;
}

.reception-filter-options.scrollable::-webkit-scrollbar-thumb {
  background: #8b8b8b;
  border-radius: 8px;
  border: 2px solid #f2f2f2;
}

.reception-filter-options.scrollable::-webkit-scrollbar-track {
  background: #f2f2f2;
}

.reception-filter-check {
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #333;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}

.reception-filter-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-check-box {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1px solid #2e7d32;
  border-radius: 3px;
  background: #fff;
  position: relative;
}

.reception-filter-check input:checked + .filter-check-box {
  background: #1b5e20;
  border-color: #1b5e20;
}

.reception-filter-check input:checked + .filter-check-box::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-color-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.filter-check-label {
  min-width: 0;
  white-space: nowrap;
}

.reception-filter-memos {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 10px;
  padding: 8px 12px 16px;
}

.reception-filter-memos label {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  color: #202124;
  font-size: 15px;
}

.reception-filter-memos input {
  width: 100%;
  height: 28px;
  padding: 3px 8px;
  border: 1px solid #cfd8dc;
  border-radius: 3px;
  background: #fff;
  color: #263238;
  font-size: 13px;
  font-family: inherit;
}

.reception-filter-memos input:focus {
  outline: none;
  border-color: #2d73d2;
  box-shadow: 0 0 0 1px rgba(45, 115, 210, 0.18);
}

.filter-column-hidden {
  display: none !important;
}

.filter-btn.active {
  background: var(--primary);
  color: var(--white);
}

.filter-btn.active:hover {
  background: var(--primary-dark);
}

/* ステータスメニュー */
.status-menu {
  background: var(--white);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  min-width: 120px;
  z-index: 1000;
  overflow: hidden;
}

.status-menu-item {
  min-height: 31px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 12px;
  color: #263238;
  cursor: pointer;
  transition: opacity 0.15s;
}

.status-menu-item:hover {
  background: #f1f8f4;
  opacity: 1;
}

.status-menu-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

/* ====================================
   ツールバー追加スタイル
==================================== */
.toolbar-btn.active,
.toolbar-icon-btn.active {
  background: var(--primary);
  color: var(--white);
}

/* ====================================
   編集モード用スタイル
==================================== */
.modal-patient input:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}

/* ====================================
   フッターボタン追加スタイル
==================================== */
.m3-footer-btn#btn-prescription {
  color: #7c3aed;
}

.m3-footer-btn#btn-billing {
  color: var(--primary);
}

.m3-footer-btn#btn-auto-calc {
  color: #0369a1;
}

.m3-footer-btn:hover {
  background: var(--gray-100);
}

/* ====================================
   処方アイコンスタイル
==================================== */
.m3-proc-icon.purple {
  background: #7c3aed;
  color: white;
}

.rx-procedure-item {
  background: #fff;
  border-left: 0;
}

/* ====================================
   M3タブコンテンツスタイル
==================================== */

/* 保険情報 */
.m3-insurance-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

.m3-insurance-card.active {
  border-color: var(--primary);
  border-width: 2px;
}

.insurance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.insurance-type {
  font-weight: 600;
  color: var(--gray-800);
}

.insurance-status {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.insurance-status.valid {
  background: #dcfce7;
  color: #166534;
}

.insurance-status.expired {
  background: #fee2e2;
  color: #dc2626;
}

.insurance-details {
  font-size: 12px;
}

.insurance-row {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px dotted var(--gray-200);
}

.insurance-row:last-child {
  border-bottom: none;
}

.insurance-row .label {
  width: 100px;
  color: var(--gray-500);
}

.insurance-row .value {
  color: var(--gray-800);
}

/* 問診 */
#interview-content .m3-patient-section { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; }
#interview-data { flex: 1; overflow: hidden; }
#interview-data .m3-section-header, .interview-detail-header, .interview-history-head { flex-shrink: 0; }
.interview-detail-text { flex: 1; min-height: 0; }
.m3-interview-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.interview-history-head, .interview-history-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  width: 100%;
  text-align: left;
  color: var(--text-primary, #003366);
  border: 0;
  border-bottom: 1px solid #cddcda;
  background: #fff;
  font: inherit;
  padding: 0;
}
.interview-history-head { background: #f3f6f5; font-size: 12px; }
.interview-history-head span, .interview-history-row span { padding: 6px; border-right: 1px solid #cddcda; }
.interview-history-row { cursor: pointer; }
.interview-history-row span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.interview-history-row.selected { background: #e8f2f0; }
.interview-history-list { max-height: 155px; overflow-y: auto; flex-shrink: 0; }
.interview-detail-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px; background: #f3f6f5; border-bottom: 1px solid #cddcda; }
.interview-date-button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 4px 0; }
.interview-detail-text { padding: 12px 8px; white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; line-height: 1.6; }
.interview-edit-overlay { position: fixed; inset: 0; z-index: 10020; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.interview-edit-dialog { width: min(1020px, 100%); max-height: 90vh; background: #f3f6f5; display: flex; flex-direction: column; box-shadow: 0 6px 24px #0003; }
.interview-edit-dialog header { display: flex; align-items: center; justify-content: space-between; background: #154f18; color: white; padding: 10px 16px; }
.interview-edit-dialog header button { border: 0; background: transparent; color: white; font-size: 26px; cursor: pointer; }
.interview-edit-fields { padding: 8px; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.interview-edit-fields input, .interview-edit-fields textarea { width: 100%; box-sizing: border-box; border: 1px solid #c6cdcb; background: #fff; color: #334; font: inherit; padding: 6px; }
.interview-edit-fields textarea { height: min(52vh, 430px); min-height: 160px; margin-top: 8px; line-height: 1.55; resize: vertical; }
.interview-edit-fields label { margin-bottom: 3px; }
#interview-edit-error { color: #b91c1c; margin: 4px 0 0; }
.interview-edit-dialog footer { display: flex; justify-content: flex-end; gap: 6px; padding: 8px; }
.interview-edit-dialog footer button { min-width: 90px; padding: 8px 16px; border: 1px solid #cdd5d3; background: #fff; cursor: pointer; font: inherit; }
.interview-edit-dialog footer .interview-edit-save { background: #154f18; color: white; }
.interview-edit-dialog footer button:disabled { opacity: .5; cursor: wait; }
.interview-calendar { z-index: 10021; }
.interview-calendar-title { flex: 1; border: 1px solid #d2dbd6; padding: 5px; background: #f7f9f8; color: #173b20; cursor: pointer; font: inherit; }
.interview-calendar-grid.months { grid-template-columns: repeat(3, 1fr); }
.interview-calendar-grid.years { grid-template-columns: 1fr; max-height: 270px; overflow-y: auto; }
.interview-calendar-grid.months button, .interview-calendar-grid.years button { min-height: 42px; border: 0; background: #fff; font: inherit; cursor: pointer; }
.interview-calendar-grid.months button.selected, .interview-calendar-grid.years button.selected { background: #154f18; color: #fff; }

.interview-item {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.interview-item:last-child {
  border-bottom: none;
}

.interview-label {
  width: 100px;
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

.interview-value {
  flex: 1;
  font-size: 13px;
  color: var(--gray-800);
}

/* PHR / サマリー / 定期 / オン資等 */
.m3-aux-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border-bottom: 0;
}

.m3-aux-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  background: #f7faf8;
}

#summary-content .m3-aux-list {
  padding: 0;
  background: #fff;
}

.m3-summary-notepad {
  width: 100%;
  min-height: 260px;
  height: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-top: 1px solid #d4dedb;
  background: #fff;
  color: #111827;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: auto;
}

.m3-summary-notepad p {
  margin: 0;
}

.m3-summary-notepad.empty {
  color: #111827;
}

.m3-summary-notepad:focus {
  outline: 1px solid #38a7d4;
  outline-offset: -1px;
}

.m3-aux-card {
  margin-bottom: 8px;
  border: 1px solid #cfded8;
  background: #fff;
}

.m3-aux-card-title {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid #dbe6e1;
  background: #f2f7f4;
  color: #0f2f25;
  font-size: 13px;
  font-weight: 700;
}

.m3-aux-status {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid #c8d2ce;
  border-radius: 2px;
  background: #fff;
  color: #53605b;
  font-size: 11px;
  font-weight: 500;
}

.m3-aux-status.active {
  border-color: #0b6a25;
  background: #e8f6ec;
  color: #07530f;
}

.m3-aux-muted {
  color: #607169;
  font-size: 11px;
  font-weight: 400;
}

.m3-aux-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.m3-aux-table th,
.m3-aux-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5eeee;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.m3-aux-table th {
  width: 86px;
  background: #fbfdfc;
  color: #54645d;
  font-weight: 500;
}

.m3-aux-table tr:last-child th,
.m3-aux-table tr:last-child td {
  border-bottom: 0;
}

.m3-aux-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
}

.m3-aux-chip {
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #cfded8;
  border-radius: 2px;
  background: #fff;
  color: #102018;
  font-size: 12px;
}

.m3-aux-empty-line {
  padding: 9px 8px;
  color: #7b8580;
  font-size: 12px;
}

.m3-aux-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px 8px;
  border-top: 1px solid #e5eeee;
}

.m3-aux-actions .btn {
  min-height: 28px;
  padding: 0 12px;
  border-radius: 2px;
  font-size: 12px;
}

.m3-aux-actions .btn.danger {
  border-color: #e2b5b5;
  color: #a51f1f;
}

.modal-m3-aux {
  width: min(520px, calc(100vw - 40px));
}

.periodic-register-dialog {
  width: min(600px, calc(100vw - 32px));
  border-radius: 0;
}

.periodic-register-body {
  padding: 0;
  color: #111827;
  font-size: 14px;
}

.periodic-register-name-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid #d8dfdc;
}

.periodic-register-name-row .form-input {
  height: 30px;
}

.periodic-register-repeat-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  min-height: 114px;
  padding: 10px 16px;
  border-bottom: 1px solid #d8dfdc;
}

.periodic-register-repeat-label {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 8px;
}

.periodic-help {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.periodic-register-repeat-options {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.periodic-register-repeat-options label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.periodic-register-repeat-options input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #3b6ee1;
}

.periodic-register-month-option select {
  width: 56px;
  height: 32px;
  padding: 0 6px;
}

.periodic-register-month-option select:disabled {
  background: #edf2f0;
  color: #68756f;
}

.periodic-register-footer {
  justify-content: flex-end;
  padding: 6px 12px;
}

.periodic-register-footer .btn {
  min-width: 56px;
  border-radius: 0;
}

#periodic-list {
  padding: 0;
  background: #fff;
}

.periodic-list-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: #111827;
  font-size: 13px;
}

.periodic-list-table th,
.periodic-list-table td {
  height: 34px;
  padding: 5px 8px;
  box-sizing: border-box;
  border-right: 1px solid #d5dfdb;
  border-bottom: 1px solid #d5dfdb;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.periodic-list-table th {
  background: #f1f6f3;
  color: #26352f;
  font-weight: 500;
}

.periodic-list-table th:nth-child(1) {
  width: 28%;
}

.periodic-list-table th:nth-child(2) {
  width: 29%;
}

.periodic-list-table th:nth-child(3) {
  width: 30%;
}

.periodic-list-table .periodic-list-actions-heading,
.periodic-list-table .periodic-list-actions {
  width: 74px;
  padding: 3px;
  border-right: 0;
  text-align: center;
  white-space: nowrap;
}

.periodic-row-action {
  width: 31px;
  height: 31px;
  margin: 0 1px;
  padding: 0;
  border: 1px solid #cfd7d4;
  border-radius: 3px;
  background: #fff;
  color: #17211d;
  cursor: pointer;
}

.periodic-row-action:hover {
  background: #edf5f0;
}

.m3-aux-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m3-aux-form.compact {
  gap: 7px;
  padding: 8px;
}

.m3-aux-form-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  color: #24352e;
  font-size: 13px;
}

.m3-aux-form-row > span {
  min-height: 30px;
  display: flex;
  align-items: center;
  color: #52635c;
}

.m3-aux-form-row textarea {
  resize: vertical;
}

.m3-aux-check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #24352e;
  font-size: 13px;
}

.m3-aux-check-row input {
  width: 17px;
  height: 17px;
  accent-color: #0b4d12;
}

/* バイタル */
.m3-vital-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#vital-content .m3-patient-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border-bottom: 0;
}

.vital-table-scroll {
  flex: 0 0 auto;
  max-height: 292px;
  overflow: auto;
  border-bottom: 1px solid #b8cbc5;
}

.vital-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
  background: #fff;
}

.vital-table th,
.vital-table td {
  height: 26px;
  padding: 0 6px;
  text-align: center;
  border-right: 1px solid #d4e0dc;
  border-bottom: 1px solid #d4e0dc;
  vertical-align: middle;
}

.vital-table th {
  background: #f3f8f6;
  font-weight: 400;
  color: #0f2f25;
}

.vital-table td {
  color: #001f3f;
}

.vital-item-head,
.vital-item-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 132px;
  min-width: 132px;
  text-align: left !important;
  background: #f3f8f6 !important;
}

.vital-item-head {
  z-index: 3;
}

.vital-date-head {
  width: 86px;
  min-width: 86px;
  white-space: nowrap;
}

.vital-check-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.vital-check-row input {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  margin: 0;
}

.vital-check-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vital-value-cell {
  width: 86px;
  min-width: 86px;
}

.vital-value-cell.empty {
  background: #fbfdfc;
}

.vital-cell-button {
  width: 100%;
  height: 23px;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: #001f3f;
  font: inherit;
  line-height: 23px;
  cursor: pointer;
}

.vital-cell-button:hover {
  background: #eaf5ef;
  color: #005a2c;
}

.vital-view-tabs {
  display: flex;
  align-items: flex-end;
  flex: 0 0 31px;
  height: 31px;
  padding: 6px 8px 0;
  border-bottom: 1px solid #0b6e2f;
  background: #f7faf9;
}

.vital-view-tab {
  height: 25px;
  padding: 0 12px;
  border: 1px solid #c8d6d1;
  border-bottom: 0;
  background: #eef3f1;
  color: #21352e;
  font-size: 12px;
  cursor: pointer;
}

.vital-view-tab.active {
  background: #00672d;
  border-color: #00672d;
  color: #fff;
  font-weight: 600;
}

.vital-chart-panel {
  flex: 1 1 auto;
  min-height: 160px;
  overflow: auto;
  padding: 8px;
  background: #fff;
}

.vital-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 145px;
  color: #6b7c76;
  font-size: 12px;
  text-align: center;
}

.vital-chart-svg {
  width: 100%;
  min-width: 480px;
  height: auto;
  display: block;
}

.vital-chart-axis,
.vital-chart-legend {
  fill: #4c5f59;
  font-size: 11px;
}

.vital-growth-note {
  margin: 0 0 8px;
  padding: 6px 8px;
  background: #fffaf0;
  border: 1px solid #f3d4a1;
  color: #6f4d00;
  font-size: 12px;
  line-height: 1.45;
}

.vital-growth-chart + .vital-growth-chart {
  margin-top: 10px;
}

.vital-growth-title {
  margin-bottom: 4px;
  color: #153b2d;
  font-size: 12px;
  font-weight: 600;
}

.modal-vital {
  width: min(430px, calc(100vw - 40px));
  max-height: none;
}

.vital-modal-body {
  padding: 12px 18px;
}

.vital-add-form {
  display: grid;
  gap: 7px;
}

.vital-input-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  font-size: 12px;
  color: #1f3328;
}

.vital-input-row .form-input {
  width: 100%;
  height: 28px;
  padding: 3px 8px;
  border: 1px solid #c8d6d1;
  border-radius: 2px;
  font-size: 12px;
}

.vital-input-unit {
  color: #5f6f6a;
}

.vital-modal-footer {
  padding: 10px 18px;
  gap: 8px;
}

/* 検査結果 */
.labresult-item {
  padding: 12px;
  background: var(--gray-50);
  border-radius: 6px;
  margin-bottom: 10px;
}

.labresult-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.labresult-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.test-name {
  font-size: 12px;
  color: var(--gray-700);
}

.test-result {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
}

.test-result.positive {
  background: #fee2e2;
  color: #dc2626;
}

.test-result.negative {
  background: #dcfce7;
  color: #166534;
}

/* 投薬履歴 */
.m3-medication-history-shell,
.m3-medication-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #fff;
}

.m3-medication-list {
  overflow: hidden;
}

.m3-medication-history-empty {
  padding: 18px 12px;
  color: #7b8580;
  font-size: 13px;
}

.medication-history-table-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #fff;
}

.medication-history-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: #0f172a;
  font-size: 12px;
}

.medication-history-table th,
.medication-history-table td {
  box-sizing: border-box;
  border-right: 1px solid #d5dfdc;
  border-bottom: 1px solid #d5dfdc;
  background: #fff;
}

.medication-history-table th:last-child,
.medication-history-table td:last-child {
  border-right: none;
}

.medication-history-drug-head {
  position: relative;
  width: 290px;
  min-width: 290px;
  height: 38px;
  padding: 0;
  color: #1f3328;
  font-weight: 500;
  text-align: left;
  vertical-align: bottom;
}

.medication-history-drug-head-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 100%;
  padding: 0 8px 5px;
}

.medication-history-window-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
  font-size: 17px;
}

.medication-history-window-btn:hover,
.medication-history-window-btn:focus {
  background: #e8f2ec;
  outline: none;
}

.medication-history-window-btn::before {
  content: "↗";
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.medication-history-window-btn i {
  display: none;
}

.medication-history-year-head {
  height: 18px;
  color: #334155;
  text-align: center;
  font-weight: 400;
}

.medication-history-month-head {
  width: 27px;
  min-width: 27px;
  height: 22px;
  color: #0f172a;
  text-align: center;
  font-weight: 400;
}

.medication-history-drug-cell {
  width: 290px;
  min-width: 290px;
  min-height: 35px;
  padding: 0 8px;
  white-space: normal;
}

.medication-history-drug-cell-inner {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 35px;
  padding: 5px 0;
}

.medication-history-drug-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: #9b72d6;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.medication-history-drug-name {
  flex: 1 1 auto;
  min-width: 0;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.25;
  vertical-align: middle;
  word-break: break-all;
}

.medication-history-month-cell {
  width: 27px;
  min-width: 27px;
  height: 35px;
  text-align: center;
  vertical-align: middle;
}

.medication-history-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #202624;
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
}

.medication-history-check:hover,
.medication-history-check:focus {
  background: #0b5a2a;
  outline: none;
}

.medication-history-check.disabled {
  cursor: default;
  opacity: 0.72;
}

/* ファイル */
#file-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.file-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  gap: 0;
  border-bottom: none;
}

#file-content .file-section {
  min-height: 100%;
}

.file-section .m3-section-header {
  min-height: 45px;
  padding: 6px 8px 6px 0;
  background: #fff;
  position: relative;
  z-index: 20;
}

.file-section .m3-section-title {
  margin-left: 8px;
}

.file-section .m3-section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 21;
}

.patient-file-toolbar-btn {
  height: 31px;
  min-width: 80px;
  padding: 0 8px;
  border: 1px solid #c8d2cf;
  border-radius: 2px;
  background: linear-gradient(#fff, #fbfcfc);
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  line-height: 29px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 22;
}

.patient-file-toolbar-btn i {
  margin-left: 3px;
  color: #111827;
  font-size: 10px;
}

.patient-file-toolbar-btn:hover {
  background: #f6faf8;
  border-color: #aebfba;
}

.patient-document-template-anchor {
  position: relative;
  display: inline-flex;
}

.m3-file-list.patient-file-dropzone {
  flex: 1 1 auto;
  min-height: 420px;
  height: 100%;
  border-top: 1px solid #d5e2e5;
  background: #dff0f8;
  color: #5b88a3;
  position: relative;
  z-index: 0;
  overflow: auto;
  cursor: pointer;
}

.m3-file-list.patient-file-dropzone.dragover {
  background: #d5edf8;
  outline: 2px dashed #6aa9c8;
  outline-offset: -8px;
}

.m3-file-list.patient-file-dropzone.has-files {
  min-height: 0;
  background: #fff;
  color: #111827;
}

.patient-file-table {
  width: 100%;
  min-height: 100%;
  height: 100%;
  border-top: none;
  font-size: 12px;
}

.patient-file-table.is-empty {
  min-height: 100%;
  height: 100%;
  background: #dff0f8;
  position: relative;
  pointer-events: none;
}

.patient-file-empty-message {
  position: absolute;
  inset: 36px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f86a5;
  font-size: 16px;
  letter-spacing: 0;
  pointer-events: none;
}

.patient-file-head,
.patient-file-row {
  display: grid;
  grid-template-columns: 118px minmax(140px, 1fr) 92px 44px 44px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
}

.patient-file-head {
  min-height: 36px;
  background: #eef8fc;
  color: #9db5bf;
  font-weight: 400;
}

.patient-file-head span,
.patient-file-row > span {
  padding: 0 8px;
  min-width: 0;
  border-right: 1px solid #d5e2e5;
}

.patient-file-head span:last-child,
.patient-file-row > span:last-of-type {
  border-right: none;
}

.patient-file-table.is-empty .patient-file-head {
  background: rgba(255, 255, 255, 0.14);
  color: #9bb5bf;
}

.patient-file-table.is-empty .patient-file-head span:nth-child(n + 2) {
  color: transparent;
}

#file-content .m3-file-list.patient-file-dropzone:not(.has-files) .m3-memo-content.empty {
  position: absolute;
  inset: 36px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: #4f86a5;
  font-size: 16px;
  pointer-events: none;
}

.patient-file-date {
  color: #111827;
}

.patient-file-name {
  min-width: 0;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-file-muted {
  color: #9ca3af;
}

.patient-file-name small {
  display: block;
  color: #6b7280;
  font-size: 11px;
  margin-top: 3px;
}

.patient-file-preview {
  display: flex;
  align-items: center;
  justify-content: center;
}

.patient-file-preview img {
  width: 72px;
  max-width: 100%;
  height: 52px;
  object-fit: cover;
  border: 1px solid #d7e0dc;
  background: #fff;
}

.patient-file-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d7e0dc;
  border-radius: 4px;
  background: #f9fafb;
  color: #0b5a2a;
  font-size: 20px;
}

.patient-file-action {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 1px solid #d7e0dc;
  border-radius: 4px;
  background: #fff;
  color: #0b2a1a;
  cursor: pointer;
}

.patient-file-action:hover {
  background: #e8f5e9;
  border-color: #8bc7a0;
}

/* 傷病名 */
.disease-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 4px;
  margin-bottom: 6px;
}

.disease-item.active {
  background: #e8f5e9;
  border-left: 3px solid var(--primary);
}

.disease-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
}

.disease-date {
  font-size: 11px;
  color: var(--gray-500);
}

.disease-status {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.disease-status.ongoing {
  background: #dbeafe;
  color: #1d4ed8;
}

.disease-status.cured {
  background: #e5e7eb;
  color: #4b5563;
}

.diagnosis-table {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c7d2cd;
  border-bottom: 0;
  font-size: 12px;
}

.diagnosis-section-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagnosis-bulk-check {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.diagnosis-bulk-check input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.diagnosis-toolbar-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #d7e0dc;
  border-radius: 3px;
  background: #fff;
  color: #0b2a1a;
  font-weight: 700;
  cursor: pointer;
}

.diagnosis-toolbar-btn:hover {
  background: #e8f5e9;
  border-color: #8bc7a0;
}

.diagnosis-table-head,
.diagnosis-row {
  display: grid;
  grid-template-columns: 28px 42px minmax(130px, 1fr) 42px 72px 72px 50px 86px 34px;
  align-items: center;
  min-height: 35px;
  border-bottom: 1px solid #c7d2cd;
}

.diagnosis-table-head {
  min-height: 28px;
  background: #dfeee3;
  color: #26342d;
  font-weight: 700;
}

.diagnosis-table-head span,
.diagnosis-row span {
  padding: 0 6px;
  min-width: 0;
}

.diagnosis-table-head > span,
.diagnosis-row > span {
  align-self: stretch;
  display: flex;
  align-items: center;
  border-right: 1px solid #c7d2cd;
}

.diagnosis-row {
  background: #fff;
}

.diagnosis-row.is-main {
  background: #fff;
}

/* 傷病名タブは左ペイン全幅を使い、操作行をコンパクトにする */
#main-screen #disease-content {
  width: 100%;
  overflow: auto;
  scrollbar-gutter: auto;
}

#main-screen #disease-content .m3-patient-section,
#main-screen #disease-content .m3-disease-list {
  width: 100%;
  box-sizing: border-box;
}

#main-screen #disease-content .m3-section-header {
  min-height: 38px;
  padding: 4px 8px;
  box-sizing: border-box;
}

#main-screen #disease-content .diagnosis-section-tools {
  gap: 5px;
}

#main-screen #disease-content .diagnosis-bulk-check {
  width: 24px;
  height: 26px;
}

#main-screen #disease-content .diagnosis-toolbar-btn {
  height: 26px;
  padding: 0 9px;
}

.diagnosis-kind {
  color: #0b5a2a;
  font-weight: 700;
}

.diagnosis-select-cell {
  display: flex;
  justify-content: center;
}

.diagnosis-select-cell input {
  width: 13px;
  height: 13px;
  margin: 0;
}

.diagnosis-row-name {
  color: #111827;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.diagnosis-suspect,
.diagnosis-date,
.diagnosis-outcome,
.diagnosis-department {
  color: #374151;
}

.diagnosis-edit-btn {
  width: 26px;
  height: 26px;
  margin: 0;
  justify-self: center;
  align-self: center;
  border: 1px solid #d7e0dc;
  border-radius: 3px;
  background: #fff;
  color: #0b5a2a;
  cursor: pointer;
}

.diagnosis-edit-btn:hover {
  background: #e8f5e9;
  border-color: #8bc7a0;
}

.diagnosis-modal {
  z-index: 3400;
}

.diagnosis-modal-content {
  width: min(600px, calc(100vw - 48px));
  max-height: min(540px, calc(100vh - 70px));
  display: flex;
  flex-direction: column;
}

.diagnosis-search-header {
  padding: 6px 8px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
}

.diagnosis-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 2px solid #36a6de;
  border-radius: 4px;
  background: #fff;
}

.diagnosis-search-box i {
  color: #6b7280;
}

.diagnosis-search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 14px;
}

.diagnosis-result-list {
  overflow-y: auto;
  padding: 0 8px 8px;
  background: #f4f7f6;
}

.diagnosis-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 7px 8px;
  border-bottom: 1px solid #d5dfdb;
  background: #fff;
}

.diagnosis-result-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diagnosis-result-name {
  color: #111827;
  font-size: 13px;
  font-weight: 600;
}

.diagnosis-result-actions {
  display: flex;
  gap: 4px;
}

.diagnosis-result-actions button {
  min-width: 50px;
  height: 30px;
  border: 1px solid #d7e0dc;
  border-radius: 4px;
  background: #fff;
  color: #0b2a1a;
  font-weight: 700;
  cursor: pointer;
}

.diagnosis-result-actions button:hover {
  background: #e8f5e9;
  border-color: #8bc7a0;
}

.diagnosis-loading,
.diagnosis-empty {
  padding: 18px;
  color: #6b7280;
  text-align: center;
}

.diagnosis-history-modal-content {
  width: min(1024px, calc(100vw - 80px));
  max-height: min(560px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
}

.diagnosis-history-body {
  padding: 10px 6px 0;
  overflow: auto;
  background: #f8fbfa;
}

.diagnosis-history-title {
  padding: 6px 4px 14px;
  border-bottom: 1px solid #cfd8d5;
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
}

.diagnosis-history-table-wrap {
  overflow: auto;
}

.diagnosis-history-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}

.diagnosis-history-table th,
.diagnosis-history-table td {
  min-height: 34px;
  padding: 6px 7px;
  border: 1px solid #cfd8d5;
  color: #111827;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.diagnosis-history-table th {
  background: #f1f6f4;
  color: #0b5a2a;
  font-weight: 700;
}

/* ====================================
   カルテ更新履歴
==================================== */
.record-update-history-modal {
  z-index: 3550;
}

.record-update-history-content {
  width: min(1020px, calc(100vw - 64px));
  max-height: min(720px, calc(100vh - 72px));
  display: flex;
  flex-direction: column;
}

.record-update-history-body {
  min-height: 0;
  padding: 10px 12px 12px;
  background: #f8fbfa;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.record-update-history-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid #cfd8d5;
  background: #ffffff;
}

.record-update-history-patient {
  min-height: 42px;
  padding: 10px 12px;
  border-bottom: 1px solid #cfd8d5;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
}

.record-update-history-note,
.record-update-history-empty,
.record-history-note {
  padding: 14px 16px;
  color: #64746e;
  font-size: 13px;
  text-align: center;
}

.record-update-history-empty.error,
.record-history-note {
  color: #b91c1c;
}

.record-history-snapshot {
  border-bottom: 1px solid #cfd8d5;
  background: #ffffff;
}

.record-history-snapshot:last-child {
  border-bottom: 0;
}

.record-history-tabbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 45px;
  padding: 10px 10px 0;
  border-bottom: 1px solid #0b5a2a;
  background: #ffffff;
}

.record-history-tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 4px 4px 0 0;
  background: #0b5a2a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.record-history-label {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid #cbd9d5;
  border-bottom: 0;
  color: #0b5a2a;
  font-size: 12px;
  font-weight: 700;
}

.record-history-restore-btn {
  min-height: 30px;
  margin-bottom: 5px;
  padding: 0 10px;
  border: 1px solid #0b5a2a;
  border-radius: 3px;
  background: #ffffff;
  color: #0b5a2a;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.record-history-restore-btn:hover {
  background: #edf7f0;
}

.record-history-restore-btn i {
  margin-right: 5px;
}

.record-history-meta-line {
  display: inline-block;
  margin: 14px 12px 3px;
  padding: 1px 4px;
  border: 1px solid #e2e8e5;
  background: #ffffff;
  color: #111827;
  font-size: 12px;
}

.record-history-context-line {
  padding: 4px 12px 8px;
  border-bottom: 1px solid #cfd8d5;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.45;
}

.record-history-snapshot .history-columns {
  display: flex;
  min-height: 260px;
  border-top: 0;
  background: #ffffff;
}

.record-history-snapshot .history-col-left {
  flex: 0 0 42%;
  border-right: 1px solid #cfd8d5;
}

.record-history-snapshot .history-col-right {
  flex: 1 1 auto;
}

.record-history-snapshot .history-col-header {
  min-height: 34px;
  padding: 7px 10px;
  border-bottom: 1px solid #cfd8d5;
  background: #fbfcfb;
  color: #111827;
  font-size: 13px;
  font-weight: 500;
}

.record-history-snapshot .history-soap-content {
  padding: 12px;
  color: #111827;
  font-size: 13px;
  line-height: 1.55;
}

.record-history-snapshot .history-billing-list {
  padding: 0;
}

.record-history-snapshot .billing-row,
.record-history-snapshot .history-prescription-row {
  min-height: 34px;
  border-bottom: 1px solid #dbe5e1;
  font-size: 13px;
}

.record-history-snapshot .billing-row:last-child,
.record-history-snapshot .history-prescription-row:last-child {
  border-bottom: 0;
}

/* ====================================
   削除カルテ復元
==================================== */
.deleted-record-restore-modal {
  z-index: 3600;
}

.deleted-record-restore-content {
  width: min(1040px, calc(100vw - 64px));
  max-height: min(720px, calc(100vh - 72px));
  display: flex;
  flex-direction: column;
}

.deleted-record-restore-body {
  min-height: 0;
  padding: 10px 12px 12px;
  background: #f8fbfa;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deleted-record-restore-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #cfd8d5;
  background: #ffffff;
}

.deleted-record-restore-patient {
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
}

.deleted-record-restore-note {
  margin-top: 3px;
  color: #64746e;
  font-size: 12px;
}

.deleted-record-restore-refresh,
.deleted-record-restore-btn,
.deleted-record-restore-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #0b5a2a;
  border-radius: 3px;
  background: #0b6b2b;
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.deleted-record-restore-refresh {
  border-color: #c6d2ce;
  background: #ffffff;
  color: #0b5a2a;
}

.deleted-record-restore-secondary {
  border-color: #c6d2ce;
  background: #ffffff;
  color: #0b5a2a;
}

.deleted-record-restore-refresh:hover,
.deleted-record-restore-btn:hover,
.deleted-record-restore-secondary:hover {
  filter: brightness(0.96);
}

.deleted-record-restore-refresh:disabled,
.deleted-record-restore-btn:disabled,
.deleted-record-restore-secondary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.deleted-record-restore-list {
  min-height: 0;
  flex: 0 0 auto;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #cfd8d5;
  background: #ffffff;
}

.deleted-record-restore-preview {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid #cfd8d5;
  background: #ffffff;
}

.deleted-record-restore-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  border-bottom: 1px solid #dce5e2;
  background: #ffffff;
}

.deleted-record-restore-row:hover,
.deleted-record-restore-row.selected {
  background: #eff8f2;
}

.deleted-record-restore-row:last-child {
  border-bottom: 0;
}

.deleted-record-restore-row-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.deleted-record-restore-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.deleted-record-restore-card {
  border-bottom: 1px solid #cfd8d5;
  background: #ffffff;
}

.deleted-record-restore-card:last-child {
  border-bottom: 0;
}

.deleted-record-restore-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  border-bottom: 1px solid #dce5e2;
}

.deleted-record-restore-card-title {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.deleted-record-restore-date {
  color: #0b5a2a;
  font-size: 13px;
  font-weight: 700;
}

.deleted-record-restore-meta {
  min-width: 0;
  color: #475569;
  font-size: 12px;
}

.deleted-record-restore-card .history-columns {
  border: 0;
}

.deleted-record-restore-card .history-col-left,
.deleted-record-restore-card .history-col-right {
  min-height: 110px;
}

.deleted-record-restore-empty,
.deleted-record-restore-warning {
  padding: 18px;
  color: #64746e;
  font-size: 13px;
  text-align: center;
}

.deleted-record-restore-empty.error,
.deleted-record-restore-warning {
  color: #b91c1c;
}

.deleted-record-restore-row .deleted-record-restore-warning {
  padding: 0;
  text-align: left;
  font-size: 12px;
}

.deleted-record-restore-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 6px 10px;
  border-bottom: 1px solid #cfd8d5;
  background: #fbfcfb;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.diagnosis-bulk-outcome-content {
  width: min(520px, calc(100vw - 72px));
}

.diagnosis-bulk-outcome-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: #f8fbfa;
}

.diagnosis-bulk-outcome-body p {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
}

.diagnosis-edit-modal-content {
  width: min(1120px, calc(100vw - 72px));
  max-height: min(700px, calc(100vh - 70px));
  display: flex;
  flex-direction: column;
}

.diagnosis-edit-body {
  display: grid;
  grid-template-columns: minmax(540px, 1fr) 306px;
  gap: 24px;
  padding: 18px 12px 12px;
  overflow: auto;
  background: #f6f9f8;
}

.diagnosis-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diagnosis-edit-line {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #0f172a;
  font-size: 13px;
}

.diagnosis-edit-line > span:first-child {
  font-weight: 500;
}

.diagnosis-edit-line input[type="text"],
.diagnosis-edit-line input[type="date"],
.diagnosis-edit-line select,
.diagnosis-edit-side input {
  width: 100%;
  height: 30px;
  padding: 4px 8px;
  border: 1px solid #cfd8d5;
  border-radius: 3px;
  background: #fff;
  font-size: 14px;
  color: #0f172a;
  box-sizing: border-box;
}

.diagnosis-edit-field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.diagnosis-edit-influenza-types {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid #cfd8d5;
}

.diagnosis-edit-influenza-types[hidden] {
  display: none;
}

.diagnosis-edit-field-inline > input[type="text"],
.diagnosis-edit-field-inline > select {
  flex: 1;
  min-width: 0;
}

.diagnosis-edit-modifier-line {
  align-items: flex-start;
}

.diagnosis-edit-selected-modifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  padding: 3px 0;
}

.diagnosis-modifier-empty {
  display: inline-flex;
  align-items: center;
  height: 24px;
  color: #7a8580;
  font-size: 12px;
}

.diagnosis-modifier-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 7px 2px 3px;
  border: 1px solid #d7e0dc;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  cursor: pointer;
}

.diagnosis-modifier-chip span {
  min-width: 20px;
  padding: 2px 4px;
  border-radius: 3px;
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.diagnosis-modifier-chip.prefix span {
  background: #e1842e;
}

.diagnosis-modifier-chip.suffix span {
  background: #8b5db7;
}

.diagnosis-modifier-chip:hover {
  border-color: #f3c1c1;
  background: #fff5f5;
}

.diagnosis-edit-checkbox,
.diagnosis-edit-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.diagnosis-edit-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.diagnosis-edit-radio-group input,
.diagnosis-edit-field-inline input[type="checkbox"],
.diagnosis-edit-checkbox input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.diagnosis-edit-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 320px;
}

.diagnosis-edit-code {
  height: 30px;
  line-height: 30px;
  color: #0f172a;
  font-size: 13px;
  text-align: center;
}

.diagnosis-edit-code span {
  margin-left: 6px;
}

.diagnosis-edit-keyword-list {
  flex: 1;
  min-height: 260px;
  border: 1px solid #cfd8d5;
  background: #f3f4f6;
  overflow-y: auto;
}

.diagnosis-modifier-option {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: none;
  border-bottom: 1px solid #d1d5db;
  background: #f8faf9;
  color: #111827;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.diagnosis-modifier-option:hover {
  background: #eef7f2;
}

.diagnosis-modifier-option span {
  min-width: 24px;
  padding: 4px 5px;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.diagnosis-modifier-option.prefix span {
  background: #e1842e;
}

.diagnosis-modifier-option.suffix span {
  background: #8b5db7;
}

.diagnosis-edit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-top: 1px solid #dbe5e1;
  background: #f8fbfa;
}

.btn-danger-soft {
  border: 1px solid #f3c1c1;
  background: #fff5f5;
  color: #dc2626;
}

.btn-danger-soft:hover {
  background: #fee2e2;
}

/* ====================================
   パスワード変更モーダル
   ==================================== */
.modal-password .modal-content {
  max-width: 400px;
}

.modal-password .modal-body {
  padding: 20px;
}

.password-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.password-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.password-form .form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.password-form .form-group input {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.password-form .form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.password-actions button {
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.password-actions .btn-cancel {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.password-actions .btn-cancel:hover {
  background: var(--gray-200);
}

.password-actions .btn-save {
  background: var(--primary);
  border: none;
  color: white;
}

.password-actions .btn-save:hover {
  background: var(--primary-dark);
}

/* ====================================
   施設管理ページ
   ==================================== */
.facility-screen {
  height: 100vh;
  background: #f5f5f5;
  color: #111;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.facility-page-header {
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 8px;
  background: #fff;
  border-top: 1px solid #d5d5d5;
  border-bottom: 2px solid #c7c7c7;
}

.facility-page-header-left,
.facility-page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.facility-logo-btn,
.facility-header-icon,
.facility-user-link {
  border: 0;
  background: transparent;
  color: #0e5217;
  cursor: pointer;
  font-family: inherit;
}

.facility-logo-btn {
  width: 28px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.facility-brand-logo {
  width: 28px;
  height: 40px;
  overflow: visible;
}

.facility-brand-leaf-main {
  fill: #6f9657;
}

.facility-brand-leaf-sub {
  fill: #315f2c;
}

.facility-brand-stem {
  fill: none;
  stroke: #315f2c;
  stroke-width: 1.2;
  stroke-linecap: round;
}

.facility-page-title {
  font-size: 18px;
  font-weight: 500;
  white-space: nowrap;
}

.facility-header-icon {
  width: 28px;
  height: 28px;
  font-size: 17px;
}

.facility-help-search {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid #cfd7d1;
  border-radius: 15px;
  background: #fbfffb;
  color: #1b5e20;
}

.facility-help-search input {
  width: 120px;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
}

.facility-user-link {
  font-weight: 600;
  white-space: nowrap;
}

.facility-page-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
}

.facility-side-nav {
  border-right: 1px solid #0e5217;
  background: #f5f5f5;
  overflow-y: auto;
}

.facility-side-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: #111;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.facility-side-item:hover {
  background: #e9eeee;
}

.facility-side-item.active {
  background: #e8f4e8;
  border-bottom-color: #0a3f12;
  color: #07530f;
  font-weight: 700;
}

.facility-main {
  min-width: 0;
  position: relative;
  overflow: auto;
  background: #f5f5f5;
  border-left: 1px solid #d2d2d2;
}

.facility-page-section {
  min-height: 100%;
  position: relative;
}

.facility-page-section h2 {
  height: 48px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 8px;
  border-bottom: 1px solid #0e5217;
  font-size: 18px;
  font-weight: 600;
}

.facility-info-wrap {
  width: min(720px, calc(100% - 80px));
  margin: 54px auto 0;
}

.facility-page-section[data-facility-panel="medical"] .facility-info-wrap {
  width: min(716px, calc(100% - 48px));
  margin: 12px auto 0;
}

.facility-section-note {
  margin: 4px 0 0;
  color: #607067;
  font-size: 13px;
}

.facility-clinic-create-card {
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid #cbd9cf;
  border-radius: 6px;
  background: #f8fbf9;
}

.facility-clinic-create-card h3 {
  margin: 0 0 14px;
  color: #135f2d;
}

.facility-clinic-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px 16px;
  margin-bottom: 16px;
}

.facility-clinic-form-grid label {
  display: grid;
  gap: 6px;
  color: #263a2d;
  font-weight: 600;
  font-size: 13px;
}

.facility-clinic-form-grid input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #b9c9be;
  border-radius: 4px;
  background: #fff;
  font: inherit;
}

.facility-standard-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(145px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin: 18px 0 10px;
  padding: 16px;
  border: 1px solid #cbd9cf;
  border-radius: 6px;
  background: #f8fbf9;
}

.facility-standard-form label {
  display: grid;
  gap: 6px;
  color: #263a2d;
  font-size: 13px;
  font-weight: 600;
}

.facility-standard-form input {
  min-width: 0;
  height: 38px;
  padding: 7px 9px;
  border: 1px solid #b9c9be;
  border-radius: 4px;
  background: #fff;
  font: inherit;
}

.facility-standard-form .facility-new-btn {
  position: static;
  height: 38px;
  white-space: nowrap;
}

.facility-standard-table {
  margin-top: 14px;
}

@media (max-width: 980px) {
  .facility-standard-form {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .facility-clinic-form-grid {
    grid-template-columns: 1fr;
  }
}

.facility-accident-wrap {
  width: min(720px, calc(100% - 80px));
  margin: 12px auto 0;
}

.facility-shared-password-wrap {
  width: min(720px, calc(100% - 80px));
  margin: 12px auto 0;
}

.facility-data-submit-wrap {
  width: min(716px, calc(100% - 48px));
  margin: 12px auto 0;
}

.facility-rme-management-wrap {
  width: 100%;
  margin: 0;
}

.facility-rme-management-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-size: 14px;
}

.facility-rme-management-table th,
.facility-rme-management-table td {
  padding: 7px 8px;
  border: 1px solid #cfd7d7;
  text-align: left;
  font-weight: 400;
  box-sizing: border-box;
}

.facility-rme-management-table th {
  height: 37px;
  background: #f4f7f6;
}

.facility-rme-management-table td {
  height: 55px;
}

.facility-rme-management-table tbody tr:nth-child(even) td {
  background: #f2f5f4;
}

.facility-rme-management-table th:last-child,
.facility-rme-management-table td:last-child {
  width: 204px;
}

.facility-rme-management-select {
  width: 160px;
  height: 31px;
  padding: 0 8px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  color: #222;
  font-family: inherit;
  font-size: 14px;
}

.facility-page-section[data-facility-panel="data-submit"] .facility-info-actions {
  margin-bottom: 8px;
}

.facility-data-submit-code-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: 138px 202px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  padding: 0 0 0 0;
  font-size: 14px;
}

.facility-data-submit-code-row > span:first-child,
.facility-data-submit-code-edit-row label {
  white-space: nowrap;
}

.facility-data-submit-code-value {
  min-height: 31px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #e6eeeb;
  box-sizing: border-box;
}

.facility-data-submit-subtitle {
  margin: 5px 0 6px;
  font-size: 14px;
  font-weight: 400;
}

.facility-data-submit-table,
.facility-data-submit-edit-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
  font-size: 14px;
}

.facility-data-submit-table th,
.facility-data-submit-table td,
.facility-data-submit-edit-table th,
.facility-data-submit-edit-table td {
  height: 36px;
  padding: 5px 7px;
  border: 1px solid #cfd7d7;
  text-align: left;
  font-weight: 400;
  box-sizing: border-box;
}

.facility-data-submit-table th,
.facility-data-submit-edit-table th {
  background: #f4f7f6;
}

.facility-data-submit-table th:nth-child(1) { width: 39%; }
.facility-data-submit-table th:nth-child(2) { width: 40%; }
.facility-data-submit-table th:nth-child(3) { width: 21%; }

.facility-shared-password-help {
  min-height: 93px;
  padding: 13px 12px;
  border: 1px solid #cfd7d7;
  background: #fff;
  color: #111;
  font-size: 14px;
  line-height: 1.6;
  box-sizing: border-box;
}

.facility-shared-password-help p {
  margin: 0;
}

.facility-shared-password-table {
  width: 100%;
  margin-top: 7px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-shared-password-table th,
.facility-shared-password-table td {
  height: 38px;
  border: 1px solid #cfd7d7;
  padding: 0 8px;
  text-align: left;
  font-weight: 400;
  box-sizing: border-box;
}

.facility-shared-password-table th {
  width: 129px;
  background: #f4f7f6;
}

.facility-shared-password-table td {
  white-space: nowrap;
}

.facility-shared-password-btn {
  height: 32px;
  margin-left: 12px;
  padding: 0 10px;
  border: 1px solid #cfd4d4;
  border-radius: 3px;
  background: #fff;
  color: #222;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.facility-page-section[data-facility-panel="accident"] .facility-info-actions {
  margin-bottom: 5px;
}

.facility-info-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.facility-page-section[data-facility-panel="medical"] .facility-info-actions {
  margin-bottom: 11px;
}

.facility-edit-btn,
.facility-new-btn,
.facility-save-btn {
  height: 32px;
  border: 0;
  background: #0b4d12;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.facility-edit-btn {
  padding: 0 14px;
  border-radius: 2px;
}

.facility-page-section[data-facility-panel="medical"] .facility-edit-btn {
  height: 30px;
  padding: 0 7px;
}

.facility-new-btn {
  position: absolute;
  top: 10px;
  right: 0;
  padding: 0 14px;
  font-size: 14px;
}

.facility-info-table,
.facility-users-table,
.facility-master-import-table,
.facility-master-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.facility-info-table th,
.facility-info-table td,
.facility-users-table th,
.facility-users-table td,
.facility-master-import-table th,
.facility-master-import-table td,
.facility-master-table th,
.facility-master-table td {
  border: 1px solid #cfd7d7;
  padding: 8px 9px;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.facility-info-table th {
  width: 220px;
  background: #f4f7f6;
}

.facility-accident-table th {
  width: 212px;
}

.facility-accident-table th,
.facility-accident-table td {
  padding: 7px 8px;
  font-size: 14px;
}

.facility-accident-radio-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.facility-accident-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.facility-accident-radio input {
  width: 18px;
  height: 18px;
  accent-color: #2d73d2;
  pointer-events: none;
}

.facility-accident-radio input:disabled {
  opacity: 1;
}

.facility-user-filter {
  height: 44px;
  display: flex;
  align-items: center;
  padding-left: 14px;
  border-bottom: 1px solid #cfd7d7;
  background: #f7f8f8;
}

.facility-user-filter label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.facility-user-filter input {
  width: 17px;
  height: 17px;
  accent-color: #0b4d12;
}

.facility-table-scroll {
  overflow: auto;
}

.facility-users-table {
  min-width: 1700px;
}

.facility-certificate-table {
  min-width: 920px;
}

.facility-certificate-table th:nth-child(1) { width: 29%; }
.facility-certificate-table th:nth-child(2) { width: 29%; }
.facility-certificate-table th:nth-child(3) { width: 29%; }
.facility-certificate-table th:nth-child(4) { width: 8%; }
.facility-certificate-table th:nth-child(5) { width: 88px; }

.facility-certificate-table td:nth-child(5) {
  text-align: center;
}

.facility-monthly-count-table {
  min-width: 720px;
}

.facility-monthly-count-table th:first-child {
  width: 72%;
}

.facility-monthly-count-table th:last-child {
  width: 28%;
}

.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(1) { width: 290px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(2) { width: 190px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(3) { width: 240px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(4) { width: 130px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(5) { width: 235px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(6) { width: 195px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(7) { width: 195px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(8) { width: 36px; }
.facility-page-section[data-facility-panel="users"] .facility-users-table th:nth-child(9) { width: 220px; }

.facility-users-table thead th {
  background: #f4f7f6;
}

.facility-users-table tbody tr:nth-child(even) td,
.facility-master-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-master-content {
  padding: 0;
}

.facility-master-import {
  padding-top: 8px;
}

.facility-master-import h3,
.facility-master-list h3,
.facility-orca-import h3 {
  margin: 0;
  padding: 0 8px 8px;
  font-size: 16px;
  font-weight: 600;
}

.facility-master-import p {
  margin: 0;
  padding: 0 8px 12px;
  font-size: 14px;
}

.facility-official-master-panel {
  padding: 12px 0 14px;
  border-top: 1px solid #d6dfdd;
}

.facility-official-master-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 8px;
}

.facility-official-master-heading h3 {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
}

.facility-official-master-summary {
  margin: 0 8px 8px;
  padding: 8px 10px;
  border: 1px solid #cfd7d7;
  background: #f6faf8;
  font-size: 13px;
  color: #26352f;
}

.facility-official-master-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}

.facility-official-master-table th,
.facility-official-master-table td {
  border: 1px solid #cfd7d7;
  padding: 7px 8px;
  text-align: left;
  font-weight: 400;
  vertical-align: top;
}

.facility-official-master-table th {
  background: #f4f7f6;
  white-space: nowrap;
}

.facility-official-master-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-official-master-status {
  display: inline-block;
  min-width: 54px;
  padding: 2px 8px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  border: 1px solid #cfd7d7;
  background: #fff;
}

.facility-official-master-status.success {
  color: #0b4d12;
  border-color: #8abf91;
  background: #edf8ef;
}

.facility-official-master-status.failed {
  color: #a33a30;
  border-color: #e0aaa5;
  background: #fff4f3;
}

.facility-official-master-status.running {
  color: #7a5b00;
  border-color: #d8c47c;
  background: #fff9dd;
}

.facility-official-master-diff {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.facility-official-master-history {
  margin-top: 10px;
}

.facility-official-master-history summary {
  cursor: pointer;
  padding: 7px 8px;
  color: #0b4d12;
  font-weight: 600;
}

.facility-master-import-table th:nth-child(1) {
  width: 430px;
}

.facility-master-import-table th:nth-child(2) {
  width: 62px;
  text-align: center;
}

.facility-master-import-table th:nth-child(4) {
  width: 80px;
}

.facility-master-import-table th:nth-child(5) {
  width: 180px;
}

.facility-master-import-table td:nth-child(2),
.facility-master-import-table td:nth-child(4),
.facility-master-import-table td:nth-child(5) {
  text-align: center;
}

.facility-other-content {
  padding: 16px;
}

.facility-other-heading {
  width: min(880px, 100%);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.facility-other-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.facility-other-save-btn {
  position: static;
  padding: 0 18px;
}

.facility-other-setting-table {
  width: min(880px, 100%);
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.facility-other-setting-table th,
.facility-other-setting-table td {
  border: 1px solid #cfd7d7;
  padding: 10px 12px;
  text-align: left;
  font-weight: 400;
}

.facility-other-setting-table th {
  width: 240px;
  background: #f4f7f6;
}

.facility-other-section-row th {
  width: auto;
  background: #eef4f1;
  color: #0b4d12;
  font-weight: 700;
}

.facility-other-setting-table td label,
.facility-other-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  margin: 2px 18px 2px 0;
  white-space: nowrap;
}

.facility-other-setting-table input[type="radio"],
.facility-other-toggle input {
  width: 17px;
  height: 17px;
  accent-color: #0b4d12;
}

.facility-other-setting-note {
  display: block;
  margin-top: 6px;
  color: #66766f;
  font-size: 12px;
}

/* 音声カルテ: 結果は自動保存せず、利用者が確認してからカルテへ挿入する。 */
.voice-karte-panel {
  flex: 0 0 auto;
  border-top: 1px solid #b9cdc3;
  background: #f5faf7;
  color: #173425;
  font-size: 12px;
}

.voice-karte-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
}

.voice-karte-btn {
  display: inline-flex;
  width: 100%;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid #9eb9aa;
  border-radius: 3px;
  background: #fff;
  color: #154527;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.voice-karte-btn.primary {
  border-color: #176b2b;
  background: #176b2b;
  color: #fff;
}

.voice-karte-btn.danger {
  border-color: #b93232;
  background: #fff;
  color: #a11f1f;
}

.voice-karte-btn:disabled,
.voice-karte-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.voice-karte-waveform {
  position: relative;
  height: 22px;
  margin: 0 8px 5px;
  overflow: hidden;
  border-radius: 2px;
  background: #edf5f0;
}

#voice-karte-waveform-canvas {
  display: block;
  width: 100%;
  height: 22px;
}

.voice-karte-waveform.is-active {
  background: #e7f3eb;
}

.voice-karte-waveform.is-processing #voice-karte-waveform-canvas {
  visibility: hidden;
}

.voice-karte-processing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-karte-spinner {
  width: 13px;
  height: 13px;
  box-sizing: border-box;
  border: 2px solid #b6c9bd;
  border-top-color: #176b2b;
  border-radius: 50%;
  animation: voice-karte-spin 0.7s linear infinite;
}

@keyframes voice-karte-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .voice-karte-spinner { animation-duration: 1.4s; }
}

@media (max-width: 760px) {
  .voice-karte-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.facility-master-import-table input[type="file"] {
  width: 100%;
  font-family: inherit;
}

.facility-list-btn,
.facility-format-btn {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid #c8cece;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-family: inherit;
  cursor: pointer;
}

.facility-import-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 2px;
  background: #0b4d12;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.facility-master-list {
  margin-top: 20px;
  overflow-x: auto;
}

.facility-master-heading {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.facility-master-heading h3 {
  padding-bottom: 0;
}

.facility-master-new-btn {
  position: static;
  flex: 0 0 auto;
  margin-right: 0;
}

.facility-master-table th:first-child,
.facility-master-table td:first-child {
  width: auto;
}

.facility-master-table th:last-child,
.facility-master-table td:last-child {
  width: 82px;
  text-align: center;
}

.facility-master-table.facility-master-table-wide {
  min-width: 980px;
}

.facility-orca-import {
  margin-top: 12px;
}

.facility-orca-alert {
  min-height: 55px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 14px;
  border-top: 1px solid #ee9d9d;
  border-bottom: 1px solid #ee9d9d;
  background: #fff1f2;
}

.facility-orca-alert strong {
  color: #c31717;
}

.facility-orca-alert button {
  min-height: 30px;
  padding: 0 20px;
  border: 1px solid #e6c7c7;
  border-radius: 3px;
  background: #fff;
  color: #8d2222;
  font-family: inherit;
  cursor: pointer;
}

.facility-log-toolbar {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border-bottom: 1px solid #cfd7d7;
  background: #f7f8f8;
}

.facility-log-date-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  color: #111;
  cursor: pointer;
}

.facility-log-date-display {
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  font-size: 16px;
}

.facility-log-table-wrap {
  overflow: auto;
}

.facility-log-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-log-table th,
.facility-log-table td {
  height: 36px;
  border: 1px solid #cfd7d7;
  padding: 7px 8px;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.facility-log-table th {
  background: #f4f7f6;
}

.facility-log-table th:nth-child(1),
.facility-log-table td:nth-child(1) {
  width: 32%;
}

.facility-log-table th:nth-child(2),
.facility-log-table td:nth-child(2) {
  width: 18%;
}

.facility-log-table th:nth-child(3),
.facility-log-table td:nth-child(3) {
  width: 21%;
}

.facility-audit-log-table {
  min-width: 1600px;
}

.facility-audit-log-table th:nth-child(1),
.facility-audit-log-table td:nth-child(1) {
  width: 14%;
}

.facility-audit-log-table th:nth-child(2),
.facility-audit-log-table td:nth-child(2) {
  width: 12%;
}

.facility-audit-log-table th:nth-child(3),
.facility-audit-log-table td:nth-child(3) {
  width: 12%;
}

.facility-audit-log-table th:nth-child(4),
.facility-audit-log-table td:nth-child(4) {
  width: 6%;
}

.facility-audit-log-table th:nth-child(5),
.facility-audit-log-table td:nth-child(5) {
  width: 18%;
}

.facility-audit-log-table th:nth-child(6),
.facility-audit-log-table td:nth-child(6) {
  width: 20%;
}

.facility-empty-cell {
  text-align: center !important;
  color: #777;
}

.facility-warning-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.facility-warning-actions .facility-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 120px;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.facility-warning-actions .facility-save-btn i {
  font-size: 12px;
}

.facility-warning-table-wrap {
  overflow: auto;
}

.facility-warning-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-warning-table th,
.facility-warning-table td {
  height: 36px;
  border: 1px solid #cfd7d7;
  padding: 6px 8px;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.facility-warning-table th {
  background: #f4f7f6;
}

.facility-warning-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-warning-table th:nth-child(1),
.facility-warning-table td:nth-child(1) {
  width: 36%;
  min-width: 360px;
}

.facility-warning-table th:nth-child(2),
.facility-warning-table td:nth-child(2) {
  width: 12%;
  min-width: 150px;
}

.facility-warning-table th:nth-child(3),
.facility-warning-table td:nth-child(3) {
  width: 6%;
  text-align: center;
}

.facility-warning-table th:nth-child(4),
.facility-warning-table td:nth-child(4) {
  width: 22%;
  min-width: 260px;
}

.facility-warning-table th:nth-child(5),
.facility-warning-table td:nth-child(5) {
  width: 22%;
  min-width: 260px;
}

.facility-warning-table th:nth-child(6),
.facility-warning-table td:nth-child(6) {
  width: 38px;
  text-align: center;
}

.facility-warning-icon.orange-circle {
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ff7a1a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.facility-warning-triangle {
  font-size: 15px;
}

.facility-warning-triangle.red {
  color: #f03a2d;
}

.facility-warning-triangle.orange {
  color: #ff7a1a;
}

.facility-warning-level-only {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}

.facility-warning-level-only.level-1 {
  color: #c4870e;
}

.facility-warning-level-only.level-2 {
  color: #e97912;
}

.facility-warning-level-only.level-3 {
  color: #e42f25;
}

.facility-warning-select {
  height: 30px;
  min-width: 84px;
  padding: 0 26px 0 8px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  font-family: inherit;
}

.facility-warning-note {
  margin-left: 8px;
}

.facility-warning-dash {
  display: block;
  text-align: center;
}

.facility-warning-delete {
  width: 28px;
  height: 28px;
  border: 1px solid #c8cece;
  border-radius: 3px;
  background: #fff;
  color: #222;
  cursor: pointer;
}

.facility-warning-delete:hover {
  background: #f5eeee;
  color: #b91c1c;
}

.facility-auto-help {
  position: absolute;
  top: 14px;
  right: 4px;
  color: #0000ee;
  font-size: 14px;
  text-decoration: none;
}

.facility-auto-help:hover {
  text-decoration: underline;
}

.facility-auto-content {
  padding-top: 16px;
}

.facility-auto-selection {
  padding: 0 12px 12px;
  border-bottom: 1px solid #333;
}

.facility-auto-section-title {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.facility-auto-section-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.facility-auto-save-btn {
  width: 54px;
  height: 31px;
  border-radius: 2px;
}

.facility-auto-setting-table,
.facility-auto-action-table {
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-auto-setting-table {
  width: min(1188px, calc(100% - 500px));
  min-width: 900px;
}

.facility-auto-setting-table th,
.facility-auto-setting-table td,
.facility-auto-action-table th,
.facility-auto-action-table td {
  border: 1px solid #cfd7d7;
  padding: 7px 8px;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.facility-auto-setting-table th {
  width: 520px;
}

.facility-auto-setting-table td label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 10px;
}

.facility-auto-setting-table input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: #3478f6;
}

.facility-auto-sub-option {
  margin-top: 6px;
  color: #9a9a9a;
}

.facility-auto-sub-option input {
  width: 16px;
  height: 16px;
  accent-color: #3478f6;
}

.facility-auto-actions {
  padding: 12px 6px 0;
}

.facility-auto-add-btn {
  position: static;
  height: 31px;
  padding: 0 12px;
}

.facility-auto-action-table {
  width: 100%;
  min-width: 1320px;
  table-layout: fixed;
}

.facility-auto-action-table thead th {
  background: #f4f7f6;
}

.facility-auto-action-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-auto-action-table th:nth-child(1),
.facility-auto-action-table td:nth-child(1) {
  width: 7%;
}

.facility-auto-action-table th:nth-child(2),
.facility-auto-action-table td:nth-child(2) {
  width: 34%;
  white-space: normal;
}

.facility-auto-action-table th:nth-child(3),
.facility-auto-action-table td:nth-child(3) {
  width: 38%;
  white-space: normal;
}

.facility-auto-action-table th:nth-child(4),
.facility-auto-action-table td:nth-child(4) {
  width: 14%;
}

.facility-auto-action-table th:nth-child(5),
.facility-auto-action-table td:nth-child(5) {
  width: 90px;
  text-align: center;
}

.facility-auto-action-table .facility-row-edit {
  margin-right: 4px;
}

.facility-auto-action-name {
  line-height: 1.45;
}

.facility-auto-action-code {
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 2px;
}

.facility-auto-condition {
  line-height: 1.45;
}

.facility-document-content {
  padding-top: 10px;
}

.facility-document-list-section,
.facility-document-parameters {
  border-top: 1px solid #cfd7d7;
  background: #fff;
}

.facility-document-heading {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-bottom: 1px solid #cfd7d7;
}

.facility-document-heading h3,
.facility-document-parameters h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.facility-document-heading p,
.facility-document-parameters p {
  margin: 4px 0 0;
  color: #374151;
  font-size: 13px;
}

.facility-document-table-wrap {
  overflow-x: auto;
}

.facility-document-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
  background: #fff;
  font-size: 14px;
}

.facility-document-table th,
.facility-document-table td {
  min-height: 38px;
  padding: 8px 10px;
  border-bottom: 1px solid #d7dfdf;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.facility-document-table thead th {
  background: #f4f7f6;
  color: #111827;
}

.facility-document-table th:nth-child(1) {
  width: 28%;
}

.facility-document-table th:nth-child(2) {
  width: 34%;
}

.facility-document-table th:nth-child(3) {
  width: 10%;
}

.facility-document-table th:nth-child(4) {
  width: 18%;
}

.facility-document-file-link {
  display: inline;
  border: 0;
  background: transparent;
  color: #0b5a2a;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

.facility-document-table small {
  display: block;
  margin-top: 2px;
  color: #6b7280;
  font-size: 11px;
}

.facility-document-actions {
  width: 84px;
  white-space: nowrap;
  text-align: center !important;
}

.facility-document-empty {
  color: #6b7280;
  text-align: center !important;
}

.facility-document-parameters {
  margin-top: 14px;
  padding: 10px;
}

.facility-document-parameter-grid {
  margin-top: 10px;
  overflow-x: auto;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[type="number"] {
  -webkit-appearance: textfield;
  appearance: textfield;
}

.facility-document-parameter-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-document-parameter-table th,
.facility-document-parameter-table td {
  height: 36px;
  padding: 7px 8px;
  border: 1px solid #cfd7d7;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.facility-document-parameter-table th {
  background: #f4f7f6;
  color: #111827;
}

.facility-document-parameter-table th:nth-child(1) {
  width: 26%;
}

.facility-document-parameter-table th:nth-child(2) {
  width: 32%;
}

.facility-document-parameter-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-document-parameter-copy {
  width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #111827;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.facility-document-parameter-copy:hover {
  background: #e8f3ec;
}

.facility-document-parameter-copy code {
  color: #111827;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.facility-document-parameter-copy i {
  color: #0b5a2a;
  font-size: 13px;
}

.facility-register-dialog.facility-document-template-dialog {
  width: min(720px, calc(100vw - 80px));
}

.facility-document-file-pick {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.facility-document-file-pick small {
  color: #6b7280;
  font-size: 12px;
}

.facility-register-dialog.patient-document-create-dialog {
  width: min(860px, calc(100vw - 80px));
}

.patient-document-create-body {
  padding: 12px;
  background: #f7f9f9;
  max-height: min(660px, calc(100vh - 180px));
  overflow-y: auto;
}

.patient-document-create-patient {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #d7dfdf;
  background: #fff;
  color: #111827;
  font-weight: 700;
}

.patient-document-create-warning {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #f3c24f;
  background: #fff8e1;
  color: #6b4d00;
  font-size: 12px;
}

.patient-document-create-warning.hidden {
  display: none;
}

.patient-document-source-map {
  margin-top: 8px;
  border: 1px solid #cfd7d7;
  background: #fff;
}

.patient-document-source-title {
  padding: 6px 9px;
  border-bottom: 1px solid #d9e0e0;
  background: #eef4f2;
  color: #0b5a2a;
  font-size: 12px;
  font-weight: 700;
}

.patient-document-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.patient-document-source-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  min-height: 48px;
  padding: 7px 9px;
  border-right: 1px solid #e2e7e7;
  border-bottom: 1px solid #e2e7e7;
}

.patient-document-source-row:nth-child(2n) {
  border-right: 0;
}

.patient-document-source-row strong {
  display: block;
  color: #111827;
  font-size: 12px;
}

.patient-document-source-row small {
  display: block;
  color: #60706a;
  font-size: 11px;
}

.patient-document-source-row p {
  display: -webkit-box;
  max-height: 34px;
  margin: 2px 0 0;
  overflow: hidden;
  color: #263238;
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.patient-document-source-badge {
  align-self: start;
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 2px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 700;
}

.patient-document-source-badge.manual {
  background: #fff3cd;
  color: #7a4d00;
}

.patient-document-source-badge.template {
  background: #e7e5e4;
  color: #44403c;
}

.patient-document-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-top: 12px;
}

.patient-document-create-grid label,
.patient-document-create-field {
  display: grid;
  gap: 4px;
  color: #111827;
  font-size: 13px;
}

.patient-document-create-field {
  margin-top: 10px;
}

.patient-document-create-grid span,
.patient-document-create-field span {
  font-weight: 700;
}

.patient-document-create-grid input,
.patient-document-create-field input,
.patient-document-create-field textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cfd7d7;
  border-radius: 2px;
  padding: 6px 8px;
  background: #fff;
  color: #111827;
  font-family: inherit;
  font-size: 13px;
}

.patient-document-create-field textarea {
  resize: vertical;
}

.patient-document-template-dropdown {
  position: fixed;
  z-index: 100000;
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: min(520px, calc(100vh - 120px));
  overflow-y: auto;
  padding: 6px 0;
  border: 1px solid #c8d0d0;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.22);
}

.patient-document-template-dropdown.hidden {
  display: none;
}

.patient-document-template-menu-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 31px;
  padding: 5px 14px;
  border: 0;
  background: transparent;
  color: #111827;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}

.patient-document-template-menu-item small {
  color: #6b7280;
  font-size: 11px;
}

.patient-document-template-menu-item:hover {
  background: #eef7ef;
}

.patient-document-template-section-title {
  padding: 7px 14px 3px;
  color: #0b5a2a;
  font-size: 12px;
  font-weight: 700;
}

.patient-document-template-empty {
  padding: 12px 14px;
  color: #6b7280;
  font-size: 12px;
}

.patient-document-template-separator {
  height: 1px;
  margin: 6px 0;
  background: #d7dfdf;
}

.facility-register-dialog.patient-document-template-doctor-dialog {
  width: min(560px, calc(100vw - 80px));
}

.patient-document-template-selected {
  padding: 8px 10px;
  border: 1px solid #d7dfdf;
  background: #fff;
  color: #111827;
  font-weight: 700;
}

.facility-register-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  color: #111827;
  font-size: 13px;
}

@media (max-width: 760px) {
  .patient-document-source-grid {
    grid-template-columns: 1fr;
  }

  .patient-document-source-row {
    border-right: 0;
  }
}

.facility-row-edit,
.facility-row-copy,
.facility-row-delete,
.facility-history-btn {
  height: 28px;
  border: 1px solid #c8cece;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-family: inherit;
  cursor: pointer;
}

.facility-row-edit {
  width: 28px;
}

.facility-row-delete {
  width: 28px;
  color: #d93025;
}

.facility-row-copy {
  min-width: 58px;
  padding: 0 8px;
}

.facility-master-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.facility-master-empty {
  height: 48px;
  color: #6c757d;
  text-align: center !important;
}

.facility-master-amount {
  text-align: right !important;
}

.facility-master-extra-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.facility-master-extra-fields.hidden {
  display: none;
}

.facility-master-extra-fields .facility-register-row {
  margin: 0;
}

.facility-master-extra-fields .facility-register-row input {
  width: 100%;
}

#facility-master-register-modal {
  z-index: 3220;
}

.facility-master-list-modal {
  z-index: 3120;
}

.facility-master-list-dialog {
  width: min(1024px, calc(100vw - 180px));
  max-height: min(82vh, 860px);
  display: grid;
  grid-template-rows: 42px 44px minmax(0, 1fr);
  background: #f8f9f9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.facility-master-list-dialog.facility-master-list-dialog-no-toolbar {
  grid-template-rows: 42px minmax(0, 1fr);
}

.facility-master-list-dialog[data-master-type="departments"],
.facility-master-list-dialog[data-master-type="comments"] {
  width: min(1024px, calc(100vw - 240px));
}

.facility-master-list-dialog[data-master-type="materials"],
.facility-master-list-dialog[data-master-type="self_pay"] {
  width: min(1024px, calc(100vw - 130px));
}

.facility-master-list-header {
  padding-left: 16px;
}

.facility-master-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
  padding: 5px 8px;
  border-bottom: 1px solid #cfd7d7;
  background: #f8f9f9;
}

.facility-master-modal-new,
.facility-master-modal-copy-btn,
.facility-master-modal-icon-btn {
  min-height: 31px;
  border: 1px solid #c8cece;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.facility-master-modal-new {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
}

.facility-master-modal-copy-btn {
  min-width: 68px;
  padding: 0 10px;
  white-space: nowrap;
}

.facility-master-modal-icon-btn {
  width: 31px;
  padding: 0;
}

.facility-master-list-table-wrap {
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.facility-master-list-table {
  width: 100%;
  min-width: 930px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.facility-master-list-dialog[data-master-type="materials"] .facility-master-list-table,
.facility-master-list-dialog[data-master-type="self_pay"] .facility-master-list-table {
  min-width: 1000px;
}

.facility-master-list-table th,
.facility-master-list-table td {
  height: 36px;
  border: 1px solid #cfd7d7;
  padding: 6px 8px;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.facility-master-list-table th {
  background: #f4f7f6;
  white-space: nowrap;
}

.facility-master-list-table tbody tr:nth-child(even) td {
  background: #f4f6f5;
}

.facility-master-modal-action-head,
.facility-master-modal-action-cell {
  width: 46px;
  min-width: 46px;
  text-align: center !important;
  white-space: nowrap;
}

.facility-master-list-dialog[data-master-type="departments"] .facility-master-modal-action-cell:last-child,
.facility-master-list-dialog[data-master-type="materials"] .facility-master-modal-action-cell:last-child,
.facility-master-list-dialog[data-master-type="self_pay"] .facility-master-modal-action-cell:last-child {
  width: 78px;
  min-width: 78px;
}

.facility-history-btn {
  padding: 0 10px;
  white-space: nowrap;
}

.karte-set-register-modal {
  z-index: 3200;
}

.karte-set-register-dialog {
  width: min(1024px, calc(100vw - 120px));
  background: #f8f9f9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.karte-set-register-header {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  background: #0b4d12;
  color: #fff;
}

.karte-set-register-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.karte-set-register-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 18px;
}

.karte-set-register-help,
.karte-set-register-close {
  border: 0;
  background: transparent;
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.karte-set-register-help {
  font-size: 18px;
}

.karte-set-register-close {
  font-size: 30px;
}

.karte-set-register-body {
  background: #f7f9f9;
}

.karte-set-register-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: center;
  padding: 4px 6px 4px 10px;
  border-bottom: 1px solid #d8e0dd;
  color: #111827;
  font-size: 14px;
}

.karte-set-register-row > span {
  align-self: center;
}

.karte-set-register-row input[type="text"],
.karte-set-register-row select {
  width: 100%;
  height: 31px;
  border: 1px solid #cbd5d1;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.karte-set-register-row input[type="text"]:focus,
.karte-set-register-row select:focus {
  outline: 2px solid #2aa7df;
  border-color: #2aa7df;
}

.karte-set-register-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 6px;
}

.karte-set-register-plus {
  width: 32px;
  height: 31px;
  border: 1px solid #cbd5d1;
  border-radius: 3px;
  background: #fff;
  color: #1f2a30;
  font-size: 26px;
  line-height: 26px;
  cursor: pointer;
}

.karte-set-register-diagnosis-title {
  grid-template-columns: minmax(0, 1fr) 32px;
}

.karte-set-register-diagnosis-list {
  min-height: 47px;
  padding: 0;
  border-bottom: 1px solid #d8e0dd;
  background: #fff;
}

.karte-set-register-empty {
  padding: 14px 14px;
  color: #111827;
  font-size: 14px;
}

.karte-set-register-diagnosis-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid #eef2f0;
}

.karte-set-register-diagnosis-item span {
  flex: 1 1 auto;
  min-width: 0;
}

.karte-set-register-diagnosis-item em {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 3px;
  background: #e8f3ec;
  color: #11602c;
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.karte-set-register-mini-btn {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #244333;
  cursor: pointer;
}

.karte-set-register-mini-btn:hover {
  background: #e8f3ec;
}

.karte-set-register-mini-btn.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

.karte-set-folder-modal,
.karte-set-edit-modal,
.karte-set-diagnosis-add-modal {
  z-index: 3400;
}

.karte-set-small-dialog {
  width: min(720px, calc(100vw - 120px));
  background: #f8f9f9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.karte-set-diagnosis-dialog {
  width: min(720px, calc(100vw - 120px));
  max-height: min(760px, calc(100vh - 90px));
  display: flex;
  flex-direction: column;
  background: #f8f9f9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.karte-set-diagnosis-body {
  padding: 10px;
  overflow: hidden;
}

.karte-set-diagnosis-search {
  width: 100%;
  height: 32px;
  margin-bottom: 8px;
  border: 1px solid #2aa7df;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font-size: 14px;
}

.karte-set-diagnosis-results {
  max-height: min(610px, calc(100vh - 190px));
  overflow-y: auto;
  border: 1px solid #d8e0dd;
  background: #fff;
}

.karte-set-diagnosis-result-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid #eef2f0;
  color: #111827;
  font-size: 13px;
}

.karte-set-diagnosis-result-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.karte-set-diagnosis-result-actions {
  display: inline-flex;
  gap: 4px;
}

.karte-set-diagnosis-result-actions button {
  min-width: 44px;
  height: 26px;
  border: 1px solid #cbd5d1;
  border-radius: 3px;
  background: #fff;
  color: #1f2a30;
  cursor: pointer;
}

.karte-set-diagnosis-result-actions button:hover {
  border-color: #0b5a2a;
  background: #e8f3ec;
}

.karte-set-register-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f7f9f9;
}

.facility-register-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.48);
}

.facility-register-dialog {
  width: 600px;
  background: #f8f9f9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.facility-master-register-dialog[data-master-type="self_pay"] {
  width: min(620px, calc(100vw - 32px));
}

.facility-master-register-dialog[data-master-type="doctors"] .facility-register-body {
  display: flex;
  flex-direction: column;
}

.facility-master-register-dialog[data-master-type="doctors"] .facility-master-extra-fields {
  display: contents;
}

.facility-master-register-dialog[data-master-type="doctors"] [data-facility-master-row="code"] {
  order: 1;
}

.facility-master-register-dialog[data-master-type="doctors"] #facility-master-name-row {
  order: 2;
}

.facility-master-register-dialog[data-master-type="doctors"] [data-facility-master-row="expiry_date"] {
  order: 3;
}

.facility-accident-dialog {
  width: 600px;
}

.facility-shared-password-dialog {
  width: 520px;
}

.facility-data-submit-dialog {
  width: 600px;
}

.facility-data-submit-modal-body {
  padding: 8px 6px 0;
}

.facility-data-submit-code-edit-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: 139px 200px minmax(0, 1fr);
  align-items: center;
  column-gap: 7px;
  font-size: 14px;
}

.facility-data-submit-code-edit-row input {
  width: 100%;
  height: 29px;
  padding: 3px 8px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}

.facility-data-submit-modal-body h4 {
  margin: 4px 0 7px;
  font-size: 14px;
  font-weight: 400;
}

.facility-data-submit-edit-table th:nth-child(1) { width: 27%; }
.facility-data-submit-edit-table th:nth-child(2) { width: 37%; }
.facility-data-submit-edit-table th:nth-child(3) { width: 36%; }

.facility-data-submit-edit-table td {
  height: 43px;
  padding: 5px 7px;
}

.facility-data-submit-edit-table select {
  width: 100%;
  height: 31px;
  padding: 2px 7px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-family: inherit;
  font-size: 14px;
}

.facility-data-submit-dialog .facility-register-footer {
  padding-top: 7px;
  padding-bottom: 7px;
}

.facility-certificate-register-dialog {
  width: 590px;
}

.facility-certificate-register-body {
  padding: 13px 12px 10px;
}

.facility-certificate-register-body > p:first-child {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.55;
}

.facility-certificate-register-note {
  margin: 8px 0 0 183px;
  color: #555;
  font-size: 12px;
  line-height: 1.5;
}

.facility-certificate-register-footer {
  gap: 8px;
}

.facility-register-header {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: #0b4d12;
  color: #fff;
}

.facility-register-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.facility-register-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.facility-register-body {
  padding: 8px 6px 8px;
  border-bottom: 1px solid #cfd7d7;
}

.facility-register-row {
  min-height: 39px;
  display: grid;
  grid-template-columns: 135px 42px minmax(0, 1fr);
  align-items: center;
  column-gap: 6px;
  font-size: 14px;
}

.facility-accident-edit-row {
  grid-template-columns: 300px 0 minmax(0, 1fr);
}

.facility-shared-password-edit-row {
  grid-template-columns: 120px 42px minmax(0, 1fr);
}

.facility-shared-password-modal-body {
  padding: 14px 12px 10px;
}

.facility-shared-password-modal-body p {
  margin: 7px 0 0 168px;
  color: #555;
  font-size: 12px;
}

.facility-accident-edit-options {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
}

.facility-accident-edit-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.facility-accident-edit-options input {
  width: 17px;
  height: 17px;
  accent-color: #3478f6;
}

.facility-register-row em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  color: #fff;
  background: #e46f60;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.facility-register-row em:empty {
  background: transparent;
}

.facility-register-row input[type="text"],
.facility-register-row input[type="email"],
.facility-register-row input[type="number"],
.facility-register-row input[type="date"] {
  height: 27px;
  width: 100%;
  padding: 3px 8px;
  border: 1px solid #cfd7d7;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
}

.facility-register-row input[readonly] {
  background: #edf2f0;
  color: #374151;
  cursor: not-allowed;
}

.facility-radio-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.facility-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.facility-radio-group input {
  width: 16px;
  height: 16px;
  accent-color: #3478f6;
}

.facility-register-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 10px;
  background: #f8f9f9;
}

.facility-save-btn {
  width: 90px;
  border-radius: 2px;
  font-size: 15px;
}

.facility-save-btn:disabled {
  cursor: wait;
  opacity: .58;
}

.facility-user-dialog-header {
  padding-right: 0;
}

.facility-user-dialog-header .facility-register-close {
  align-self: stretch;
  width: 49px;
  border-left: 2px solid #13b8ca;
  background: #164b2f;
  font-size: 28px;
  font-weight: 700;
}

.facility-user-edit-body {
  padding: 0 6px;
}

.facility-user-static-value {
  min-width: 0;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facility-user-password-row,
.facility-user-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.facility-user-password-reset,
.facility-user-status-toggle {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #cfd7d7;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.facility-user-status-toggle.is-danger {
  border-color: #edc9c4;
  background: #fff3f1;
  color: #d63d32;
}

.facility-user-status-toggle.is-success {
  border-color: #acd5b1;
  background: #f0faf2;
  color: #0b4d12;
}

.facility-user-history-dialog {
  width: 600px;
}

.facility-user-history-body {
  padding-bottom: 6px;
  background: #f8f9f9;
}

.facility-user-history-body h4 {
  height: 30px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 7px;
  font-size: 16px;
  font-weight: 400;
}

.facility-user-history-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-size: 14px;
}

.facility-user-history-table th,
.facility-user-history-table td {
  height: 36px;
  padding: 5px 7px;
  border: 1px solid #cfd7d7;
  text-align: left;
  font-weight: 400;
}

.facility-user-history-table th:nth-child(1),
.facility-user-history-table td:nth-child(1) {
  width: 50%;
}

.facility-user-history-table th:nth-child(2),
.facility-user-history-table td:nth-child(2) {
  width: 15%;
}

.facility-user-history-table th:nth-child(3),
.facility-user-history-table td:nth-child(3) {
  width: 35%;
}

.facility-password-history-table th:nth-child(1),
.facility-password-history-table td:nth-child(1) {
  width: 54%;
}

.facility-password-history-table th:nth-child(2),
.facility-password-history-table td:nth-child(2) {
  width: 46%;
}

/* ====================================
   施設管理モーダル
   ==================================== */
.modal-facility .modal-content {
  max-width: 700px;
  max-height: 85vh;
}

.modal-facility .modal-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.facility-tabs {
  display: flex;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.facility-tab {
  padding: 12px 24px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.facility-tab:hover {
  color: var(--gray-800);
  background: var(--gray-100);
}

.facility-tab.active {
  color: var(--primary);
  background: white;
}

.facility-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.facility-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.facility-pane {
  display: none;
}

.facility-pane.active {
  display: block;
}

/* 施設基本情報 */
.facility-form {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px 16px;
  align-items: center;
}

.facility-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  text-align: right;
}

.facility-form input,
.facility-form select,
.facility-form textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.facility-form input:focus,
.facility-form select:focus,
.facility-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.15);
}

.facility-form textarea {
  resize: vertical;
  min-height: 80px;
}

/* 診療科・スタッフ一覧 */
.facility-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.facility-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.facility-list-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.facility-list-header .btn-add {
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.facility-list-header .btn-add:hover {
  background: var(--primary-dark);
}

.facility-list-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.facility-list-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 4px;
  gap: 12px;
}

.facility-list-item .item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
}

.facility-list-item .item-info {
  font-size: 12px;
  color: var(--gray-500);
}

.facility-list-item .item-actions {
  display: flex;
  gap: 4px;
}

.facility-list-item .item-actions button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reception-edit-history-modal,
.reception-edit-history-detail-modal {
  z-index: 4200;
}

.reception-edit-history-detail-modal {
  z-index: 4300;
}

.reception-edit-history-dialog {
  width: min(1280px, calc(100vw - 48px));
  height: min(720px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.reception-edit-history-detail-dialog {
  width: min(1120px, calc(100vw - 64px));
  height: min(620px, calc(100vh - 64px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
}

.reception-edit-history-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f8faf9;
  border-bottom: 1px solid #cfdad3;
}

.reception-edit-history-nav-btn,
.reception-edit-history-refresh,
.reception-edit-history-detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #c8d4cc;
  border-radius: 3px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}

.reception-edit-history-nav-btn:hover,
.reception-edit-history-refresh:hover,
.reception-edit-history-detail-btn:hover {
  background: #eef7f0;
  border-color: var(--primary);
}

.reception-edit-history-date {
  min-width: 128px;
  padding: 5px 10px;
  border: 1px solid #c8d4cc;
  background: #fff;
  color: #0f3f1a;
  font-weight: 700;
  text-align: center;
}

.reception-edit-history-note {
  margin-left: auto;
  color: #647067;
  font-size: 12px;
}

.reception-edit-history-table-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
}

.reception-edit-history-table-wrap.detail {
  max-height: 330px;
  border-top: 1px solid #d8e0dc;
}

.reception-edit-history-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.reception-edit-history-detail-table {
  min-width: 900px;
}

.reception-edit-history-table th,
.reception-edit-history-table td {
  padding: 6px 7px;
  border-right: 1px solid #d8e0dc;
  border-bottom: 1px solid #d8e0dc;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reception-edit-history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f6f3;
  color: #123c20;
  font-weight: 700;
  white-space: nowrap;
}

.reception-edit-history-table tr.is-cancelled {
  background: #fff7f7;
}

.reception-edit-history-table th:nth-child(1),
.reception-edit-history-table td:nth-child(1) { width: 44px; text-align: center; }
.reception-edit-history-table th:nth-child(2),
.reception-edit-history-table td:nth-child(2) { width: 44px; text-align: center; }
.reception-edit-history-table th:nth-child(3),
.reception-edit-history-table td:nth-child(3) { width: 58px; text-align: center; }
.reception-edit-history-table th:nth-child(4),
.reception-edit-history-table td:nth-child(4) { width: 82px; text-align: center; }
.reception-edit-history-table th:nth-child(5),
.reception-edit-history-table td:nth-child(5) { width: 82px; }
.reception-edit-history-table th:nth-child(6),
.reception-edit-history-table td:nth-child(6) { width: 150px; }
.reception-edit-history-table th:nth-child(7),
.reception-edit-history-table td:nth-child(7) { width: 46px; text-align: center; }
.reception-edit-history-table th:nth-child(8),
.reception-edit-history-table td:nth-child(8) { width: 120px; }
.reception-edit-history-table th:nth-child(9),
.reception-edit-history-table td:nth-child(9) { width: 90px; }
.reception-edit-history-table th:nth-child(10),
.reception-edit-history-table td:nth-child(10) { width: 90px; }
.reception-edit-history-table th:nth-child(11),
.reception-edit-history-table td:nth-child(11) { width: 150px; }
.reception-edit-history-table th:nth-child(12),
.reception-edit-history-table td:nth-child(12) { width: 130px; }
.reception-edit-history-table th:nth-child(13),
.reception-edit-history-table td:nth-child(13) { width: 140px; }
.reception-edit-history-table th:nth-child(14),
.reception-edit-history-table td:nth-child(14) { width: 70px; text-align: center; }

.reception-edit-history-detail-table th:nth-child(1),
.reception-edit-history-detail-table td:nth-child(1) { width: 150px; text-align: left; }
.reception-edit-history-detail-table th:nth-child(2),
.reception-edit-history-detail-table td:nth-child(2) { width: 110px; text-align: left; }
.reception-edit-history-detail-table th:nth-child(3),
.reception-edit-history-detail-table td:nth-child(3) { width: 220px; text-align: left; }
.reception-edit-history-detail-table th:nth-child(4),
.reception-edit-history-detail-table td:nth-child(4) { width: 210px; text-align: left; }
.reception-edit-history-detail-table th:nth-child(5),
.reception-edit-history-detail-table td:nth-child(5) { width: 210px; text-align: left; }

.reception-edit-history-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 20px;
  padding: 0 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.reception-edit-history-kana,
.reception-edit-history-name,
.reception-edit-history-sub {
  display: block;
}

.reception-edit-history-kana,
.reception-edit-history-sub {
  color: #68736c;
  font-size: 11px;
  line-height: 1.35;
}

.reception-edit-history-name {
  color: #0f172a;
  font-weight: 600;
}

.reception-edit-history-memo {
  white-space: nowrap;
}

.reception-edit-history-empty {
  padding: 18px;
  color: #647067;
  text-align: center;
}

.reception-edit-history-empty.error {
  color: #b42318;
}

.reception-edit-history-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 18px;
  background: #fff;
}

.reception-edit-history-detail-section + .reception-edit-history-detail-section {
  margin-top: 14px;
}

.reception-edit-history-detail-heading {
  margin-bottom: 6px;
  color: #103d1c;
  font-size: 13px;
  font-weight: 700;
}

.reception-edit-history-summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.reception-edit-history-summary-table th,
.reception-edit-history-summary-table td {
  padding: 7px 8px;
  border: 1px solid #d8e0dc;
  vertical-align: middle;
}

.reception-edit-history-summary-table th {
  width: 86px;
  background: #f1f6f3;
  color: #123c20;
  text-align: left;
}

.facility-list-item .item-actions button:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.facility-list-item .item-actions button.delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* 施設モーダルフッター */
.facility-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

.facility-footer button {
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.facility-footer .btn-cancel {
  background: white;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.facility-footer .btn-cancel:hover {
  background: var(--gray-100);
}

.facility-footer .btn-save {
  background: var(--primary);
  border: none;
  color: white;
}

.facility-footer .btn-save:hover {
  background: var(--primary-dark);
}

/* ====================================
   カルテ日付表示
   ==================================== */
.m3-karte-date {
  cursor: default;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ====================================
   オーダーゾーン 薬剤リスト
   ==================================== */
.m3-drug-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.m3-drug-category {
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.m3-drug-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--gray-50);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  transition: background-color 0.2s;
}

.m3-drug-category-header:hover {
  background: var(--gray-100);
}

.m3-drug-category-header i {
  font-size: 10px;
  color: var(--gray-500);
  transition: transform 0.2s;
}

.m3-drug-count {
  font-size: 11px;
  font-weight: normal;
  color: var(--gray-500);
  margin-left: auto;
}

.m3-drug-category-items {
  display: flex;
  flex-direction: column;
}

.m3-drug-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background-color 0.15s;
}

.m3-drug-item.frequent {
  background: #f7fff8;
}

.m3-drug-item:last-child {
  border-bottom: none;
}

.m3-drug-item:hover {
  background: #e8f5e9;
}

.m3-drug-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4caf50;
  color: white;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.m3-drug-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m3-drug-name {
  font-size: 12px;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m3-drug-default {
  font-size: 11px;
  color: var(--gray-600);
  line-height: 1.35;
}

/* ====================================
   M3 dense visual polish
   ==================================== */
.main-screen {
  background: #eef3f1;
  color: #111827;
  font-size: 12px;
  line-height: 1.35;
}

.app-header {
  height: 46px;
  padding: 0 6px;
  background: #fbfcf8;
  border-bottom: 1px solid #b8cac5;
  box-shadow: none;
  color: #111827;
}

.header-left,
.header-right {
  gap: 8px;
  min-width: 0;
}

.btn-back {
  width: 28px;
  height: 40px;
  background: transparent;
  color: #2f6f3f;
  border-radius: 0;
  font-size: 24px;
}

.btn-back:hover {
  background: #eaf4ec;
  color: #14532d;
}

.header-patient-info {
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  color: #111827;
}

.patient-id-text {
  font-size: 17px;
  font-weight: 500;
  color: #111827;
}

.patient-name {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  color: #111827;
}

.patient-kana,
.patient-age {
  font-size: 16px;
  color: #111827;
  letter-spacing: 0;
}

.patient-gender-badge {
  width: 20px;
  height: 22px;
  padding: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.patient-gender-badge.female {
  background: #d33d4b;
}

.patient-gender-badge.male {
  background: #0f6b3a;
}

.patient-calendar-icon,
.icon-btn,
.icon-btn-sm {
  color: #0b5a2a;
}

.header-icons-left,
.header-icons {
  gap: 1px;
}

.icon-btn,
.icon-btn-sm {
  width: 27px;
  height: 30px;
  border-radius: 0;
  font-size: 16px;
}

.icon-btn-sm:hover,
.icon-btn:hover {
  background: #e8f2ec;
}

.icon-btn-sm .badge {
  top: 1px;
  right: 0;
  background: #c72835;
  border-radius: 50%;
  min-width: 14px;
  height: 14px;
  padding: 0;
  line-height: 14px;
}

.header-alert-note {
  min-width: 220px;
  max-width: 420px;
  padding-left: 8px;
  margin-left: 4px;
  border-left: 1px solid #cfdbd7;
  color: #1f2937;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-btn {
  height: 32px;
  padding: 0 8px;
  background: transparent;
  color: #0b5a2a;
  border: none;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
}

.user-dropdown-btn:hover {
  background: #e8f2ec;
}

.m3-common-header,
.m3-sub-header,
.m3-karte-body {
  background: #c8d5d1;
  gap: 1px;
}

.m3-common-header {
  min-height: 62px;
  border-bottom: 1px solid #b9c9c4;
}

.m3-sub-header {
  height: 30px;
  border-bottom: 1px solid #b9c9c4;
}

.m3-panel-left,
.m3-header-zone-patient,
.m3-subheader-patient {
  flex: 0 0 clamp(400px, 29vw, 560px) !important;
  min-width: 0;
}

.m3-zone-karte-wrapper,
.m3-header-zone-karte,
.m3-subheader-karte {
  flex: 1 1 auto !important;
  min-width: 420px;
}

.m3-panel-right,
.m3-header-zone-order,
.m3-subheader-order {
  flex: 0 0 clamp(300px, 20vw, 390px) !important;
  min-width: 0;
}

.m3-header-zone,
.m3-subheader-zone,
.m3-panel,
.m3-zone-karte-wrapper {
  background: #fff;
  border-right: none;
}

.m3-panel-tabs-wrapper {
  background: #f7faf8;
}

.m3-panel-tabs-row {
  height: 31px;
  border-bottom: 1px solid #cbd9d5;
}

.m3-panel-tabs-row .m3-panel-tab {
  padding: 4px 5px;
  background: #f9fbfa;
  border-right: 1px solid #cbd9d5;
  color: #17241c;
  font-size: 13px;
  font-weight: 400;
}

.m3-panel-tabs-row .m3-panel-tab:hover {
  background: #edf5ef;
}

.m3-panel-tabs-row .m3-panel-tab.active {
  background: #0f6b3a !important;
  color: #fff !important;
  border-color: #0f6b3a !important;
  font-weight: 600 !important;
}

.m3-order-header-wrap .m3-panel-tabs-wrapper {
  min-width: 0;
}

.m3-all-btn-wrap {
  padding: 0 6px;
  border-left: 1px solid #cbd9d5;
}

.m3-all-btn,
.m3-all-btn-wrap .m3-all-btn {
  height: 28px;
  padding: 0 10px;
  border-color: #cbd9d5;
  border-radius: 0;
  font-size: 12px;
}

.m3-header-zone-karte {
  padding: 3px 8px;
  justify-content: flex-start;
}

.m3-karte-header-row1 {
  height: 28px;
  padding: 0;
  margin: 0;
  border-bottom: 1px solid #cbd9d5;
  gap: 6px;
}

.m3-karte-header-row2 {
  height: 28px;
  gap: 10px;
  font-size: 13px;
  color: #111827;
}

.m3-karte-date {
  padding: 3px 10px;
  border-color: #0f6b3a;
  border-radius: 0;
  color: #0f6b3a;
  font-size: 14px;
}

.m3-karte-tag {
  padding: 3px 12px;
  background: #0f6b3a;
  border-radius: 0;
  font-size: 13px;
}

.m3-karte-header-row1,
.m3-karte-header-row2 {
  width: 100%;
  justify-content: space-between;
}

.m3-karte-tabs-left,
.m3-karte-header-actions,
.m3-karte-context-left,
.m3-karte-context-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.m3-karte-tabs-left {
  gap: 0;
  flex: 1;
}

.m3-karte-tab-list {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.m3-karte-tab-item {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  height: 26px;
  margin-left: 5px;
  padding: 0;
  border: 0;
  background: #e8eeeb;
  color: #142018;
  cursor: pointer;
}

.m3-karte-tab-item .m3-karte-tag {
  margin-left: 0;
  background: transparent;
  color: inherit;
}

.m3-karte-tab-item.active {
  background: #0f5b18;
  color: #fff;
}

.m3-karte-tab-item:not(.active):hover {
  background: #dbe5df;
}

.m3-karte-tab-item .m3-tag-close {
  background: transparent;
  color: inherit;
}

.m3-karte-header-actions,
.m3-karte-context-right {
  gap: 6px;
  margin-left: 10px;
  flex-shrink: 0;
}

.m3-karte-context-left {
  gap: 14px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.m3-karte-date {
  height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #0f6b3a;
  background: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.m3-karte-tag {
  height: 26px;
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  color: #fff;
  white-space: nowrap;
}

#karte-insurance-tab {
  position: relative;
  padding-left: 20px;
}

#karte-insurance-tab::before {
  content: '*';
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  visibility: hidden;
}

#karte-insurance-tab.is-unsaved::before {
  visibility: visible;
}

.m3-tag-close,
.m3-tag-add,
.m3-karte-icon-action {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 13px;
}

/* Keep the close action visually inside the selected insurance tab. */
.m3-tag-close {
  width: 22px;
  background: #0f6b3a;
  color: #fff;
}

.m3-tag-add {
  border-left: 1px solid #cbd9d5;
  font-size: 16px;
}

.m3-tag-add:hover,
.m3-karte-icon-action:hover {
  background: #edf5ef;
  color: #0f6b3a;
}

.m3-tag-close:hover {
  background: #0b512d;
  color: #fff;
}

.m3-karte-icon-action {
  color: #0b5a2a;
}

.m3-karte-header-btn {
  height: 26px;
  padding: 0 9px;
  border: 1px solid #cbd9d5;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.m3-karte-header-btn:hover {
  background: #edf5ef;
}

.m3-header-value {
  font-size: 14px;
  color: #111827;
  font-weight: 400;
}

.m3-header-value.dept {
  color: #111827;
  font-weight: 400;
}

.m3-header-value.doctor {
  overflow: hidden;
  text-overflow: ellipsis;
}

.m3-header-value.insurance {
  padding: 0;
  background: transparent;
  color: #111827;
  border-radius: 0;
}

.m3-header-value.public-expense {
  padding: 0;
  background: transparent;
  color: #111827;
  border-radius: 0;
}

.m3-header-status {
  color: #111827;
  font-weight: 400;
}

.m3-claim-select {
  width: 158px;
  flex-shrink: 0;
  height: 26px;
  padding: 0 24px 0 8px;
  border: 1px solid #cbd9d5;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-family: inherit;
}

.m3-subheader-zone {
  padding: 0 6px;
  border-right: none;
  background: #fbfcfb;
}

.m3-subheader-karte-inner,
.m3-subheader-soap-part,
.m3-subheader-proc-part {
  background: #fbfcfb;
}

.m3-subheader-soap-part,
.m3-subheader-proc-part {
  padding: 0 7px;
  border-right: 1px solid #cbd9d5;
  justify-content: space-between;
  min-width: 0;
}

.m3-subheader-proc-part {
  border-right: none;
}

.m3-subheader-toolset {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.m3-subheader-title {
  flex-shrink: 0;
  white-space: nowrap;
}

.m3-subheader-soap-part .m3-subheader-toolset {
  gap: 3px;
  overflow: hidden;
}

.m3-subheader-search {
  height: 24px;
  padding: 2px 6px;
  border: 1px solid #cbd9d5;
  border-radius: 0;
  background: #fff;
  font-size: 13px;
}

.m3-subheader-search:focus {
  outline: 1px solid #0d8fd6;
  border-color: #0d8fd6;
}

.m3-icon-btn,
.m3-icon-btn-sm,
.m3-tool-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  color: #0b5a2a;
}

.m3-icon-btn:hover,
.m3-icon-btn-sm:hover,
.m3-tool-btn:hover {
  background: #e8f2ec;
}

.m3-history-date-bar,
.m3-doctor-info-bar,
.m3-soap-header,
.m3-procedure-header,
.m3-soap-footer,
.m3-order-footer {
  background: #fbfcfb;
  border-color: #cbd9d5;
}

.m3-history-date-bar {
  height: 36px;
  padding: 4px 7px;
}

.m3-history-date {
  font-size: 14px;
  color: #111827;
}

.m3-history-tag {
  background: #0f6b3a;
  border-radius: 0;
  font-size: 13px;
}

.m3-history-columns,
.m3-history-col-left,
.m3-history-col-right {
  background: #fff;
}

.m3-history-col-left,
.m3-subheader-soap-part {
  border-color: #cbd9d5;
}

.m3-history-col-body {
  padding: 7px;
  font-size: 13px;
  line-height: 1.55;
}

.m3-history-item {
  min-height: 26px;
  padding: 3px 6px;
  gap: 6px;
  border-bottom: 1px solid #dbe5e1;
  font-size: 13px;
}

.m3-item-icon,
.m3-proc-icon {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: #2e8b44;
  font-size: 11px;
}

.m3-soap-editor {
  padding: 10px;
  font-size: 13px;
  line-height: 1.6;
  background: #fff;
}

.m3-procedure-list {
  padding: 0;
  background: #fff;
}

.m3-proc-item {
  min-height: 31px;
  padding: 5px 8px;
  border-bottom: 1px solid #dbe5e1;
  font-size: 13px;
}

.m3-panel-right .m3-panel-content {
  padding: 0;
  background: #fff;
}

.m3-order-list,
.m3-drug-list {
  border-top: 1px solid #dbe5e1;
}

.m3-order-item,
.m3-drug-item {
  min-height: 32px;
  padding: 6px 8px;
  gap: 7px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
}

.procedure-group-suggestion-item {
  display: block;
  align-items: flex-start;
  width: 100%;
  min-height: 48px;
  padding: 6px 8px 7px 4px;
  border: 0;
  border-bottom: 1px solid #dbe5e1;
  background: #f8fbfa;
  color: #111827;
  text-align: left;
  cursor: pointer;
}

.procedure-group-suggestion-item:hover {
  background: #e8f5e9;
}

.procedure-group-suggestion-text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.procedure-group-suggestion-lines {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.procedure-group-suggestion-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.procedure-group-suggestion-main {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: flex-start;
  gap: 5px;
}

.procedure-group-suggestion-name,
.procedure-group-suggestion-subline,
.procedure-group-suggestion-dose,
.procedure-group-suggestion-usage {
  color: #111827;
}

.procedure-group-suggestion-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.procedure-group-suggestion-dose {
  flex: 0 0 auto;
  max-width: 82px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
}

.procedure-group-suggestion-subline,
.procedure-group-suggestion-usage {
  display: block;
  padding-left: 32px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

.m3-order-item:hover,
.m3-drug-item:hover {
  background: #eef7ef;
}

.m3-order-icon {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: #6078c8;
  font-size: 12px;
}

.m3-order-icon.green {
  background: #4caf50;
}

.m3-order-icon.home {
  background: #c49a4a;
}

.m3-order-icon.lime {
  background: #9bc857;
}

.m3-order-icon.cyan {
  background: #67c7d8;
}

.m3-order-icon.purple {
  background: #a177d2;
}

.m3-order-icon.orange {
  background: #f0a42a;
}

.m3-order-icon.yellow {
  background: #e7b947;
}

.m3-order-icon.pink {
  background: #d782c9;
}

.m3-order-icon.rose {
  background: #c8928f;
}

.m3-order-name,
.m3-drug-name {
  font-size: 13px;
  color: #111827;
}

.m3-order-points {
  min-width: 44px;
  color: #111827;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.m3-drug-item.frequent {
  background: #fbfffb;
}

.m3-drug-icon {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: #a177d2;
  font-size: 12px;
}

.m3-drug-default {
  color: #111827;
  font-size: 12px;
  line-height: 1.4;
}

.m3-footer-btn {
  width: 40px;
  height: 38px;
  border-radius: 2px;
  background: #006b2e;
}

.m3-footer-btn:hover {
  background: #005321;
}

/* ====================================
   処置・行為アイテム編集UI
   ==================================== */
.m3-procedure-list {
  position: relative;
}

.m3-proc-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-100);
  position: relative;
  transition: background-color 0.15s;
}

.m3-proc-item:last-child {
  border-bottom: none;
}

.m3-proc-item:hover {
  background: #f0f9ff;
}

/* 個別削除ボタン（×） - ホバー時のみ表示 */
.proc-item-delete-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 3px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.m3-proc-item:hover .proc-item-delete-btn,
.m3-proc-item:focus-within .proc-item-delete-btn {
  display: flex;
}

.proc-item-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.proc-item-delete-btn i {
  font-size: 12px;
}

/* 全削除ボタン（ゴミ箱） - ホバー時のみ表示 */
.proc-delete-all-btn {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
}

.m3-procedure-list:hover .proc-delete-all-btn {
  display: flex;
}

.proc-delete-all-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.proc-delete-all-btn i {
  font-size: 14px;
}

/* Final M3 visual overrides kept at the end for later component rules. */
.m3-panel-right,
.m3-header-zone-order,
.m3-subheader-order {
  flex: 0 0 clamp(360px, 20vw, 390px) !important;
}

.m3-procedure-list {
  padding: 0;
  background: #fff;
  color: #111827;
}

.m3-proc-item {
  min-height: 34px;
  padding: 6px 5px 6px 4px;
  border-bottom: 1px solid #dbe5e1;
  border-radius: 0;
  font-size: 13px;
  background: #fff;
  gap: 6px;
}

.m3-proc-name {
  flex: 1;
  min-width: 0;
  color: #111827;
  font-weight: 400;
  line-height: 1.35;
}

.procedure-action-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-wrap: anywhere;
}

.procedure-row-move-buttons {
  flex: 0 0 18px;
  width: 18px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  opacity: 0.32;
  transition: opacity 0.12s ease;
}

.procedure-row-move-buttons.spacer {
  opacity: 0;
}

.procedure-action-item:hover .procedure-row-move-buttons,
.procedure-action-item:focus-within .procedure-row-move-buttons {
  opacity: 1;
}

.procedure-row-move-btn {
  width: 18px;
  height: 13px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475569;
  line-height: 1;
  cursor: pointer;
}

.procedure-row-move-btn:hover {
  color: #0b5a2a;
}

.procedure-row-move-btn:disabled {
  color: #c4ccc8;
  cursor: default;
}

.proc-action-menu-btn {
  padding: 0;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.proc-action-menu-btn:hover,
.proc-action-menu-btn:focus {
  filter: brightness(0.95);
  outline: 1px solid rgba(11, 90, 42, 0.25);
  outline-offset: 1px;
}

.procedure-action-mainline {
  display: block;
  min-width: 0;
  line-height: 1.35;
}

#main-screen .procedure-action-mainline .proc-kind-tag {
  margin-right: 5px;
}

#main-screen .procedure-action-mainline .procedure-warning-btn {
  margin-left: 5px;
  vertical-align: -3px;
}

.procedure-action-text {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.procedure-action-comments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
  line-height: 1.25;
}

.procedure-action-comment-chip,
.procedure-not-billable-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #f7fbf8;
  color: #1f2937;
  font-size: 11px;
  gap: 4px;
}

.procedure-not-billable-badge {
  border-color: #f2b46d;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 600;
}

.procedure-action-comment-karte {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.procedure-action-comment-karte .procedure-action-comment-position {
  color: #475569;
  font-weight: 600;
}

.procedure-action-comment-type {
  padding: 1px 4px;
  border-radius: 2px;
  background: #e6f3df;
  color: #25713a;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.procedure-action-comment-prescription {
  padding: 1px 4px;
  border-radius: 2px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.procedure-action-comment-position {
  color: #64748b;
  white-space: nowrap;
}

.procedure-action-comment-name {
  overflow-wrap: anywhere;
}

.procedure-action-comment-remove {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 14px;
  line-height: 14px;
}

.procedure-action-comment-remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

.procedure-entry-row.is-not-billable {
  background: #fffaf3;
}

.procedure-action-menu {
  position: fixed;
  z-index: 21000;
  width: 166px;
  border: 1px solid #78bdd0;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.procedure-action-menu.hidden {
  display: none;
}

.procedure-action-menu [hidden] {
  display: none !important;
}

.procedure-action-menu button {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-bottom: 1px solid #e2ebe7;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.procedure-action-menu button:last-child {
  border-bottom: 0;
}

.procedure-action-menu button:hover,
.procedure-action-menu button:focus {
  background: #eaf7fb;
  outline: none;
}

.procedure-comment-overlay {
  position: fixed;
  inset: 0;
  z-index: 22000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.45);
}

.procedure-comment-overlay.hidden {
  display: none;
}

.procedure-comment-modal {
  width: min(600px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #111827;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.procedure-comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 7px 14px;
  background: #0f5b17;
  color: #fff;
}

.procedure-comment-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.procedure-comment-close {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  font-weight: 600;
  line-height: 24px;
}

.procedure-comment-prescription-remark-row {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 6px 6px 0;
  padding: 7px 10px;
  border: 1px solid #cbd9d5;
  background: #f8fbf9;
  font-size: 14px;
}

.procedure-comment-prescription-remark-row.hidden {
  display: none;
}

.procedure-comment-prescription-remark-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.procedure-comment-position {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 6px 6px 0;
  padding: 8px 10px;
  border: 1px solid #cbd9d5;
  background: #f8fbf9;
  gap: 10px;
  font-size: 14px;
}

.procedure-comment-position.hidden {
  display: none;
}

.prescription-info-overlay {
  position: fixed;
  inset: 0;
  z-index: 22500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}

.prescription-info-overlay.hidden {
  display: none;
}

.prescription-info-modal {
  width: min(600px, calc(100vw - 48px));
  max-height: min(82vh, 640px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #c4d4ce;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

.prescription-info-modal-detail {
  width: min(960px, calc(100vw - 48px));
  height: min(86vh, 720px);
  max-height: min(86vh, 720px);
}

.prescription-info-modal-detail .prescription-info-table {
  table-layout: fixed;
}

.prescription-info-modal-detail .prescription-info-table th {
  width: 188px;
  text-align: center;
  vertical-align: middle;
}

.prescription-info-modal-detail .prescription-info-table td {
  min-height: 34px;
  padding: 5px 6px;
}

.prescription-info-modal-detail .prescription-info-row-long td {
  min-height: 72px;
}

.prescription-info-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 8px 10px;
  background: #0f5b17;
  color: #fff;
}

.prescription-info-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.prescription-info-close {
  width: 32px;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  font-weight: 700;
  line-height: 24px;
}

.prescription-info-close:hover,
.prescription-info-close:focus {
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

.prescription-info-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 8px;
  background: #fff;
}

.prescription-info-table {
  width: 100%;
  border-collapse: collapse;
  color: #111827;
  font-size: 14px;
}

.prescription-info-table th,
.prescription-info-table td {
  border: 1px solid #cbd9d5;
  vertical-align: top;
}

.prescription-info-table th {
  width: 190px;
  padding: 8px 10px;
  background: #f1f1f1;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.prescription-info-table td {
  min-height: 36px;
  padding: 8px 10px;
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prescription-info-row-plain th {
  width: 190px;
}

.prescription-info-row-plain td {
  min-height: 240px;
}

.prescription-info-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border-top: 1px solid #d6e2dd;
  background: #fff;
  text-align: right;
}

.prescription-info-footer.hidden {
  display: none;
}

.prescription-info-footer .btn {
  flex: 0 0 auto;
  min-width: 70px;
  min-height: 36px;
  border: 0;
  background: #e5e7eb;
  color: #111827;
}

.prescription-info-source {
  margin-right: auto;
  color: #525b56;
  font-size: 12px;
  overflow-wrap: anywhere;
  text-align: left;
}

.prescription-info-status {
  margin: 0;
  padding: 16px 10px;
  font-size: 14px;
  line-height: 1.6;
}

.prescription-info-modal :focus-visible {
  outline: 2px solid #246cbd;
  outline-offset: -2px;
}

@media (max-width: 600px) {
  .prescription-info-overlay {
    padding: 8px;
  }

  .prescription-info-modal-detail {
    width: calc(100vw - 16px);
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
  }

  .prescription-info-modal-detail .prescription-info-table th {
    width: 88px;
    padding: 6px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.procedure-comment-position-label {
  font-weight: 600;
}

.procedure-comment-position label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.procedure-comment-search {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 8px 6px;
  padding: 0 8px;
  border: 2px solid #36a6de;
  border-radius: 3px;
  background: #fff;
  color: #94a3b8;
  gap: 8px;
}

.procedure-comment-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  border: 0;
  outline: 0;
  color: #111827;
  font: inherit;
  font-size: 14px;
}

.procedure-comment-list {
  flex: 1 1 auto;
  min-height: 260px;
  overflow-y: auto;
  border-top: 1px solid #dbe5e1;
}

.procedure-comment-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 7px 14px;
  border: 0;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  gap: 8px;
}

.procedure-comment-option:hover,
.procedure-comment-option:focus {
  background: #f0faf2;
  outline: none;
}

.procedure-comment-option-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.procedure-comment-empty {
  padding: 18px 14px;
  color: #64748b;
  font-size: 13px;
}

.proc-kind-tag {
  flex: 0 0 auto;
  padding: 2px 7px;
  background: #dce6ff;
  color: #31558d;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.m3-proc-pts {
  flex: 0 0 auto;
  margin-left: auto;
  min-width: 44px;
  white-space: nowrap;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  text-align: right;
  transition: opacity 0.12s ease;
}

.procedure-action-item:hover .m3-proc-pts,
.procedure-action-item:focus-within .m3-proc-pts {
  opacity: 0;
}

.self-pay-proc-item {
  align-items: flex-start;
  min-height: 66px;
  padding: 7px 40px 8px 8px;
  gap: 8px;
}

.self-pay-proc-item .m3-proc-icon {
  background: #6b7280;
}

.self-pay-proc-item .procedure-action-text {
  padding-top: 3px;
}

.self-pay-proc-controls {
  display: flex;
  flex: 0 0 104px;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-left: auto;
}

.self-pay-proc-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #111827;
  font-size: 12px;
  white-space: nowrap;
}

.self-pay-proc-input {
  width: 64px;
  height: 28px;
  padding: 3px 7px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-family: inherit;
  text-align: right;
}

.self-pay-proc-amount {
  width: 86px;
}

.self-pay-proc-quantity {
  width: 58px;
}

.self-pay-proc-input::-webkit-outer-spin-button,
.self-pay-proc-input::-webkit-inner-spin-button {
  margin: 0;
}

.self-pay-proc-input:focus {
  outline: none;
  border-color: #36a6de;
  box-shadow: 0 0 0 1px rgba(54, 166, 222, 0.18);
}

.procedure-action-group,
.rx-claim-group {
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
}

.procedure-action-item {
  cursor: pointer;
  position: relative;
}

.rx-procedure-item {
  cursor: pointer;
  position: relative;
}

.procedure-action-group.manual-grouped,
.rx-claim-group.manual-grouped {
  border-left: 0;
  background: #fff;
}

.procedure-action-item.is-group-anchor-selected,
.rx-procedure-item.is-group-anchor-selected {
  background: #e8f5e9;
  box-shadow: inset 0 0 0 1px #43a85f;
}

.rx-claim-group.is-group-anchor-selected {
  background: #eef9f2;
  box-shadow: inset 0 0 0 2px #8fd2d9;
}

.rx-claim-group.is-group-anchor-selected .rx-edit-item,
.rx-claim-group.is-group-anchor-selected .rx-shared-controls {
  background: #eef9f2;
}

.procedure-action-item.is-group-anchor-selected:hover,
.rx-procedure-item.is-group-anchor-selected:hover {
  background: #ddf0e3;
}

.procedure-action-group.manual-grouped .procedure-action-item.is-manual-group-child,
.rx-claim-group.manual-grouped .rx-procedure-item.is-manual-group-child {
  padding-left: 8px;
}

.procedure-action-group.manual-grouped .procedure-action-item.is-manual-group-child::before,
.rx-claim-group.manual-grouped .rx-procedure-item.is-manual-group-child::before {
  content: none;
}

.procedure-group-anchor-chip {
  display: none;
}

.procedure-action-item.is-group-anchor-selected .procedure-group-anchor-chip,
.rx-procedure-item.is-group-anchor-selected .procedure-group-anchor-chip {
  display: none;
}

.procedure-action-group .m3-proc-item,
.rx-claim-group .m3-proc-item {
  border-bottom: none;
}

.procedure-action-group.grouped .m3-proc-item {
  min-height: 35px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.procedure-action-group.grouped .m3-proc-item:hover .proc-item-delete-btn,
.procedure-action-group.grouped .m3-proc-item:focus-within .proc-item-delete-btn {
  display: flex;
  color: #0b5a2a;
}

.procedure-action-group.grouped .proc-item-delete-btn:hover {
  background: #e5f3e8;
  color: #064e1b;
}

.procedure-group-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 41px;
  padding: 5px 72px 6px 8px;
  background: #fff;
}

.proc-group-count-input {
  width: 56px;
  height: 28px;
  padding: 3px 7px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  font-size: 13px;
  text-align: center;
}

.proc-group-count-unit {
  min-width: 18px;
  color: #111827;
  font-size: 12px;
}

.procedure-group-delete-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
}

.procedure-group-delete-btn:hover {
  color: #dc2626;
}

.m3-proc-icon {
  width: 34px;
  height: 23px;
  border-radius: 2px;
  background: #2e8b44;
  font-size: 12px;
  line-height: 1;
}

.m3-proc-icon.blue {
  background: #6078c8;
}

.m3-proc-icon.green {
  background: #4caf50;
}

.m3-proc-icon.home {
  background: #c49a4a;
}

.m3-proc-icon.lime {
  background: #9bc857;
}

.m3-proc-icon.cyan {
  background: #67c7d8;
}

.m3-proc-icon.orange {
  background: #f0a42a;
}

.m3-proc-icon.yellow {
  background: #e7b947;
}

.m3-proc-icon.pink {
  background: #d782c9;
}

.m3-proc-icon.rose {
  background: #c8928f;
}

.proc-icon-caret {
  margin-left: 2px;
  font-size: 8px;
  line-height: 1;
}

.rx-edit-item {
  display: block;
  padding: 6px 4px 8px;
  border-bottom: 1px solid #dbe5e1;
}

.rx-proc-main,
.rx-proc-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rx-proc-main {
  min-height: 28px;
  margin-bottom: 5px;
}

.rx-proc-main .rx-dose-input {
  margin-left: auto;
}

.rx-proc-controls {
  margin-left: 40px;
}

.rx-claim-group.manual-grouped .rx-edit-item {
  min-height: 34px;
  padding-bottom: 4px;
}

.rx-claim-group.manual-grouped .rx-proc-main {
  margin-bottom: 0;
}

.rx-shared-controls {
  min-height: 36px;
  margin-left: 0;
  padding: 4px 8px 6px;
  border-top: 1px solid #edf3f1;
  background: #fff;
}

.rx-edit-item .m3-proc-name {
  min-width: 0;
  white-space: normal;
  line-height: 1.35;
}

.rx-dose-input,
.rx-days-input,
.rx-dispensing-select,
.rx-usage-select,
.rx-usage-picker {
  height: 28px;
  border-color: #cbd9d5;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
}

.rx-dose-input,
.rx-days-input {
  width: 56px;
  padding: 3px 6px;
  border: 1px solid #cbd9d5;
}

.rx-days-input {
  width: 48px;
}

.rx-dispensing-select {
  width: 82px;
}

.rx-usage-select {
  flex: 1;
  min-width: 0;
  max-width: 220px;
}

.rx-usage-picker {
  flex: 1;
  min-width: 0;
  max-width: 220px;
  padding: 3px 24px 3px 8px;
  border: 1px solid #cbd9d5;
  color: #111827;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.rx-usage-picker::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #475569;
}

.rx-usage-picker span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-usage-picker:hover,
.rx-usage-picker:focus {
  border-color: #38a7d4;
  outline: none;
}

.rx-unit,
.rx-days-label {
  min-width: 18px;
  color: #111827;
  font-size: 12px;
}

.rx-usage-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 23000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.45);
}

.rx-usage-dialog-overlay.hidden {
  display: none;
}

.rx-usage-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: #f8faf9;
  color: #111827;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.rx-usage-dialog-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px 7px 12px;
  background: #0f5b17;
  color: #fff;
}

.rx-usage-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.rx-usage-dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  background: #064b12;
  color: #fff;
  cursor: pointer;
  font-size: 27px;
  font-weight: 600;
  line-height: 28px;
}

.rx-usage-dialog-close:hover,
.rx-usage-dialog-close:focus {
  background: #073f11;
  outline: none;
}

.rx-usage-search-input {
  height: 29px;
  margin: 7px 8px 5px;
  padding: 3px 8px;
  border: 1px solid #55a8ff;
  background: #fff;
  color: #111827;
  font-size: 15px;
}

.rx-usage-search-input:focus {
  outline: 1px solid #55a8ff;
}

.rx-usage-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 16px 10px;
  padding: 10px 12px;
  border: 1px solid #d5ddda;
  background: #fff;
}

.rx-usage-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #111827;
  font-size: 14px;
  white-space: nowrap;
}

.rx-usage-filter input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.rx-usage-option-list {
  flex: 1;
  min-height: 280px;
  overflow-y: auto;
  margin: 0 8px 8px;
  border: 1px solid #cbd5d1;
  background: #fff;
}

.rx-usage-option {
  display: block;
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #d5ddda;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.rx-usage-option:hover,
.rx-usage-option:focus,
.rx-usage-option.selected {
  background: #eef9f2;
  outline: none;
}

.rx-usage-empty {
  padding: 16px;
  color: #64748b;
  font-size: 14px;
}

#patient-info-content {
  background: #fff;
  min-height: 0;
  overflow-y: auto;
}

#patient-info-content .m3-patient-section {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #cbd9d5;
}

#patient-info-content .m3-patient-section:nth-of-type(2) {
  flex: 1 1 330px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

#patient-info-content .m3-patient-section.gray-bg {
  flex: 0 0 auto;
  min-height: 0;
  margin-top: 0;
  background: #fff;
  border-top: 1px solid #cbd9d5;
  display: block;
}

#patient-info-content .m3-section-header {
  height: 31px;
  padding: 0 12px;
  background: #f6faf8;
  border-bottom: 1px solid #cbd9d5;
}

#patient-info-content .m3-patient-section.gray-bg .m3-section-header {
  background: #f6faf8;
  border-bottom: 1px solid #cbd9d5;
}

#patient-info-content .m3-section-title {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

#patient-info-content .m3-section-actions {
  gap: 10px;
}

#patient-info-content .m3-icon-btn-sm {
  width: 24px;
  height: 24px;
  color: #0b5a2a;
  font-size: 15px;
}

#patient-info-content .m3-patient-table {
  border-top: none;
  background: #fff;
}

#patient-info-content .m3-patient-row {
  min-height: 34px;
  padding: 0;
  border-bottom: 1px solid #cbd9d5;
  background: #fff;
}

#patient-info-content .m3-patient-row:last-child {
  border-bottom: none;
}

#patient-info-content .m3-patient-label {
  width: 120px;
  padding: 7px 11px;
  background: #f4f7f6;
  border-right: 1px solid #cbd9d5;
  color: #111827;
  font-size: 12px;
  line-height: 1.4;
}

#patient-info-content .m3-patient-value {
  flex: 1;
  padding: 6px 8px;
  color: #111827;
  font-size: 13px;
  line-height: 1.4;
}

#patient-info-content .m3-patient-value .m3-patient-kana {
  display: block;
  margin-bottom: 1px;
  color: #111827;
  font-size: 13px;
  line-height: 1.2;
}

#patient-info-content .m3-patient-value .m3-patient-kanji {
  display: block;
  color: #111827;
  font-weight: 400;
  line-height: 1.2;
}

#patient-info-content .m3-memo-content {
  flex: 0 0 auto;
  min-height: 0;
  padding: 10px 12px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  line-height: 1.5;
}

#patient-info-content .m3-patient-section:nth-of-type(2) .m3-memo-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#patient-info-content .m3-memo-content.empty {
  flex: 0 0 auto;
  min-height: 31px;
  padding: 7px 12px;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#patient-info-content .m3-patient-section.gray-bg .m3-memo-content {
  background: #fff;
}

/* ====================================
   Insurance registration
   ==================================== */
#insurance-content {
  background: #f3f6f5;
  overflow-y: auto;
}

.insurance-check-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 37px;
  padding: 0 12px;
  background: #f3f6f5;
  border-bottom: 1px solid #cbd9d5;
  font-size: 15px;
}

.insurance-check-label {
  padding: 3px 6px;
  background: #006b2e;
  border-radius: 2px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.insurance-last-confirmed {
  display: inline-flex;
  align-items: center;
  color: #111827;
  font-size: 15px;
  line-height: 1.35;
  white-space: nowrap;
}

.insurance-section {
  margin: 0;
  background: #f3f6f5;
  border-bottom: 1px solid #cbd9d5;
}

.insurance-section-header {
  height: 36px;
  padding: 0 12px;
  background: #f3f6f5;
  border-bottom: 1px solid #cbd9d5;
}

#insurance-content .m3-section-title {
  color: #111827;
  font-size: 14px;
  font-weight: 400;
}

.insurance-actions {
  align-items: center;
  gap: 10px;
}

.insurance-current-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #111827;
  font-size: 13px;
  white-space: nowrap;
}

.insurance-add-btn i,
.insurance-section-header .fa-plus {
  font-size: 18px;
}

.m3-insurance-list {
  background: #fff;
}

.insurance-empty {
  min-height: 31px;
  padding: 7px 6px;
  background: #fff;
  border-bottom: 1px solid #cbd9d5;
  font-size: 13px;
  color: #111827;
}

.insurance-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-size: 13px;
}

.insurance-table th,
.insurance-table td {
  height: 35px;
  padding: 5px 11px;
  border-right: 1px solid #cbd9d5;
  border-bottom: 1px solid #cbd9d5;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.insurance-table th {
  background: #f3f6f5;
  color: #111827;
}

.insurance-table th:last-child,
.insurance-table td:last-child {
  border-right: none;
}

.insurance-row-actions {
  width: 72px;
  padding: 2px 4px !important;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
}

.insurance-row-actions .m3-icon-btn-sm {
  width: 30px !important;
  height: 30px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 2px;
  border: 1px solid #d7dfdc;
  border-radius: 3px;
  background: #fff;
  color: #0b5a2a;
}

.insurance-row-actions .m3-icon-btn-sm:hover {
  background: #e8f2ec;
  border-color: #b7c9c1;
}

.insurance-history-modal {
  z-index: 4250;
}

.insurance-history-dialog {
  width: min(1024px, calc(100vw - 60px));
  height: min(462px, calc(100vh - 70px));
  max-height: calc(100vh - 70px);
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.insurance-history-dialog .modal-header {
  flex: 0 0 42px;
  height: 42px;
  padding: 0 14px;
  background: #0b5317;
  border-bottom: 0;
  color: #fff;
}

.insurance-history-dialog .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.insurance-history-dialog .modal-close {
  color: #fff;
}

.insurance-history-table-wrap {
  min-height: 0;
  flex: 1 1 auto;
  margin: 8px;
  border: 1px solid #d6ddda;
  background: #fff;
  overflow: auto;
}

.insurance-history-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

.insurance-history-table th,
.insurance-history-table td {
  height: 28px;
  padding: 4px 8px;
  border-right: 1px solid #d6ddda;
  border-bottom: 1px solid #d6ddda;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insurance-history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f4f3;
  color: #374151;
  font-weight: 400;
}

.insurance-history-table th:last-child,
.insurance-history-table td:last-child {
  border-right: 0;
}

.insurance-history-time { width: 166px; }
.insurance-history-action { width: 48px; }
.insurance-history-user { width: 100px; }
.insurance-history-info { width: 430px; }
.insurance-history-reduction { width: 92px; }
.insurance-history-category { width: 112px; }
.insurance-history-date { width: 110px; }
.insurance-history-holder { width: 150px; }

.insurance-history-table .insurance-history-message td {
  height: 330px;
  color: #64748b;
  text-align: center;
  vertical-align: middle;
}

.insurance-history-table .insurance-history-message.error td {
  color: #b91c1c;
}

.medical-insurance-table th:nth-child(1) {
  width: 20%;
}

.medical-insurance-table th:nth-child(2) {
  width: 11%;
  min-width: 54px;
  white-space: nowrap;
}

.medical-insurance-table th:nth-child(3) {
  width: 19%;
}

.medical-insurance-table th:nth-child(4) {
  width: 18%;
}

.medical-insurance-table th:nth-child(5) {
  width: 21%;
}

.medical-insurance-table th:nth-child(6) {
  width: 72px;
}

.medical-insurance-table th:nth-child(2),
.medical-insurance-table td:nth-child(2) {
  white-space: nowrap;
}

.modal-insurance {
  width: min(1200px, 96vw);
  height: min(650px, 92vh);
  max-height: 92vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.modal-insurance .modal-header {
  height: 42px;
  padding: 0 16px;
  background: #006b2e;
  border-bottom: none;
  color: #fff;
}

.modal-insurance .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-help-btn,
.modal-insurance .modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
}

.insurance-modal-patient {
  min-height: 49px;
  padding: 13px 14px;
  background: #fff;
  border-bottom: 1px solid #d4dedb;
  font-size: 16px;
}

.modal-body-insurance {
  flex: 1;
  overflow-y: auto;
  background: #f3f6f5;
}

.insurance-form-row {
  display: grid;
  grid-template-columns: 195px 1fr;
  min-height: 43px;
  border-bottom: 1px solid #d4dedb;
}

.insurance-form-row > label {
  padding: 11px 14px;
  color: #111827;
  font-size: 14px;
}

.insurance-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  min-width: 0;
}

.insurance-field input,
.insurance-field select {
  height: 30px;
  padding: 3px 8px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
}

.insurance-field input:focus,
.insurance-field select:focus {
  outline: 2px solid #38bdf8;
  border-color: #0284c7;
}

.insurance-input-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.insurance-field-error {
  color: #dc2626;
  font-size: 12px;
  line-height: 1.3;
}

.insurance-field input.field-invalid {
  border-color: #dc2626;
}

.insurance-field input.field-invalid:focus {
  border-color: #dc2626;
  outline-color: rgba(220, 38, 38, 0.22);
}

#insurance-insurer-number,
#insurance-type,
#insurance-symbol,
#insurance-number,
#insurance-type,
#insurance-burden-ratio,
#insurance-limit-category {
  width: 400px;
  max-width: 55vw;
}

#insurance-branch-number {
  width: 100px;
}

#insurance-holder-name {
  width: 205px;
}

.insurance-branch-label,
.insurance-holder-label {
  margin-left: 12px;
  color: #111827;
  white-space: nowrap;
}

.insurance-date-range input {
  width: 220px;
}

.insurance-radio-field label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.modal-footer-insurance {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 7px 10px;
  background: #f8faf9;
  border-top: 1px solid #cbd9d5;
}

.insurance-record-delete-btn {
  min-width: 55px;
  height: 32px;
  margin-right: auto;
  padding: 0 12px;
  border-radius: 2px;
  font-size: 14px;
}

.insurance-delete-confirm-modal {
  z-index: 12000;
}

.insurance-delete-confirm-box {
  width: min(600px, calc(100vw - 32px));
  min-height: 95px;
  padding: 10px 16px 14px;
  box-sizing: border-box;
  border-radius: 0;
  background: #fff;
  color: #111827;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.13);
}

.insurance-delete-confirm-message {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

.insurance-delete-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.insurance-delete-confirm-actions .btn {
  min-width: 92px;
  height: 39px;
  padding: 0 12px;
  border-radius: 3px;
  font-size: 15px;
}

/* Screenshot-matched medical insurance modal */
.modal-insurance {
  width: min(1200px, calc(100vw - 24px));
  height: min(594px, calc(100vh - 24px));
  max-height: calc(100vh - 24px);
  border-radius: 0;
  background: #fff;
}

.modal-insurance .modal-header {
  height: 42px;
  padding: 0 15px;
  background: #075b17;
  color: #fff;
}

.modal-insurance .modal-header h3 {
  color: #fff;
  font-size: 18px;
  font-weight: 500;
}

.modal-insurance .modal-close,
.modal-insurance .modal-help-btn {
  color: #fff;
}

.insurance-modal-patient {
  min-height: 49px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #d6dedb;
  font-size: 16px;
}

.insurance-modal-actions {
  display: flex;
  align-items: center;
}

.insurance-top-action {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d6dedb;
  border-right: none;
  background: #fff;
  color: #111827;
  font-size: 13px;
  cursor: pointer;
}

.insurance-top-action:last-child {
  border-right: 1px solid #d6dedb;
}

.modal-body-insurance {
  background: #f4f4f4;
}

.workers-comp-fields {
  padding: 10px 14px 12px;
  border-bottom: 1px solid #b7c9c2;
  background: #edf6ee;
}

.workers-comp-fields h4 {
  margin: 0 0 9px;
  color: #075b17;
  font-size: 15px;
  font-weight: 600;
}

.workers-comp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.workers-comp-grid label {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: #111827;
  font-size: 13px;
}

.workers-comp-grid input,
.workers-comp-grid select,
.workers-comp-grid textarea {
  min-width: 0;
  width: 100%;
  padding: 4px 7px;
  border: 1px solid #c7d3cf;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.workers-comp-grid input,
.workers-comp-grid select {
  height: 30px;
}

.workers-comp-grid textarea {
  resize: vertical;
}

.workers-comp-wide {
  grid-column: 1 / -1;
}

.workers-initial-required::after {
  content: "初回必須";
  justify-self: start;
  grid-column: 2;
  margin-top: -5px;
  color: #b42318;
  font-size: 11px;
}

.workers-comp-note {
  margin: 8px 0 0;
  color: #52635c;
  font-size: 12px;
}

@media (max-width: 900px) {
  .workers-comp-grid {
    grid-template-columns: 1fr;
  }

  .workers-comp-wide {
    grid-column: auto;
  }
}

.insurance-form-row {
  grid-template-columns: 165px 1fr;
  min-height: 43px;
  background: #f4f4f4;
}

.insurance-form-row > label {
  padding: 11px 14px;
  font-size: 14px;
}

.insurance-note {
  font-size: 12px;
}

.insurance-field {
  padding: 5px 4px;
  gap: 8px;
}

#insurance-form .insurance-field:not(:has(> .required-badge)) {
  padding-left: 43px;
}

#insurance-form .insurance-validity-label {
  padding-right: 2px;
  white-space: nowrap;
}

#insurance-form .insurance-validity-label .insurance-note {
  font-size: 10px;
  letter-spacing: -0.3px;
}

.insurance-field input,
.insurance-field select {
  height: 30px;
  border-color: #cdd8d5;
  border-radius: 3px;
  font-size: 14px;
}

.insurance-field input:disabled {
  background: #dfe8e5;
}

.insurance-field select:disabled {
  background: #dfe8e5;
  color: #6b7280;
  cursor: not-allowed;
}

.insurance-input-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.insurance-field-error {
  color: #dc2626;
  font-size: 12px;
  line-height: 1.3;
}

.insurance-field input.field-invalid {
  border-color: #dc2626;
}

.insurance-field input.field-invalid:focus {
  border-color: #dc2626;
  outline-color: rgba(220, 38, 38, 0.22);
}

#insurance-insurer-number,
#insurance-symbol,
#insurance-number,
#insurance-limit-category,
#insurance-burden-ratio,
#insurance-reduction-type,
#insurance-facility-status {
  width: 400px;
  max-width: 42vw;
}

#insurance-branch-number {
  width: 100px;
}

#insurance-holder-name,
#insurance-reduction-ratio {
  width: 205px;
}

#insurance-valid-from,
#insurance-valid-until,
#insurance-qualification-acquired-date,
#insurance-facility-valid-from,
#insurance-facility-valid-until {
  width: 220px;
}

#insurance-qualification-unknown-reason {
  width: 110px;
}

#insurance-qualification-unknown-detail {
  width: 54px;
}

.insurance-facility-row {
  min-height: 74px;
}

.insurance-facility-row > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.insurance-facility-field {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.insurance-facility-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.insurance-organization-row {
  min-height: 78px;
}

.insurance-organization-row > label {
  display: flex;
  align-items: center;
}

.insurance-organization-field {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.insurance-organization-field > label {
  display: grid;
  grid-template-columns: 70px 400px;
  align-items: center;
  gap: 8px;
  color: #111827;
  white-space: nowrap;
}

.insurance-organization-field input {
  width: 400px;
  max-width: 42vw;
}

.insurance-inline-label,
.insurance-branch-label,
.insurance-holder-label {
  margin-left: 10px;
  color: #111827;
  white-space: nowrap;
}

#public-expense-form .insurance-inline-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  line-height: 1;
}

#public-expense-form .insurance-inline-label input[type="checkbox"] {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
}

.modal-footer-insurance {
  height: 44px;
  padding: 7px 10px;
  background: #f8faf9;
}

.modal-footer-insurance .btn-register {
  min-width: 55px;
  height: 30px;
  padding: 0 14px;
  border-radius: 2px;
  background: #075b17;
  font-size: 14px;
}

.modal-public-expense {
  height: auto;
  max-height: calc(100vh - 24px);
}

.modal-public-expense #public-expense-form {
  flex: 0 1 auto;
  overflow-y: auto;
}

#public-expense-type,
#public-expense-municipality {
  width: min(920px, 72vw);
}

.public-expense-rule-note,
#public-expense-rule-note {
  margin-top: 4px;
  color: #5d6f68;
  font-size: 12px;
  line-height: 1.4;
}

.public-expense-claim-row select {
  min-width: 160px;
}

.public-expense-note-row textarea {
  width: min(920px, 72vw);
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid #cdd8d5;
  border-radius: 3px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}

#public-expense-payer-number,
#public-expense-recipient-number {
  width: 250px;
}

.public-expense-number-stack {
  flex: 0 0 250px;
}

.public-expense-number-warning {
  color: #f04416;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.public-expense-burden-row {
  border-bottom: none;
}

.public-expense-limit-wrap {
  padding: 12px 16px 14px;
  background: #f4f4f4;
}

.public-expense-limit-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.public-expense-limit-table th,
.public-expense-limit-table td {
  height: 36px;
  padding: 5px 8px;
  border: 1px solid #cdd8d5;
  font-weight: 400;
}

.public-expense-limit-table thead th {
  background: #e9eceb;
  text-align: center;
}

.public-expense-limit-table tbody th {
  width: 170px;
  background: #f8faf9;
  text-align: center;
}

.public-expense-limit-table td {
  text-align: center;
  white-space: nowrap;
}

.public-expense-limit-table input {
  width: 84px;
  height: 28px;
  margin: 0 6px;
  padding: 3px 7px;
  border: 1px solid #cdd8d5;
  border-radius: 3px;
  background: #fff;
  text-align: right;
  font-family: inherit;
}

.public-expense-limit-table input:disabled {
  background: #dfe8e5;
  color: #6b7280;
}

.public-expense-table {
  min-width: 600px;
}

#public-expense-list {
  overflow-x: auto;
}

.public-expense-table th,
.public-expense-table td {
  padding: 2px 3px;
  white-space: nowrap;
}

.public-expense-table th {
  height: 30px;
}

.public-expense-table td {
  height: 37px;
}

.public-expense-table th:nth-child(1) {
  width: 24%;
}

.public-expense-table th:nth-child(2) {
  width: 26%;
}

.public-expense-table th:nth-child(3) {
  width: 24%;
}

.public-expense-table th:nth-child(5) {
  width: 78px;
}

.public-expense-table .insurance-row-actions .m3-icon-btn-sm {
  color: #5b625f;
}

.insurance-date-picker {
  position: fixed;
  width: 278px;
  padding: 10px 12px 12px;
  background: #fff;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 3600;
}

.insurance-date-picker.hidden {
  display: none;
}

.insurance-date-picker-header {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
}

.insurance-date-nav,
.insurance-date-picker-footer button {
  height: 30px;
  border: 1px solid #d6dedb;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  font-family: inherit;
}

.insurance-date-nav {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.insurance-date-nav:hover,
.insurance-date-picker-footer button:hover {
  background: #eef6f0;
}

.insurance-date-picker-title {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d6dedb;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
}

.insurance-date-weekdays,
.insurance-date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

.insurance-date-weekdays {
  margin-bottom: 5px;
  color: #666;
  font-size: 14px;
  font-weight: 600;
}

.insurance-date-weekdays span {
  height: 22px;
  line-height: 22px;
}

.insurance-date-weekdays .sunday,
.insurance-date-day.sunday {
  color: #ef4444;
}

.insurance-date-weekdays .saturday,
.insurance-date-day.saturday {
  color: #2563eb;
}

.insurance-date-day {
  width: 34px;
  height: 34px;
  margin: 0 auto 2px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #2f3337;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
}

.insurance-date-day:hover {
  background: #e7f1e9;
}

.insurance-date-day.outside {
  color: #b4b9bd;
}

.insurance-date-day.selected {
  background: #176928;
  color: #fff;
  font-weight: 700;
}

.insurance-date-day.today:not(.selected) {
  border: 1px solid #176928;
}

.insurance-date-picker-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.insurance-date-picker-footer button {
  min-width: 56px;
  padding: 0 12px;
  font-size: 13px;
}

/* ====================================
   Reception modal flow: search -> new patient
   ==================================== */
.patient-search-screen {
  align-items: center;
  justify-content: center;
  padding: 42px 24px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2200;
}

.patient-search-container {
  width: min(1200px, calc(100vw - 48px));
  height: min(642px, calc(100vh - 84px));
  background: #fff;
  border: 1px solid #0b5a2a;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.patient-search-header {
  height: 43px;
  padding: 0 12px;
  background: #00621f;
  border-bottom: 1px solid #004b18;
}

.patient-search-header h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.search-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 0;
  font-size: 32px;
  font-weight: 700;
}

.patient-search-bar {
  height: 42px;
  padding: 4px 6px;
  gap: 8px;
  background: #fff;
  border-bottom: 1px solid #cbd9d5;
}

.search-input-wrapper {
  height: 31px;
  padding: 0 8px;
  background: #fff;
  border: 2px solid #16a7d8;
  border-radius: 4px;
}

.search-input-wrapper i {
  display: none;
}

.search-input-wrapper input {
  font-size: 14px;
}

.patient-search-bar .btn-primary {
  height: 31px;
  padding: 0 10px;
  background: #00621f;
  border: 1px solid #00621f;
  border-radius: 2px;
  font-size: 13px;
}

.patient-search-results {
  background: #fff;
}

.search-results-table {
  font-size: 14px;
}

.search-results-table th,
.search-results-table td {
  height: 36px;
  padding: 5px 7px;
  border-right: 1px solid #cbd9d5;
  border-bottom: 1px solid #cbd9d5;
}

.search-results-table th {
  background: #f3f6f5;
  border-bottom: 1px solid #cbd9d5;
  color: #111827;
  font-size: 13px;
  font-weight: 400;
}

.search-results-table th:last-child,
.search-results-table td:last-child {
  border-right: none;
}

.search-results-table tbody tr:hover {
  background: #eef7ef;
}

.search-results-table .col-patient-no {
  width: 64px;
  text-align: center;
}

.search-results-table .col-kana {
  width: 145px;
}

.search-results-table .col-name {
  width: 140px;
}

.search-results-table .col-gender {
  width: 42px;
}

.search-results-table .col-birth {
  width: 160px;
}

.search-results-table .col-age {
  width: 44px;
}

.search-results-table .col-last {
  width: 100px;
}

.search-results-table .col-actions {
  width: 245px;
}

.search-action-buttons {
  gap: 4px;
}

.search-action-btn {
  height: 30px;
  padding: 0 12px;
  border-color: #cfd8d5;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

.patient-search-footer {
  height: 42px;
  justify-content: flex-end;
  padding: 5px 10px;
  gap: 8px;
  background: #f3f6f5;
  border-top: 1px solid #cbd9d5;
}

.patient-search-footer .btn {
  height: 31px;
  padding: 0 10px;
  border-radius: 2px;
  font-size: 13px;
}

.patient-search-footer .btn-outline {
  background: #00621f;
  border-color: #00621f;
  color: #fff;
}

.modal {
  z-index: 3000;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: none;
}

.modal-patient {
  width: min(1200px, calc(100vw - 80px));
  max-height: calc(100vh - 120px);
  border-radius: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

.modal-patient .modal-header {
  height: 42px;
  padding: 0 14px;
  background: #00621f;
  border-radius: 0;
}

.modal-patient .modal-header h3 {
  font-size: 17px;
  letter-spacing: 0;
}

.modal-patient .modal-close {
  font-size: 32px;
  font-weight: 700;
}

.modal-body-patient {
  max-height: calc(100vh - 205px);
  overflow-y: auto;
  background: #f3f6f5;
}

.form-row-patient {
  min-height: 43px;
  border-bottom: 1px solid #d3dfdb;
}

.form-label-patient {
  width: clamp(130px, 24vw, 290px);
  min-width: clamp(130px, 24vw, 290px);
  padding: 10px 8px;
  background: #f3f6f5;
  border-right: none;
  color: #111827;
  font-size: 14px;
  font-weight: 400;
  justify-content: space-between;
  gap: 8px;
}

.form-label-patient .required-badge {
  margin-left: auto;
}

.form-input-area {
  padding: 5px 10px;
  gap: 8px;
}

.form-input-area.address-section {
  padding: 5px 10px;
  gap: 5px;
}

.modal-patient input,
.modal-patient select {
  height: 29px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  font-size: 14px;
}

.modal-patient input:focus,
.modal-patient select:focus {
  outline: 2px solid #14aee5;
  border-color: #0284c7;
  box-shadow: none;
}

.modal-patient .input-medium {
  width: 492px;
  max-width: 60vw;
}

.modal-patient .input-wide {
  flex: 0 1 585px;
  min-width: 280px;
}

.modal-patient .address-section .input-address,
.modal-patient .address-section .select-prefecture,
.modal-patient .select-facility {
  width: 100%;
}

.modal-patient .input-postal {
  width: 292px;
  max-width: 45vw;
}

.modal-patient .address-section .select-prefecture {
  max-width: none;
  min-height: 32px;
  padding: 4px 28px 4px 8px;
  line-height: 20px;
  box-sizing: border-box;
}

.modal-footer-patient {
  height: 59px;
  padding: 11px 12px;
  background: #f3f6f5;
  border-top: 1px solid #cbd9d5;
}

.modal-footer-patient .btn {
  height: 38px;
  border-radius: 3px;
  font-size: 14px;
}

.modal-footer-patient .btn-register,
.modal-footer-patient .btn-register-checkin {
  background: #00621f;
}

/* Reception header contrast */
.reception-header .icon-btn,
.reception-header .icon-text {
  color: #f8fff9;
}

.reception-header .icon-btn {
  background: rgba(255, 255, 255, 0.12);
}

.reception-header .icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.reception-header .user-dropdown-btn {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-radius: 3px;
  font-weight: 700;
}

.reception-header .user-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.reception-header .header-search-box {
  background: rgba(255, 255, 255, 0.2);
}

.reception-header .header-search-box i,
.reception-header .header-search-input,
.reception-header .header-search-input::placeholder {
  color: #ffffff;
  opacity: 1;
}

/* ====================================
   自動算定確認モーダル
==================================== */
.modal-auto-calc {
  width: min(600px, calc(100vw - 48px));
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2px;
}

.modal-auto-calc .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
  background: #145716;
  border-bottom: 0;
  color: #ffffff;
}

.modal-auto-calc .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.auto-calc-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.auto-calc-badges {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
}

.auto-calc-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.13);
  white-space: nowrap;
}

.auto-calc-help,
.modal-auto-calc .modal-close {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
}

.auto-calc-help {
  font-size: 18px;
}

.modal-auto-calc .modal-close {
  font-size: 28px;
  line-height: 1;
}

.auto-calc-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #ffffff;
}

.auto-calc-confirm-message {
  margin: 0;
  padding: 12px 10px 10px;
  font-size: 14px;
  color: #333333;
}

.auto-calc-notices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 10px 10px;
}

.auto-calc-notice {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid #d8dde1;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.45;
}

.auto-calc-notice.warning {
  border-color: #f8d48a;
  background: #fff8e8;
  color: #7c4a03;
}

.auto-calc-notice.info {
  border-color: #b9d7f7;
  background: #eef6ff;
  color: #1d4f7a;
}

.auto-calc-confirm-list {
  margin: 0 6px 10px;
  border: 1px solid #cdd3d8;
  background: #ffffff;
}

.auto-calc-select-all-row,
.auto-calc-item {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #d8dde1;
  background: #f8faf9;
  cursor: pointer;
}

.auto-calc-confirm-list > :last-child {
  border-bottom: 0;
}

.auto-calc-select-all-row {
  font-size: 14px;
  color: #333333;
}

.auto-calc-select-all-row input[type="checkbox"],
.auto-calc-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #6aa4ed;
  cursor: pointer;
}

.auto-calc-item:hover {
  background: #f1f6f4;
}

.auto-calc-item.disabled {
  color: #8b949e;
  background: #f3f5f6;
  cursor: default;
}

.auto-calc-item-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  border-radius: 2px;
  background: #7085d8;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.auto-calc-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auto-calc-item-name {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 500;
  color: #333333;
}

.auto-calc-item.disabled .auto-calc-item-name {
  color: #6f7780;
}

.auto-calc-item-reason {
  overflow-wrap: anywhere;
  font-size: 11px;
  color: #6f7780;
}

.auto-calc-item-score {
  min-width: 56px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #333333;
}

.auto-calc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-top: 1px solid #d8dde1;
  background: #f4f6f5;
}

.auto-calc-summary {
  font-size: 12px;
  color: #555f68;
}

.auto-calc-summary strong {
  color: #145716;
  font-weight: 700;
}

.auto-calc-actions {
  display: flex;
  justify-content: flex-end;
}

.auto-calc-actions .btn {
  min-width: 92px;
  height: 34px;
  border-radius: 3px;
}

.auto-calc-actions .btn-primary {
  border-color: #0960a8;
  background: #145716;
  color: #ffffff;
}

.auto-calc-actions .btn-primary:disabled {
  border-color: #b8c0c7;
  background: #b8c0c7;
  cursor: not-allowed;
}

/* 空状態 */
.auto-calc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 20px;
  color: var(--gray-500);
}

.auto-calc-empty i {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.auto-calc-empty p {
  margin: 0;
  font-size: 14px;
}

/* ローディング状態 */
.auto-calc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 20px;
}

.auto-calc-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: #145716;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.auto-calc-loading p {
  margin-top: 12px;
  font-size: 13px;
  color: var(--gray-500);
}

/* ====================================
   カルテ保存前警告一覧モーダル
==================================== */
.karte-warning-list-modal {
  z-index: 5200;
}

.prescription-audit-disable-modal {
  z-index: 5300;
}

.modal-karte-warning-list {
  width: min(1200px, calc(100vw - 64px));
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2px;
}

.modal-karte-warning-list .modal-header {
  min-height: 42px;
  padding: 0 14px;
  background: #145716;
  border-bottom: 0;
  color: #fff;
}

.modal-karte-warning-list .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.modal-karte-warning-list .modal-close {
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  opacity: 1;
}

.karte-warning-list-body {
  padding: 12px;
  overflow: auto;
  background: #f7faf8;
}

.karte-warning-list-intro {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 12px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid #d7e1db;
  color: #111827;
  font-size: 14px;
}

.karte-warning-list-table-wrap {
  background: #fff;
  border: 1px solid #cfded6;
  overflow: auto;
}

.karte-warning-list-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.karte-warning-list-table th,
.karte-warning-list-table td {
  padding: 10px 12px;
  border-right: 1px solid #cfded6;
  border-bottom: 1px solid #cfded6;
  vertical-align: middle;
  word-break: break-word;
}

.karte-warning-list-table th {
  background: #f3f7f5;
  font-weight: 600;
  text-align: center;
}

.karte-warning-list-table th:nth-child(1),
.karte-warning-list-table td:nth-child(1) {
  width: 28%;
}

.karte-warning-list-table th:nth-child(2),
.karte-warning-list-table td:nth-child(2) {
  width: 24%;
}

.karte-warning-list-table th:nth-child(3),
.karte-warning-list-table td:nth-child(3) {
  width: 40%;
}

.karte-warning-list-table th:nth-child(4),
.karte-warning-list-table td:nth-child(4) {
  width: 8%;
  text-align: center;
}

.karte-warning-list-kind {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #111827;
  font-weight: 500;
}

.karte-warning-list-kind i {
  color: #e53935;
  font-size: 14px;
}

.karte-warning-list-kind.karte-warning-level-3 i {
  color: #dc2626;
}

.karte-warning-list-kind.karte-warning-level-2 i {
  color: #f97316;
}

.karte-warning-list-kind.karte-warning-level-1 i {
  color: #f5a000;
}

.karte-warning-list-actions {
  white-space: nowrap;
}

.karte-warning-item-link {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0b5a2a;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.karte-warning-item-link:hover,
.karte-warning-item-link:focus-visible {
  color: #073d1d;
  text-decoration-thickness: 2px;
}

.karte-warning-open-karte-btn {
  display: inline-flex;
  color: #0b5a2a;
}

.karte-warning-disable-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: 1px solid #d7e1db;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  cursor: pointer;
}

.karte-warning-disable-btn:hover,
.karte-warning-disable-btn:focus {
  border-color: #f97316;
  background: #fff7ed;
  color: #c2410c;
  outline: none;
}

.karte-warning-list-action-empty {
  color: #94a3b8;
}

.karte-warning-indication-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.karte-warning-comment-code-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f04438;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.karte-warning-list-footer {
  min-height: 60px;
  justify-content: flex-end;
  background: #f7faf8;
  border-top: 1px solid #cfded6;
}

.karte-warning-list-save {
  min-width: 92px;
  height: 38px;
  background: #075b17;
  border-color: #075b17;
  color: #fff;
  font-weight: 700;
}

.karte-warning-list-save:hover {
  background: #064b13;
  border-color: #064b13;
}

.modal-prescription-audit-disable {
  width: min(760px, calc(100vw - 64px));
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2px;
}

.modal-prescription-audit-disable .modal-header {
  min-height: 42px;
  padding: 0 14px;
  background: #145716;
  border-bottom: 0;
  color: #fff;
}

.modal-prescription-audit-disable .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.modal-prescription-audit-disable .modal-close {
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  opacity: 1;
}

.prescription-audit-disable-body {
  padding: 12px;
  overflow: auto;
  background: #f7faf8;
}

.prescription-audit-disable-intro {
  min-height: 54px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid #d7e1db;
  color: #111827;
  font-size: 13px;
  line-height: 1.6;
}

.prescription-audit-disable-table-wrap {
  background: #fff;
  border: 1px solid #cfded6;
  overflow: auto;
}

.prescription-audit-disable-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.prescription-audit-disable-table th,
.prescription-audit-disable-table td {
  padding: 10px 12px;
  border-right: 1px solid #cfded6;
  border-bottom: 1px solid #cfded6;
  vertical-align: middle;
  word-break: break-word;
}

.prescription-audit-disable-table th {
  background: #f3f7f5;
  font-weight: 600;
  text-align: center;
}

.prescription-audit-disable-table th:nth-child(1),
.prescription-audit-disable-table td:nth-child(1) {
  width: 34%;
}

.prescription-audit-disable-table th:nth-child(2),
.prescription-audit-disable-table td:nth-child(2) {
  width: 26%;
}

.prescription-audit-disable-table th:nth-child(3),
.prescription-audit-disable-table td:nth-child(3) {
  width: 40%;
}

.prescription-audit-disable-options {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 2px 2px;
  color: #111827;
  font-size: 13px;
}

.prescription-audit-disable-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.prescription-audit-disable-footer {
  min-height: 58px;
  justify-content: flex-end;
  background: #f7faf8;
  border-top: 1px solid #cfded6;
}

.prescription-audit-disable-submit {
  min-width: 92px;
  height: 38px;
  background: #075b17;
  border-color: #075b17;
  color: #fff;
  font-weight: 700;
}

.prescription-audit-disable-submit:hover,
.prescription-audit-disable-submit:focus {
  background: #064b13;
  border-color: #064b13;
  color: #fff;
}

/* ====================================
   カルテ未保存確認ダイアログ
==================================== */
.karte-discard-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.karte-discard-overlay.hidden {
  display: none;
}

.karte-discard-box {
  width: min(600px, calc(100vw - 48px));
  padding: 14px 18px 15px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.karte-discard-box p {
  margin: 0 0 12px;
  color: #111827;
  font-size: 15px;
  line-height: 1.45;
}

.karte-discard-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.karte-discard-actions button {
  height: 36px;
  padding: 0 12px;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.karte-discard-cancel {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}

.karte-discard-confirm {
  border: 1px solid #0f4411;
  background: #145716;
  color: #ffffff;
  font-weight: 700;
}

/* ====================================
   算定チェック警告パネル
   ==================================== */
.calculation-warning-panel {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  margin: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 13px;
}

.calculation-warning-panel.hidden {
  display: none;
}

.calculation-warning-panel .warning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #ffc107;
  color: #664d03;
  font-weight: 600;
  border-radius: 5px 5px 0 0;
}

.calculation-warning-panel .warning-header i {
  font-size: 16px;
}

.calculation-warning-panel .warning-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #664d03;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.calculation-warning-panel .warning-close:hover {
  color: #332600;
}

.calculation-warning-panel .warning-body {
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.calculation-warning-panel .warning-section {
  margin-bottom: 8px;
}

.calculation-warning-panel .warning-section:last-child {
  margin-bottom: 0;
}

.calculation-warning-panel .warning-section-title {
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.calculation-warning-panel .error-section .warning-section-title {
  color: #dc3545;
}

.calculation-warning-panel .warn-section .warning-section-title {
  color: #856404;
}

.calculation-warning-panel .warning-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.calculation-warning-panel .warning-item.error {
  background: #f8d7da;
  border-left: 3px solid #dc3545;
}

.calculation-warning-panel .warning-item.warning {
  background: #fff3cd;
  border-left: 3px solid #ffc107;
}

.calculation-warning-panel .warning-rule {
  font-weight: 600;
  font-size: 12px;
  color: #333;
}

.calculation-warning-panel .warning-message {
  font-size: 12px;
  color: #555;
}

/* 処方チェック警告（薬剤相互作用・投与日数） */
.drug-warning-panel {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  margin: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 13px;
}

.drug-warning-panel.hidden {
  display: none;
}

.drug-warning-panel .warning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #dc3545;
  color: #fff;
  font-weight: 600;
  border-radius: 5px 5px 0 0;
}

.drug-warning-panel .warning-body {
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.drug-warning-panel .interaction-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #f8d7da;
  border-left: 3px solid #dc3545;
  border-radius: 4px;
  margin-bottom: 6px;
}

.drug-warning-panel .interaction-drugs {
  font-weight: 600;
  color: #721c24;
}

.drug-warning-panel .interaction-type {
  font-size: 11px;
  color: #856404;
  background: #fff3cd;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
}

.drug-warning-panel .interaction-message {
  font-size: 12px;
  color: #555;
}

/* ====================================
   自費項目パネル
   ==================================== */
.self-pay-freeform {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.self-pay-freeform-title {
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.self-pay-freeform-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.self-pay-input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}

.self-pay-input:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.self-pay-input::placeholder {
  color: #9ca3af;
}

#self-pay-free-name {
  flex: 1;
  min-width: 120px;
}

.self-pay-price {
  width: 100px;
  text-align: right;
}

.self-pay-unit {
  font-size: 13px;
  color: #374151;
}

.self-pay-add-btn {
  height: 32px;
  padding: 0 14px;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
}

.self-pay-add-btn:hover {
  background: #16a34a;
}

.self-pay-add-btn:active {
  background: #15803d;
}

.self-pay-master-list {
  margin-top: 8px;
}

.self-pay-master-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
  padding-left: 4px;
}

.self-pay-master-empty {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 20px;
}

.self-pay-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.self-pay-item:hover {
  background: #fef3c7;
  border-color: #fcd34d;
}

.self-pay-item .item-icon {
  width: 22px;
  height: 22px;
  background: #8b91a6;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.self-pay-item .item-name {
  flex: 1;
  font-size: 13px;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.self-pay-item .item-price {
  font-size: 13px;
  font-weight: 600;
  color: #dc2626;
  margin-right: 8px;
}

.self-pay-item .item-qty {
  font-size: 11px;
  color: #6b7280;
  margin-right: 8px;
}

.self-pay-item .item-add-btn {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.self-pay-item:hover .item-add-btn {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

/* ====================================
   Karte reference layout alignment
   ==================================== */
#main-screen.main-screen {
  height: 100vh;
  overflow: hidden;
  background: #c8d5d1;
}

#main-screen .app-header {
  height: 45px;
  padding: 0 4px;
  border-bottom: 1px solid #b8cac5;
  background: #fbfcf8;
}

#main-screen .header-left {
  flex: 1 1 auto;
  min-width: 0;
}

#main-screen .header-right {
  flex: 0 0 auto;
}

#main-screen .header-alert-note {
  display: none;
}

#main-screen .m3-common-header {
  height: 62px;
  min-height: 62px;
  max-height: 62px;
  flex: 0 0 62px;
  border-bottom: 1px solid #b9c9c4;
  overflow: hidden;
}

#main-screen .m3-sub-header {
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  flex: 0 0 30px;
  border-bottom: 1px solid #b9c9c4;
  overflow: hidden;
}

#main-screen .m3-karte-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#main-screen .m3-panel-left,
#main-screen .m3-header-zone-patient,
#main-screen .m3-subheader-patient {
  flex: 0 0 clamp(540px, 33.45vw, 650px) !important;
  min-width: 0;
}

#main-screen .m3-panel-right,
#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order {
  flex: 0 0 clamp(420px, 26vw, 520px) !important;
  min-width: 0;
}

#main-screen .m3-header-zone-order {
  height: 62px;
  min-height: 62px;
  max-height: 62px;
  overflow: hidden;
}

#main-screen .m3-subheader-order {
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  overflow: hidden;
}

#main-screen .m3-zone-karte-wrapper,
#main-screen .m3-header-zone-karte,
#main-screen .m3-subheader-karte {
  flex: 1 1 auto !important;
  min-width: 560px;
}

#main-screen .m3-header-zone,
#main-screen .m3-subheader-zone,
#main-screen .m3-panel,
#main-screen .m3-zone-karte-wrapper {
  background: #fff;
  border-right: none;
}

#main-screen .m3-panel-tabs-row {
  height: 31px !important;
  min-height: 31px;
  max-height: 31px;
  flex: 0 0 31px;
  box-sizing: border-box;
  border-bottom: 1px solid #cbd9d5;
  overflow: hidden;
}

#main-screen .m3-order-header-wrap {
  height: 62px;
  min-height: 62px;
  max-height: 62px;
  overflow: hidden;
  align-items: stretch;
}

#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  display: grid;
  grid-template-rows: 31px 31px;
  height: 62px;
  min-height: 62px;
  max-height: 62px;
  overflow: hidden;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab {
  -webkit-appearance: none !important;
  appearance: none !important;
  flex: 1 1 0;
  min-width: 0;
  height: 31px !important;
  min-height: 31px;
  max-height: 31px;
  padding: 0 6px !important;
  box-sizing: border-box;
  border: 0 !important;
  border-right: 1px solid #cbd9d5 !important;
  border-radius: 0 !important;
  background: #f9fbfa;
  color: #17241c;
  font-size: 13px;
  font-weight: 400 !important;
  line-height: 1;
  white-space: nowrap;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  position: relative;
  top: 0 !important;
  vertical-align: top;
  user-select: none;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
  transition: background-color 0.12s ease, color 0.12s ease;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab:last-child {
  border-right: 0 !important;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab:hover,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus-visible,
#main-screen .m3-panel-tabs-row .m3-panel-tab:active {
  height: 31px !important;
  min-height: 31px;
  max-height: 31px;
  padding: 0 6px !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
  top: 0 !important;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab.active {
  background: #0f6b3a !important;
  color: #fff !important;
  border-right-color: #cbd9d5 !important;
  font-weight: 400 !important;
  height: 31px !important;
  min-height: 31px;
  max-height: 31px;
  padding: 0 6px !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
  top: 0 !important;
}

#main-screen .m3-all-btn,
#main-screen .m3-all-btn:focus,
#main-screen .m3-all-btn:focus-visible,
#main-screen .m3-all-btn:active {
  -webkit-appearance: none !important;
  appearance: none !important;
  height: 28px !important;
  min-height: 28px;
  max-height: 28px;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  position: relative;
  top: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
}

#main-screen .m3-subheader-zone {
  padding: 0 4px;
}

#main-screen .m3-subheader-search {
  height: 25px;
  border-color: #cbd9d5;
  border-radius: 0;
  font-size: 13px;
}

#main-screen .m3-karte-panels {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 43% minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(34px, auto);
  min-height: 0;
  gap: 1px;
  background: #cbd9d5;
}

#main-screen .m3-karte-panels .m3-panel-soap {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  border-left: 1px solid #36a6de;
  border-top: 1px solid #36a6de;
}

#main-screen .m3-karte-panels .m3-panel-procedure {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  border-left: 1px solid #cbd9d5;
}

#main-screen .m3-soap-editor {
  padding: 24px 14px 12px;
  background: #fff;
  color: #000;
  font-size: 14px;
  line-height: 1.65;
  font-family: "Yu Gothic UI", "Meiryo", sans-serif;
}

#main-screen .m3-soap-editor p {
  margin: 0 0 10px;
}

#main-screen .m3-soap-editor strong {
  color: #000;
  font-weight: 500;
}

#main-screen .m3-karte-header-row2.karte-no-record-context {
  align-items: center;
  justify-content: flex-start;
  padding: 0 12px;
  background: #fff;
}

#main-screen .m3-karte-header-row2.karte-no-record-context .m3-karte-context-left,
#main-screen .m3-karte-header-row2.karte-no-record-context .m3-karte-context-right {
  display: none;
}

#main-screen .karte-no-record-title {
  color: #17241c;
  font-size: 14px;
  line-height: 1;
}

#main-screen .m3-soap-editor.karte-empty-state {
  padding: 14px 12px;
  color: #8a9690;
  cursor: default;
}

#main-screen .karte-empty-message {
  color: #8a9690;
  font-size: 14px;
  line-height: 1.5;
}

#main-screen .m3-soap-footer {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 34px;
  height: auto;
  padding: 4px 8px;
  border-top: 1px solid #cbd9d5;
  border-left: 1px solid #36a6de;
  border-bottom: 1px solid #36a6de;
  background: #fbfcfb;
}

#main-screen .m3-karte-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 2px;
  font-size: 13px;
}

#main-screen .m3-procedure-list {
  padding: 0;
  background: #fff;
  font-size: 13px;
}

#main-screen .procedure-entry-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 34px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid #d7e2de;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#main-screen .procedure-entry-row:hover {
  background: #f5faf7;
}

#main-screen .m3-proc-item,
#main-screen .rx-procedure-item {
  min-height: 36px;
  padding: 5px 8px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
  font-size: 13px;
}

#main-screen .m3-proc-item:hover,
#main-screen .rx-procedure-item:hover {
  background: #f4faf6;
}

#main-screen .m3-proc-icon,
#main-screen .rx-icon,
#main-screen .billing-icon,
#main-screen .m3-order-icon {
  width: 31px;
  height: 22px;
  border-radius: 2px;
  font-size: 12px;
  flex: 0 0 31px;
  margin-top: 1px;
  color: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#main-screen .self-pay-proc-item .m3-proc-icon {
  width: 31px;
  min-width: 31px;
  height: 22px;
  font-size: 12px;
}

#main-screen .self-pay-proc-item .self-pay-proc-controls {
  flex-basis: 104px;
}

#main-screen .self-pay-proc-item .self-pay-proc-amount {
  width: 86px;
}

#main-screen .self-pay-proc-item .self-pay-proc-quantity {
  width: 58px;
}

#main-screen .rx-claim-group {
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
}

#main-screen .procedure-group-footer {
  min-height: 30px;
  padding: 3px 8px 3px 46px;
  border-top: 1px solid #eef3f1;
  background: #fff;
}

#main-screen .procedure-action-text {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 3px;
}

#main-screen .m3-proc-name {
  display: inline;
  color: #111827;
  font-weight: 400;
  line-height: 1.35;
}

#main-screen .m3-proc-pts {
  flex: 0 0 58px;
  min-width: 58px;
  margin-left: auto;
  padding-top: 3px;
  color: #111827;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

#main-screen .procedure-action-item:hover .m3-proc-pts,
#main-screen .procedure-action-item:focus-within .m3-proc-pts {
  opacity: 1;
}

#main-screen .procedure-row-move-buttons {
  display: none;
}

#main-screen .proc-icon-caret {
  margin-left: 3px;
  font-size: 8px;
  line-height: 1;
  opacity: 0.9;
}

#main-screen .proc-kind-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 2px;
  background: #dce8ff;
  color: #31558d;
  font-size: 10px;
  font-weight: 600;
  vertical-align: baseline;
  white-space: nowrap;
}

#main-screen .proc-item-delete-btn {
  right: 8px;
  color: #0b5a2a;
}

/* Final overrides for the order candidate and selected prescription lists. */
#main-screen .m3-drug-list,
#main-screen .m3-order-list {
  border-top: 1px solid #d7e2de;
}

#main-screen .m3-drug-item,
#main-screen .m3-order-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 48px;
  padding: 6px 8px 7px 4px;
  border-bottom: 1px solid #d7e2de;
  background: #f8fbfa;
}

#main-screen .m3-drug-item.frequent {
  background: #edf8ef;
}

#main-screen .m3-drug-item:hover,
#main-screen .m3-order-item:hover {
  background: #e8f5e9;
}

#main-screen .m3-drug-icon,
#main-screen .m3-order-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 0;
  border-radius: 2px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

#main-screen .m3-drug-icon {
  background: #a177d2;
}

#main-screen .m3-drug-text,
#main-screen .m3-order-text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

#main-screen .m3-drug-name,
#main-screen .m3-order-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .m3-drug-default,
#main-screen .m3-order-points {
  display: block;
  min-width: 0;
  margin-left: 0;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

#main-screen .rx-edit-item {
  display: block;
  min-height: 52px;
  padding: 5px 8px 6px 4px;
}

#main-screen .rx-claim-group.manual-grouped .rx-edit-item {
  min-height: 28px;
  padding: 5px 8px 2px 4px;
}

#main-screen .rx-proc-main {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 24px;
  margin-bottom: 1px;
}

#main-screen .rx-proc-main .m3-proc-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  font-size: 12px;
}

#main-screen .rx-drug-name {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#main-screen .rx-dose-cluster {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-left: 0;
  padding-right: 0;
}

#main-screen .rx-dose-input,
#main-screen .rx-days-input,
#main-screen .rx-dispensing-select,
#main-screen .rx-usage-picker {
  height: 22px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #111827;
  font-size: 13px;
}

#main-screen .rx-dose-input {
  width: 38px;
  padding: 0;
  text-align: right;
}

#main-screen .rx-days-input {
  width: 28px;
  padding: 0;
  text-align: right;
}

#main-screen .rx-dispensing-select {
  width: 34px;
  padding: 0;
  appearance: none;
}

#main-screen .rx-usage-picker {
  flex: 0 1 auto;
  max-width: none;
  min-width: 0;
  padding: 0;
  text-align: left;
}

#main-screen .rx-usage-picker::after {
  content: none;
}

#main-screen .rx-usage-picker span {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 24px;
  margin-left: 28px;
  padding: 0 8px 5px 0;
  border-top: 0;
  background: transparent;
}

#main-screen .rx-unit,
#main-screen .rx-days-label {
  min-width: 0;
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
}

#main-screen .proc-item-delete-btn {
  opacity: 0;
}

#main-screen .rx-claim-group:hover .proc-item-delete-btn,
#main-screen .rx-procedure-item:focus-within .proc-item-delete-btn {
  opacity: 1;
}

/* Final prescription column alignment override. */
#main-screen .rx-proc-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 6px;
  align-items: start;
}

#main-screen .rx-proc-main .m3-proc-icon {
  grid-column: 1;
}

#main-screen .rx-proc-main .rx-drug-name {
  grid-column: 2;
}

#main-screen .rx-prescription-text {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

#main-screen .rx-prescription-text .rx-drug-name {
  width: 100%;
}

#main-screen .rx-dose-cluster {
  display: contents;
}

#main-screen .rx-dose-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-unit {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 5px;
  align-items: center;
}

#main-screen .rx-dispensing-select {
  grid-column: 1;
  width: 76px;
}

#main-screen .rx-usage-picker {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}

#main-screen .rx-days-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-days-label {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

/* Final prescription column alignment override. */
#main-screen .rx-proc-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 6px;
  align-items: start;
}

#main-screen .rx-proc-main .m3-proc-icon {
  grid-column: 1;
}

#main-screen .rx-proc-main .rx-drug-name {
  grid-column: 2;
}

#main-screen .rx-dose-cluster {
  display: contents;
}

#main-screen .rx-dose-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-unit {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 5px;
  align-items: center;
}

#main-screen .rx-dispensing-select {
  grid-column: 1;
  width: 76px;
}

#main-screen .rx-usage-picker {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}

#main-screen .rx-days-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-days-label {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

/* Detailed remembered group candidates: show every included action/drug. */
#main-screen .procedure-group-suggestion-item {
  display: block;
  min-height: 48px;
  padding: 6px 8px 7px 4px;
  border: 0;
  border-bottom: 1px solid #d7e2de;
  background: #f8fbfa;
  color: #111827;
  text-align: left;
  cursor: pointer;
}

#main-screen .procedure-group-suggestion-item:hover {
  background: #e8f5e9;
}

#main-screen .procedure-group-suggestion-lines {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

#main-screen .procedure-group-suggestion-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

#main-screen .procedure-group-suggestion-main {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: flex-start;
  gap: 5px;
}

#main-screen .procedure-group-suggestion-name {
  flex: 1 1 auto;
  min-width: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#main-screen .procedure-group-suggestion-dose {
  flex: 0 0 auto;
  max-width: 82px;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
}

#main-screen .procedure-group-suggestion-usage {
  display: block;
  padding-left: 32px;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

/* Prescription rows: keep amount/day inputs and units in one clean column. */
#main-screen .rx-proc-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 6px;
  align-items: start;
}

#main-screen .rx-proc-main .m3-proc-icon {
  grid-column: 1;
}

#main-screen .rx-proc-main .rx-drug-name {
  grid-column: 2;
}

#main-screen .rx-dose-cluster {
  display: contents;
}

#main-screen .rx-dose-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-unit {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 5px;
  align-items: center;
}

#main-screen .rx-dispensing-select {
  grid-column: 1;
  width: 76px;
}

#main-screen .rx-usage-picker {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}

#main-screen .rx-days-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-days-label {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

/* Order candidate list: compact two-line prescription style */
#main-screen .m3-drug-list,
#main-screen .m3-order-list {
  border-top: 1px solid #d7e2de;
}

#main-screen .m3-drug-item,
#main-screen .m3-order-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 48px;
  padding: 6px 8px 7px 4px;
  border-bottom: 1px solid #d7e2de;
  background: #f8fbfa;
}

#main-screen .m3-drug-item.frequent {
  background: #edf8ef;
}

#main-screen .m3-drug-item:hover,
#main-screen .m3-order-item:hover {
  background: #e8f5e9;
}

#main-screen .m3-drug-icon,
#main-screen .m3-order-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 0;
  border-radius: 2px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

#main-screen .m3-drug-icon {
  background: #a177d2;
}

#main-screen .m3-drug-text,
#main-screen .m3-order-text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

#main-screen .m3-drug-name,
#main-screen .m3-order-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .m3-drug-default,
#main-screen .m3-order-points {
  display: block;
  min-width: 0;
  margin-left: 0;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

/* Selected prescription list: same visual rhythm, controls stay editable but read like text */
#main-screen .rx-edit-item {
  display: block;
  min-height: 52px;
  padding: 5px 8px 6px 4px;
}

#main-screen .rx-claim-group.manual-grouped .rx-edit-item {
  min-height: 28px;
  padding: 5px 8px 2px 4px;
}

#main-screen .rx-proc-main {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 24px;
  margin-bottom: 1px;
}

#main-screen .rx-proc-main .m3-proc-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  font-size: 12px;
}

#main-screen .rx-drug-name {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#main-screen .rx-dose-cluster {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-left: 0;
  padding-right: 0;
}

#main-screen .rx-dose-input,
#main-screen .rx-days-input,
#main-screen .rx-dispensing-select,
#main-screen .rx-usage-picker {
  height: 22px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #111827;
  font-size: 13px;
}

#main-screen .rx-dose-input {
  width: 38px;
  padding: 0;
  text-align: right;
}

#main-screen .rx-days-input {
  width: 28px;
  padding: 0;
  text-align: right;
}

#main-screen .rx-dispensing-select {
  width: 34px;
  padding: 0;
  appearance: none;
}

#main-screen .rx-usage-picker {
  flex: 0 1 auto;
  max-width: none;
  min-width: 0;
  padding: 0;
  text-align: left;
}

#main-screen .rx-usage-picker::after {
  content: none;
}

#main-screen .rx-usage-picker span {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 24px;
  margin-left: 28px;
  padding: 0 8px 5px 0;
  border-top: 0;
  background: transparent;
}

#main-screen .rx-unit,
#main-screen .rx-days-label {
  min-width: 0;
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
}

#main-screen .proc-item-delete-btn {
  opacity: 0;
}

#main-screen .rx-claim-group:hover .proc-item-delete-btn,
#main-screen .rx-procedure-item:focus-within .proc-item-delete-btn {
  opacity: 1;
}

#main-screen .procedure-entry-row:hover .proc-item-delete-btn,
#main-screen .procedure-entry-row:focus-within .proc-item-delete-btn {
  display: flex;
}

#main-screen .rx-edit-item {
  display: block;
  padding: 6px 8px 8px 10px;
}

#main-screen .rx-proc-main {
  min-height: 28px;
  margin-bottom: 5px;
}

#main-screen .rx-proc-main .m3-proc-icon {
  margin-top: 0;
}

#main-screen .rx-proc-main .m3-proc-name {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 3px;
}

#main-screen .rx-proc-controls {
  margin-left: 38px;
}

#main-screen .rx-dose-input,
#main-screen .rx-days-input {
  width: 56px;
  height: 28px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  text-align: center;
}

#main-screen .rx-dispensing-select,
#main-screen .rx-usage-select,
#main-screen .rx-usage-picker {
  height: 28px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
}

#main-screen .m3-panel-left .m3-tab-content,
#main-screen .m3-history-list {
  height: 100%;
  min-height: 0;
  background: #fff;
}

#main-screen .m3-panel-left .m3-tab-content {
  flex: 1 1 auto;
  overflow: hidden;
}

#main-screen #history-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#main-screen #history-content > #history-list {
  flex: 1 1 0;
  height: auto;
  min-height: 100%;
}

#main-screen .m3-history-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow-y: auto;
}

#main-screen .history-card {
  border-bottom: 1px solid #cbd9d5;
  background: #fff;
}

#main-screen .m3-history-list > .history-card {
  flex: 0 0 auto;
}

#main-screen .m3-history-list > .history-card.expanded {
  flex: 0 0 auto;
  display: block;
  min-height: 0;
}

#main-screen .m3-history-list > .history-card.expanded:last-child {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

#main-screen .history-card-header {
  min-height: 36px;
  padding: 4px 7px;
  gap: 7px;
  border-bottom: 1px solid #cbd9d5;
  background: #fbfcfb;
  cursor: default;
}

#main-screen .history-card-header:hover,
#main-screen .history-card.active .history-card-header {
  background: #fbfcfb;
}

#main-screen .history-card.active .history-card-header {
  border-left: none;
}

#main-screen .history-date {
  color: #111827;
  font-size: 14px;
  font-weight: 500;
}

#main-screen .history-insurance {
  min-width: 78px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 0;
  background: #0f6b3a;
  color: #fff;
  font-size: 13px;
}

#main-screen .history-card-info {
  min-height: 31px;
  padding: 6px 7px;
  border-bottom: 1px solid #cbd9d5;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#main-screen .history-card-body {
  display: none;
  min-height: 0;
}

#main-screen .m3-history-list > .history-card.expanded .history-card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#main-screen .m3-history-list > .history-card.expanded:last-child .history-card-body {
  flex: 1 1 auto;
}

#main-screen .history-columns {
  display: flex;
  min-height: 120px;
  border-top: none;
  background: #fff;
}

#main-screen .m3-history-list > .history-card.expanded .history-columns {
  min-height: 120px;
}

#main-screen .m3-history-list > .history-card.expanded:last-child .history-columns {
  flex: 1 1 auto;
}

#main-screen .history-col-left {
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #cbd9d5;
}

#main-screen .history-col-right {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

#main-screen .history-col-header {
  height: 31px;
  padding: 5px 7px;
  border-bottom: 1px solid #cbd9d5;
  background: #fbfcfb;
  color: #4b5563;
  font-size: 13px;
  font-weight: 400;
}

#main-screen .history-soap-content {
  flex: 1 1 auto;
  padding: 10px 7px 14px;
  color: #111827;
  font-size: 13px;
  line-height: 1.55;
}

#main-screen .history-soap-section {
  margin: 0 0 18px;
}

#main-screen .history-soap-label {
  margin-bottom: 3px;
  color: #111827;
  font-weight: 500;
}

#main-screen .history-soap-text {
  color: #111827;
}

#main-screen .history-empty-row {
  padding: 10px 8px;
  color: #6b7280;
  font-size: 13px;
}

#main-screen .history-soap-content p {
  margin: 0 0 7px;
}

#main-screen .history-soap-content strong {
  color: #111827;
  font-weight: 600;
}

#main-screen .history-billing-list {
  flex: 1 1 auto;
  padding: 0;
}

#main-screen .billing-row {
  min-height: 31px;
  padding: 5px 8px;
  border-bottom: 1px solid #dbe5e1;
  color: #111827;
  font-size: 13px;
}

#main-screen .billing-row[data-history-copy-item-record-id],
#main-screen .history-prescription-row[data-history-copy-item-record-id] {
  cursor: pointer;
}

#main-screen .billing-row[data-history-copy-item-record-id]:hover,
#main-screen .history-prescription-row[data-history-copy-item-record-id]:hover {
  background: #eef9f2;
}

#main-screen .billing-name {
  color: #111827;
  font-size: 13px;
}

#main-screen .billing-qty,
#main-screen .billing-count {
  margin-left: auto;
  color: #111827;
  font-size: 12px;
}

#main-screen .billing-points {
  margin-left: auto;
  color: #111827;
  font-size: 12px;
  white-space: nowrap;
}

#main-screen .billing-count {
  margin-left: 8px;
  white-space: nowrap;
}

#main-screen .history-prescription-row {
  padding: 5px 8px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#main-screen .history-prescription-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

#main-screen .history-prescription-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin-left: 28px;
  color: #374151;
  font-size: 12px;
}

#main-screen .history-prescription-sub i {
  color: #5f6f68;
}

#main-screen .history-prescription-usage {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin-left: 28px;
  color: #111827;
  font-size: 13px;
}

#main-screen .history-prescription-row .billing-name {
  flex: 1 1 auto;
  min-width: 0;
}

#main-screen .history-prescription-row .billing-qty {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

#main-screen .m3-panel-right .m3-panel-content {
  padding: 0;
  overflow-y: auto;
  background: #fff;
}

#main-screen .m3-order-list,
#main-screen .m3-drug-list,
#main-screen .m3-set-tree {
  border-top: 1px solid #d7e2de;
}

#main-screen .m3-order-item,
#main-screen .m3-drug-item,
#main-screen .m3-tree-header,
#main-screen .m3-tree-leaf {
  min-height: 36px;
  padding: 6px 8px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#main-screen .m3-order-item:hover,
#main-screen .m3-drug-item:hover,
#main-screen .m3-tree-header:hover,
#main-screen .m3-tree-leaf:hover {
  background: #e8f5e9;
}

#main-screen .m3-order-item,
#main-screen .m3-drug-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 48px;
  padding: 6px 8px 7px 4px;
  border-bottom: 1px solid #d7e2de;
  background: #f8fbfa;
}

#main-screen .m3-drug-item.frequent {
  background: #edf8ef;
}

#main-screen .m3-order-icon,
#main-screen .m3-drug-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 0;
  border-radius: 2px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

#main-screen .m3-drug-icon {
  background: #a177d2;
}

#main-screen .m3-order-text,
#main-screen .m3-drug-text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

#main-screen .m3-order-name,
#main-screen .m3-drug-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .m3-order-points,
#main-screen .m3-drug-default {
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  margin-left: 0;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
}

#main-screen .m3-set-tree {
  border-top: 1px solid #dbe5e1;
}

#main-screen .m3-tree-item,
#main-screen .m3-tree-node-item {
  border-bottom: none;
}

#main-screen .m3-tree-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 36px;
  padding: 3px 4px;
  border-bottom: 1px solid #dbe5e1;
  background: #fff;
  color: #111827;
  font-size: 13px;
}

#main-screen .m3-tree-node-item > .m3-tree-row {
  padding-left: 4px;
}

#main-screen .m3-tree-row:hover {
  background: #f4faf6;
}

#main-screen .m3-tree-children {
  padding-left: 0;
  background: #fff;
}

#main-screen .m3-tree-node-item.expanded > .m3-tree-children {
  display: block;
}

#main-screen .m3-tree-grip {
  display: inline-flex;
  width: 18px;
  height: 26px;
  padding: 0;
  color: #7f9189;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.m3-set-preview {
  position: fixed;
  z-index: 1400;
  width: min(390px, calc(100vw - 24px));
  padding: 0;
  overflow: visible;
  background: #fff;
  border: 1px solid #cfd6d2;
  border-radius: 3px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  color: #202823;
  font-size: 13px;
  line-height: 1.65;
  pointer-events: none;
}

.m3-set-preview-scroll {
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 12px 12px 10px;
}

.m3-set-preview.hidden {
  display: none;
}

.m3-set-preview::before,
.m3-set-preview::after {
  content: '';
  position: absolute;
  top: var(--m3-set-preview-arrow-top, 50%);
  left: 100%;
  border-style: solid;
  transform: translateY(-50%);
}

.m3-set-preview::before {
  border-width: 9px 0 9px 9px;
  border-color: transparent transparent transparent #cfd6d2;
}

.m3-set-preview::after {
  margin-left: -1px;
  border-width: 8px 0 8px 8px;
  border-color: transparent transparent transparent #fff;
}

.m3-set-preview-section + .m3-set-preview-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #d8ddda;
}

.m3-set-preview-karte {
  white-space: normal;
}

.m3-set-preview-karte img {
  max-width: 100%;
  height: auto;
}

.m3-set-preview-empty {
  color: #3d4741;
}

.m3-set-preview-order-row,
.m3-set-preview-diagnosis-row {
  display: block;
  padding: 2px 0;
}

.m3-set-preview-diagnosis-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
}

.m3-set-preview-main-label {
  font-weight: 600;
}

#main-screen .m3-tree-row:hover > .m3-tree-grip,
#main-screen .m3-tree-row:focus-within > .m3-tree-grip,
#main-screen .m3-tree-item[data-category-role="large"] > .m3-tree-row > .m3-tree-grip,
#main-screen .m3-tree-item.is-dragging > .m3-tree-row > .m3-tree-grip,
#main-screen .m3-tree-node-item.is-dragging > .m3-tree-row > .m3-tree-grip {
  opacity: 1;
}

#main-screen .m3-tree-grip:hover,
#main-screen .m3-tree-grip:focus-visible {
  color: #245c45;
  outline: 0;
  background: #e7f3ec;
  border-radius: 3px;
}

#main-screen .m3-tree-toggle {
  border: 0;
  background: transparent;
  color: #1f2a30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

#main-screen .m3-tree-grip:active {
  cursor: grabbing;
}

#main-screen .m3-tree-grip > i {
  pointer-events: none;
}

#main-screen .m3-tree-toggle {
  width: 18px;
  height: 24px;
  margin-left: calc(var(--tree-depth, 0) * 14px);
  padding: 0;
  font-size: 12px;
}

#main-screen .m3-tree-toggle.spacer {
  visibility: hidden;
}

#main-screen .m3-tree-label,
#main-screen .karte-set-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

#main-screen .m3-tree-label:hover,
#main-screen .karte-set-name:hover {
  text-decoration: none;
}

#main-screen .karte-set-actions {
  margin-left: auto;
  gap: 4px;
}

#main-screen .karte-set-action-btn {
  width: 27px;
  height: 27px;
  border-color: #cbd5d1;
  border-radius: 3px;
}

#main-screen .m3-order-name,
#main-screen .m3-drug-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#main-screen .m3-order-points,
#main-screen .m3-drug-default {
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  margin-left: 0;
  color: #111827;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
}

#main-screen .m3-order-footer {
  height: 48px;
  padding: 5px 8px;
  border-top: 1px solid #cbd9d5;
  background: #fbfcfb;
}

#main-screen .m3-footer-group {
  gap: 6px;
}

#main-screen .m3-footer-btn {
  width: 40px;
  height: 38px;
  border-radius: 2px;
  background: #075b17;
}

#main-screen .m3-footer-btn:hover {
  background: #064811;
}

/* Receipt-like procedure panel polish */
#main-screen .m3-panel-right,
#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order {
  flex-basis: clamp(470px, 28vw, 520px) !important;
}

#main-screen .m3-procedure-list {
  padding: 0;
  background: #fff;
}

#main-screen .procedure-action-group,
#main-screen .rx-claim-group {
  border-bottom: 1px solid #d7e2de;
  background: #fff;
  cursor: pointer;
}

#main-screen .procedure-action-item {
  cursor: pointer;
  position: relative;
}

#main-screen .rx-procedure-item {
  cursor: pointer;
  position: relative;
  border-left: 0;
}

#main-screen .procedure-action-group.manual-grouped,
#main-screen .rx-claim-group.manual-grouped {
  border-left: 0;
  background: #fff;
}

#main-screen .procedure-action-item.is-group-anchor-selected,
#main-screen .rx-procedure-item.is-group-anchor-selected {
  background: #e8f5e9;
  box-shadow: inset 0 0 0 1px #43a85f;
}

#main-screen .procedure-action-group.is-group-anchor-selected,
#main-screen .rx-claim-group.is-group-anchor-selected {
  background: #eef9f2;
  box-shadow: inset 0 0 0 2px #8fd2d9;
}

#main-screen .procedure-action-group.is-group-anchor-selected .procedure-action-item,
#main-screen .procedure-action-group.is-group-anchor-selected .procedure-group-footer,
#main-screen .rx-claim-group.is-group-anchor-selected .rx-edit-item,
#main-screen .rx-claim-group.is-group-anchor-selected .rx-shared-controls {
  background: #eef9f2;
}

#main-screen .procedure-action-item.is-group-anchor-selected:hover,
#main-screen .rx-procedure-item.is-group-anchor-selected:hover {
  background: #ddf0e3;
}

#main-screen .procedure-action-group.manual-grouped .procedure-action-item.is-manual-group-child,
#main-screen .rx-claim-group.manual-grouped .rx-procedure-item.is-manual-group-child {
  padding-left: 12px;
}

#main-screen .procedure-action-group.manual-grouped .procedure-action-item.is-manual-group-child::before,
#main-screen .rx-claim-group.manual-grouped .rx-procedure-item.is-manual-group-child::before {
  content: none;
}

#main-screen .procedure-action-group .m3-proc-item,
#main-screen .rx-claim-group .m3-proc-item,
#main-screen .procedure-action-item,
#main-screen .rx-procedure-item {
  border-bottom: 0;
}

#main-screen .procedure-entry-row {
  min-height: 35px;
  padding: 6px 8px 6px 12px;
  gap: 8px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
}

#main-screen .procedure-action-group.grouped .m3-proc-item {
  min-height: 35px;
  padding-top: 6px;
  padding-bottom: 6px;
}

#main-screen .procedure-entry-row:hover {
  background: #f6faf7;
}

#main-screen .m3-proc-icon {
  width: 32px;
  height: 23px;
  flex: 0 0 32px;
  margin-top: 0;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

#main-screen .m3-proc-icon.blue {
  background: #6078c8;
}

#main-screen .m3-proc-icon.pink {
  background: #d889cf;
}

#main-screen .m3-proc-icon.purple {
  background: #a177d2;
}

/* 算定区分アイコン: M3の区分色へ統一 */
#main-screen .m3-proc-icon.blue,
#main-screen .m3-order-icon.blue,
.category-badge.blue {
  background: #6678cc;
}

#main-screen .m3-proc-icon.home,
#main-screen .m3-order-icon.home,
.category-badge.home {
  background: #c89e63;
}

#main-screen .m3-proc-icon.purple,
#main-screen .m3-order-icon.purple,
#main-screen .history-prescription-row .billing-icon,
.category-badge.purple {
  background: #a57bc9;
  color: #fff;
}

#main-screen .m3-proc-icon.green,
#main-screen .m3-order-icon.green,
.category-badge.green {
  background: #63bd66;
}

#main-screen .m3-proc-icon.cyan,
#main-screen .m3-order-icon.cyan,
.category-badge.cyan {
  background: #59c7dc;
}

#main-screen .m3-proc-icon.yellow,
#main-screen .m3-order-icon.yellow,
.category-badge.yellow {
  background: #e5ba43;
}

#main-screen .m3-proc-icon.orange,
#main-screen .m3-order-icon.orange,
.category-badge.orange {
  background: #f07f24;
}

#main-screen .m3-proc-icon.lime,
#main-screen .m3-order-icon.lime,
.category-badge.lime {
  background: #92bf73;
}

#main-screen .m3-proc-icon.rose,
#main-screen .m3-order-icon.rose,
.category-badge.rose {
  background: #b99093;
}

#main-screen .m3-proc-icon.pink,
#main-screen .m3-order-icon.pink,
.category-badge.pink {
  background: #d98dcc;
}

#main-screen .m3-proc-icon.self-pay,
#main-screen .m3-order-icon.self-pay,
.category-badge.self-pay,
#main-screen .self-pay-proc-item .m3-proc-icon.self-pay {
  background: #8b91a6;
}

#main-screen .procedure-action-text {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
}

#main-screen .m3-proc-name {
  color: #111827;
  font-weight: 400;
  line-height: 1.35;
}

#main-screen .m3-proc-name-nowrap {
  white-space: nowrap;
}

#main-screen .m3-proc-pts {
  flex: 0 0 60px;
  min-width: 60px;
  margin-left: auto;
  padding-top: 2px;
  color: #111827;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

#main-screen .procedure-group-footer {
  min-height: 42px;
  padding: 5px 74px 7px 48px;
  border-top: 1px solid #eef3f1;
  justify-content: flex-end;
  gap: 6px;
}

#main-screen .proc-group-count-input,
#main-screen .rx-dose-input,
#main-screen .rx-days-input,
#main-screen .self-pay-proc-input {
  height: 29px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  text-align: center;
}

#main-screen .proc-group-count-input {
  width: 56px;
}

#main-screen .rx-edit-item {
  display: block;
  min-height: 62px;
  padding: 6px 8px 7px 6px;
}

#main-screen .rx-claim-group.manual-grouped .rx-edit-item {
  min-height: 32px;
  padding: 5px 8px 3px 6px;
}

#main-screen .rx-proc-main {
  display: flex;
  align-items: flex-start;
  min-height: 27px;
  margin-bottom: 4px;
  gap: 6px;
  cursor: pointer;
}

#main-screen .rx-claim-group.manual-grouped .rx-proc-main {
  margin-bottom: 0;
}

#main-screen .rx-drug-name {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#main-screen .rx-dose-cluster {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-left: auto;
  padding-right: 34px;
}

#main-screen .rx-dose-input {
  width: 48px;
  padding: 3px 5px;
  text-align: right;
}

#main-screen .rx-unit,
#main-screen .rx-days-label {
  min-width: 16px;
  color: #111827;
  font-size: 12px;
  line-height: 28px;
}

#main-screen .rx-proc-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  margin-left: 28px;
  padding: 2px 8px 6px 0;
}

#main-screen .rx-shared-controls {
  min-height: 32px;
  margin-left: 28px;
  padding: 2px 8px 6px 0;
  border-top: 1px solid #edf3f1;
  background: #fff;
}

#main-screen .rx-dispensing-select {
  width: 76px;
  padding: 3px 22px 3px 6px;
  appearance: auto;
}

#main-screen .rx-usage-select,
#main-screen .rx-usage-picker {
  flex: 1 1 auto;
  min-width: 150px;
  max-width: none;
  padding: 3px 24px 3px 8px;
  text-align: left;
}

#main-screen .rx-dispensing-select,
#main-screen .rx-usage-select,
#main-screen .rx-usage-picker {
  height: 28px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  box-shadow: none;
  color: #111827;
  font-size: 12px;
}

#main-screen .rx-days-input {
  width: 44px;
  padding: 3px 5px;
  text-align: right;
}

#main-screen .proc-item-delete-btn {
  right: 8px;
  color: #0b5a2a;
  opacity: 0;
}

#main-screen .rx-proc-main .m3-proc-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  font-size: 12px;
}

#main-screen .rx-usage-picker::after {
  content: "";
}

#main-screen .rx-usage-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#main-screen .rx-claim-group:hover .proc-item-delete-btn,
#main-screen .rx-procedure-item:focus-within .proc-item-delete-btn {
  opacity: 1;
}
/* Final prescription column alignment override at EOF. */
#main-screen .rx-proc-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 6px;
  align-items: start;
}

#main-screen .rx-proc-main .m3-proc-icon {
  grid-column: 1;
}

#main-screen .rx-proc-main .rx-drug-name {
  grid-column: 2;
}

#main-screen .rx-prescription-text {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

#main-screen .rx-prescription-text .rx-drug-name {
  width: 100%;
}

#main-screen .rx-dose-cluster {
  display: contents;
}

#main-screen .rx-dose-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-unit {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 56px 28px 22px;
  column-gap: 5px;
  align-items: center;
}

#main-screen .rx-dispensing-select {
  grid-column: 1;
  width: 76px;
}

#main-screen .rx-usage-picker {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}

#main-screen .rx-days-input {
  grid-column: 3;
  width: 56px;
  justify-self: stretch;
}

#main-screen .rx-days-label {
  grid-column: 4;
  width: 28px;
  min-width: 28px;
  justify-self: start;
}

/* Last grouped prescription delete button override. */
#main-screen .rx-group-delete-btn {
  grid-column: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 28px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #0b5a2a;
  cursor: pointer;
  justify-self: center;
}

#main-screen .rx-group-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Position selected billing row delete buttons; visibility is controlled per row below. */
#main-screen .procedure-action-item.procedure-entry-row {
  padding-right: 40px !important;
}

#main-screen .procedure-action-item.procedure-entry-row .proc-item-delete-btn {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: inline-flex !important;
  z-index: 4;
}

#main-screen .procedure-warning-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f5a000;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

#main-screen .procedure-warning-btn:hover,
#main-screen .procedure-warning-btn:focus {
  color: #d97706;
  outline: none;
}

#main-screen .procedure-warning-btn.karte-warning-level-3 {
  color: #dc2626;
}

#main-screen .procedure-warning-btn.karte-warning-level-2 {
  color: #f97316;
}

#main-screen .procedure-warning-btn.karte-warning-level-1 {
  color: #f5a000;
}

#main-screen .procedure-warning-btn.comment-warning-code-btn {
  border-radius: 50%;
  background: #f04438;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

#main-screen .procedure-warning-btn.comment-warning-code-btn:hover,
#main-screen .procedure-warning-btn.comment-warning-code-btn:focus {
  background: #d92d20;
  color: #fff;
}

#main-screen .procedure-warning-yen-mark {
  line-height: 1;
}

#main-screen .procedure-warning-btn .fa-exclamation-circle {
  color: #dc2626;
}

#main-screen .rx-drug-mainline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
}

#main-screen .rx-prescription-text .rx-drug-mainline .rx-drug-name {
  flex: 1 1 auto;
  width: auto;
}

#main-screen .rx-requirement-badges {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 3px;
  margin-left: 4px;
}

#main-screen .rx-requirement-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  border: 1px solid #c7d2fe;
  border-radius: 3px;
  background: #eef2ff;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

#main-screen .rx-requirement-badge.long-term,
#main-screen .rx-requirement-badge.patient-choice {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

#main-screen .rx-requirement-badge.comment-required {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

#main-screen .rx-requirement-badge.temporary,
#main-screen .rx-requirement-badge.refill {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

#main-screen .prescription-warning-btn {
  margin-top: 0;
}

#main-screen .prescription-audit-icons {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

#main-screen .procedure-warning-btn.prescription-indication-btn {
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

#main-screen .procedure-warning-btn.prescription-indication-btn:hover,
#main-screen .procedure-warning-btn.prescription-indication-btn:focus {
  background: #ea580c;
  color: #fff;
}

#main-screen .self-pay-proc-item {
  min-height: 66px;
  padding: 7px 40px 8px 12px;
  align-items: flex-start;
}

#main-screen .self-pay-proc-item .self-pay-proc-controls {
  flex: 0 0 104px;
  margin-left: auto;
}

/* Stabilize the order tabs so category clicks never nudge the whole karte view. */
#main-screen .m3-common-header {
  flex: 0 0 62px !important;
  height: 62px !important;
  min-height: 62px !important;
  max-height: 62px !important;
  overflow: hidden;
}

#main-screen .m3-header-zone-order,
#main-screen .m3-order-header-wrap,
#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  height: 62px !important;
  min-height: 62px !important;
  max-height: 62px !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-header-zone-order {
  flex: 0 0 clamp(470px, 28vw, 520px) !important;
}

#main-screen .m3-order-header-wrap {
  display: flex;
  align-items: stretch;
}

#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-rows: 31px 31px;
}

#main-screen .m3-panel-tabs-row {
  flex: 0 0 31px !important;
  height: 31px !important;
  min-height: 31px !important;
  max-height: 31px !important;
  margin: 0 !important;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab,
#main-screen .m3-panel-tabs-row .m3-panel-tab:hover,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus-visible,
#main-screen .m3-panel-tabs-row .m3-panel-tab:active,
#main-screen .m3-panel-tabs-row .m3-panel-tab.active {
  height: 31px !important;
  min-height: 31px !important;
  max-height: 31px !important;
  padding: 0 6px !important;
  margin: 0 !important;
  line-height: 1 !important;
  transform: none !important;
  top: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}

#main-screen .m3-sub-header,
#main-screen .m3-subheader-order {
  flex: 0 0 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-panel-right .m3-panel-content,
#main-screen #category-tree {
  overflow-anchor: none;
}

/* Keep the order header at the same height as the settled Set tab state. */
#main-screen {
  --m3-stable-order-row-height: 34px;
  --m3-stable-order-header-height: calc(var(--m3-stable-order-row-height) * 2);
}

#main-screen .m3-common-header,
#main-screen .m3-header-zone-patient,
#main-screen .m3-header-zone-order,
#main-screen .m3-order-header-wrap,
#main-screen .m3-panel-tabs-wrapper,
#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  height: var(--m3-stable-order-header-height) !important;
  min-height: var(--m3-stable-order-header-height) !important;
  max-height: var(--m3-stable-order-header-height) !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-common-header {
  flex: 0 0 var(--m3-stable-order-header-height) !important;
}

#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  grid-template-rows: var(--m3-stable-order-row-height) var(--m3-stable-order-row-height) !important;
}

#main-screen .m3-panel-tabs-row,
#main-screen .m3-panel-tabs-row .m3-panel-tab,
#main-screen .m3-panel-tabs-row .m3-panel-tab:hover,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus,
#main-screen .m3-panel-tabs-row .m3-panel-tab:focus-visible,
#main-screen .m3-panel-tabs-row .m3-panel-tab:active,
#main-screen .m3-panel-tabs-row .m3-panel-tab.active {
  height: var(--m3-stable-order-row-height) !important;
  min-height: var(--m3-stable-order-row-height) !important;
  max-height: var(--m3-stable-order-row-height) !important;
  line-height: 1 !important;
  box-sizing: border-box;
}

/* Keep the right order/search column inside the viewport and remove click-time layout jumps. */
#main-screen .m3-panel-left,
#main-screen .m3-header-zone-patient,
#main-screen .m3-subheader-patient {
  flex: 0 1 clamp(360px, 32vw, 620px) !important;
  min-width: 280px !important;
}

#main-screen .m3-panel-right,
#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order {
  flex: 0 1 clamp(360px, 28vw, 520px) !important;
  min-width: 320px !important;
  max-width: 520px !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-zone-karte-wrapper,
#main-screen .m3-header-zone-karte,
#main-screen .m3-subheader-karte {
  min-width: 420px !important;
}

#main-screen .m3-subheader-order {
  display: flex !important;
  align-items: center;
  padding: 2px 6px !important;
}

#main-screen .m3-subheader-order .m3-subheader-search {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

#main-screen .m3-panel-tabs-row .m3-panel-tab,
#main-screen .m3-all-btn,
#main-screen .user-dropdown-btn {
  will-change: auto;
  backface-visibility: hidden;
}

#main-screen .user-dropdown {
  position: relative;
  flex: 0 0 auto;
}

#main-screen .user-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 4100;
  contain: layout paint;
}

/* Lock the karte shell rows so order-category content cannot nudge the screen. */
#main-screen {
  --m3-app-header-height: 45px;
  --m3-stable-order-row-height: 34px;
  --m3-stable-order-header-height: calc(var(--m3-stable-order-row-height) * 2);
  --m3-stable-subheader-height: 30px;
}

#main-screen.main-screen:not(.hidden) {
  display: grid !important;
  grid-template-rows:
    var(--m3-app-header-height)
    var(--m3-stable-order-header-height)
    var(--m3-stable-subheader-height)
    minmax(0, 1fr);
  height: 100vh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#main-screen .app-header {
  position: relative !important;
  height: var(--m3-app-header-height) !important;
  min-height: var(--m3-app-header-height) !important;
  max-height: var(--m3-app-header-height) !important;
  overflow: visible !important;
  z-index: 4000;
}

#main-screen .m3-common-header,
#main-screen .m3-header-zone,
#main-screen .m3-header-zone-patient,
#main-screen .m3-header-zone-karte,
#main-screen .m3-header-zone-order,
#main-screen .m3-order-header-wrap,
#main-screen .m3-panel-tabs-wrapper,
#main-screen .m3-order-header-wrap .m3-panel-tabs-wrapper {
  height: var(--m3-stable-order-header-height) !important;
  min-height: var(--m3-stable-order-header-height) !important;
  max-height: var(--m3-stable-order-header-height) !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-common-header,
#main-screen .m3-sub-header {
  min-width: 0;
}

#main-screen .m3-header-zone-karte {
  display: grid !important;
  grid-template-rows: var(--m3-stable-order-row-height) var(--m3-stable-order-row-height);
  align-items: stretch !important;
  justify-content: stretch !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

#main-screen .m3-karte-header-row1,
#main-screen .m3-karte-header-row2 {
  height: var(--m3-stable-order-row-height) !important;
  min-height: var(--m3-stable-order-row-height) !important;
  max-height: var(--m3-stable-order-row-height) !important;
  box-sizing: border-box;
}

#main-screen .m3-sub-header,
#main-screen .m3-subheader-zone,
#main-screen .m3-subheader-order {
  height: var(--m3-stable-subheader-height) !important;
  min-height: var(--m3-stable-subheader-height) !important;
  max-height: var(--m3-stable-subheader-height) !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-karte-body {
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
}

#main-screen .m3-panel-right .m3-panel-content,
#main-screen #category-tree {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}

#main-screen #category-tree > .m3-order-list,
#main-screen #category-tree > .m3-drug-list,
#main-screen #category-tree > .m3-set-tree {
  margin-top: 0 !important;
  border-top: 0 !important;
}

/* Keep prescription quantity and unit labels aligned without wrapping. */
#main-screen {
  --rx-row-icon-col: 32px;
  --rx-row-gap: 6px;
  --rx-row-input-col: 56px;
  --rx-row-unit-col: 56px;
  --rx-row-delete-col: 22px;
  --rx-row-control-first-col: 76px;
  --rx-row-pad-left: 12px;
  --rx-row-pad-right: 8px;
  --rx-control-indent: calc(var(--rx-row-icon-col) + var(--rx-row-gap));
}

#main-screen .rx-proc-main {
  display: grid !important;
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    var(--rx-row-input-col)
    var(--rx-row-unit-col)
    var(--rx-row-delete-col) !important;
  column-gap: var(--rx-row-gap) !important;
  align-items: start !important;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#main-screen .rx-edit-item.procedure-entry-row,
#main-screen .rx-claim-group.manual-grouped .rx-edit-item.procedure-entry-row {
  padding-left: var(--rx-row-pad-left);
  padding-right: var(--rx-row-pad-right);
}

#main-screen .rx-proc-main .m3-proc-icon {
  width: var(--rx-row-icon-col);
  min-width: var(--rx-row-icon-col);
  height: 23px;
  flex-basis: var(--rx-row-icon-col);
}

#main-screen .rx-proc-controls,
#main-screen .rx-shared-controls {
  display: grid !important;
  grid-template-columns:
    var(--rx-row-control-first-col)
    minmax(0, 1fr)
    var(--rx-row-input-col)
    var(--rx-row-unit-col)
    var(--rx-row-delete-col) !important;
  column-gap: var(--rx-row-gap) !important;
  align-items: center !important;
  margin-left: var(--rx-control-indent) !important;
  margin-right: 0 !important;
  width: calc(100% - var(--rx-control-indent)) !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box;
}

/* Shared controls are outside each drug row, so account for the row padding too. */
#main-screen .rx-shared-controls {
  margin-left: calc(var(--rx-row-pad-left) + var(--rx-control-indent)) !important;
  width: calc(100% - var(--rx-row-pad-left) - var(--rx-row-pad-right) - var(--rx-control-indent)) !important;
}

#main-screen .rx-unit,
#main-screen .rx-days-label {
  display: inline-flex;
  align-items: center;
  width: var(--rx-row-unit-col);
  min-width: var(--rx-row-unit-col);
  height: 28px;
  overflow: hidden;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}

#main-screen .rx-dose-input,
#main-screen .rx-days-input {
  width: var(--rx-row-input-col) !important;
  min-width: var(--rx-row-input-col);
  box-sizing: border-box;
  justify-self: stretch;
}

/* Fix the karte shell as real areas instead of gap-drawn separator lines. */
#main-screen {
  --m3-patient-column-width: clamp(360px, 32vw, 620px);
  --m3-karte-column-min-width: 420px;
  --m3-order-column-width: clamp(360px, 28vw, 520px);
  --m3-karte-soap-column-width: 43%;
}

#main-screen .m3-common-header,
#main-screen .m3-sub-header,
#main-screen .m3-karte-body {
  display: grid !important;
  grid-template-columns:
    var(--m3-patient-column-width)
    minmax(var(--m3-karte-column-min-width), 1fr)
    var(--m3-order-column-width);
  column-gap: 0 !important;
  gap: 0 !important;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#main-screen .m3-common-header {
  grid-template-rows: var(--m3-stable-order-header-height);
}

#main-screen .m3-sub-header {
  grid-template-rows: var(--m3-stable-subheader-height);
}

#main-screen .m3-karte-body {
  grid-template-rows: minmax(0, 1fr);
}

#main-screen .m3-header-zone-patient,
#main-screen .m3-subheader-patient,
#main-screen .m3-panel-left {
  grid-column: 1;
}

#main-screen .m3-header-zone-karte,
#main-screen .m3-subheader-karte,
#main-screen .m3-zone-karte-wrapper {
  grid-column: 2;
}

#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order,
#main-screen .m3-panel-right {
  grid-column: 3;
}

#main-screen .m3-header-zone-patient,
#main-screen .m3-subheader-patient,
#main-screen .m3-panel-left,
#main-screen .m3-header-zone-karte,
#main-screen .m3-subheader-karte,
#main-screen .m3-zone-karte-wrapper,
#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order,
#main-screen .m3-panel-right {
  flex: none !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box;
  overflow: hidden;
}

#main-screen .m3-header-zone-patient,
#main-screen .m3-subheader-patient,
#main-screen .m3-panel-left,
#main-screen .m3-header-zone-karte,
#main-screen .m3-subheader-karte,
#main-screen .m3-zone-karte-wrapper {
  border-right: 1px solid #cbd9d5 !important;
}

#main-screen .m3-header-zone-order,
#main-screen .m3-subheader-order,
#main-screen .m3-panel-right {
  border-right: 0 !important;
}

#main-screen .m3-zone-karte-wrapper {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

#main-screen .m3-subheader-karte {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

#main-screen .m3-subheader-karte-inner {
  display: grid !important;
  grid-template-columns: var(--m3-karte-soap-column-width) minmax(0, 1fr);
  column-gap: 0 !important;
}

#main-screen .m3-subheader-soap-part,
#main-screen .m3-subheader-proc-part {
  flex: none !important;
  width: auto !important;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}

#main-screen .m3-subheader-soap-part {
  border-right: 0 !important;
}

#main-screen .m3-subheader-proc-part {
  border-left: 1px solid #cbd9d5 !important;
  border-right: 0 !important;
}

#main-screen .m3-karte-panels {
  display: grid !important;
  grid-template-columns: var(--m3-karte-soap-column-width) minmax(0, 1fr);
  gap: 0 !important;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#main-screen .m3-karte-panels .m3-panel-soap,
#main-screen .m3-karte-panels .m3-panel-procedure {
  flex: none !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box;
}

#main-screen .m3-karte-panels .m3-panel-soap {
  border-right: 0 !important;
}

#main-screen .m3-karte-panels .m3-panel-procedure {
  border-left: 1px solid #cbd9d5 !important;
}

#main-screen .m3-soap-editor,
#main-screen .m3-procedure-list,
#main-screen .m3-panel-left .m3-tab-content,
#main-screen .m3-panel-right .m3-panel-content {
  scrollbar-gutter: stable;
}

/* Selected procedure hover state: normal shows points, hover/focus shows delete controls. */
#main-screen #procedure-items .procedure-action-item.procedure-entry-row {
  padding-right: 8px !important;
  align-items: center;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row > .m3-proc-icon,
#main-screen #procedure-items .procedure-action-item.procedure-entry-row > .m3-proc-pts {
  align-self: center;
  margin-top: 0;
  padding-top: 0;
}

/* Set tree hierarchy colors and persistent category controls. */
#main-screen #category-tree [data-category-role="large"] > .m3-tree-row {
  background: #f4f6f5;
  border-bottom: 1px solid #dce2df;
}

#main-screen #category-tree [data-category-role="middle"] > .m3-tree-row {
  background: #f4f6f5;
  border-bottom: 1px solid #dce2df;
}

#main-screen #category-tree [data-category-role="small"] > .m3-tree-row {
  background: #fafbfa;
  border-bottom: 1px solid #dce2df;
}

#main-screen #category-tree [data-category-role="large"] > .m3-tree-row:hover {
  background: #eef1ef;
}

#main-screen #category-tree [data-category-role="middle"] > .m3-tree-row:hover {
  background: #eef1ef;
}

#main-screen #category-tree [data-category-role="small"] > .m3-tree-row:hover {
  background: #f6f8f7;
}

#main-screen #category-tree .karte-set-actions {
  display: inline-flex;
  visibility: visible;
  opacity: 1;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row .proc-item-delete-btn {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 4;
}

#main-screen.patient-overview #karte-date-display,
#main-screen.patient-overview #karte-no-record-title {
  visibility: hidden;
}

#main-screen #procedure-items .self-pay-proc-item.procedure-entry-row {
  display: grid !important;
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    var(--order-numeric-control-width)
    var(--rx-row-delete-col);
  column-gap: var(--rx-row-gap);
  align-items: start;
  padding: 6px var(--rx-row-pad-right) 7px var(--rx-row-pad-left) !important;
}

#main-screen #procedure-items .self-pay-proc-item .m3-proc-icon {
  grid-column: 1;
  width: var(--rx-row-icon-col);
  min-width: var(--rx-row-icon-col);
}

#main-screen #procedure-items .self-pay-proc-item .procedure-action-text {
  grid-column: 2;
  min-width: 0;
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-controls {
  grid-column: 3;
  grid-row: 1 / span 2;
  justify-self: end;
  align-self: start;
  flex: none;
  width: var(--order-numeric-control-width);
  margin-left: 0;
}

#main-screen #procedure-items .self-pay-proc-item.procedure-entry-row > .proc-item-delete-btn {
  position: static !important;
  grid-column: 4;
  grid-row: 1;
  align-self: start;
  justify-self: center;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  width: var(--rx-row-delete-col);
  height: 23px;
  margin: 0;
  padding: 0;
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-field {
  display: grid;
  grid-template-columns: var(--order-numeric-input-col) var(--order-numeric-unit-col);
  column-gap: var(--rx-row-gap);
  align-items: center;
  width: 100%;
  justify-content: end;
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-input {
  flex: 0 0 auto;
  grid-column: 1;
  justify-self: end;
  width: var(--order-numeric-input-col) !important;
  min-width: var(--order-numeric-input-col);
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-quantity {
  width: var(--order-numeric-input-col) !important;
  min-width: var(--order-numeric-input-col);
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-field span {
  grid-column: 2;
  width: var(--order-numeric-unit-col);
  min-width: var(--order-numeric-unit-col);
  text-align: left;
  white-space: nowrap;
}

#main-screen #procedure-items .proc-item-delete-btn,
#main-screen #procedure-items .procedure-action-comment-remove,
#main-screen #procedure-items .procedure-group-delete-btn,
#main-screen #procedure-items .rx-group-delete-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:hover > .proc-item-delete-btn,
#main-screen #procedure-items .procedure-action-item.procedure-entry-row:focus-within > .proc-item-delete-btn,
#main-screen #procedure-items .procedure-action-item.procedure-entry-row:hover .procedure-action-comment-remove,
#main-screen #procedure-items .procedure-action-item.procedure-entry-row:focus-within .procedure-action-comment-remove,
#main-screen #procedure-items .procedure-action-group:hover > .procedure-group-footer .procedure-group-delete-btn,
#main-screen #procedure-items .procedure-action-group:focus-within > .procedure-group-footer .procedure-group-delete-btn,
#main-screen #procedure-items .rx-procedure-item.procedure-entry-row:hover .proc-item-delete-btn,
#main-screen #procedure-items .rx-procedure-item.procedure-entry-row:focus-within .proc-item-delete-btn,
#main-screen #procedure-items .procedure-group-footer:hover .procedure-group-delete-btn,
#main-screen #procedure-items .procedure-group-footer:focus-within .procedure-group-delete-btn,
#main-screen #procedure-items .rx-shared-controls:hover .rx-group-delete-btn,
#main-screen #procedure-items .rx-shared-controls:focus-within .rx-group-delete-btn {
  opacity: 1 !important;
  visibility: visible;
  pointer-events: auto;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row .m3-proc-pts {
  opacity: 1 !important;
  visibility: visible;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:hover > .m3-proc-pts,
#main-screen #procedure-items .procedure-action-item.procedure-entry-row:focus-within > .m3-proc-pts {
  opacity: 0 !important;
  visibility: hidden;
}

/* M3-like prescription row refinement: keep quantity/day controls closer to the right edge. */
#main-screen {
  --rx-row-unit-col: 56px;
  --rx-row-delete-col: 18px;
  --rx-row-pad-right: 4px;
  --order-numeric-input-col: var(--rx-row-input-col);
  --order-numeric-unit-col: 56px;
  --order-numeric-control-width: calc(var(--order-numeric-input-col) + var(--rx-row-gap) + var(--order-numeric-unit-col));
}

#main-screen .rx-unit,
#main-screen .rx-days-label {
  justify-content: flex-start;
  width: var(--rx-row-unit-col);
  min-width: var(--rx-row-unit-col);
}

#main-screen .rx-unit.rx-unit-stacked {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  height: 29px;
  line-height: 1.05;
  white-space: normal;
}

#main-screen .rx-unit.rx-unit-stacked .rx-unit-line {
  display: block;
}

#main-screen #procedure-items .rx-proc-main {
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    var(--order-numeric-control-width)
    var(--rx-row-delete-col) !important;
}

#main-screen #procedure-items .rx-dose-cluster {
  grid-column: 3;
  display: inline-grid !important;
  grid-template-columns: var(--order-numeric-input-col) var(--order-numeric-unit-col);
  column-gap: var(--rx-row-gap);
  align-items: center;
  justify-content: end;
  width: var(--order-numeric-control-width);
  min-width: var(--order-numeric-control-width);
  margin-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box;
  white-space: nowrap;
}

#main-screen #procedure-items .rx-dose-cluster .rx-dose-input,
#main-screen #procedure-items .rx-days-cluster .rx-days-input,
#main-screen #procedure-items .proc-group-count-cluster .proc-group-count-input {
  flex: 0 0 var(--order-numeric-input-col);
  grid-column: 1;
  justify-self: end;
  width: var(--order-numeric-input-col) !important;
  min-width: var(--order-numeric-input-col);
  text-align: left !important;
}

#main-screen #procedure-items .rx-dose-cluster .rx-unit,
#main-screen #procedure-items .rx-days-cluster .rx-days-label,
#main-screen #procedure-items .proc-group-count-cluster .proc-group-count-unit {
  flex: 0 0 auto;
  grid-column: 2;
  width: var(--order-numeric-unit-col);
  min-width: var(--order-numeric-unit-col);
  text-align: left;
  white-space: nowrap;
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-input {
  text-align: left !important;
}

/* 自費も通常算定の回数欄と同じ右端に揃える。 */
#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-controls {
  width: calc(var(--order-numeric-input-col) + var(--rx-row-gap) + 18px);
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-field {
  grid-template-columns: var(--order-numeric-input-col) 18px;
}

#main-screen #procedure-items .self-pay-proc-item .self-pay-proc-field span {
  width: 18px;
  min-width: 18px;
}

#main-screen #procedure-items .rx-dose-cluster .rx-unit.rx-unit-stacked {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  height: 29px;
  line-height: 1.05;
  white-space: normal;
}

#main-screen #procedure-items .rx-dose-cluster .rx-unit.rx-unit-stacked .rx-unit-line {
  display: block;
}

#main-screen #procedure-items .rx-proc-controls,
#main-screen #procedure-items .rx-shared-controls {
  grid-template-columns:
    var(--rx-row-control-first-col)
    minmax(0, 1fr)
    var(--order-numeric-control-width)
    var(--rx-row-delete-col) !important;
}

#main-screen #procedure-items .rx-days-cluster,
#main-screen #procedure-items .proc-group-count-cluster {
  display: inline-grid;
  grid-template-columns: var(--order-numeric-input-col) var(--order-numeric-unit-col);
  column-gap: var(--rx-row-gap);
  align-items: center;
  justify-content: end;
  width: var(--order-numeric-control-width);
  min-width: var(--order-numeric-control-width);
  white-space: nowrap;
}

#main-screen #procedure-items .rx-proc-controls .rx-days-cluster,
#main-screen #procedure-items .rx-shared-controls .rx-days-cluster {
  grid-column: 3;
  justify-self: end;
}

#main-screen #procedure-items .rx-shared-controls .rx-group-delete-btn {
  grid-column: 4;
}

/* A standalone prescription is deleted from the bottom-right control column. */
#main-screen #procedure-items .rx-proc-controls > .rx-control-delete-btn {
  position: static !important;
  grid-column: 4;
  align-self: center;
  justify-self: center;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  width: var(--rx-row-delete-col);
  height: 28px;
  margin: 0;
  padding: 0;
}

#main-screen #procedure-items .procedure-group-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--order-numeric-control-width) var(--rx-row-delete-col);
  column-gap: var(--rx-row-gap);
  align-items: center;
  padding-left: var(--rx-row-pad-left) !important;
  padding-right: var(--rx-row-pad-right) !important;
}

#main-screen #procedure-items .procedure-group-footer .proc-group-count-cluster {
  grid-column: 2;
  justify-self: end;
}

#main-screen #procedure-items .procedure-group-footer .procedure-group-delete-btn {
  grid-column: 3;
  justify-self: center;
}

#main-screen .rx-proc-main .proc-item-delete-btn {
  justify-self: center;
}

#main-screen .procedure-action-comments {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-top: 4px;
  gap: 3px;
}

#main-screen .procedure-action-comment-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  width: 100%;
  min-height: 26px;
  column-gap: 4px;
}

#main-screen .procedure-action-comment-row.is-editable-text-comment {
  align-items: center;
}

#main-screen .procedure-action-comment-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: #5b6b63;
  font-size: 13px;
}

#main-screen .procedure-action-comment-visual-free .procedure-action-comment-icon {
  color: #5b6b63;
  font-size: 13px;
}

#main-screen .procedure-action-comment-visual-karte .procedure-action-comment-icon {
  color: #4f6472;
  font-size: 14px;
}

#main-screen .procedure-action-comment-visual-document .procedure-action-comment-icon {
  color: #0b5a2a;
  font-size: 12px;
}

#main-screen .procedure-action-comment-karte .procedure-action-comment-icon {
  font-size: 14px;
}

#main-screen .procedure-action-comment-body {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
}

#main-screen .procedure-action-comment-row.is-editable-text-comment .procedure-action-comment-body {
  align-items: center;
}

#main-screen .procedure-action-comment-row.is-editable-text-comment .procedure-action-comment-icon,
#main-screen .procedure-action-comment-row.is-editable-text-comment .procedure-action-comment-remove {
  margin-top: 0;
}

#main-screen .procedure-action-comment-meta {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 3px;
}

#main-screen .procedure-action-comment-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 58px;
  min-height: 58px;
  max-height: 240px;
  padding: 5px 7px;
  box-sizing: border-box;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  resize: none;
  overflow: auto;
  white-space: pre-wrap;
}

#main-screen .procedure-action-comment-typed-input {
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  padding: 5px 8px;
  resize: none;
  white-space: normal;
}

#main-screen .procedure-action-comment-typed-label {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: inherit;
}

#main-screen .procedure-action-comment-name {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 25px;
  padding: 3px 6px;
  border: 1px solid #cbd9d5;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#main-screen .procedure-action-comment-remove {
  justify-self: center;
  width: 18px;
  height: 24px;
  color: #0b5a2a;
  font-weight: 700;
}

#main-screen .procedure-action-comment-remove:hover {
  background: #e9f6ec;
  color: #0b5a2a;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) {
  flex-wrap: wrap;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .procedure-action-comments {
  order: 10;
  flex: 0 0 calc(100% - 39px);
  width: calc(100% - 39px);
  margin: 3px 0 0 39px;
}

#main-screen #procedure-items .self-pay-proc-item.procedure-entry-row > .procedure-action-comments {
  grid-column: 2 / 5;
  grid-row: 2;
  width: 100%;
  margin: 3px 0 0;
}

/* M3-style procedure group: action, comments, and quantity are distinct rows. */
#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) {
  display: grid !important;
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    60px
    var(--rx-row-delete-col);
  column-gap: var(--rx-row-gap);
  align-items: start;
  min-height: 35px;
  padding: 6px var(--rx-row-pad-right) 4px var(--rx-row-pad-left) !important;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .m3-proc-icon {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .procedure-action-text {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding-top: 2px;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .m3-proc-pts {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  width: 60px;
  min-width: 60px;
  margin: 0;
  padding-top: 2px;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .proc-item-delete-btn {
  position: static !important;
  grid-column: 4;
  grid-row: 1;
  align-self: start;
  justify-self: center;
  width: var(--rx-row-delete-col);
  height: 23px;
  margin: 0;
  padding: 0;
  transform: none !important;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) > .procedure-action-comments {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  margin: 4px 0 0;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) .procedure-action-comment-row {
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    60px
    var(--rx-row-delete-col);
  column-gap: var(--rx-row-gap);
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) .procedure-action-comment-icon {
  grid-column: 1;
  justify-self: center;
  width: var(--rx-row-icon-col);
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) .procedure-action-comment-body {
  grid-column: 2 / 4;
  min-width: 0;
}

#main-screen #procedure-items .procedure-action-item.procedure-entry-row:not(.self-pay-proc-item) .procedure-action-comment-remove {
  grid-column: 4;
  justify-self: center;
  width: var(--rx-row-delete-col);
}

#main-screen #procedure-items .procedure-action-group > .procedure-group-footer {
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    calc(var(--order-numeric-input-col) + var(--rx-row-gap) + 18px)
    var(--rx-row-delete-col);
  min-height: 38px;
  padding: 3px var(--rx-row-pad-right) 6px var(--rx-row-pad-left) !important;
  border-top: 0;
}

#main-screen #procedure-items .procedure-action-group > .procedure-group-footer .proc-group-count-cluster {
  grid-column: 3;
  grid-template-columns: var(--order-numeric-input-col) 18px;
  width: calc(var(--order-numeric-input-col) + var(--rx-row-gap) + 18px);
  min-width: calc(var(--order-numeric-input-col) + var(--rx-row-gap) + 18px);
}

#main-screen #procedure-items .procedure-action-group > .procedure-group-footer .proc-group-count-unit {
  width: 18px;
  min-width: 18px;
}

#main-screen #procedure-items .procedure-action-group > .procedure-group-footer .procedure-group-delete-btn {
  grid-column: 4;
}


/* M3-like prescription comments: comments use the same right-side delete column as the drug row. */
#main-screen #procedure-items .rx-procedure-item .rx-proc-main > .proc-item-delete-btn {
  position: static !important;
  grid-column: 4;
  grid-row: 1;
  align-self: start;
  transform: none !important;
  width: var(--rx-row-delete-col);
  height: 23px;
  margin: 0;
  padding: 0;
  justify-self: center;
}

#main-screen .rx-proc-main > .procedure-action-comments {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-top: 0;
  gap: 2px;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-row {
  display: grid;
  grid-template-columns:
    var(--rx-row-icon-col)
    minmax(0, 1fr)
    var(--rx-row-input-col)
    var(--rx-row-unit-col)
    var(--rx-row-delete-col);
  column-gap: var(--rx-row-gap);
  align-items: center;
  width: 100%;
  min-height: 24px;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-row.is-editable-text-comment {
  min-height: 26px;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-icon {
  grid-column: 1;
  width: var(--rx-row-icon-col);
  justify-content: center;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-body {
  grid-column: 2 / 5;
  min-width: 0;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-input {
  width: 100%;
  height: 58px;
  min-height: 58px;
  box-sizing: border-box;
}

#main-screen .rx-proc-main > .procedure-action-comments .procedure-action-comment-remove {
  grid-column: 5;
  width: var(--rx-row-delete-col);
  height: 22px;
  color: #0b5a2a;
  font-weight: 700;
  justify-self: center;
}

#main-screen .rx-proc-main > .procedure-action-comments .is-generic-name-comment .procedure-action-comment-name {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1.35;
}

.numeric-keypad {
  position: fixed;
  z-index: 30000;
  display: grid;
  grid-template-columns: repeat(3, 36px);
  width: max-content;
  padding: 1px;
  border: 1px solid #cbd9d5;
  background: #fff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.18);
}

.numeric-keypad.hidden {
  display: none;
}

.numeric-keypad-key {
  width: 36px;
  height: 31px;
  border: 0;
  border-right: 1px solid #d7e1dc;
  border-bottom: 1px solid #d7e1dc;
  background: #fff;
  color: #111827;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.numeric-keypad-key:nth-child(3n) {
  border-right: 0;
}

.numeric-keypad-key:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.numeric-keypad-key:hover,
.numeric-keypad-key:focus-visible {
  background: #eaf6ef;
  color: #0b5a2a;
  outline: none;
}

.numeric-keypad-key:disabled {
  background: #f3f5f4;
  color: #b8c2be;
  cursor: not-allowed;
}

.numeric-keypad-key.is-clear {
  color: #0b5a2a;
  font-weight: 700;
}

/* 労災・自賠責（患者保険等） */
.labor-auto-add-control {
  position: relative;
  display: inline-flex;
}

.labor-auto-add-menu {
  position: absolute;
  z-index: 1200;
  top: 30px;
  right: -116px;
  width: 160px;
  padding: 8px 0;
  border: 1px solid #d5dbd8;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.labor-auto-add-menu button {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 16px;
  border: 0;
  background: #fff;
  color: #111827;
  text-align: left;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.labor-auto-add-menu button:hover,
.labor-auto-add-menu button:focus-visible {
  background: #eef5f0;
  outline: none;
}

.labor-auto-insurance-table th:nth-child(1) { width: 24%; }
.labor-auto-insurance-table th:nth-child(2) { width: 34%; }
.labor-auto-insurance-table th:nth-child(3) { width: 18%; }
.labor-auto-insurance-table th:nth-child(4) { width: 18%; }
.labor-auto-insurance-table th:nth-child(5) { width: 42px; }

.labor-auto-insurance-table .insurance-row-actions {
  width: 42px;
}

.modal-workers-insurance {
  width: min(1024px, calc(100vw - 32px));
  height: min(840px, calc(100vh - 52px));
  max-height: calc(100vh - 52px);
  background: #fff;
}

#workers-insurance-modal {
  align-items: flex-start;
  padding-top: 44px;
  box-sizing: border-box;
}

.workers-insurance-patient {
  min-height: 58px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid #d5dcda;
  background: #fff;
  color: #111827;
  font-size: 18px;
}

.workers-insurance-form {
  overflow-y: auto;
  padding: 0 18px;
  background: #f7f8f8;
}

.workers-insurance-form-row {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: 52px;
  border-bottom: 1px solid #d5dcda;
  background: #f7f8f8;
}

.workers-insurance-form-row > label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  padding: 8px 0;
  color: #111827;
  font-size: 14px;
  font-weight: 400;
}

.workers-insurance-form-row > label small {
  grid-column: 1 / -1;
  margin-top: -5px;
  color: #374151;
  font-size: 9px;
  line-height: 1.2;
}

.workers-form-required {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 19px;
  padding: 0 4px;
  border-radius: 1px;
  background: #ef7565;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.workers-insurance-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 0 7px 10px;
}

.workers-insurance-field input,
.workers-insurance-field select {
  width: 100%;
  height: 31px;
  min-width: 0;
  padding: 3px 8px;
  border: 1px solid #ccd5d2;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 14px;
}

.workers-insurance-field input:focus,
.workers-insurance-field select:focus {
  border-color: #159bd4;
  outline: 2px solid rgba(21, 155, 212, 0.28);
}

.workers-policy-number-field input { flex: 1; }

.workers-confirm-later {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  white-space: nowrap;
  font-size: 13px;
}

.workers-confirm-later input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.workers-single-date-field input { max-width: 360px; }

.workers-date-range-field input {
  flex: 1 1 0;
  width: auto;
}

.workers-address-row,
.workers-office-row {
  min-height: 78px;
}

.workers-address-field,
.workers-office-field {
  position: relative;
  padding-top: 29px;
}

.workers-prefecture-caption {
  position: absolute;
  top: 6px;
  left: 10px;
  color: #111827;
  font-size: 12px;
}

.workers-address-field select,
.workers-office-field select:first-of-type {
  flex: 0 0 120px;
  width: 120px;
}

.workers-address-field input,
.workers-office-field select:last-of-type {
  flex: 1 1 auto;
}

.workers-initial-month-field input {
  width: 120px;
}

.modal-workers-insurance .modal-footer-insurance {
  min-height: 50px;
  padding: 6px 10px;
  background: #f7f8f8;
}

.modal-workers-insurance .modal-footer-insurance .btn-register {
  min-width: 55px;
  height: 31px;
  padding: 0 13px;
}

#auto-insurance-modal {
  align-items: flex-start;
  padding-top: 44px;
  box-sizing: border-box;
}

.modal-auto-insurance {
  width: min(1024px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - 52px);
  background: #fff;
}

.auto-insurance-form {
  flex: 0 1 auto;
  overflow-y: auto;
}

.auto-insurance-form .workers-insurance-form-row {
  min-height: 42px;
}

.auto-insurance-form .workers-single-date-field input {
  max-width: none;
}

.auto-calculation-options {
  gap: 15px;
}

.auto-calculation-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: #111827;
  font-size: 14px;
}

.auto-calculation-options input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: #3578e5;
}

.modal-auto-insurance .modal-footer-insurance {
  min-height: 44px;
  padding: 6px 10px;
  background: #f7f8f8;
}

.modal-auto-insurance .modal-footer-insurance .btn-register {
  min-width: 55px;
  height: 31px;
  padding: 0 13px;
}

/* レセプト特記事項（患者保険等） */
.receipt-special-note-table th:nth-child(1) { width: 38%; }
.receipt-special-note-table th:nth-child(2) { width: 25%; }
.receipt-special-note-table th:nth-child(3) { width: 25%; }
.receipt-special-note-table th:nth-child(4) { width: 42px; }

.receipt-special-note-table .insurance-row-actions {
  width: 42px;
}

#receipt-special-note-modal {
  align-items: flex-start;
  padding-top: min(24vh, 160px);
  box-sizing: border-box;
}

.modal-receipt-special-note {
  width: min(600px, calc(100vw - 30px));
  height: min(460px, calc(100vh - 42px));
  border-radius: 0;
  background: #fff;
}

.modal-receipt-special-note .modal-header {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  background: #0b5717;
}

.modal-receipt-special-note .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-receipt-special-note .modal-close {
  font-size: 27px;
  font-weight: 700;
  opacity: 1;
}

.receipt-special-note-form {
  flex: 1 1 auto;
  padding: 7px 6px 0;
  background: #fff;
}

.receipt-special-note-form-row {
  display: grid;
  grid-template-columns: 126px 215px;
  align-items: center;
  min-height: 32px;
  color: #111827;
  font-size: 14px;
}

.receipt-special-note-form-row label {
  white-space: nowrap;
}

.receipt-special-note-form-row select,
.receipt-special-note-form-row input {
  width: 215px;
  height: 29px;
  padding: 2px 9px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-special-note-form-row input::placeholder {
  color: #94a3a8;
}

.receipt-special-note-footer {
  display: flex;
  flex: 0 0 49px;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 11px;
  box-sizing: border-box;
  border-top: 1px solid #d4ddda;
  background: #f7f8f8;
}

.receipt-special-note-footer .btn-register {
  width: 90px;
  height: 36px;
  padding: 0 12px;
  border-radius: 2px;
  background: #0b5717;
  font-size: 14px;
}

/* 症状詳記・傷病の経過（患者保険等） */
.receipt-symptom-detail-table th:nth-child(1) { width: 49%; }
.receipt-symptom-detail-table th:nth-child(2) { width: 15%; }
.receipt-symptom-detail-table th:nth-child(3) { width: 16%; }
.receipt-symptom-detail-table th:nth-child(4) { width: 14%; }
.receipt-symptom-detail-table th:nth-child(5) { width: 42px; }

.receipt-symptom-detail-table .insurance-row-actions {
  width: 42px;
}

#receipt-symptom-detail-modal {
  align-items: center;
  box-sizing: border-box;
}

.modal-receipt-symptom-detail {
  display: flex;
  width: min(1024px, calc(100vw - 32px));
  height: min(708px, calc(100vh - 30px));
  max-height: calc(100vh - 30px);
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.modal-receipt-symptom-detail .modal-header {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  background: #0b5717;
}

.modal-receipt-symptom-detail .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-receipt-symptom-detail .modal-close {
  font-size: 27px;
  font-weight: 700;
  opacity: 1;
}

.receipt-symptom-detail-form {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  background: #fff;
  color: #111827;
  font-size: 14px;
}

.receipt-symptom-detail-row-label {
  box-sizing: border-box;
  padding-left: 10px;
  white-space: nowrap;
}

.receipt-symptom-detail-kind-row {
  display: grid;
  min-height: 76px;
  grid-template-columns: 270px minmax(0, 1fr);
  align-items: start;
  border-bottom: 1px solid #d7dfdc;
}

.receipt-symptom-detail-kind-row > .receipt-symptom-detail-row-label {
  padding-top: 13px;
}

.receipt-symptom-detail-kind-controls {
  display: grid;
  grid-template-columns: 134px minmax(0, 1fr);
  grid-template-rows: 38px 38px;
  align-items: center;
  padding-right: 9px;
}

.receipt-symptom-detail-kind-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.receipt-symptom-detail-kind-controls select {
  width: 100%;
  height: 29px;
  padding: 2px 9px;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

#main-screen .m3-tree-item.is-dragging > .m3-tree-row,
#main-screen .m3-tree-node-item.is-dragging > .m3-tree-row {
  opacity: 0.42;
}

#main-screen .m3-tree-row.drag-before::after,
#main-screen .m3-tree-row.drag-after::after {
  content: '';
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  height: 3px;
  pointer-events: none;
  background: #16834f;
}

#main-screen .m3-tree-row.drag-before::after {
  top: 0;
  transform: translateY(-50%);
}

#main-screen .m3-tree-row.drag-after::after {
  bottom: 0;
  transform: translateY(50%);
}

#main-screen .m3-tree-row.drag-inside {
  background: #dff3e7;
  box-shadow: inset 0 0 0 2px #16834f;
}

.receipt-claim-result-warning {
  margin-top: 5px;
  color: #a44900;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.receipt-claim-result-warning i {
  margin-right: 4px;
}

.receipt-symptom-detail-kind-controls select:disabled {
  border-color: #d7dcda;
  background: #eef1f0;
  color: #737b78;
  cursor: not-allowed;
  opacity: 1;
}

.receipt-symptom-detail-content-row {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: 270px minmax(0, 1fr);
  border-bottom: 1px solid #d7dfdc;
}

.receipt-symptom-detail-content-row > .receipt-symptom-detail-row-label {
  padding-top: 10px;
}

.receipt-symptom-detail-content-row textarea {
  min-height: 180px;
  margin: 10px 9px 16px 0;
  padding: 8px;
  resize: none;
  border: 1px solid #cbd5d1;
  border-radius: 0;
  background: #fff;
  color: #111827;
  font: inherit;
  line-height: 1.5;
}

.receipt-symptom-detail-period-row,
.receipt-symptom-detail-insurance-row {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid #d7dfdc;
}

.receipt-symptom-detail-period-row {
  min-height: 50px;
}

.receipt-symptom-detail-insurance-row {
  min-height: 49px;
}

.receipt-symptom-detail-row-label small {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 400;
}

.receipt-symptom-detail-period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.receipt-symptom-detail-period-controls input {
  width: 215px;
  height: 29px;
  padding: 2px 9px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-symptom-detail-period-controls input::placeholder {
  color: #94a3a8;
}

.receipt-symptom-detail-insurance-row select {
  width: calc(100% - 9px);
  height: 29px;
  padding: 2px 9px;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-symptom-detail-footer {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 11px;
  box-sizing: border-box;
  background: #f7f8f8;
}

.receipt-symptom-detail-footer .btn-register {
  width: 55px;
  height: 32px;
  padding: 0 10px;
  border-radius: 2px;
  background: #0b5717;
  font-size: 14px;
}

.receipt-summary-comment-table th:nth-child(1) { width: 28%; }
.receipt-summary-comment-table th:nth-child(2) { width: 23%; }
.receipt-summary-comment-table th:nth-child(3) { width: 24%; }
.receipt-summary-comment-table th:nth-child(4) { width: 19%; }
.receipt-summary-comment-table th:nth-child(5) { width: 42px; }

.receipt-summary-comment-table .insurance-row-actions {
  text-align: center;
}

#receipt-summary-comment-modal {
  align-items: center;
  box-sizing: border-box;
}

.modal-receipt-summary-comment {
  display: flex;
  width: min(600px, calc(100vw - 32px));
  height: min(698px, calc(100vh - 30px));
  max-height: calc(100vh - 30px);
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.modal-receipt-summary-comment .modal-header {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  background: #0b5717;
}

.modal-receipt-summary-comment .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-receipt-summary-comment .modal-close {
  font-size: 27px;
  font-weight: 700;
  opacity: 1;
}

.receipt-summary-comment-form {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  background: #fff;
  color: #111827;
  font-size: 14px;
}

.receipt-summary-comment-row-label {
  box-sizing: border-box;
  padding-left: 10px;
  white-space: nowrap;
}

.receipt-summary-comment-position-row,
.receipt-summary-comment-content-row,
.receipt-summary-comment-period-row,
.receipt-summary-comment-insurance-row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  border-bottom: 1px solid #d7dfdc;
}

.receipt-summary-comment-position-row {
  min-height: 50px;
  align-items: center;
}

.receipt-summary-comment-position-row select,
.receipt-summary-comment-insurance-row select {
  width: calc(100% - 10px);
  height: 29px;
  padding: 2px 9px;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-summary-comment-content-row {
  min-height: 0;
  flex: 1 1 auto;
}

.receipt-summary-comment-content-row > .receipt-summary-comment-row-label {
  padding-top: 10px;
}

.receipt-summary-comment-content-row textarea {
  min-height: 180px;
  margin: 48px 10px 18px 0;
  padding: 8px;
  resize: none;
  border: 1px solid #cbd5d1;
  border-radius: 0;
  background: #fff;
  color: #111827;
  font: inherit;
  line-height: 1.5;
}

.receipt-summary-comment-period-row {
  min-height: 67px;
  align-items: center;
}

.receipt-summary-comment-insurance-row {
  min-height: 49px;
  align-items: center;
}

.receipt-summary-comment-row-label small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 400;
}

.receipt-summary-comment-period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.receipt-summary-comment-period-controls input {
  width: 193px;
  height: 29px;
  padding: 2px 9px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-summary-comment-period-controls input::placeholder {
  color: #94a3a8;
}

.receipt-summary-comment-footer {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 11px;
  box-sizing: border-box;
  background: #f7f8f8;
}

.receipt-summary-comment-footer .btn-register {
  width: 55px;
  height: 32px;
  padding: 0 10px;
  border-radius: 2px;
  background: #0b5717;
  font-size: 14px;
}

/* 福祉請求書備考欄コメント（患者保険等） */
.welfare-invoice-comment-table th:nth-child(1) { width: 49%; }
.welfare-invoice-comment-table th:nth-child(2) { width: 25%; }
.welfare-invoice-comment-table th:nth-child(3) { width: 20%; }
.welfare-invoice-comment-table th:nth-child(4) { width: 42px; }

.welfare-invoice-comment-table .insurance-row-actions {
  width: 42px;
  text-align: center;
}

#welfare-invoice-comment-modal {
  align-items: center;
  box-sizing: border-box;
}

.modal-welfare-invoice-comment {
  display: flex;
  width: min(1022px, calc(100vw - 32px));
  height: min(297px, calc(100vh - 30px));
  max-height: calc(100vh - 30px);
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.modal-welfare-invoice-comment .modal-header {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  background: #0b5717;
}

.modal-welfare-invoice-comment .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-welfare-invoice-comment .modal-close {
  font-size: 27px;
  font-weight: 700;
  opacity: 1;
}

.welfare-invoice-comment-form {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  background: #fff;
  color: #111827;
  font-size: 14px;
}

.welfare-invoice-comment-row-label {
  box-sizing: border-box;
  padding-left: 10px;
  white-space: nowrap;
}

.welfare-invoice-comment-content-row,
.welfare-invoice-comment-period-row {
  display: grid;
  grid-template-columns: 264px 57px minmax(0, 1fr);
  border-bottom: 1px solid #d7dfdc;
}

.welfare-invoice-comment-content-row {
  min-height: 111px;
  align-items: start;
}

.welfare-invoice-comment-content-row > .welfare-invoice-comment-row-label {
  padding-top: 11px;
}

.welfare-invoice-comment-content-row > .required-badge,
.welfare-invoice-comment-period-row > .required-badge {
  align-self: start;
  width: 37px;
  height: 26px;
  margin-top: 9px;
  padding: 0;
  line-height: 26px;
  text-align: center;
}

.welfare-invoice-comment-content-row textarea {
  height: 85px;
  margin: 9px 8px 16px 0;
  padding: 8px;
  resize: none;
  border: 1px solid #cbd5d1;
  border-radius: 0;
  background: #fff;
  color: #111827;
  font: inherit;
  line-height: 1.5;
}

.welfare-invoice-comment-period-row {
  min-height: 67px;
  align-items: center;
}

.welfare-invoice-comment-period-row > .required-badge {
  align-self: center;
  margin-top: 0;
}

.welfare-invoice-comment-row-label small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 400;
}

.welfare-invoice-comment-period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.welfare-invoice-comment-period-controls input {
  width: 215px;
  height: 29px;
  padding: 2px 9px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.welfare-invoice-comment-period-controls input::placeholder {
  color: #94a3a8;
}

.welfare-invoice-comment-note {
  min-height: 33px;
  margin: 0;
  padding: 7px 5px 5px;
  box-sizing: border-box;
  color: #111827;
  font-size: 12px;
  line-height: 20px;
}

.welfare-invoice-comment-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 9px;
  box-sizing: border-box;
  border-top: 1px solid #d7dfdc;
  background: #f7f8f8;
}

.welfare-invoice-comment-footer .btn-register {
  width: 55px;
  height: 32px;
  padding: 0 10px;
  border-radius: 2px;
  background: #0b5717;
  font-size: 14px;
}

/* レセプト一部負担金欄（患者保険等） */
.receipt-copayment-table-list th:nth-child(1),
.receipt-copayment-table-list th:nth-child(2) { width: 22%; }
.receipt-copayment-table-list th:nth-child(3) { width: 18%; }
.receipt-copayment-table-list th:nth-child(4) { width: 31%; }
.receipt-copayment-table-list th:nth-child(5) { width: 42px; }

.receipt-copayment-table-list .insurance-row-actions {
  width: 42px;
  text-align: center;
}

#receipt-copayment-modal {
  align-items: center;
  box-sizing: border-box;
}

.modal-receipt-copayment {
  display: flex;
  width: min(1024px, calc(100vw - 32px));
  height: min(599px, calc(100vh - 30px));
  max-height: calc(100vh - 30px);
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.modal-receipt-copayment .modal-header {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 0;
  background: #0b5717;
}

.modal-receipt-copayment .modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-receipt-copayment .modal-close {
  font-size: 27px;
  font-weight: 700;
  opacity: 1;
}

.receipt-copayment-form {
  min-height: 0;
  flex: 1 1 auto;
  padding: 0 10px 10px;
  box-sizing: border-box;
  overflow: auto;
  background: #fff;
  color: #111827;
  font-size: 14px;
}

.receipt-copayment-period-row {
  display: grid;
  min-height: 51px;
  grid-template-columns: 254px 57px minmax(0, 1fr);
  align-items: center;
}

.receipt-copayment-period-row > label {
  padding-left: 0;
  white-space: nowrap;
}

.receipt-copayment-period-row > .required-badge {
  width: 37px;
  height: 26px;
  padding: 0;
  line-height: 26px;
  text-align: center;
}

.receipt-copayment-period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.receipt-copayment-period-controls input {
  width: 145px;
  height: 32px;
  padding: 2px 9px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 2px;
  background: #fff;
  color: #111827;
  font: inherit;
}

.receipt-copayment-period-controls input:last-child {
  width: 145px;
}

.receipt-copayment-table {
  min-width: 650px;
  height: 441px;
  border-top: 1px solid #cbd5d1;
  border-left: 1px solid #cbd5d1;
  box-sizing: border-box;
}

.receipt-copayment-table-header {
  display: grid;
  height: 34px;
  grid-template-columns: 138px minmax(0, 1fr);
  background: #f5f6f6;
  font-size: 13px;
  text-align: center;
}

.receipt-copayment-table-header > span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #cbd5d1;
  border-bottom: 1px solid #cbd5d1;
}

.receipt-copayment-insurance-block {
  display: grid;
  height: 250px;
  grid-template-columns: 138px minmax(0, 1fr);
}

.receipt-copayment-payer-label {
  display: flex;
  align-items: flex-end;
  padding: 0 5px 9px;
  box-sizing: border-box;
  border-right: 1px solid #cbd5d1;
  border-bottom: 1px solid #cbd5d1;
}

.receipt-copayment-insurance-values {
  display: grid;
  grid-template-rows: repeat(4, 48px) 58px;
  border-right: 1px solid #cbd5d1;
  border-bottom: 1px solid #cbd5d1;
}

.receipt-copayment-insurance-values > label {
  display: flex;
  align-items: center;
  padding-left: 15px;
  gap: 7px;
  box-sizing: border-box;
  font-size: 14px;
}

.receipt-copayment-amount {
  width: 120px;
  height: 28px;
  padding: 2px 7px;
  box-sizing: border-box;
  border: 1px solid #cbd5d1;
  border-radius: 0;
  background: #fff;
  color: #111827;
  font: inherit;
  text-align: right;
}

.receipt-copayment-amount[type="number"] {
  -webkit-appearance: auto;
  appearance: auto;
}

.receipt-copayment-amount[type="number"]::-webkit-outer-spin-button,
.receipt-copayment-amount[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: auto;
  opacity: 1;
}

.receipt-copayment-insurance-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 119px 0 15px;
  box-sizing: border-box;
}

#receipt-copayment-difference {
  min-width: 110px;
  text-align: right;
  white-space: nowrap;
}

.receipt-copayment-public-row {
  display: grid;
  height: 39px;
  grid-template-columns: 138px minmax(0, 1fr);
  margin: 0;
  border-right: 1px solid #cbd5d1;
  border-bottom: 1px solid #cbd5d1;
  font-weight: 400;
}

.receipt-copayment-public-row:last-child {
  height: 41px;
}

.receipt-copayment-public-row > span {
  border-right: 1px solid #cbd5d1;
}

.receipt-copayment-public-row > span {
  display: flex;
  align-items: center;
  padding: 0 5px;
  box-sizing: border-box;
}

.receipt-copayment-public-row > input {
  align-self: center;
  margin-left: 5px;
}

.receipt-copayment-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 13px;
  box-sizing: border-box;
  border-top: 1px solid #d7dfdc;
  background: #f7f8f8;
}

.receipt-copayment-footer .btn-register {
  width: 55px;
  height: 32px;
  padding: 0 10px;
  border-radius: 2px;
  background: #0b5717;
  font-size: 14px;
}

@media (max-width: 760px) {
  .receipt-symptom-detail-kind-row,
  .receipt-symptom-detail-content-row,
  .receipt-symptom-detail-period-row,
  .receipt-symptom-detail-insurance-row {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .receipt-summary-comment-position-row,
  .receipt-summary-comment-content-row,
  .receipt-summary-comment-period-row,
  .receipt-summary-comment-insurance-row {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .welfare-invoice-comment-content-row,
  .welfare-invoice-comment-period-row {
    grid-template-columns: 190px 57px minmax(0, 1fr);
  }

  .receipt-copayment-period-row {
    grid-template-columns: 190px 57px minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .workers-insurance-form-row {
    grid-template-columns: 165px minmax(0, 1fr);
  }

  .workers-address-field select,
  .workers-office-field select:first-of-type {
    flex-basis: 90px;
    width: 90px;
  }
}

/* M3 DigiKar-inspired chart typography with a little more reading room. */
#main-screen #karte-editor.m3-soap-editor {
  padding: 6px 8px 12px;
  font-size: 13px;
  line-height: 21px;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
}

#main-screen #karte-editor.m3-soap-editor *,
#main-screen #karte-editor.m3-soap-editor p {
  font-family: inherit;
}

#main-screen #karte-editor.m3-soap-editor p {
  min-height: 1.5em;
  margin: 0;
}

#main-screen #karte-editor.m3-soap-editor strong {
  font-weight: 400;
}

#main-screen #karte-editor.m3-soap-editor .karte-soap-section-body {
  margin: 0;
}

/* 施設管理: 管理シート */
.facility-management-sheets-wrap {
  max-width: 920px;
  border: 1px solid #d4ddda;
  background: #fff;
}

.facility-management-sheets-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border-bottom: 1px solid #d4ddda;
}

.facility-management-sheets-heading h3 { margin: 0 0 6px; font-size: 16px; }
.facility-management-sheets-heading p { margin: 0; color: #5f6f68; font-size: 13px; line-height: 1.6; }

.facility-management-sheets-status {
  padding: 10px 20px;
  border-bottom: 1px solid #e0e6e3;
  background: #f5f8f7;
  color: #335d45;
  font-size: 13px;
}

.facility-management-sheets-enabled {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 2px;
  font-weight: 600;
}

.facility-management-sheets-form { display: grid; gap: 18px; padding: 16px 20px 20px; }
.facility-management-sheets-form label {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 6px 14px;
}
.facility-management-sheets-form label > span { font-weight: 600; }
.facility-management-sheets-form input {
  width: 100%;
  height: 36px;
  padding: 6px 10px;
  box-sizing: border-box;
  border: 1px solid #bfcac5;
  border-radius: 3px;
  font: inherit;
}
.facility-management-sheets-form input:focus { border-color: #168b4b; outline: 2px solid rgba(22, 139, 75, 0.12); }
.facility-management-sheets-form small { grid-column: 2; color: #687770; font-size: 12px; }
.facility-management-sheets-note {
  padding: 12px 20px;
  border-top: 1px solid #e0e6e3;
  background: #fffaf0;
  color: #735c2d;
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .facility-management-sheets-heading { align-items: stretch; flex-direction: column; }
  .facility-management-sheets-form label { grid-template-columns: 1fr; }
  .facility-management-sheets-form small { grid-column: 1; }
}

/* Keep the surrounding columns fixed while same-day karte tabs share the available header width. */
#main-screen .m3-karte-header-row1 {
  min-width: 0;
  overflow: hidden;
}

#main-screen .m3-karte-tabs-left {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

#main-screen .m3-karte-date,
#main-screen .m3-tag-add,
#main-screen .m3-karte-header-actions {
  flex: 0 0 auto;
}

#main-screen .m3-karte-tab-list {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  overflow: hidden;
  scrollbar-width: none;
}

#main-screen .m3-karte-tab-list::-webkit-scrollbar {
  display: none;
}

#main-screen .m3-karte-tab-item {
  flex: 0 1 auto;
  min-width: 42px;
  max-width: 240px;
  overflow: hidden;
}

#main-screen .m3-karte-tab-item .m3-karte-tag {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding-right: 5px;
  padding-left: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#main-screen .m3-karte-tab-item #karte-insurance-tab {
  padding-left: 7px;
}

#main-screen .m3-karte-tab-item #karte-insurance-tab.is-unsaved {
  padding-left: 18px;
}

#main-screen .m3-karte-tab-item .m3-tag-close {
  flex: 0 0 20px;
  width: 20px;
}

/* Fill both order-category rows evenly without placeholder cells. */
#main-screen .m3-order-header-wrap .m3-panel-tabs-row {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  width: 100%;
}

#main-screen .m3-order-header-wrap .m3-panel-tabs-row .m3-panel-tab {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
#web-printable-preview-modal,
.web-printable-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.62);
}

.web-printable-preview-panel {
  width: min(1120px, 96vw);
  height: min(900px, 94vh);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.web-printable-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 18px;
  color: #fff;
  background: #176b32;
}

.web-printable-preview-header h2 {
  margin: 0;
  font-size: 17px;
}

.web-printable-preview-close {
  border: 0;
  color: #fff;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.web-printable-preview-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 9px 12px;
  border-bottom: 1px solid #d8e2dc;
  background: #f4f8f5;
}

.web-printable-preview-tabs.single {
  display: none;
}

.web-printable-preview-tabs button {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid #b9cbbf;
  border-radius: 5px;
  color: #244b30;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.web-printable-preview-tabs button.active {
  border-color: #176b32;
  color: #fff;
  background: #176b32;
}

.web-printable-preview-body {
  min-height: 0;
  padding: 12px;
  background: #dfe6e1;
}

.web-printable-preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid #b9c7bd;
  background: #fff;
}

.web-printable-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid #d8e2dc;
}

.web-printable-preview-footer p {
  margin: 0;
  color: #526057;
  font-size: 12px;
}

.web-printable-preview-footer > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  #web-printable-preview-modal,
  .web-printable-preview-modal {
    padding: 0;
  }

  .web-printable-preview-panel {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  .web-printable-preview-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .web-printable-preview-footer > div,
  .web-printable-preview-footer .btn {
    flex: 1;
  }
}
.karte-detail-loading {
  cursor: progress;
  opacity: 0.82;
}

.patient-chart-pdf-modal { display: flex; align-items: center; justify-content: center; }
/* Header-anchored, staff-only clinic chat. */
.staff-chat-widget { position: relative; display: flex; align-items: center; flex: 0 0 auto; }
.staff-chat-trigger:not(.icon-btn) {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  color: #165322; background: transparent; border: 0; border-radius: 4px;
  cursor: pointer; font-size: 18px;
}
.staff-chat-trigger:not(.icon-btn):hover, .staff-chat-trigger:not(.icon-btn)[aria-expanded="true"] { background: #e6f0e7; }
.reception-header .staff-chat-trigger.icon-btn { padding: 0; }
.reception-header .staff-chat-trigger.icon-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.24); }
.staff-chat-trigger:focus-visible, .staff-chat-close:focus-visible, .staff-chat-send:focus-visible {
  outline: 2px solid #246a38; outline-offset: 2px;
}
.staff-chat-panel {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 5000;
  display: flex; flex-direction: column; width: min(420px, calc(100vw - 20px));
  height: min(540px, calc(100vh - 64px)); min-height: 280px;
  color: #1c2b20; background: #fff; border: 1px solid #b7c8ba;
  box-shadow: 0 8px 24px #172e2033; text-align: left;
}
.staff-chat-panel[hidden] { display: none !important; }
.staff-chat-heading {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 39px; padding: 0 8px; background: #165322; color: #fff;
  font-size: 15px; font-weight: 600;
}
.staff-chat-close {
  width: 30px; height: 30px; border: 1px solid #b4d0b7; border-radius: 3px;
  background: transparent; color: #fff; cursor: pointer;
}
.staff-chat-messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; background: #f9fbf9;
}
.staff-chat-state { margin: auto; color: #65746b; text-align: center; font-size: 13px; }
.staff-chat-message { max-width: 90%; align-self: flex-start; }
.staff-chat-message.own { align-self: flex-end; }
.staff-chat-message-meta { margin: 0 2px 3px; color: #617166; font-size: 11px; }
.staff-chat-message.own .staff-chat-message-meta { text-align: right; }
.staff-chat-message-body {
  padding: 8px 10px; border: 1px solid #d7e3d8; border-radius: 9px;
  background: #fff; color: #172b1c; white-space: pre-wrap; overflow-wrap: anywhere;
  line-height: 1.5; font-size: 13px;
}
.staff-chat-message.own .staff-chat-message-body { background: #e6f4e6; border-color: #c5dfc8; }
.staff-chat-patient-name { display: block; margin-top: 2px; color: #d8ead9; font-size: 11px; font-weight: 400; }
.staff-chat-message-image { display: block; width: min(100%, 260px); max-height: 220px; margin-top: 5px; border-radius: 7px; object-fit: cover; }
.staff-chat-form { flex: 0 0 auto; padding: 8px; border-top: 1px solid #d8e2d8; background: #fff; }
.staff-chat-form textarea {
  display: block; width: 100%; min-height: 66px; max-height: 100px; box-sizing: border-box;
  padding: 7px 8px; border: 1px solid #c8d5cc; border-radius: 3px;
  resize: vertical; color: #1c2b20; background: #fff; font: inherit; font-size: 13px;
}
.staff-chat-form-bottom { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 5px; }
.staff-chat-count { color: #829086; font-size: 11px; }
.staff-chat-send { border: 0; background: transparent; color: #165322; cursor: pointer; font-size: 20px; }
.staff-chat-send:disabled { color: #aab9ac; cursor: not-allowed; }
.staff-chat-panel .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.patient-chart-pdf-dialog { width: min(600px, calc(100vw - 32px)); }
.patient-chart-pdf-dialog .patient-chart-pdf-close {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 32px; width: 32px; height: 32px; padding: 0;
  border: 1px solid rgb(255 255 255 / 65%); border-radius: 3px;
  background: transparent; color: #fff; font-size: 25px; line-height: 1; opacity: 1;
}
.patient-chart-pdf-dialog .patient-chart-pdf-close:hover { background: rgb(255 255 255 / 16%); }
.patient-chart-pdf-dialog .patient-chart-pdf-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.patient-chart-pdf-dialog .modal-body { padding: 12px; }
.patient-chart-pdf-guidance { padding: 10px 12px; border: 1px solid #cbd4ce; background: #fff; line-height: 1.55; }
.patient-chart-pdf-guidance p { margin: 0; }
.patient-chart-pdf-actions { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 10px; }
.patient-chart-pdf-history { display: inline-flex; align-items: center; gap: 5px; margin: 0; white-space: nowrap; }
.patient-chart-pdf-results h3 { margin: 8px 0 8px; font-size: 15px; font-weight: 500; }
.patient-chart-pdf-result-empty { padding: 12px; border: 1px solid #cbd4ce; background: #fff; }
.patient-chart-pdf-results table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; }
.patient-chart-pdf-results th, .patient-chart-pdf-results td { padding: 7px 6px; border: 1px solid #d6ded9; text-align: left; vertical-align: middle; }
.patient-chart-pdf-results th { background: #f5f8f6; font-weight: 500; }
.patient-chart-pdf-download { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border: 1px solid #cbd4ce; border-radius: 3px; color: #173d2a; background: #fff; }
.patient-chart-pdf-download:hover { background: #edf5ef; }
@media (max-width: 620px) {
  .patient-chart-pdf-actions { align-items: flex-start; flex-direction: column; }
  .patient-chart-pdf-results { overflow-x: auto; }
  .patient-chart-pdf-results table { min-width: 560px; }
}
/* Role separation: reception staff can view the chart but cannot mutate clinical content. */
body[data-clinical-edit="readonly"] #btn-karte-tab-add,
body[data-clinical-edit="readonly"] #btn-karte-tab-close,
body[data-clinical-edit="readonly"] #btn-open-deleted-records,
body[data-clinical-edit="readonly"] #btn-regular-register,
body[data-clinical-edit="readonly"] #btn-set-register,
body[data-clinical-edit="readonly"] #btn-karte-context-edit,
body[data-clinical-edit="readonly"] #btn-open-diagnosis-modal,
body[data-clinical-edit="readonly"] #btn-bulk-diagnosis-outcome,
body[data-clinical-edit="readonly"] .diagnosis-bulk-check,
body[data-clinical-edit="readonly"] #btn-add-schema,
body[data-clinical-edit="readonly"] .m3-checkbox:has(#karte-rx-one-package-remark),
body[data-clinical-edit="readonly"] #karte-rx-one-package-remark,
body[data-clinical-edit="readonly"] #karte-rx-one-package-remark + *,
body[data-clinical-edit="readonly"] #karte-late-entry,
body[data-clinical-edit="readonly"] #btn-prescription,
body[data-clinical-edit="readonly"] #btn-auto-calc,
body[data-clinical-edit="readonly"] #btn-lab-order,
body[data-clinical-edit="readonly"] #btn-temp-save,
body[data-clinical-edit="readonly"] #btn-confirm,
body[data-clinical-edit="readonly"] #procedure-items button,
body[data-clinical-edit="readonly"] #procedure-items input,
body[data-clinical-edit="readonly"] #procedure-items textarea,
body[data-clinical-edit="readonly"] #procedure-items select,
body[data-clinical-edit="readonly"] [data-restore-version],
body[data-clinical-edit="readonly"] [data-save-care-completion] {
  display: none !important;
}

body[data-clinical-edit="readonly"] #karte-editor {
  background: #f7f8f7;
  cursor: default;
}

body[data-clinical-edit="readonly"] #category-tree {
  opacity: 0.72;
}

.clinical-role-readonly-note {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #d7c98b;
  border-radius: 3px;
  background: #fff9dc;
  color: #6b5711;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#menu-facility[hidden],
#menu-facility-main[hidden] {
  display: none !important;
}
