﻿:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #dbe2ef;
  --text: #1d2b3a;
  --muted: #6a778b;
  --brand: #2b7a78;
  --brand-soft: #e6f4f3;
  --warn: #c97a1a;
  --ok: #2f9e44;
  --patient: #2f6fdd;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f6f8fc 0%, #eef3f8 100%);
}
.auth-card {
  width: min(100%, 380px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.08);
}
.auth-brand { margin-bottom: 16px; }
.auth-brand h1 { margin: 0; font-size: 28px; }
.auth-brand p { margin: 8px 0 0; color: var(--muted); }
.auth-submit { width: 100%; margin-top: 16px; }
.auth-hint { min-height: 20px; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  width: 100%;
}

.sidebar {
  background: #133b5c;
  color: #e9f2ff;
  padding: 20px 14px;
}
.sidebar h1 { margin: 0; font-size: 20px; }
.sidebar p { margin: 8px 0 20px; color: #b7c7dd; font-size: 13px; }
.sidebar nav { display: grid; gap: 8px; }
.nav-group { display: grid; gap: 8px; }
.nav-group-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: #e9f2ff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-group-toggle:hover,
.nav-group-toggle.expanded {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}
.nav-group-arrow {
  transition: transform 0.2s ease;
  font-size: 12px;
}
.nav-group-toggle.expanded .nav-group-arrow { transform: rotate(180deg); }
.nav-submenu {
  display: grid;
  gap: 8px;
  padding-left: 12px;
}
.nav-submenu.is-collapsed { display: none; }
.nav-link {
  border: 1px solid transparent;
  background: transparent;
  color: #e9f2ff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.nav-link.active,
.nav-link:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.nav-sublink { font-size: 14px; }

.content { padding: 28px 30px 32px; }
.content > .panel,
.content > .panel.active {
  width: 100%;
  min-width: 0;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
}

.page-toolbar,
.subpage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px 20px;
}
.page-toolbar {
  margin-bottom: 18px;
  padding-bottom: 12px;
}
.page-toolbar-title {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}
.page-toolbar-title::before {
  content: "";
  width: 6px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand) 0%, #6db3aa 100%);
  box-shadow: 0 6px 14px rgba(43, 122, 120, 0.18);
}
.page-toolbar-actions {
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.page-toolbar-actions .page-hero-main {
  flex: 1 1 360px;
}
.page-toolbar-actions .page-description {
  font-size: 13px;
  line-height: 1.6;
}
.subpage-head {
  margin-bottom: 18px;
  align-items: center;
  padding: 0 2px 10px;
  border-bottom: 1px solid #e6edf5;
}
.subpage-head-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.subpage-head-main::before {
  content: "";
  width: 6px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand) 0%, #6db3aa 100%);
  box-shadow: 0 6px 14px rgba(43, 122, 120, 0.18);
  margin-right: 10px;
}
.subpage-head-module {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--muted);
}
.subpage-head-title {
  margin: 0;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}
.subpage-head-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.page-hero-main {
  flex: 1 1 520px;
  min-width: 0;
}
.page-hero-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.page-breadcrumb {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
}
.panel { display: none; gap: 16px; }
.panel.active { display: grid; }
.in-subpage { margin-bottom: 16px; }

