:root {
  --bg: #f4f7f6;
  --bg-accent: #e8f1ee;
  --surface: #ffffff;
  --ink: #1a3040;
  --muted: #5a6f78;
  --line: #d4e2df;
  --brand: #1a6b7c;
  --brand-dark: #143f52;
  --brand-navy: #1b3a75;
  --brand-mint: #3ec9a8;
  --personal-accent: var(--brand);
  --personal-radius: var(--radius);
  --personal-font-scale: 1;
  --danger: #a33b2d;
  --warn-bg: #f4efe3;
  --warn-ink: #6a5428;
  --shadow: 0 10px 28px rgba(27, 58, 117, 0.07);
  --focus-ring: var(--brand-mint);
  --radius: 16px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: calc(16px * var(--personal-font-scale, 1));
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(62, 201, 168, 0.12) 0%, transparent 42%),
    linear-gradient(180deg, #f7f9f8 0%, var(--bg) 48%, var(--bg-accent) 100%);
  line-height: 1.6;
}

body.theme-bg-plain {
  background: var(--bg);
}

body.theme-bg-soft {
  background:
    radial-gradient(circle at top right, #fbfdfc 0%, transparent 38%),
    linear-gradient(160deg, #f2f7f5 0%, #e4eeea 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px 16px 40px;
}

.site-footer {
  padding: 0 16px 24px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer a {
  color: var(--brand-dark);
}

.screen {
  width: min(960px, 100%);
  margin: 0 auto;
}

.screen-home {
  width: min(1240px, 100%);
}

.screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(460px, 100%);
  min-height: calc(100vh - 96px);
}

.screen-loading .panel-narrow {
  width: 100%;
  margin: 0;
}

.screen[hidden],
.modal[hidden],
.error[hidden],
#dev-mode-panel[hidden] {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.panel-narrow {
  width: min(460px, 100%);
  margin: 8vh auto 0;
}

.brand-mark {
  margin: 0 0 8px;
  color: var(--brand-navy);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-mark-inline {
  margin: 0;
  font-size: 1.2rem;
}

.panel-loading {
  text-align: center;
  padding: 40px 32px 36px;
  border-color: rgba(27, 58, 117, 0.08);
  box-shadow: 0 16px 40px rgba(27, 58, 117, 0.08);
}

.boot-brand-logo,
.home-brand-logo {
  display: block;
  width: min(100%, 280px);
  max-height: 104px;
  height: auto;
  margin: 0 auto 20px;
  object-fit: contain;
}

.home-brand-logo {
  width: auto;
  max-width: 168px;
  height: 36px;
  max-height: 36px;
  margin: 0;
}

.boot-loading-title {
  margin: 0 0 16px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--brand-navy);
}

.boot-loading-indicator {
  width: 26px;
  height: 26px;
  margin: 4px auto 14px;
  border: 2px solid rgba(27, 58, 117, 0.12);
  border-top-color: var(--brand-mint);
  border-radius: 50%;
  animation: boot-loading-spin 0.9s linear infinite;
}

@keyframes boot-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.panel-loading .screen-lead {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.github-connection-check {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1.4;
}

.screen-title {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.screen-lead,
.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.hospital-chip {
  display: inline-block;
  margin: 0 0 16px;
  padding: 8px 12px;
  background: #edf5f2;
  border-radius: 999px;
  color: var(--brand-dark);
  font-size: 0.95rem;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.field-inline .field-label {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.field-label {
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

/* Checkboxes must not inherit full-width / 48px text-field sizing */
input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border-radius: 3px;
  flex-shrink: 0;
  accent-color: var(--brand);
}

.setup-ai-key-help {
  margin-top: -6px;
  margin-bottom: 0;
}

/* Keep clear of password-manager / extension icons on the key input */
.setup-ai-key-link-wrap {
  margin: 4px 0 0;
  padding-right: 44px;
  max-width: 100%;
}

a.setup-ai-key-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: auto;
  max-width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  text-decoration: none;
  text-align: center;
  white-space: normal;
  line-height: 1.35;
}

a.setup-ai-key-link[hidden] {
  display: none !important;
}

input:focus,
select:focus,
button:focus-visible,
.app-card-clickable:focus-visible {
  outline: 2px solid var(--brand-mint);
  outline-offset: 2px;
}

.btn {
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn[aria-busy="true"] {
  position: relative;
}

.btn[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12em;
  animation: senshin-spin 0.8s linear infinite;
}

@keyframes senshin-spin {
  to {
    transform: rotate(360deg);
  }
}

.btn:disabled,
.btn.is-save-disabled:disabled,
.btn[aria-disabled="true"]:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: #c5ccc9 !important;
  color: #6a7370 !important;
  border-color: #b0b8b5 !important;
  filter: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: #1f8a6e;
  color: #fff;
  border-color: #18755c;
}

.btn-primary:hover:not(:disabled) {
  background: #176f58;
}

.btn-primary.is-save-enabled:not(:disabled) {
  background: #1f8a6e;
}

.btn-primary.is-save-disabled:disabled,
.btn-primary:disabled {
  background: #c5ccc9 !important;
}

.save-status-bar,
.save-status-saving,
.save-status-saved,
.save-status-error {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.save-status-saving {
  background: #eef2f0;
  color: #334;
}

.save-status-saved {
  background: #e5f6ef;
  color: #0f5c45;
  border: 1px solid #9dceb8;
}

.save-status-error {
  background: #fdecea;
  color: #8a1f1f;
  border: 1px solid #e2a4a4;
}

.btn-secondary {
  background: #eef2f0;
  border-color: #9aada6;
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: #e0e8e4;
}

.btn-danger {
  background: #b24335;
  color: #fff;
  border-color: #8f3227;
}

.btn-danger:hover:not(:disabled) {
  background: #943628;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.88rem;
}

.btn-ghost {
  margin-top: 12px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  text-decoration: underline;
  font-weight: 500;
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.home-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 4px 2px 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.home-header-main {
  min-width: 0;
  flex: 1;
}

.home-header-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.home-header .brand-mark-inline {
  color: var(--brand-navy);
  font-size: 1.18rem;
  letter-spacing: 0.04em;
}

.home-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.home-meta-item {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.home-meta-item strong {
  color: var(--ink);
  font-weight: 700;
}

.home-meta .home-hospital-id {
  font-size: 0.85rem;
  opacity: 0.85;
}

.home-logout-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  border-color: var(--line);
}

.dev-panel {
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--warn-bg);
  border: 1px solid #e2d4b4;
  border-radius: var(--radius);
  color: var(--warn-ink);
}

.dev-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8d7a8;
  font-size: 0.85rem;
  font-weight: 700;
}

.section-title {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brand-navy);
}

.screen-home .section-title {
  margin-bottom: 12px;
}

.mind-reset-card {
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  background: #f7faf9;
  border: 1px solid rgba(27, 58, 117, 0.08);
  border-left: 3px solid var(--personal-accent, var(--brand-mint));
  border-radius: var(--personal-radius, var(--radius));
  box-shadow: none;
}

.mind-reset-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  margin-top: 1px;
  border-radius: 999px;
  background: rgba(62, 201, 168, 0.14);
  color: var(--brand-navy);
  font-size: 0.85rem;
}

.mind-reset-content {
  min-width: 0;
  flex: 1;
}

.mind-reset-top {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mind-reset-card .section-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mind-reset-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.mind-reset-body {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--ink);
}

.backup-status-lines {
  white-space: pre-line;
  line-height: 1.65;
}

.section-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
}

.apps-section {
  margin-top: 8px;
}

.screen-home .home-group {
  margin-top: 20px;
}

.home-inline-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  margin: 0;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid rgba(27, 58, 117, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.home-inline-status.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid rgba(27, 58, 117, 0.12);
  border-top-color: var(--brand-mint);
  border-radius: 50%;
  animation: boot-loading-spin 0.9s linear infinite;
}

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

#common-settings-list {
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

#account-menu-list {
  --account-menu-icon-ratio: 1.38;
  --account-menu-icon-height: clamp(104px, 13vh, 132px);
  --account-menu-icon-width: max(12em, calc(var(--account-menu-icon-height) * var(--account-menu-icon-ratio)));
  grid-template-columns: repeat(auto-fill, minmax(var(--account-menu-icon-width), var(--account-menu-icon-width)));
  gap: 14px 18px;
  justify-content: start;
}

