:root {
  --ink: #17231f;
  --ink-soft: #576862;
  --surface: #f6f7f3;
  --surface-strong: #ffffff;
  --surface-alt: #ebf2ef;
  --line: #d6dfdb;
  --line-strong: #b9c9c2;
  --brand: #1d6c5b;
  --brand-dark: #13473c;
  --brand-soft: #e1f0eb;
  --alert: #b94c3d;
  --alert-soft: #f9e7e3;
  --shadow: 0 18px 44px rgba(24, 44, 39, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(225, 240, 235, 0.95), transparent 28%),
    linear-gradient(180deg, #fbfcfa 0%, var(--surface) 54%, #eef2ef 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.page {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.08;
}

.header-copy {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.session-badge {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(185, 201, 194, 0.8);
  border-radius: 999px;
  padding: 10px 12px 10px 16px;
  box-shadow: var(--shadow);
}

.session-user {
  font-size: 14px;
  font-weight: 700;
}

.session-state {
  color: var(--ink-soft);
  font-size: 12px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 18px;
  align-items: stretch;
}

.hero-copy,
.card,
.patient-item,
.report-item,
.summary-strip,
.patient-bar,
.status-banner {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(214, 223, 219, 0.92);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: 28px;
  padding: 30px 28px;
  background:
    linear-gradient(135deg, rgba(225, 240, 235, 0.95), rgba(255, 255, 255, 0.98)),
    rgba(255, 255, 255, 0.94);
}

.hero-copy h2 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.18;
}

.hero-copy p:last-child {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.8;
}

.card {
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}

.account-card {
  max-width: 560px;
}

.account-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-card-wide {
  max-width: 860px;
}

.section-title {
  margin: 0 0 16px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

input[type='text'],
input[type='password'],
input[type='date'],
input[type='month'],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fdfefd;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(29, 108, 91, 0.12);
}

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

.inline-message {
  min-height: 20px;
  margin: 0 0 12px;
  color: var(--alert);
  font-size: 13px;
  font-weight: 600;
}

.helper-text,
.screen-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.btn-secondary {
  color: var(--brand-dark);
  background: white;
  border: 1.5px solid var(--line-strong);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.view-actions {
  display: flex;
  gap: 10px;
}

.screen-title {
  font-size: 24px;
  font-weight: 800;
}

.summary-strip,
.patient-bar,
.status-banner {
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.status-banner {
  background: var(--alert-soft);
  border-color: rgba(185, 76, 61, 0.28);
  color: #7b2c20;
}

.patient-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-soft);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.filter-chip.active {
  background: var(--brand-soft);
  border-color: rgba(29, 108, 91, 0.4);
  color: var(--brand-dark);
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.patient-item,
.report-item {
  border-radius: 18px;
  padding: 16px;
}

.patient-item-shell {
  display: flex;
  gap: 12px;
  align-items: center;
}

.patient-button {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
}

.patient-action-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.patient-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-soft), #f2faf7);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.patient-meta {
  flex: 1;
}

.patient-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.patient-address {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.summary-divider {
  margin: 0 8px;
  color: var(--ink-soft);
}

.summary-subtext {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 14px;
  align-items: start;
}

.detail-main,
.detail-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.detail-grid-span-2 {
  grid-column: 1 / -1;
}

.detail-extra-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-extra-row {
  border: 1px solid rgba(214, 223, 219, 0.8);
  border-radius: 12px;
  padding: 12px;
  background: rgba(246, 247, 243, 0.75);
}

.detail-extra-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.detail-extra-value {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-extra-value a {
  color: var(--brand);
}

.detail-extra-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-helper {
  margin-bottom: 10px;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-section-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-section-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid rgba(214, 223, 219, 0.92);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.detail-section-fields {
  flex: 1 1 auto;
  display: grid;
  gap: 12px;
}

.detail-page-section-content {
  min-height: 110px;
}

.photo-toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.photo-file-field {
  flex: 1 1 220px;
}

.photo-caption-field {
  flex: 1 1 220px;
}

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

.document-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.document-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(214, 223, 219, 0.92);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  padding: 14px 16px;
}

.document-meta {
  flex: 1 1 280px;
  min-width: 0;
}

.document-title {
  margin-bottom: 8px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.document-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.document-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.document-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.document-preview-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(214, 223, 219, 0.92);
  border-radius: 14px;
  background: rgba(245, 249, 247, 0.92);
  padding: 10px;
}

.document-preview-link {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(221, 231, 227, 0.74);
}

.document-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.document-preview-name {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}

.document-preview-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.document-file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.document-file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.document-link {
  color: var(--brand);
  font-size: 13px;
  text-decoration: none;
  word-break: break-all;
}

.document-link:hover {
  text-decoration: underline;
}

.document-empty {
  color: var(--ink-soft);
  font-size: 13px;
}

.document-toolbar {
  display: flex;
  flex: 0 1 320px;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.document-delete {
  padding: 8px 12px;
  font-size: 12px;
}

.document-delete:disabled {
  opacity: 0.58;
}

.document-file-input {
  flex: 1 1 220px;
}

.photo-card {
  border: 1px solid rgba(214, 223, 219, 0.92);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(24, 44, 39, 0.07);
}

.photo-card a {
  display: block;
  line-height: 0;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf2ef;
}

.photo-caption,
.photo-meta {
  padding: 0 12px 10px;
}

.photo-caption {
  padding-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.photo-meta {
  color: var(--ink-soft);
  font-size: 12px;
}

.photo-empty {
  border: 1px dashed rgba(185, 201, 194, 0.9);
  border-radius: 16px;
  padding: 18px 16px;
  color: var(--ink-soft);
  background: rgba(246, 247, 243, 0.7);
  text-align: center;
}

.history-photo-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(214, 223, 219, 0.92);
}

.history-photo-toolbar {
  margin-bottom: 8px;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-soft);
  padding: 12px 10px;
  font-weight: 700;
}

.tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-color: transparent;
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option-chip,
.score-chip,
.status-chip {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 600;
}

.option-chip.active,
.status-chip.active,
.score-chip.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: rgba(29, 108, 91, 0.4);
}

.score-chip.score-3.active {
  background: #f8e8e2;
  color: #8d2d21;
  border-color: rgba(185, 76, 61, 0.4);
}

.score-row,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(214, 223, 219, 0.8);
}

.score-row:last-child,
.status-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.score-buttons,
.status-buttons {
  display: flex;
  gap: 6px;
}

.score-row span,
.status-row span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

.action-row.compact {
  justify-content: stretch;
}

.action-row.compact .btn {
  flex: 1;
}

.report-item h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.report-meta,
.report-detail {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.report-detail strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(24px);
  background: rgba(23, 35, 31, 0.94);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 999;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .page {
    padding: 14px 12px 42px;
  }

  .app-header,
  .hero-card,
  .view-header,
  .action-row,
  .detail-section-row,
  .detail-section-header {
    flex-direction: column;
  }

  .detail-section-row .btn {
    width: 100%;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .session-badge {
    width: 100%;
    justify-content: space-between;
    border-radius: 20px;
  }

  .chip-grid {
    grid-template-columns: 1fr;
  }

  .detail-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .score-row,
  .status-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .patient-item-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .patient-actions,
  .photo-toolbar,
  .document-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .patient-filter-bar {
    flex-direction: column;
  }

  .score-buttons,
  .status-buttons,
  .view-actions,
  .action-row .btn,
  .view-header .btn,
  .patient-actions .btn,
  .photo-toolbar .btn,
  .document-toolbar .btn,
  .filter-chip {
    width: 100%;
  }

  .view-actions {
    flex-direction: column;
  }
}