.card-head-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.card-title-plain {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.field-group-head-tight .card-title-plain {
  margin-bottom: 0;
}
.card-head-action {
  flex-shrink: 0;
  white-space: nowrap;
}
.field-help {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.field-group-one-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 18px;
}
.field-group-one-line > .field-label {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
  padding-top: 8px;
}
.field-group-one-line > .time-range-inline-tools,
.field-group-one-line > .duration-generate-bar {
  flex: 1 1 200px;
  min-width: 0;
}

.field-group {
  padding: 4px 0 8px;
}
.field-group-actions {
  padding-bottom: 0;
}
.field-group-head {
  margin-bottom: 8px;
}
.schedule-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-group-head-tight {
  margin-bottom: 8px;
}
.field-group-head-tight .field-label {
  margin-bottom: 0;
}
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.field-separator {
  height: 1px;
  margin: 8px 0 12px;
  background: var(--line);
  border: 0;
}
.duration-generate-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  justify-content: flex-start;
}
.duration-input-label {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.duration-input-label input {
  width: 4.5rem;
  max-width: 100%;
}
.duration-generate-bar .primary {
  flex-shrink: 0;
  min-height: 40px;
  padding-left: 20px;
  padding-right: 20px;
}

.card-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.save-hint-inline {
  flex: 1 1 200px;
  margin: 0;
  min-width: 0;
}
.hint-tight {
  margin-top: 8px;
  margin-bottom: 0;
}

.subpage { display: none; }
.subpage.active { display: grid; gap: 16px; }
.schedule-editor-shell {
  gap: 18px;
}
.schedule-editor-hero {
  gap: 20px;
}
.schedule-editor-hero-main {
  flex: 1 1 480px;
}
.schedule-editor-grid {
  display: block;
  width: 100%;
  max-width: none;
  gap: 16px;
}
.schedule-rule-card {
  width: 100%;
}
.schedule-card-head {
  margin-bottom: 8px;
}
.card-section-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(18, 38, 63, 0.04);
}
.card h3 { margin: 0 0 8px; }
.card p { margin: 0 0 12px; color: var(--muted); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}
.event-inline-actions {
  grid-template-columns: minmax(0, 1fr) auto;
}
.event-inline-actions .secondary {
  min-width: 112px;
  white-space: nowrap;
}
.event-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 12px;
}
.event-editor-actions .primary {
  flex: 0 0 auto;
  min-width: 140px;
  padding-left: 24px;
  padding-right: 24px;
}
.form-col { display: grid; gap: 10px; }
label { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.primary,
.secondary {
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
}
.danger {
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(18, 38, 63, 0.04);
}
.primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}
.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(18, 38, 63, 0.04);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
}
.workday-chip-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.workday-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-width: 0;
  transition: 0.18s ease;
}
.workday-chip.active {
  background: var(--brand-soft);
  border-color: #9fd2cc;
  color: var(--brand);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(43, 122, 120, 0.1);
}
.workday-hidden-inputs { display: none; }
.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.week-head { gap: 12px; }
.week-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.muted { color: var(--muted); font-size: 13px; }