#common-settings-list .app-card {
  min-height: 0;
  padding: 12px 10px 10px;
  position: relative;
  border-color: rgba(27, 58, 117, 0.08);
  box-shadow: 0 8px 20px rgba(27, 58, 117, 0.06);
}
#account-menu-list .app-card {
  min-height: 0;
  width: var(--account-menu-icon-width);
  padding: 0;
  position: relative;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: center;
}
#account-menu-list .app-card.app-card-clickable:hover {
  transform: translateY(-1px);
  border-color: transparent;
  box-shadow: none;
}
#account-menu-list .app-card-header,
#common-settings-list .app-card-header {
  height: auto;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
#account-menu-list .app-card-main,
#common-settings-list .app-card-main { flex: 0 1 auto; width: 100%; }
#common-settings-list .app-card-icon {
  box-sizing: border-box;
  width: 96px;
  height: 96px;
  padding: 0;
  overflow: hidden;
  border-radius: 20px;
  background: #f7faf9;
  box-shadow: inset 0 0 0 1px rgba(27, 58, 117, 0.04);
}
#account-menu-list .app-card-icon {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--account-menu-icon-width);
  height: auto;
  aspect-ratio: var(--account-menu-icon-ratio) / 1;
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
  background: transparent;
  box-shadow: none;
}
#common-settings-list .app-card-icon-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}
#account-menu-list .app-card-icon-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  transform: none;
}
@media (max-width: 959px) {
  #account-menu-list {
    --account-menu-icon-height: clamp(96px, 16vw, 120px);
  }
}
@media (max-width: 640px) {
  #account-menu-list {
    --account-menu-icon-height: clamp(88px, 22vw, 112px);
  }
}
/* Compliance 数字カード: 既存 96px 枠と状態色トークンのみ使う */
#app-card-list .app-card-icon--count,
#uncontracted-app-card-list .app-card-icon--count {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}
#app-card-list .app-card-icon--count-red,
#uncontracted-app-card-list .app-card-icon--count-red {
  background: #fdecea;
  color: var(--danger);
}
#app-card-list .app-card-icon--count-yellow,
#uncontracted-app-card-list .app-card-icon--count-yellow {
  background: var(--warn-bg);
  color: var(--warn-ink);
}
#app-card-list .app-card-icon--count-complete,
#uncontracted-app-card-list .app-card-icon--count-complete {
  background: #d8f3e7;
  color: #0f6b4c;
}
#app-card-list .app-card-icon--count-unknown,
#uncontracted-app-card-list .app-card-icon--count-unknown {
  background: #e6e8e7;
  color: #4d5653;
}
/* 設定メニュー（ホーム外）。共通設定は既存96px枠、アカウント管理は横長PNGを全体表示する。 */
#management-settings-list .app-card-icon--settings,
#account-menu-list .app-card-icon--settings,
#common-settings-list .app-card-icon--settings {
  overflow: hidden;
}
#management-settings-list .app-card-icon--settings .app-card-icon-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
#common-settings-list .app-card-icon--settings .app-card-icon-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
  transform-origin: center center;
}
#account-menu-list .app-card-icon--settings .app-card-icon-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: none;
}
.account-theme-block {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
#app-card-list .app-card-title,
#uncontracted-app-card-list .app-card-title,
#management-settings-list .app-card-title,
#common-settings-list .app-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  color: var(--brand-navy);
}
#account-menu-list .app-card-title {
  display: block;
  min-width: 0;
  margin-top: 2px;
  color: var(--brand-navy);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  word-break: keep-all;
  line-break: strict;
}
#app-card-list .app-card-id,
#uncontracted-app-card-list .app-card-id,
#management-settings-list .app-card-id,
#account-menu-list .app-card-id,
#common-settings-list .app-card-id { display: none; }
#app-card-list .app-card-status,
#uncontracted-app-card-list .app-card-status,
#management-settings-list .app-card-status,
#account-menu-list .app-card-status,
#common-settings-list .app-card-status { position: static; font-size: 0.72rem; margin-top: 2px; }
#app-card-list .app-card-launch-state,
#uncontracted-app-card-list .app-card-launch-state,
#management-settings-list .app-card-launch-state,
#account-menu-list .app-card-launch-state,
#common-settings-list .app-card-launch-state { margin-top: 2px; font-size: 0.72rem; }
#app-card-list.app-reorder-mode .app-card { user-select: none; }
#app-card-list .app-card-reorder-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(20, 98, 117, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--brand-dark);
  cursor: grab;
  touch-action: none;
  font-size: 1rem;
  line-height: 1;
}
#app-card-list .app-card-reorder-handle:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
#app-card-list .app-card.is-dragging .app-card-reorder-handle { cursor: grabbing; }

