:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --line: #dbe5ee;
  --text: #1d2733;
  --muted: #667587;
  --primary: #1f7a8c;
  --primary-dark: #135565;
  --accent: #d97706;
  --green: #178f65;
  --red: #c2413a;
  --shadow: 0 14px 32px rgba(37, 51, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

body.auth-open {
  overflow: hidden;
}

.sidebar {
  background: #172331;
  color: #fff;
  min-height: 100vh;
  padding: 24px 16px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4fb3bf, #1f7a8c 55%, #f59e0b);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 19px;
  margin-bottom: 4px;
}

.brand span {
  color: #9fb0c3;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #c9d6e3;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #25364a;
  color: #fff;
}

.db-status {
  margin-top: 28px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd7e5;
  font-size: 13px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.topbar p,
.panel-head span {
  color: var(--muted);
}

.top-actions,
.form-actions,
.export-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

button,
a {
  font-family: inherit;
}

.primary-btn,
.ghost-btn,
.small-btn,
.icon-btn {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.ghost-btn {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.small-btn {
  min-height: 30px;
  padding: 0 10px;
  background: #e7f4f2;
  color: var(--primary-dark);
  border-color: #b9deda;
  font-weight: 700;
}

.small-btn:hover {
  background: #d7eeeb;
}

.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #f2f6f9;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.metric.accent strong {
  color: var(--accent);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.overview-metrics {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.overview-metric {
  position: relative;
  min-height: 132px;
  padding: 20px 22px;
  overflow: hidden;
}

.overview-metric::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: var(--primary);
}

.overview-metric[data-tone="green"]::before {
  background: #2f855a;
}

.overview-metric[data-tone="amber"]::before {
  background: #d18a27;
}

.overview-metric span,
.overview-metric small {
  display: block;
}

.overview-metric strong {
  margin-top: 8px;
  color: var(--text);
  font-size: 34px;
  line-height: 1.1;
}

.overview-metric small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.overview-workspace {
  display: grid;
  gap: 16px;
}

.recent-work-panel {
  padding: 0;
  overflow: hidden;
}

.overview-panel-head {
  align-items: center;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.overview-panel-head > div:first-child span,
.overview-module-panel .panel-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.overview-recent-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.overview-recent-tools input {
  width: 230px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.overview-recent-tools input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.12);
}

.overview-scope-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f3f6f8;
}

.overview-scope-btn {
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.overview-scope-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(20, 43, 62, 0.12);
}

.overview-recent-table-wrap {
  overflow-x: auto;
}

.overview-recent-table {
  min-width: 760px;
}

.overview-recent-table th,
.overview-recent-table td {
  padding: 13px 20px;
}

.overview-recent-table tbody tr:hover {
  background: #f8fbfc;
}

.recent-patient-name,
.recent-patient-no {
  display: block;
}

.recent-patient-name {
  color: var(--text);
  font-size: 14px;
}

.recent-patient-no {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.overview-module-panel .panel-head {
  margin-bottom: 14px;
}

.overview-module-panel .bar-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 28px;
}

.overview-module-panel .bar-row {
  grid-template-columns: 96px minmax(0, 1fr) 58px;
  min-height: 34px;
}

.overview-module-panel .bar-track {
  height: 9px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 17px;
}

.bar-list,
.rating-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.bar-track {
  height: 12px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  min-width: 4px;
}

.rating-item {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 68px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.rating-item:last-child {
  border-bottom: 0;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  background: #e7f4f2;
  color: var(--primary-dark);
  font-weight: 700;
}

.line-chart {
  min-height: 210px;
}

.line-chart svg {
  width: 100%;
  height: 210px;
  display: block;
}

.table-wrap,
.compact-table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.compact-table {
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
}

.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 99px;
  background: #edf7ed;
  color: var(--green);
  font-weight: 700;
}

.tag.warn {
  background: #fff7e6;
  color: var(--accent);
}

.result-entry-btn,
.wave-entry-btn {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 11px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.result-entry-btn {
  background: #edf7ed;
  border-color: #cfe8d3;
  color: var(--green);
}

.result-entry-btn:hover {
  background: #dff1e2;
}

.wave-entry-btn {
  background: #e7f4f2;
  border-color: #b9deda;
  color: var(--primary-dark);
}

.wave-entry-btn:hover {
  background: #d7eeeb;
}

.wave-entry-btn.empty {
  background: #fff7e6;
  border-color: #f0dab1;
  color: var(--accent);
}

.entry-form {
  display: grid;
  gap: 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

legend {
  padding: 0 8px;
  color: var(--primary-dark);
  font-weight: 700;
}

label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

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

#entryMessage {
  color: var(--muted);
  font-size: 14px;
}

#entryMessage.ok {
  color: var(--green);
}

#entryMessage.fail {
  color: var(--red);
}

.export-panel {
  max-width: 760px;
}

.export-box {
  justify-content: space-between;
  border: 1px solid var(--line);
  background: #f8fbfd;
  border-radius: 8px;
  padding: 18px;
}

.export-box p {
  color: var(--muted);
  margin-top: 8px;
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal.active {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  position: absolute;
  top: 32px;
  right: 32px;
  bottom: 32px;
  left: 32px;
  max-width: 1180px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  flex: 0 0 auto;
  min-height: 72px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-head p {
  color: var(--muted);
  margin-top: 5px;
}

.modal-head > div,
.modal-body,
.modal-body > * {
  min-width: 0;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 18px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
}

.export-modal-panel {
  top: 7vh;
  bottom: auto;
  max-width: 920px;
  max-height: 86vh;
}

.export-modal-body {
  gap: 18px;
}

.export-page-panel {
  max-width: 1180px;
}

.export-page-body {
  display: grid;
  gap: 12px;
}

.export-form {
  display: grid;
  gap: 16px;
}

.period-control {
  width: fit-content;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f7fa;
}

.period-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.period-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(37, 51, 66, 0.12);
}

.export-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.export-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.export-simple-preview {
  min-width: 0;
}

.export-simple-preview > span {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.export-simple-preview h3 {
  margin: 0 0 5px;
  font-size: 18px;
}

.export-simple-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.export-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.export-preview-head h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.export-preview-head p,
.export-message,
.export-option-desc {
  color: var(--muted);
  font-size: 13px;
}

.export-summary-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  min-height: 48px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.export-summary-bar span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 20px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.export-summary-bar span:first-child {
  padding-left: 0;
}

.export-summary-bar span:last-child {
  border-right: 0;
}

.export-summary-bar strong {
  color: var(--text);
  font-size: 19px;
}

.export-message {
  max-width: 360px;
  margin: 0;
  text-align: right;
}

.export-message.fail {
  color: var(--red);
}

.export-message:empty {
  display: none;
}

.export-compact-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.export-compact-summary strong {
  color: var(--text);
  font-size: 15px;
}

.export-compact-summary > span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.export-compact-summary .export-message {
  margin-left: auto;
}

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

.export-primary-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid #9bcdd2;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #f3fbfb;
}

.export-primary-copy {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.export-primary-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 17px;
}

.export-recommend-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 5px;
  background: #16879a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.export-primary-option .primary-btn {
  min-width: 146px;
  white-space: nowrap;
}

.export-primary-option .primary-btn:disabled {
  border-color: #d7e0e7;
  background: #e8eef2;
  color: #82909c;
  cursor: not-allowed;
}

.export-secondary-title {
  margin: 0 1px -4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.export-option {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fff;
}

.export-option-copy {
  min-width: 0;
}

.export-option-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.export-option-desc {
  display: block;
  margin-top: 5px;
  line-height: 1.45;
}

.export-format-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #edf5f7;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.export-option .primary-btn {
  min-width: 72px;
  padding-inline: 14px;
  white-space: nowrap;
}

.export-option .primary-btn:disabled {
  border-color: #d7e0e7;
  background: #e8eef2;
  color: #82909c;
  cursor: not-allowed;
}

.export-separate-details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.export-separate-details > summary,
.export-advanced-filters > summary {
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.export-separate-details[open] > summary,
.export-advanced-filters[open] > summary {
  color: var(--primary-dark);
}

.export-separate-details .export-actions {
  margin-top: 12px;
}

.format-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.format-status span {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e9f5f2;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.format-status .reserved {
  background: #f1f5f9;
  color: var(--muted);
}

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

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.detail-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.patient-profile-summary {
  margin-bottom: 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #fbfdfe;
}

.patient-profile-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.patient-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.patient-profile-title {
  min-width: 0;
}

.patient-profile-title span,
.patient-profile-title small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.patient-profile-title strong {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: 21px;
}

.patient-profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.patient-profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.quick-export-btn {
  min-height: 36px;
  white-space: nowrap;
}

.patient-profile-badges span {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e9f5f2;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.patient-fact-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 0;
  margin: 12px 0 0;
}

.patient-fact-grid > div {
  min-width: 0;
  padding: 0 14px;
  border-left: 1px solid var(--line);
}

.patient-fact-grid > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.patient-fact-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.patient-fact-grid dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.patient-support-grid {
  margin-bottom: 0;
}

.patient-health-card {
  padding: 0 18px;
}

.patient-health-section {
  padding: 14px 0;
}

.patient-health-section h3 {
  margin-bottom: 10px;
}

.patient-health-section + .patient-health-section {
  border-top: 1px solid var(--line);
}

.condition-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 20px;
}

.condition-row {
  min-width: 0;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #edf1f4;
  color: var(--text);
  font-size: 13px;
}

.condition-row strong {
  font-size: 12px;
}

.condition-row.has-condition strong {
  color: #b45309;
}

.condition-row.no-condition strong {
  color: var(--green);
}

.condition-row.unknown-condition strong {
  color: var(--muted);
}

.medication-list {
  display: grid;
  gap: 8px;
}

.medication-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 34px;
  color: var(--text);
}

.medication-row > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.medication-row span,
.medication-row small {
  color: var(--muted);
  font-size: 12px;
}

.medication-row strong {
  font-size: 13px;
}

.health-empty {
  color: var(--muted);
  font-size: 13px;
}

.patient-history-card {
  min-height: max-content;
  padding: 0;
  overflow: hidden;
}

.detail-section-head {
  padding: 14px 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-section-head h3 {
  margin-bottom: 4px;
}

.detail-section-head p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.patient-history-card .table-wrap {
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
}

.patient-history-card table {
  min-width: 720px;
}

.history-count {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef7f6;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.patient-wave-actions {
  flex-wrap: nowrap;
}

.table-metrics {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.table-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
}

.table-metrics b {
  color: var(--primary-dark);
}

.assessment-summary {
  --assessment-accent: #1f7a8c;
  min-height: 116px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--assessment-accent);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.assessment-module_1 { --assessment-accent: #2878b5; }
.assessment-module_2 { --assessment-accent: #168b82; }
.assessment-module_3 { --assessment-accent: #7c5cc4; }
.assessment-module_4 { --assessment-accent: #2563eb; }
.assessment-module_5 { --assessment-accent: #c2415d; }
.assessment-module_6 { --assessment-accent: #c56a24; }

.assessment-eyebrow {
  color: var(--assessment-accent);
  font-size: 12px;
  font-weight: 800;
}

.assessment-summary h3 {
  margin: 8px 0 6px;
  font-size: 21px;
}

.assessment-summary-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.assessment-module-icon {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(31, 74, 98, 0.15);
}

.assessment-summary p,
.section-heading p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.assessment-primary-result {
  min-width: 190px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.assessment-summary-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.assessment-export-btn {
  min-height: 38px;
  white-space: nowrap;
}

.assessment-primary-result span,
.assessment-primary-result strong {
  display: block;
}

.assessment-primary-result span {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.assessment-primary-result strong {
  color: var(--assessment-accent);
  font-size: 23px;
  overflow-wrap: anywhere;
}

.module-result-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
}

.module-result-list div {
  min-width: 0;
  padding: 11px 0;
  border-bottom: 1px solid #edf1f5;
}

.module-result-list dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.module-result-list dd {
  margin: 0;
  font-weight: 700;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin-bottom: 5px;
}

.assessment-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.assessment-metric {
  min-width: 0;
  padding: 12px;
  border-radius: 7px;
  background: #f7f9fb;
}

.assessment-metric span,
.assessment-metric strong {
  display: block;
}

.assessment-metric span {
  color: var(--muted);
  font-size: 12px;
}

.assessment-metric strong {
  margin: 7px 0 10px;
  color: var(--metric-color);
  font-size: 20px;
}

.metric-track {
  height: 5px;
  border-radius: 5px;
  background: #e4e9ef;
  overflow: hidden;
}

.metric-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--metric-color);
}

.metric-value-line {
  width: 34px;
  height: 3px;
  border-radius: 3px;
  background: var(--metric-color);
}

.analysis-chart-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.chart-legend span {
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--legend-color);
}

.assessment-trend {
  width: 100%;
  height: 220px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.app-chart-card {
  overflow: hidden;
}

.app-chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
}

.app-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #607184;
  font-size: 11px;
  font-weight: 700;
}

.app-chart-legend i {
  width: 13px;
  height: 3px;
  border-radius: 2px;
}

.app-result-chart {
  width: 100%;
  height: 300px;
  display: block;
  margin-top: 10px;
}

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

.screening-metric {
  padding: 15px;
  border: 1px solid #e0e8ef;
  border-radius: 7px;
  background: #fbfdfe;
}

.screening-metric span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #607184;
  font-size: 12px;
  font-weight: 700;
}

.screening-metric span b {
  color: var(--screening-color);
  font-size: 17px;
}

.screening-metric strong {
  display: block;
  margin: 6px 0 9px;
  color: var(--screening-color);
  font-size: 26px;
}

.screening-metric > div {
  height: 5px;
  overflow: hidden;
  border-radius: 4px;
  background: #e8eef3;
}

.screening-metric > div i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--screening-color);
}

.section-symbol {
  margin-right: 6px;
  color: #7c5cc4;
}

.mbti-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mbti-summary-grid > div {
  padding: 13px 10px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--summary-color) 28%, #e3eaf0);
  border-radius: 7px;
  background: color-mix(in srgb, var(--summary-color) 5%, #fff);
}

.mbti-summary-grid span,
.mbti-summary-grid strong {
  display: block;
}

.mbti-summary-grid span {
  color: #607184;
  font-size: 11px;
}

.mbti-summary-grid strong {
  margin-top: 5px;
  color: var(--summary-color);
  font-size: 19px;
}

.medical-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.medical-metric-grid > div {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--medical-color) 25%, #e3eaf0);
  border-radius: 7px;
  background: #fbfdfe;
}

.medical-metric-grid span,
.medical-metric-grid strong {
  display: block;
}

.medical-metric-grid span {
  color: #607184;
  font-size: 11px;
}

.medical-metric-grid strong {
  margin-top: 6px;
  color: var(--medical-color);
  font-size: 22px;
}

.training-comparison-report {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.comparison-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border: 1px solid #bfe1e7;
  border-radius: 8px;
  background: linear-gradient(135deg, #f2fbfc 0%, #f7f9ff 100%);
}

.comparison-report-head h3 {
  margin: 5px 0 4px;
  font-size: 22px;
}

.comparison-report-head p {
  margin: 0;
  color: #607184;
}

.comparison-duration {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 92px;
  justify-content: center;
  padding: 10px 14px;
  border-left: 1px solid #cce1e7;
}

.comparison-duration strong {
  font-size: 30px;
  color: #15788d;
}

.comparison-duration span {
  color: #607184;
}

.comparison-table {
  border: 1px solid #e0e8ef;
  border-radius: 6px;
  overflow: hidden;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.3fr) repeat(3, minmax(90px, 1fr));
  align-items: center;
  min-height: 46px;
  padding: 0 16px;
  border-top: 1px solid #e7edf2;
}

.comparison-row:first-child {
  border-top: 0;
}

.comparison-row span:not(:first-child) {
  text-align: right;
}

.comparison-header {
  background: #f5f8fb;
  color: #607184;
  font-size: 13px;
  font-weight: 700;
}

.comparison-row .positive {
  color: #15936f;
  font-weight: 700;
}

.comparison-row .negative {
  color: #c2413a;
  font-weight: 700;
}

.comparison-bar-legend {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 8px;
  color: #607184;
  font-size: 12px;
  font-weight: 700;
}

.comparison-bar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.comparison-bar-legend i {
  width: 14px;
  height: 8px;
  border-radius: 3px;
}

.comparison-bar-legend .before {
  background: rgba(100, 116, 139, 0.72);
}

.comparison-bar-legend .after {
  background: rgba(0, 184, 217, 0.86);
}

.comparison-bar-chart {
  width: 100%;
  height: 260px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.comparison-ai-card {
  border-color: #c9d8ef;
  background: #f8faff;
}

.band-list {
  display: grid;
  gap: 14px;
}

.band-row {
  display: grid;
  grid-template-columns: 54px minmax(80px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.band-row > div {
  height: 8px;
  border-radius: 6px;
  background: #e8edf2;
  overflow: hidden;
}

.band-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--band-color);
}

.band-row strong {
  text-align: right;
}

.analysis-source-tag {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef7f6;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.ai-analysis-copy {
  padding: 16px 18px;
  border-left: 4px solid #7c5cc4;
  background: #f7f6fb;
  color: #27313d;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.analysis-disclaimer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.info-list div {
  min-width: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.info-list dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.info-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef7f6;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 13px;
}

.muted-chip {
  background: #f2f5f8;
  color: var(--muted);
}

.tight table {
  min-width: 680px;
}

.wave-grid {
  display: grid;
  gap: 14px;
}

.wave-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f9fcfd;
}

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

.wave-head strong,
.wave-head span {
  display: block;
}

.wave-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.small-link {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 700;
}

.wave-svg {
  width: 100%;
  height: 180px;
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.distribution-list {
  display: grid;
  gap: 16px;
}

.distribution-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
}

.distribution-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.distribution-row span {
  color: var(--muted);
  font-size: 12px;
}

.distribution-track {
  height: 10px;
  border-radius: 6px;
  background: #e8edf2;
  overflow: hidden;
}

.distribution-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--distribution-color);
}

.distribution-row b {
  color: var(--distribution-color);
  text-align: right;
}

.filter-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(3, minmax(140px, 0.8fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.patient-filter-toolbar {
  grid-template-columns: minmax(210px, 1.25fr) minmax(180px, 1fr) repeat(3, minmax(125px, 0.72fr)) auto;
}

.session-filter-toolbar {
  grid-template-columns: minmax(260px, 1.5fr) minmax(180px, 0.9fr) minmax(160px, 0.8fr) auto;
}

.export-filter-toolbar {
  grid-template-columns: minmax(300px, 1.5fr) minmax(180px, 0.8fr) auto;
}

.export-main-btn {
  min-width: 108px;
  min-height: 46px;
  font-weight: 700;
  white-space: nowrap;
}

.export-advanced-filters {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.export-advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  padding-top: 12px;
}

.export-advanced-grid .custom-date-fields {
  grid-column: 1 / -1;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.custom-date-fields {
  grid-column: 1 / span 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  padding-top: 2px;
}

.custom-date-fields[hidden] {
  display: none;
}

.filter-summary {
  min-height: 24px;
  margin: 0 2px 12px;
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.small-btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.raw-eeg-detail {
  display: grid;
  gap: 16px;
}

.raw-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.raw-summary-strip span {
  min-height: 58px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.raw-summary-strip b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 18px;
}

.raw-wave-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.raw-wave-panel > strong {
  display: block;
  margin-bottom: 8px;
}

.wave-view-toolbar,
.wave-panel-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.wave-view-toolbar {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wave-view-toolbar > div:first-child,
.wave-panel-caption {
  min-width: 0;
}

.wave-view-toolbar span,
.wave-panel-caption span {
  color: var(--muted);
  font-size: 12px;
}

.wave-view-toolbar > div:first-child span {
  display: block;
  margin-top: 3px;
}

.wave-mode-control {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f3f6f8;
}

.wave-mode-btn {
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.wave-mode-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(20, 43, 62, 0.12);
}

.wave-panel-caption {
  margin-bottom: 8px;
}

.raw-wave-svg {
  width: 100%;
  height: auto;
  min-height: 330px;
  display: block;
  background: #fff;
}

.matrix-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.matrix-preview-head span {
  color: var(--muted);
  font-size: 12px;
}

.raw-matrix-table {
  min-width: 980px;
}

.raw-matrix-table th,
.raw-matrix-table td {
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .metric-grid,
  .dashboard-grid,
  fieldset,
  .filter-toolbar,
  .session-filter-toolbar,
  .raw-summary-strip {
    grid-template-columns: 1fr;
  }

  .custom-date-fields {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .filter-actions {
    justify-content: stretch;
  }

  .filter-actions button {
    flex: 1;
  }

  .overview-recent-tools {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .overview-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .overview-recent-tools input,
  .overview-scope-control {
    width: 100%;
  }

  .overview-module-panel .bar-list {
    grid-template-columns: 1fr;
  }

  .wave-view-toolbar,
  .wave-panel-caption {
    align-items: flex-start;
    flex-direction: column;
  }

  .wave-mode-control {
    width: 100%;
  }

  .topbar,
  .export-box {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-panel {
    inset: 12px;
  }

  .detail-grid,
  .info-list,
  .module-result-list,
  .assessment-metric-grid,
  .export-filter-grid,
  .export-actions {
    grid-template-columns: 1fr;
  }

  .export-primary-option {
    grid-template-columns: 1fr;
  }

  .export-preview {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-compact-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-compact-summary > span {
    padding-left: 0;
    border-left: 0;
  }

  .export-message {
    max-width: none;
    text-align: left;
  }

  .export-advanced-grid {
    grid-template-columns: 1fr;
  }

  .export-advanced-grid .custom-date-fields {
    grid-column: auto;
  }

  .patient-profile-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .patient-profile-badges {
    margin: 0;
  }

  .patient-profile-actions {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    margin-left: 66px;
  }

  .quick-export-btn {
    width: 100%;
  }

  .patient-fact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 0;
  }

  .patient-fact-grid > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

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

  .medication-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .detail-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .history-count {
    align-self: flex-start;
  }

  .assessment-summary,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .assessment-primary-result {
    min-width: 0;
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .assessment-summary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .assessment-export-btn {
    width: 100%;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .band-row {
    grid-template-columns: 42px minmax(50px, 1fr) 36px;
    gap: 6px;
  }

  .export-modal-panel {
    max-height: calc(100vh - 24px);
  }

  .export-preview-head,
  .matrix-preview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .export-message {
    max-width: none;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .condition-list {
    grid-template-columns: 1fr;
  }

  .period-control {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-btn {
    padding: 0 6px;
  }

  .export-option {
    grid-template-columns: 1fr;
  }

  .export-option .primary-btn {
    width: 100%;
  }
}

/* Account management */
.admin-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 0;
  background: var(--surface);
}

.admin-auth-gate.active {
  display: grid;
}

.admin-auth-panel [hidden] {
  display: none !important;
}

.admin-auth-panel {
  width: 100%;
  min-height: 100vh;
  padding: 48px 24px;
  border: 0;
  border-radius: 0;
  background: #edf5f7;
  box-shadow: none;
  display: grid;
  place-items: center;
}

.admin-auth-content {
  width: min(520px, 100%);
  padding: 40px 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(37, 51, 66, 0.12);
}

.admin-auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.admin-auth-brand strong,
.admin-auth-brand span {
  display: block;
}

.admin-auth-brand strong {
  margin-bottom: 5px;
  font-size: 25px;
}

.admin-auth-brand span,
.admin-auth-panel label,
.account-form label,
.password-form label {
  color: var(--muted);
  font-size: 13px;
}

.admin-auth-panel label,
.account-form label,
.password-form label {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  font-weight: 700;
}

.admin-auth-panel input,
.account-form input,
.account-form select,
.password-form input,
.account-toolbar input,
.account-toolbar select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: 0;
}

.admin-auth-panel input:focus,
.account-form input:focus,
.account-form select:focus,
.password-form input:focus,
.account-toolbar input:focus,
.account-toolbar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.12);
}

.admin-auth-submit {
  width: 100%;
  min-height: 50px;
  font-size: 16px;
}

.admin-auth-message,
.account-form-message {
  min-height: 20px;
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.admin-auth-message.fail,
.account-form-message.fail {
  color: var(--red);
}

.admin-identity {
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
}

.account-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.account-summary-grid article {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
}

.account-summary-grid span,
.account-summary-grid small {
  display: block;
  color: var(--muted);
}

.account-summary-grid strong {
  display: block;
  margin: 7px 0 4px;
  font-size: 26px;
}

.account-summary-grid small {
  font-size: 12px;
}

.account-panel {
  padding: 20px;
}

.account-panel-head {
  align-items: center;
}

.account-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin: 16px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.account-toolbar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-summary {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.account-table-wrap {
  max-height: calc(100vh - 405px);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-table {
  min-width: 760px;
}

.account-table th,
.account-table td {
  padding: 10px 8px;
}

.account-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7fa;
}

.account-name,
.account-number {
  display: block;
  white-space: nowrap;
}

.account-number {
  font-family: Consolas, "Microsoft YaHei", sans-serif;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.account-warning,
.account-role,
.device-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  margin-top: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eaf5ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.account-warning {
  background: #fff3df;
  color: var(--accent);
}

.account-role.admin {
  background: #e7f1f5;
  color: var(--primary-dark);
}

.device-chip {
  margin: 0;
  background: #edf4f8;
  color: #3d596b;
  white-space: normal;
}

.muted-text {
  color: var(--muted);
  white-space: nowrap;
}

.account-counts {
  color: var(--muted);
  line-height: 1.5;
  white-space: normal;
}

.account-status-toggle {
  display: inline-grid;
  grid-template-columns: 28px auto;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f6f8;
  color: var(--muted);
  cursor: pointer;
}

.account-status-toggle i {
  position: relative;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: #aab6c0;
}

.account-status-toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.account-status-toggle.enabled {
  border-color: #b9ded1;
  background: #edf8f3;
  color: var(--green);
}

.account-status-toggle.enabled i {
  background: var(--green);
}

.account-status-toggle.enabled i::after {
  transform: translateX(12px);
}

.account-actions {
  display: grid;
  gap: 6px;
  white-space: nowrap;
}

.account-actions button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
}

.account-modal-panel,
.password-modal-panel {
  top: 8vh;
  bottom: auto;
  max-width: 720px;
  max-height: 84vh;
}

.password-modal-panel {
  max-width: 480px;
}

.account-form,
.password-form {
  padding: 20px;
  overflow-y: auto;
}

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

.account-device-field,
.account-password-field {
  grid-column: 1 / -1;
}

.account-form label small {
  font-weight: 400;
}

.account-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.timing-panel {
  max-width: 1120px;
}

.timing-panel-head {
  align-items: flex-end;
}

.timing-account-field {
  display: grid;
  gap: 7px;
  min-width: 260px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.timing-account-field select {
  width: 100%;
  height: 44px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.timing-rule {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  background: #f2f8f9;
  color: var(--muted);
  line-height: 1.6;
}

.timing-rule strong {
  flex: 0 0 auto;
  color: var(--ink);
}

.timing-rows {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.timing-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 190px;
  gap: 20px;
  align-items: center;
  min-height: 84px;
  padding: 14px 18px;
  background: #fff;
}

.timing-row + .timing-row {
  border-top: 1px solid var(--line);
}

.timing-module,
.timing-preview {
  display: grid;
  gap: 4px;
}

.timing-module strong,
.timing-preview strong {
  color: var(--ink);
  font-size: 16px;
}

.timing-module span,
.timing-preview span {
  color: var(--muted);
  font-size: 13px;
}

.timing-input {
  display: flex;
  align-items: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.timing-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 137, 154, 0.12);
}

.timing-input input {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.timing-input span {
  padding-right: 12px;
  color: var(--muted);
}

.timing-preview {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.timing-preview strong {
  color: var(--primary-dark);
}

.timing-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  min-height: 72px;
}

.timing-message {
  margin: 0 auto 0 0;
  color: var(--muted);
}

.timing-message.ok {
  color: var(--green);
}

.timing-message.fail {
  color: var(--red);
}

@media (max-width: 1100px) {
  .account-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .account-summary-grid,
  .account-toolbar,
  .account-form-grid {
    grid-template-columns: 1fr;
  }

  .account-device-field,
  .account-password-field {
    grid-column: auto;
  }

  .account-modal-panel,
  .password-modal-panel {
    inset: 12px;
    max-height: none;
  }

  .admin-identity {
    display: none;
  }

  .admin-auth-panel {
    padding: 20px;
    background: #edf5f7;
  }

  .admin-auth-content {
    padding: 30px 24px;
  }

  .timing-panel-head,
  .timing-rule,
  .timing-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .timing-account-field {
    min-width: 0;
  }

  .timing-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .timing-preview {
    padding: 0;
    border-left: 0;
  }
}