.calendar-week-grid {
  display: block;
  overflow-x: auto;
  padding-bottom: 4px;
}
.calendar-matrix {
  min-width: 860px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.matrix-row {
  display: grid;
  grid-template-columns: 90px repeat(auto-fit, minmax(180px, 1fr));
  align-items: stretch;
}
.matrix-row + .matrix-row { border-top: 1px solid var(--line); }
.matrix-time-head,
.matrix-time-cell {
  background: #f4f7fc;
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
  border-right: 1px solid var(--line);
  position: sticky;
  left: 0;
  z-index: 3;
}
.matrix-time-cell {
  font-size: 13px;
  font-weight: 700;
  color: #3a4b5f;
}
.matrix-day-head {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #33475b;
  border-right: 1px solid var(--line);
  background: #fafcff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.matrix-day-head span {
  margin-left: 6px;
  font-weight: 400;
  color: var(--muted);
}
.matrix-slot-cell {
  min-height: 46px;
  padding: 6px 8px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fcf9;
}
.matrix-slot-cell.patient { background: #eef4ff; }
.matrix-slot-cell.manual { background: #fff8ee; }
.matrix-slot-cell.empty-cell {
  color: #c0c9d5;
  justify-content: center;
  background: #fbfcfe;
}
.matrix-header .matrix-time-head { z-index: 4; }
.matrix-slot-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.matrix-tag {
  font-size: 11px;
  color: #5d7388;
}
.ghost-tag { visibility: hidden; }
.matrix-patient {
  font-size: 12px;
  color: #1d2b3a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.matrix-patient-link {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.matrix-patient-link:hover {
  color: #0a58ca;
}
.ghost-text { visibility: hidden; }
.matrix-plus {
  min-width: 30px;
  height: 24px;
  padding: 0;
}
.small-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 2px 0;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 700;
  cursor: pointer;
}
.add-btn {
  font-weight: 700;
  color: var(--brand);
  border-color: #9fd2cc;
  background: #f0fbfa;
}
.cancel-btn {
  min-width: 42px;
  font-size: 12px;
  line-height: 1;
  color: #a14a39;
  border-color: #e6c5bc;
  background: #fff4f1;
 }
.slot-plus {
  min-width: 36px;
  padding: 1px 0;
}
.slot-plus:disabled {
  color: #9aa6b2;
  border-color: #d5dbe3;
  background: #f3f5f8;
  cursor: not-allowed;
}

.slot-edit-table-head {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr) 64px;
  gap: 12px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.slot-edit-list {
  display: grid;
  gap: 0;
  width: 100%;
}
.slot-edit-item {
  border-bottom: 1px solid #e8edf3;
  padding: 12px 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
}
.slot-edit-order {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.slot-edit-field {
  display: block;
}
.slot-edit-field-label {
  display: none;
}
.slot-edit-field input[type="time"] {
  width: 100%;
  max-width: none;
  height: 34px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
}
.slot-row-remove {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #6a7d90;
  white-space: nowrap;
  font-size: 12px;
  text-align: left;
}
.slot-row-remove:hover {
  color: var(--text);
  background: transparent;
}
.slot-edit-empty {
  padding: 16px 0 8px;
}
.slot-edit-item > .slot-row-error {
  grid-column: 1 / -1;
  white-space: normal;
  padding-top: 6px;
}
.slot-row-error {
  color: #b54708;
  font-size: 12px;
  line-height: 1.5;
}
.slot-add-btn {
  margin-top: 0;
  align-self: auto;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

@media (min-width: 1200px) {
  .content {
    padding-right: 36px;
  }
  .schedule-rule-card {
    padding: 24px 28px;
  }
}
.schedule-save-bar {
  position: static;
  padding-bottom: 0;
  background: transparent;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; }

.result-list, .rule-list { margin: 0; padding-left: 18px; }
.result-list li, .rule-list li { margin: 6px 0; }
.content-card-head {
  margin-bottom: 0;
}
.content-publish-list {
  display: grid;
  gap: 12px;
}
.content-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.content-list-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid #e4ebf3;
  border-radius: 14px;
  background: #fff;
}
.content-list-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}
.content-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.content-list-title-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.content-list-title {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}
.content-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 13px;
}
.content-list-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.content-list-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 120px;
}
.content-list-actions .secondary {
  width: 100%;
}
.article-list-card .content-list-actions {
  min-width: 156px;
}
.article-list-actions {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
}
.article-list-actions .secondary {
  width: auto;
}
.article-editor-status-hint {
  margin-top: 0;
}
.edit-patient-btn {
  margin-left: 8px;
  font-size: 12px;
  padding: 2px 8px;
}

.photo-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.photo-grid-item {
  position: relative;
}
.photo-grid img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.photo-grid-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(33, 33, 33, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}
.photo-grid-remove:hover {
  background: rgba(33, 33, 33, 0.86);
}
.hint { margin-top: 10px; color: var(--brand); font-size: 13px; }