#app-card-list .app-card.is-dragging {
  position: fixed; margin: 0; pointer-events: none; cursor: grabbing; z-index: 1000;
  opacity: .9; transform-origin: top left;
  box-shadow: 0 20px 48px rgba(14, 86, 104, 0.3);
}
#app-card-list .app-card-placeholder { border: 2px dashed var(--personal-accent, var(--brand)); background: rgba(31,107,92,.08); box-shadow: none; }

.app-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--personal-radius, var(--radius));
  box-shadow: var(--shadow);
}

.app-card-clickable {
  display: block;
  width: 100%;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.app-card-clickable:hover {
  border-color: var(--personal-accent, var(--brand-mint));
  box-shadow: 0 12px 24px rgba(27, 58, 117, 0.1);
}

.app-card-clickable:active {
  transform: translateY(1px);
}

.app-card-clickable.is-disabled {
  cursor: not-allowed;
  opacity: 0.82;
}

.app-card-clickable.is-disabled.is-hospital-disabled,
.app-card-clickable.is-hospital-disabled {
  cursor: not-allowed;
  opacity: 1;
  filter: grayscale(1);
  background: #f0f0f0;
  border-color: #c8c8c8;
  color: #6a6a6a;
}

.app-card-clickable.is-hospital-disabled .app-card-icon {
  background: #e0e0e0;
  color: #6a6a6a;
}

.app-card-clickable.is-hospital-disabled .app-card-status {
  background: #d8d8d8;
  color: #444;
}

.app-card-clickable.is-hospital-disabled:hover {
  transform: none;
  border-color: #c8c8c8;
}

.app-card-clickable.is-launching {
  border-color: var(--personal-accent, var(--brand-mint));
  background: #f6fbf9;
}

.app-card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: #edf5f2;
  color: var(--brand-dark);
  font-size: 1.25rem;
  font-weight: 700;
}

.app-card-icon-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}
.app-card-icon svg { width: 62%; height: 62%; }
.app-card-status[hidden] { display: none; }

.app-card-main {
  min-width: 0;
  flex: 1;
}

.app-card-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.app-card-title {
  margin: 0;
  font-size: 1.1rem;
}

.app-card-status {
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf5f2;
  color: var(--brand-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.app-card-id {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-card-desc {
  margin: 0;
  color: var(--ink);
}

.app-card-launch-state {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.app-card-launch-state[hidden] {
  display: none !important;
}

.app-card-launch-state::before {
  content: "";
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: senshin-spin 0.8s linear infinite;
}

.app-reorder-mode .app-card-clickable {
  cursor: grab;
}

.app-reorder-mode .app-card-clickable:active,
.app-card-clickable.is-dragging {
  cursor: grabbing;
}

.app-card-clickable.is-dragging {
  opacity: 0.78;
  outline: 2px dashed var(--personal-accent, var(--brand));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 32, 29, 0.45);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 24px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

@media (max-width: 640px) {
  .panel-narrow {
    margin-top: 4vh;
  }

  .home-header {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }

  .home-header .btn {
    width: 100%;
  }

  .home-brand-logo {
    height: 32px;
    max-height: 32px;
  }

  .mind-reset-card {
    padding: 12px 14px;
  }

  .mind-reset-icon {
    width: 26px;
    height: 26px;
  }

  .panel-loading {
    padding: 32px 22px 28px;
  }
}

@media print {
  .no-print {
    display: none !important;
  }
}

/* --- 総合ホーム追加グループ / マスター / アカウント --- */

.screen-wide {
  width: min(1100px, 100%);
}

.home-group {
  margin-top: 22px;
}

.sub-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sub-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.master-summary {
  margin: 0 0 14px;
  color: var(--muted);
}

.master-split {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
}

.master-pane {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input {
  flex: 1;
}

.master-list {
  display: grid;
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
}

.master-list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
}

.master-list-item.active {
  border-color: var(--brand);
  background: #edf5f2;
}

.master-list-sub {
  color: var(--muted);
  font-size: 0.82rem;
}

.master-list-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.master-placeholder,
.master-empty {
  color: var(--muted);
  padding: 12px 0;
}

.master-detail-title,
.master-subtitle {
  margin: 0 0 10px;
}

.master-dl {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.master-dl > div {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #e5eeea;
}

.master-dl dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.master-dl dd {
  margin: 0;
  font-weight: 600;
}

.master-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.master-csv-panel {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
}

.master-csv-summary {
  margin: 8px 0 12px;
  font-weight: 700;
}

.master-csv-preview {
  display: grid;
  gap: 12px;
  max-height: 320px;
  overflow: auto;
  margin-bottom: 8px;
}

.master-csv-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
}

.master-csv-block h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.master-csv-block.valid h4 {
  color: var(--brand-dark);
}

.master-csv-block.error h4 {
  color: var(--danger);
}

.master-csv-block ul {
  margin: 0;
  padding-left: 1.1rem;
}

.master-csv-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 12px 0;
}
.master-csv-options label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}
.master-csv-column-map {
  margin: 12px 0;
  overflow-x: auto;
}
.master-csv-map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.master-csv-map-table th,
.master-csv-map-table td {
  border-bottom: 1px solid #ddd;
  padding: 6px 8px;
  text-align: left;
}
.master-csv-block li {
  margin: 4px 0;
  font-size: 0.9rem;
}

.master-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

.form-grid-patient {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-patient .form-grid-full {
  grid-column: 1 / -1;
}

.address-textarea {
  width: 100%;
  min-height: 4.5em;
  resize: vertical;
  line-height: 1.45;
  font: inherit;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .form-grid-patient {
    grid-template-columns: 1fr;
  }
  .form-grid-patient .form-grid-full,
  .form-grid-patient .form-grid-name,
  .form-grid-patient .form-grid-kana {
    grid-column: auto;
  }
}

.setup-steps {
  margin: 12px 0 0;
  padding-left: 1.2rem;
  line-height: 1.7;
}
.setup-steps .setup-step.done {
  color: var(--text-muted, #5a6570);
}

.form-narrow {
  max-width: 420px;
}

.master-linked-list {
  margin: 0 0 12px;
  padding-left: 1.1rem;
}

.linkish {
  background: none;
  border: none;
  color: var(--brand-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  min-height: auto;
  font-weight: 600;
}

.account-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.account-tab {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.account-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.account-table-wrap {
  overflow: auto;
  margin-bottom: 16px;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.account-table th,
.account-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.account-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 18px;
  border-radius: 10px;
  background: #1c2b28;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast-error {
  background: var(--danger);
}

.msg.warn {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.msg.error {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecea;
  color: var(--danger);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

#prompt-input {
  margin-top: 10px;
}

@media (max-width: 800px) {
  .master-split {
    grid-template-columns: 1fr;
  }

  .master-dl > div {
    grid-template-columns: 1fr;
  }
}

/* --- 状態・職種バッジ / アカウント一覧 --- */

.status-badge,
.job-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.5;
}

.status-tone-active {
  background: #d8f3e7;
  color: #0f6b4c;
}

.status-tone-stopped {
  background: #f3d8d4;
  color: #8a2f24;
}

.status-tone-other {
  background: #e6e8e7;
  color: #4d5653;
}

.job-tone-dentist {
  background: #d9e7f8;
  color: #1d4f86;
}
.job-tone-hygienist {
  background: #d8f0e2;
  color: #1b6b45;
}
.job-tone-assistant {
  background: #fce6cc;
  color: #8a4b10;
}
.job-tone-office {
  background: #e7dff3;
  color: #5a3d7a;
}
.job-tone-other {
  background: #e5e7e6;
  color: #555;
}

.hospital-status-panel,
.hospital-edit-panel {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
}

.status-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.account-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.account-filters label {
  display: grid;
  gap: 4px;
  font-size: 0.86rem;
  font-weight: 600;
}

.account-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.account-table th,
.account-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.account-table th {
  background: #edf5f2;
  position: sticky;
  top: 0;
}

.account-table tr.row-stopped {
  background: #f7f1f0;
}

.account-actions-cell {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.perm-details {
  margin-top: 4px;
  font-size: 0.82rem;
}

.perm-list {
  margin: 4px 0 0;
  padding-left: 1.1rem;
}

.perm-ok {
  color: #1b6b45;
}
.perm-ng {
  color: #6a7370;
}

.hint-inline {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.password-fieldset {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.audit-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
}

.fs-check-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.fs-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.fs-check-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
}

.fs-advanced {
  margin-top: 12px;
}

.app-card.is-selected {
  outline: 2px solid var(--brand);
  background: #eef8f4;
}

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

.operator-table-wrap {
  max-height: 62vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.operator-table {
  min-width: 1180px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.operator-table th,
.operator-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  background: #fff;
  white-space: nowrap;
}

.operator-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #edf5f2;
  color: var(--brand-dark);
}

/* A列: 医院名 — 横スクロール時に固定 */
.operator-table th.op-col-name,
.operator-table td.op-col-name {
  position: sticky;
  left: 0;
  min-width: 10rem;
  max-width: 16rem;
  z-index: 2;
  background: #fff;
  box-shadow: 2px 0 0 rgba(15, 55, 45, 0.08);
}

.operator-table th.op-col-name {
  z-index: 5;
  background: #edf5f2;
  top: 0;
}

.operator-table tbody tr:hover td {
  background: #f7fbf9;
}

.operator-table tbody tr:hover td.op-col-name {
  background: #f7fbf9;
}

.operator-table tbody tr.is-selected td {
  background: #eef8f4;
}

.operator-table tbody tr.is-selected td.op-col-name {
  background: #eef8f4;
}

.operator-table input[type="number"] {
  width: 6.5rem;
  min-height: 36px;
}

.operator-switch {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 7rem;
  font-weight: 700;
}

.operator-switch input {
  width: 1.1rem;
  height: 1.1rem;
}

.operator-cell-muted {
  color: var(--muted);
}

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.view-toggle .active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.setup-status-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbf9;
  padding: 12px 14px;
}

.setup-status-summary summary {
  cursor: pointer;
  font-weight: 700;
}

.setup-status-summary[open] summary {
  margin-bottom: 10px;
}

.setup-remaining-list {
  margin: 8px 0 0;
  padding-left: 1.2rem;
}

.theme-panel {
  width: min(560px, 100%);
}

.theme-panel .modal-actions {
  flex-wrap: wrap;
}

.theme-preview-chip {
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- 各アプリで表示する患者情報 --- */

.fs-table-scroll {
  overflow: auto;
  max-width: 100%;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.fs-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.fs-table th,
.fs-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.fs-table th {
  background: #edf5f2;
  position: sticky;
  top: 0;
  z-index: 1;
}

.fs-table input[type="text"],
.fs-table input[type="number"] {
  min-height: 40px;
  width: 100%;
}

.fs-check {
  text-align: center !important;
}

.fs-key {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== Core home role layout (landscape 4-area / portrait stacked) ===== */
.home-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body:has(#screen-home:not([hidden])) {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body:has(#screen-home:not([hidden])) .site-footer {
  flex: 0 0 auto;
  padding: 2px 16px 6px;
  font-size: 0.75rem;
}

body:has(#screen-home:not([hidden])):has(.home-uncontracted-section:not(.is-empty)),
body:has(#screen-home:not([hidden])):has(.home-apps-status) {
  height: auto;
  min-height: 100dvh;
  overflow: auto;
}

body:has(#screen-home:not([hidden])):has(.home-uncontracted-section:not(.is-empty)) .app-shell,
body:has(#screen-home:not([hidden])):has(.home-apps-status) .app-shell {
  height: auto;
  overflow: visible;
}

body:has(#screen-home:not([hidden])):has(.home-uncontracted-section:not(.is-empty)) .screen-home,
body:has(#screen-home:not([hidden])):has(.home-apps-status) .screen-home {
  height: auto;
  overflow: visible;
}

@media (min-width: 960px) {
  body:has(#screen-home:not([hidden])) {
    position: relative;
  }

  body:has(#screen-home:not([hidden])) .site-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background: transparent;
  }

  .screen-home {
    padding-bottom: 32px;
  }
}

@media (min-width: 960px) {
  .screen-home .mind-reset-body::before {
    display: none;
  }
}

body:has(#screen-home:not([hidden])) {
  background: #f5f7f9;
}

.app-shell:has(#screen-home:not([hidden])) {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  padding: 8px 20px 6px;
  overflow: hidden;
}

.screen-home {
  display: flex;
  flex-direction: column;
  width: min(1680px, 100%);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.home-header {
  flex: 0 0 auto;
  margin-bottom: 4px;
  padding: 2px 2px 6px;
}

.home-header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
}

.screen-home .home-brand-logo {
  width: auto;
  height: clamp(54px, 7.2vh, 74px);
  max-height: 74px;
  max-width: min(360px, 44vw);
}

.screen-home .home-meta {
  margin: 0;
  font-size: clamp(0.84rem, 1.12vw, 0.96rem);
}

.screen-home .home-logout-btn {
  min-height: 40px;
  padding: 8px 18px;
  font-size: 0.9rem;
}

.home-board {
  --home-hygiene: #2f80c9;
  --home-doctor: #d67a45;
  --home-common: #2e8b78;
  --home-management: #5a6e80;
  --home-hygiene-bg: #d4e9f8;
  --home-hygiene-bg-top: #e7f3fb;
  --home-doctor-bg: #f4dcc8;
  --home-doctor-bg-top: #f8e8d8;
  --home-common-bg: #cfeadf;
  --home-common-bg-top: #e0f3ec;
  --home-management-bg: #e4eaf1;
  --home-management-bg-top: #eef2f6;
  --home-hygiene-tile: #c5dff4;
  --home-doctor-tile: #f0c9ad;
  --home-common-tile: #b7dfd4;
  --home-management-tile: #d5dde6;
  --home-icon-ratio: 1.38;
  --home-icon-height: clamp(118px, 15vh, 148px);
  --home-icon-width: calc(var(--home-icon-height) * var(--home-icon-ratio));
  --home-card-width: var(--home-icon-width);
  --home-icon-pad: 0px;
  --home-title-gap: 2px;
  --home-mgmt-icon-height: clamp(78px, 10vh, 100px);
  --home-mgmt-icon-width: calc(var(--home-mgmt-icon-height) * var(--home-icon-ratio));
  --home-mgmt-card-width: var(--home-mgmt-icon-width);
  --home-title-size: clamp(1.02rem, 1.35vw, 1.18rem);
  --home-role-title-size: clamp(1.12rem, 1.5vw, 1.32rem);
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 1.06fr) minmax(0, 1.78fr) minmax(160px, 20%);
  grid-template-rows: minmax(min-content, 1fr) minmax(min-content, auto) auto auto auto;
  grid-template-areas:
    "hygiene doctor common quote"
    "mgmt    mgmt   common quote"
    "other   other  other  quote"
    "status  status status quote"
    "uncon   uncon  uncon  quote";
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.home-apps-section,
.home-role-board,
.home-apps-chrome {
  display: contents;
}

.home-role-panel--hygiene { grid-area: hygiene; --home-role-color: var(--home-hygiene); --home-role-bg: var(--home-hygiene-bg); --home-role-bg-top: var(--home-hygiene-bg-top); --home-role-tile: var(--home-hygiene-tile); }
.home-role-panel--doctor { grid-area: doctor; --home-role-color: var(--home-doctor); --home-role-bg: var(--home-doctor-bg); --home-role-bg-top: var(--home-doctor-bg-top); --home-role-tile: var(--home-doctor-tile); }
.home-role-panel--common { grid-area: common; --home-role-color: var(--home-common); --home-role-bg: var(--home-common-bg); --home-role-bg-top: var(--home-common-bg-top); --home-role-tile: var(--home-common-tile); }
.home-role-panel--other { grid-area: other; --home-role-color: var(--home-management); --home-role-bg: var(--home-management-bg); --home-role-bg-top: var(--home-management-bg-top); --home-role-tile: var(--home-management-tile); }
.home-role-panel--management,
.home-mgmt-section { grid-area: mgmt; --home-role-color: var(--home-management); --home-role-bg: var(--home-management-bg); --home-role-bg-top: var(--home-management-bg-top); --home-role-tile: var(--home-management-tile); }
.mind-reset-card { grid-area: quote; }
.home-apps-status { grid-area: status; }
.home-uncontracted-section { grid-area: uncon; }

.home-role-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 10px 12px 8px;
  background:
    linear-gradient(180deg, var(--home-role-bg-top, var(--home-role-bg)) 0%, var(--home-role-bg) 100%);
  border: 1px solid rgba(27, 58, 117, 0.07);
  border-radius: 26px;
  box-shadow: 0 10px 26px rgba(27, 58, 117, 0.08);
}

.home-role-panel--hygiene,
.home-role-panel--doctor,
.home-role-panel--common {
  height: 100%;
  min-height: min-content;
  overflow: visible;
}

.home-role-panel--management {
  height: auto;
  min-height: min-content;
  overflow: visible;
  padding: 8px 12px 6px;
}

.home-role-title {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--home-role-color);
  font-size: var(--home-role-title-size, 1rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.home-role-title::before {
  content: "";
  width: 4px;
  height: 0.92em;
  border-radius: 99px;
  background: var(--home-role-color);
}

.home-role-grid {
  flex: 1 0 auto;
  display: grid;
  gap: 6px 8px;
  justify-content: start;
  justify-items: start;
  align-content: start;
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: min-content;
  grid-auto-rows: min-content;
}

.home-role-grid > * {
  min-width: 0;
  min-height: min-content;
}

.home-role-panel--hygiene .home-role-grid,
.home-role-panel--doctor .home-role-grid {
  grid-template-columns: minmax(0, var(--home-card-width));
  justify-content: start;
  align-content: start;
}

.home-role-panel--common .home-role-grid {
  align-content: start;
}

.home-role-panel--common .home-role-grid,
.home-role-panel--other .home-role-grid {
  grid-template-columns: repeat(2, minmax(0, var(--home-card-width)));
  justify-content: start;
}

.home-role-panel--management .home-role-grid,
#management-settings-list.home-role-grid {
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, var(--home-mgmt-card-width)));
  justify-content: start;
  justify-items: start;
  max-width: none;
  width: 100%;
}

#app-card-list .home-app-card,
#uncontracted-app-card-list .home-app-card {
  min-width: 0;
  min-height: min-content;
  width: 100%;
  max-width: var(--home-card-width);
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: center;
}

#management-settings-list .home-app-card {
  min-width: 0;
  min-height: min-content;
  width: 100%;
  max-width: var(--home-mgmt-card-width);
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: center;
}

#app-card-list .home-app-card .app-card-header,
#uncontracted-app-card-list .home-app-card .app-card-header,
#management-settings-list .home-app-card .app-card-header {
  height: auto;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--home-title-gap, 2px);
}

#app-card-list .home-app-card .app-card-main,
#uncontracted-app-card-list .home-app-card .app-card-main,
#management-settings-list .home-app-card .app-card-main {
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
}

#app-card-list .home-app-card .app-card-icon,
#uncontracted-app-card-list .home-app-card .app-card-icon {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--home-icon-width);
  height: auto;
  aspect-ratio: var(--home-icon-ratio) / 1;
  padding: var(--home-icon-pad, 0px);
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--home-role-color, var(--brand-navy));
  font-size: calc(var(--home-icon-height) * 0.36);
  box-shadow: none;
}

#management-settings-list .home-app-card .app-card-icon {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--home-mgmt-icon-width);
  height: auto;
  aspect-ratio: var(--home-icon-ratio) / 1;
  padding: var(--home-icon-pad, 0px);
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--home-role-color, var(--brand-navy));
  font-size: calc(var(--home-mgmt-icon-height) * 0.36);
  box-shadow: none;
}