.patient-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.patient-home-toolbar {
  margin-bottom: 18px;
}
.patient-search-row {
  flex: 1 1 560px;
  max-width: 640px;
  grid-template-columns: 1fr auto;
  margin-bottom: 0;
}
.patient-search-row input[type="text"] {
  width: 100%;
  max-width: none;
}
.patient-view-actions {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  margin-bottom: 0;
}
.patient-list {
  display: grid;
  gap: 12px;
}
.patient-list-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid #e4ebf3;
  border-radius: 14px;
  background: #fff;
}
.patient-list-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}
.patient-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.patient-list-name {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}
.patient-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 13px;
}
.patient-list-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.patient-list-stat {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #edf1f5;
}
.patient-list-stat-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}
.patient-list-stat-value {
  display: block;
  color: var(--text);
  font-weight: 700;
}
.patient-list-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}
.patient-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.patient-detail-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.patient-detail-tab.is-active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.order-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.patient-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.patient-detail-grid-wide .patient-summary-item {
  min-height: 100%;
}
.patient-summary-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #ebeff4;
  background: #f9fbfd;
}
.patient-summary-item.patient-inline-field {
  gap: 8px;
  color: var(--muted);
}
.patient-summary-item.patient-inline-field textarea {
  min-height: 88px;
  resize: vertical;
}
.patient-inline-field .patient-summary-label {
  margin-bottom: 0;
}
.patient-order-context {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.patient-order-context-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e7edf5;
  background: #fbfcfe;
}
.patient-order-context-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.patient-order-context-item span {
  display: block;
  color: var(--text);
  font-weight: 600;
}
.patient-summary-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}
.patient-summary-value {
  display: block;
  color: var(--text);
  font-weight: 600;
}
.patient-record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.patient-record-head-actions {
  display: flex;
  gap: 10px;
}
.patient-detail-savebar {
  position: sticky;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid #dce7f1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
}
.patient-detail-savebar .hint {
  margin: 0;
  min-height: 20px;
}
.patient-detail-savebar .primary {
  min-width: 112px;
}
.patient-record-list {
  display: grid;
  gap: 12px;
}
.patient-record-card {
  border: 1px solid #e7edf5;
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}
.patient-record-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.patient-record-card-title {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.patient-record-card-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.patient-record-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.patient-record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
}
.patient-record-field {
  min-width: 0;
}
.patient-record-field.full {
  grid-column: 1 / -1;
}
.patient-record-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}
.patient-record-value {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.patient-record-photos {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.patient-photo-trigger {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.patient-photo-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 10px;
}
.patient-record-photos img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}
.patient-baseline-photos {
  margin-top: 16px;
}
.patient-baseline-photos h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
}
.patient-photo-viewer-card {
  max-width: min(92vw, 980px);
}
.patient-photo-viewer-copy {
  margin-top: 6px;
}
.patient-photo-viewer-body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 8px;
}
.patient-photo-viewer-body img {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 900px);
  width: auto;
  height: auto;
  border-radius: 16px;
  object-fit: contain;
  background: #fff;
}
.patient-record-patient {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f6fbfa;
  border: 1px solid #dce9e6;
  color: var(--text);
  font-weight: 600;
}
.patient-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.patient-family-list {
  display: grid;
  gap: 12px;
}
.family-block {
  display: grid;
  gap: 0;
  padding: 16px 18px;
  border: 1px solid #e4ebf3;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(19, 59, 92, 0.04);
}
.family-member-list {
  display: grid;
  gap: 0;
}
.family-dependent-list {
  display: grid;
  gap: 0;
  margin-left: 18px;
  padding: 8px 0 0;
}
.family-dependent-item {
  position: relative;
  padding-top: 8px;
  border-top: 1px solid #edf2f6;
}
.family-dependent-item::before {
  content: "";
  position: absolute;
  left: 36px;
  top: 0;
  bottom: calc(50% - 1px);
  border-left: 2px solid #dcebe7;
}
.family-dependent-item .family-member-main::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 18px;
  border-top: 2px solid #dcebe7;
  transform: translateY(-50%);
}
.family-member-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) minmax(120px, 0.9fr) minmax(120px, 0.9fr) minmax(88px, 0.6fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 6px;
}
.family-member-row.is-primary {
  padding-top: 4px;
  padding-bottom: 12px;
}
.family-member-main {
  min-width: 0;
  position: relative;
}
.family-dependent-item .family-member-main {
  padding-left: 42px;
}
.family-member-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.family-member-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.family-member-col {
  min-width: 0;
}
.family-member-label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  color: var(--muted);
}
.family-member-value {
  display: block;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.family-member-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.family-member-actions .primary,
.family-member-actions .secondary,
.family-member-actions .danger {
  min-width: 78px;
  padding: 7px 10px;
  font-size: 14px;
  flex: 0 0 auto;
}
.family-role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #edf4ff;
  color: var(--patient);
}
.family-role-badge.primary {
  background: var(--brand-soft);
  color: var(--brand);
}
.patient-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #fbfcfe;
}

.is-hidden {
  display: none !important;
}
.patient-kind-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 4px 0 8px;
}
.patient-kind-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.inline-radio input {
  width: auto;
  margin: 0;
}
.patient-primary-wrap {
  margin-bottom: 4px;
}
.patient-primary-wrap label {
  max-width: 420px;
}
.patient-form-layout {
  display: grid;
  gap: 16px;
}
.patient-section {
  border: 1px solid #e8edf5;
  border-radius: 14px;
  padding: 16px;
  background: #fcfdff;
}
.patient-section-head {
  margin-bottom: 12px;
}
.patient-section-head h4 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--text);
}
.patient-section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.option-field {
  display: grid;
  gap: 10px;
}
.option-field-head {
  margin-bottom: -2px;
}
.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
}
.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #d9e4f0;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.option-chip input {
  width: auto;
  margin: 0;
}
.option-chip-other {
  background: #f7fafc;
}
.option-other-input {
  max-width: 360px;
}