#app-card-list .home-app-card .app-card-icon-image,
#uncontracted-app-card-list .home-app-card .app-card-icon-image,
#management-settings-list .home-app-card .app-card-icon-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  transform: none;
}

#app-card-list .home-app-card .app-card-title,
#uncontracted-app-card-list .home-app-card .app-card-title,
#management-settings-list .home-app-card .app-card-title {
  display: block;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: var(--home-title-size, 0.86rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  overflow: visible;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  overflow-wrap: anywhere;
  word-break: keep-all;
  line-break: strict;
  text-wrap: pretty;
}

#app-card-list .home-app-card.is-disabled,
#uncontracted-app-card-list .home-app-card.is-disabled,
#management-settings-list .home-app-card.is-disabled,
#app-card-list .home-app-card.is-hospital-disabled,
#uncontracted-app-card-list .home-app-card.is-hospital-disabled {
  filter: none;
  background: transparent;
  border: none;
  opacity: 0.72;
}

#app-card-list .home-app-card.is-hospital-disabled .app-card-icon,
#uncontracted-app-card-list .home-app-card.is-hospital-disabled .app-card-icon {
  filter: grayscale(1);
  background: transparent;
}

#app-card-list .home-app-card.is-hospital-disabled .app-card-title,
#uncontracted-app-card-list .home-app-card.is-hospital-disabled .app-card-title {
  color: #6a6a6a;
}

#app-card-list .home-app-card.is-hospital-disabled .app-card-status,
#uncontracted-app-card-list .home-app-card.is-hospital-disabled .app-card-status {
  margin-top: 2px;
  padding: 1px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #6a6a6a;
  background: #e4e6e8;
}

#app-card-list .home-app-card.app-card-clickable:hover,
#uncontracted-app-card-list .home-app-card.app-card-clickable:hover,
#management-settings-list .home-app-card.app-card-clickable:hover {
  transform: translateY(-1px);
  border-color: transparent;
  box-shadow: none;
}

#app-card-list .home-app-card .app-card-status,
#uncontracted-app-card-list .home-app-card .app-card-status,
#management-settings-list .home-app-card .app-card-status {
  margin-left: auto;
  margin-right: auto;
}

#app-card-list .app-card-icon--count,
#uncontracted-app-card-list .app-card-icon--count {
  --count-badge: #4d5653;
  position: relative;
  font-size: calc(var(--home-icon-height) * 0.3);
  font-weight: 700;
  line-height: 1;
  background: transparent;
}

#app-card-list .app-card-icon--count::before,
#uncontracted-app-card-list .app-card-icon--count::before {
  content: none;
}

#app-card-list .app-card-icon--count .app-card-icon-count,
#uncontracted-app-card-list .app-card-icon--count .app-card-icon-count {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  min-width: 1.55em;
  height: 1.55em;
  padding: 0 0.32em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--count-badge);
  color: #fff;
  font-size: clamp(0.68rem, calc(var(--home-icon-height) * 0.2), 0.86rem);
  box-shadow: 0 4px 10px rgba(27, 58, 117, 0.16);
}