.account-page-card {
  padding: 0;
  overflow: hidden;
}
.account-page-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.account-page-current {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}
.account-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.account-table-wrap {
  padding: 0 16px 8px;
  overflow-x: auto;
}
.account-table {
  margin-top: 4px;
}
.account-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.admin {
  background: var(--brand-soft);
  color: var(--brand);
}
.badge.member {
  background: #edf4ff;
  color: var(--patient);
}
.badge.active {
  background: #ebf8ef;
  color: var(--ok);
}
.badge.disabled {
  background: #fff2e7;
  color: var(--warn);
}
.empty-card {
  color: var(--muted);
}
.modal-card-compact {
  width: min(100%, 460px);
}
.modal-copy {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.32);
  z-index: 30;
}
.modal-card {
  width: min(100%, 420px);
  background: #fff;
  border-radius: 18px;
  border: 1px solid #dde6ef;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.18);
}
.modal-card-wide {
  width: min(100%, 1180px);
}
.schedule-patient-modal-card {
  --schedule-patient-action-width: 104px;
  --schedule-patient-card-side-pad: 14px;
  width: min(100%, 720px);
  padding: 16px 16px 18px;
}
.schedule-patient-close {
  width: 36px;
  height: 36px;
  border: 1px solid #d9e3ef;
  border-radius: 999px;
  background: #f7fafc;
  color: #607086;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.schedule-patient-close:hover {
  background: #edf3f8;
  border-color: #c9d8e8;
  color: #314155;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.modal-head h3 {
  margin: 0;
  font-size: 18px;
}
.schedule-patient-modal-body {
  display: grid;
  gap: 10px;
}
.schedule-patient-modal-body .hint {
  margin: 0;
}
.schedule-patient-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.schedule-patient-section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.schedule-patient-section-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.schedule-patient-inline-hint {
  color: var(--warn);
}
.schedule-patient-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--schedule-patient-action-width);
  gap: 8px;
  align-items: stretch;
  padding-right: var(--schedule-patient-card-side-pad);
}
.schedule-patient-toolbar input[type="text"] {
  min-height: 42px;
  padding-top: 0;
  padding-bottom: 0;
}
.schedule-patient-toolbar-btn,
.schedule-patient-create-btn {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 700;
  width: var(--schedule-patient-action-width);
  justify-content: center;
}
.schedule-patient-toolbar-btn {
  box-shadow: 0 6px 14px rgba(43, 122, 120, 0.12);
}
.schedule-patient-create-btn {
  border-color: #d7e2ef;
  background: #f9fbfd;
  color: #38526d;
  box-shadow: none;
}
.schedule-patient-create-btn:hover {
  background: #f1f6fb;
  border-color: #c6d7e8;
}
.schedule-patient-list {
  display: grid;
  gap: 10px;
  max-height: 44vh;
  overflow: auto;
}
.schedule-patient-card {
  border: 1px solid #dde6ef;
  border-radius: 12px;
  padding: 14px var(--schedule-patient-card-side-pad);
  background: linear-gradient(180deg, #fbfdff 0%, #f6f9fc 100%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 14px;
}
.schedule-patient-card-main {
  flex: 1 1 360px;
  min-width: 0;
  display: grid;
  gap: 5px;
}
.schedule-patient-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.schedule-patient-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.schedule-patient-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4fb;
  color: #47627f;
  font-size: 11px;
  font-weight: 700;
}
.schedule-patient-meta,
.schedule-patient-record {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.schedule-patient-card-actions {
  flex: 0 0 var(--schedule-patient-action-width);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.schedule-patient-add-btn {
  width: var(--schedule-patient-action-width);
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(43, 122, 120, 0.12);
}
.schedule-patient-footer {
  display: flex;
  justify-content: flex-end;
  padding-right: var(--schedule-patient-card-side-pad);
  margin-top: 2px;
}
.schedule-patient-empty {
  padding: 20px 16px;
  border: 1px dashed #cfd9e6;
  border-radius: 14px;
  color: var(--muted);
  background: #fbfcfe;
  text-align: center;
}
.inventory-toolbar {
  margin-bottom: 16px;
}
.inventory-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: none;
}
.inventory-filter-row input[type="text"] {
  flex: 1 1 320px;
  min-width: 240px;
}
.inventory-filter-row select {
  flex: 0 0 180px;
  min-width: 180px;
}
.inventory-filter-row .secondary {
  flex: 0 0 auto;
}
.inventory-list {
  display: grid;
  gap: 14px;
}
.inventory-list-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  border: 1px solid #e3ebf3;
  border-radius: 18px;
  background: #fff;
}
.inventory-list-main {
  display: grid;
  gap: 12px;
}
.inventory-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.inventory-list-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.inventory-list-title {
  margin: 0;
  font-size: 18px;
}
.inventory-list-subtitle {
  color: var(--muted);
  font-size: 13px;
}
.inventory-list-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.inventory-metric {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fbfe;
}
.inventory-metric span {
  color: var(--muted);
  font-size: 12px;
}
.inventory-metric strong {
  font-size: 16px;
}
.inventory-list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.inventory-workspace {
  display: grid;
  gap: 18px;
}
.inventory-detail-actions {
  flex-wrap: wrap;
}
.inventory-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.inventory-summary-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fbfe;
}
.inventory-summary-label {
  color: var(--muted);
  font-size: 12px;
}
.inventory-summary-value {
  color: var(--text);
  font-weight: 600;
}
.inventory-detail-card {
  display: grid;
  gap: 14px;
}
.inventory-table-wrap {
  overflow-x: auto;
}
.inventory-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
.inventory-table th,
.inventory-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e8eef5;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.inventory-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.inventory-entry-table input,
.inventory-entry-table select {
  min-width: 100px;
}
.inventory-entry-table .inventory-line-unit,
.inventory-entry-table .inventory-line-remaining {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}
.inventory-modal-tools {
  display: flex;
  justify-content: flex-start;
}
.inventory-modal-table-wrap {
  max-height: 360px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; }
  .grid.two { grid-template-columns: 1fr; }
  .calendar-matrix { min-width: 680px; }
  .page-toolbar-title,
  .subpage-head-title {
    font-size: 20px;
  }
  .page-hero-actions,
  .subpage-head-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .calendar-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .schedule-editor-grid { grid-template-columns: 1fr; }
  .slot-edit-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .slot-edit-table-head {
    display: none;
  }
  .family-member-row {
    grid-template-columns: 1fr;
  }
  .family-dependent-list {
    margin-left: 0;
    padding-left: 0;
  }
  .family-dependent-item {
    padding-top: 10px;
  }
  .family-member-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .patient-view-actions {
    width: 100%;
    justify-content: stretch;
  }
  .patient-view-actions .primary {
    width: 100%;
  }
  .patient-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .patient-search-row {
    max-width: none;
  }
  .patient-list-card {
    grid-template-columns: 1fr;
  }
  .content-list-card {
    grid-template-columns: 1fr;
  }
  .inventory-list-card {
    grid-template-columns: 1fr;
  }
  .inventory-list-metrics,
  .inventory-summary-grid {
    grid-template-columns: 1fr;
  }
  .content-list-actions {
    min-width: 0;
  }
  .patient-list-actions {
    flex-direction: row;
    justify-content: flex-start;
  }
  .content-list-actions {
    flex-direction: row;
    justify-content: flex-start;
  }
  .patient-form-actions .primary {
    width: 100%;
  }
  .workday-chip-grid {
    gap: 4px;
  }
  .workday-chip {
    padding: 8px 2px;
    font-size: 12px;
  }
  .event-inline-actions {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .account-page-tools {
    align-items: stretch;
  }
  .account-page-actions {
    width: 100%;
  }
  .account-page-actions .secondary,
  .account-page-actions .primary {
    width: 100%;
    justify-content: center;
  }
  .account-actions {
    justify-content: stretch;
  }
  .account-actions .secondary {
    width: 100%;
  }
}