#app-card-list .app-card-icon--count-red,
#uncontracted-app-card-list .app-card-icon--count-red {
  --count-badge: var(--danger);
  background: transparent;
  color: var(--danger);
}

#app-card-list .app-card-icon--count-yellow,
#uncontracted-app-card-list .app-card-icon--count-yellow {
  --count-badge: var(--warn-ink);
  background: transparent;
  color: var(--warn-ink);
}

#app-card-list .app-card-icon--count-complete,
#uncontracted-app-card-list .app-card-icon--count-complete {
  --count-badge: #0f6b4c;
  background: transparent;
  color: #0f6b4c;
}

#app-card-list .app-card-icon--count-unknown,
#uncontracted-app-card-list .app-card-icon--count-unknown {
  --count-badge: #4d5653;
  background: transparent;
  color: #4d5653;
}

.home-apps-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.screen-home .mind-reset-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 20px 16px 22px;
  overflow: hidden;
  background-color: #f4f8f3;
  background-image: url("../assets/brand/mind-reset-spring-leaves.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 78% 30%;
  border: 1px solid rgba(46, 139, 120, 0.12);
  border-radius: 26px;
  box-shadow: 0 10px 26px rgba(27, 58, 117, 0.08);
}

.screen-home .mind-reset-card::before,
.screen-home .mind-reset-card::after {
  content: none;
}

.mind-reset-leaf {
  display: none;
}

.screen-home .mind-reset-icon,
.screen-home .mind-reset-content {
  position: relative;
  z-index: 1;
}

.screen-home .mind-reset-icon {
  position: absolute;
  top: 16px;
  left: 14px;
  width: 22px;
  height: 22px;
  background: transparent;
  color: #1a2b4d;
  font-size: 0.95rem;
}

.screen-home .mind-reset-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.screen-home .mind-reset-top {
  margin-bottom: 0;
  padding-left: 26px;
}

.screen-home .mind-reset-card .section-title {
  color: #1a2b4d;
  font-size: clamp(1rem, 1.28vw, 1.12rem);
  letter-spacing: 0.06em;
}

.screen-home .mind-reset-date {
  color: #1a2b4d;
  font-size: 0.88rem;
  font-weight: 600;
}

.screen-home .mind-reset-top,
.screen-home .mind-reset-card .section-title,
.screen-home .mind-reset-date {
  writing-mode: horizontal-tb;
}

.screen-home .mind-reset-body {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  align-self: center;
  margin-top: auto;
  margin-bottom: auto;
  margin-left: auto;
  margin-right: auto;
  max-height: min(78%, 32em);
  max-width: calc(100% - 8px);
  padding: 6px 10px 18px;
  font-size: clamp(1.08rem, 1.55vw, 1.34rem);
  font-weight: 600;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: #1a2b4d;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.92), 0 0 22px rgba(247, 250, 246, 0.78);
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.screen-home .mind-reset-body::before {
  content: "“";
  display: block;
  margin-bottom: 0.2em;
  font-size: 1.6em;
  line-height: 0.8;
  color: rgba(26, 43, 77, 0.28);
  font-weight: 700;
}

.home-uncontracted-section {
  display: none;
  margin-top: 0;
  padding: 12px 14px 14px;
  background: #f7f8f8;
  border-radius: 18px;
}

.home-uncontracted-section.is-empty {
  padding: 0;
  margin: 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.home-uncontracted-section.is-empty .section-title {
  font-size: 0.8rem;
  color: var(--muted);
}

.home-uncontracted-section.is-empty .hint {
  margin: 0;
  font-size: 0.8rem;
}

@media (min-width: 960px) and (max-height: 920px) {
  .home-board {
    --home-icon-height: clamp(112px, 14.6vh, 136px);
    --home-mgmt-icon-height: clamp(74px, 9.8vh, 94px);
    --home-title-size: clamp(0.98rem, 1.28vw, 1.12rem);
    --home-role-title-size: clamp(1.08rem, 1.42vw, 1.24rem);
    gap: 10px;
  }
}

@media (min-width: 960px) and (max-height: 820px) {
  .home-board {
    --home-icon-height: clamp(110px, 14.8vh, 132px);
    --home-mgmt-icon-height: clamp(72px, 9.6vh, 90px);
    --home-title-size: clamp(0.98rem, 1.28vw, 1.12rem);
    --home-role-title-size: clamp(1.08rem, 1.42vw, 1.24rem);
    gap: 10px;
  }

  .home-role-panel {
    padding: 10px 10px 8px;
  }

  .home-role-title {
    margin-bottom: 6px;
  }

  .screen-home .home-brand-logo {
    height: clamp(48px, 6.2vh, 58px);
    max-height: 58px;
  }
}

@media (min-width: 960px) and (max-width: 1220px) {
  .home-board {
    --home-icon-height: clamp(112px, 15vh, 140px);
    --home-mgmt-icon-height: clamp(74px, 10vh, 96px);
    --home-title-size: clamp(0.98rem, 1.3vw, 1.14rem);
    --home-role-title-size: clamp(1.08rem, 1.45vw, 1.26rem);
    gap: 10px;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 1.04fr) minmax(0, 1.74fr) minmax(156px, 20%);
  }

  .screen-home .home-brand-logo {
    height: clamp(52px, 6.6vh, 64px);
    max-height: 64px;
  }

  .home-role-panel {
    padding: 10px 10px 8px;
  }
}

@media (min-width: 960px) and (max-width: 1220px) and (max-height: 920px) {
  .home-board {
    --home-icon-height: clamp(110px, 14.4vh, 132px);
    --home-mgmt-icon-height: clamp(72px, 9.6vh, 90px);
  }
}

@media (min-width: 960px) and (max-width: 1220px) and (max-height: 820px) {
  .home-board {
    --home-icon-height: clamp(108px, 14.2vh, 128px);
    --home-mgmt-icon-height: clamp(70px, 9.4vh, 86px);
  }
}

@media (max-width: 959px) {
  body:has(#screen-home:not([hidden])) {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
    display: block;
  }

  .app-shell:has(#screen-home:not([hidden])) {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 12px 16px 16px;
  }

  .screen-home {
    width: min(860px, 100%);
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .home-board {
    --home-icon-height: clamp(104px, 14vw, 132px);
    --home-mgmt-icon-height: clamp(76px, 10vw, 96px);
    --home-icon-pad: 0px;
    --home-title-size: clamp(0.96rem, 1.9vw, 1.1rem);
    --home-role-title-size: clamp(1.06rem, 2.1vw, 1.22rem);
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "quote"
      "hygiene"
      "doctor"
      "common"
      "mgmt"
      "other"
      "status"
      "uncon";
    gap: 10px;
    overflow: visible;
  }

  .home-role-panel--hygiene,
  .home-role-panel--doctor,
  .home-role-panel--common,
  .home-role-panel--management {
    height: auto;
    min-height: min-content;
    overflow: visible;
  }

  .screen-home .mind-reset-card {
    height: auto;
    min-height: 0;
    flex-direction: row;
    align-items: flex-start;
    padding: 14px 18px;
    background-size: cover;
    background-position: 72% 18%;
  }

  .screen-home .mind-reset-icon {
    position: static;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    color: #1a2b4d;
  }

  .screen-home .mind-reset-top {
    padding-left: 0;
  }

  .screen-home .mind-reset-body {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    align-self: stretch;
    margin-top: 2px;
    margin-bottom: 0;
    max-height: none;
    max-width: none;
    padding: 0;
    font-size: 1.02rem;
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: #1a2b4d;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  }

  .screen-home .mind-reset-body::before {
    display: inline;
    margin: 0 0.15em 0 0;
    font-size: 1.35em;
    vertical-align: -0.15em;
  }

  .home-role-panel {
    padding: 10px 12px 8px;
  }

  .home-role-grid {
    flex: 0 0 auto;
    justify-content: start;
    align-content: start;
    gap: 8px 8px;
  }

  .home-role-panel--hygiene .home-role-grid {
    grid-template-columns: repeat(3, minmax(0, var(--home-card-width)));
  }

  .home-role-panel--doctor .home-role-grid {
    grid-template-columns: repeat(2, minmax(0, var(--home-card-width)));
    justify-content: start;
    justify-items: start;
    width: 100%;
    max-width: none;
  }

  .home-role-panel--common .home-role-grid,
  .home-role-panel--other .home-role-grid {
    grid-template-columns: repeat(4, minmax(0, var(--home-card-width)));
  }

  .home-role-panel--management .home-role-grid,
  #management-settings-list.home-role-grid {
    grid-template-columns: repeat(2, minmax(0, var(--home-mgmt-card-width)));
    justify-content: start;
    width: 100%;
    max-width: none;
  }

  #app-card-list .home-app-card .app-card-icon,
  #uncontracted-app-card-list .home-app-card .app-card-icon {
    border-radius: 22px;
  }

  #management-settings-list .home-app-card .app-card-icon {
    border-radius: 16px;
  }
}

@media (max-width: 959px) and (min-width: 700px) and (min-height: 1000px) {
  body:has(#screen-home:not([hidden])) {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
    display: flex;
    flex-direction: column;
  }

  .app-shell:has(#screen-home:not([hidden])) {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
  }

  .screen-home {
    height: auto;
    overflow: visible;
  }

  .home-board {
    --home-icon-height: clamp(112px, 15vw, 140px);
    --home-mgmt-icon-height: clamp(80px, 10.5vw, 100px);
    overflow: visible;
  }
}

@media (max-width: 640px) {
  body:has(#screen-home:not([hidden])) {
    height: auto;
    overflow: auto;
    display: block;
  }

  .app-shell:has(#screen-home:not([hidden])) {
    height: auto;
    overflow: visible;
    padding: 8px 10px 16px;
  }

  .screen-home {
    height: auto;
    overflow: visible;
  }

  .screen-home .home-header {
    flex-direction: row;
    align-items: center;
    padding: 2px 0 6px;
  }

  .screen-home .home-header .btn {
    width: auto;
  }

  .home-header-main {
    gap: 4px 12px;
  }

  .screen-home .home-meta {
    gap: 2px 10px;
    font-size: 0.8rem;
  }

  .screen-home .home-brand-logo {
    height: clamp(40px, 11vw, 50px);
    max-height: 50px;
    max-width: 200px;
  }

  .home-board {
    --home-icon-height: clamp(72px, 19vw, 96px);
    --home-mgmt-icon-height: clamp(40px, 11vw, 54px);
    --home-title-size: clamp(0.82rem, 3.3vw, 0.96rem);
    --home-role-title-size: clamp(0.94rem, 3.7vw, 1.08rem);
    --home-icon-pad: 0px;
    gap: 8px;
  }

  .home-role-panel--hygiene .home-role-grid {
    grid-template-columns: repeat(3, minmax(0, var(--home-card-width)));
  }

  .home-role-panel--doctor .home-role-grid {
    grid-template-columns: repeat(2, minmax(0, var(--home-card-width)));
    width: 100%;
    justify-content: start;
  }

  .home-role-panel--common .home-role-grid,
  .home-role-panel--other .home-role-grid {
    grid-template-columns: repeat(4, minmax(0, var(--home-card-width)));
  }

  .home-role-panel--management .home-role-grid,
  #management-settings-list.home-role-grid {
    grid-template-columns: repeat(2, minmax(0, var(--home-mgmt-card-width)));
    justify-content: start;
  }

  #app-card-list .home-app-card .app-card-icon,
  #uncontracted-app-card-list .home-app-card .app-card-icon {
    border-radius: 16px;
  }

  #management-settings-list .home-app-card .app-card-icon {
    border-radius: 14px;
  }

  #app-card-list .home-app-card,
  #uncontracted-app-card-list .home-app-card,
  #management-settings-list .home-app-card {
    min-height: min-content;
  }

  .screen-home .mind-reset-card {
    padding: 12px 14px;
    background-position: 78% 16%;
  }

  .screen-home .mind-reset-body {
    writing-mode: horizontal-tb;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #1a2b4d;
  }
}
