:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #202833;
  --muted: #687486;
  --line: #dfe5ec;
  --line-strong: #c8d1dc;
  --nav: #2f4056;
  --nav-active: #20324a;
  --blue: #2f80ed;
  --blue-soft: #edf5ff;
  --green: #29935f;
  --green-soft: #eaf7f0;
  --red: #c2414b;
  --red-soft: #fae9eb;
  --amber: #a86713;
  --amber-soft: #fff4df;
  --gray-soft: #f7f8fa;
  --shadow: 0 8px 26px rgba(23, 37, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 1180px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 224px;
  padding: 14px 10px;
  overflow-y: auto;
  background: var(--nav);
  color: #eef5f7;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 4px;
  background: #10886d;
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #b8c8d3;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 2px;
  margin-top: 12px;
}

.nav-item {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #d3dde6;
  font-weight: 700;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--nav-active);
  color: #fff;
}

.main {
  min-height: 100vh;
  margin-left: 224px;
  padding: 16px 22px 38px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.topbar p,
.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.account-actions,
.table-tools,
.row-actions,
.drawer-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions {
  flex-wrap: nowrap;
}

.account-actions {
  flex-wrap: nowrap;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 220px;
  padding: 0 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #344256;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-actions {
  flex-wrap: wrap;
}

.drawer-actions .action-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.mode-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #4d5968;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.green {
  border-color: #ccebd8;
  background: var(--green-soft);
  color: var(--green);
}

.tag.red {
  border-color: #f2c9ce;
  background: var(--red-soft);
  color: var(--red);
}

.tag.amber {
  border-color: #f1d7aa;
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.blue {
  border-color: #cddff8;
  background: var(--blue-soft);
  color: var(--blue);
}

.btn,
.icon-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #334155;
  font-weight: 700;
}

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

.btn.danger {
  border-color: #e6a8ae;
  background: #fff5f6;
  color: var(--red);
}

.btn.small {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-btn {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.icon-btn {
  width: 30px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.tab-btn {
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: #fff;
  color: #455468;
  font-weight: 800;
}

.tab-btn.active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}

.dashboard {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

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

.metric-grid.gym-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric {
  min-height: 66px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.metric-action {
  width: 100%;
  color: inherit;
  text-align: left;
}

.metric-action:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.metric small {
  color: var(--muted);
}

.filters,
.panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 130px 130px 120px 120px 72px 72px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field label {
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea,
.readonly-value {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

.readonly-value {
  display: flex;
  align-items: center;
  background: #f7f8fa;
  color: var(--muted);
}

textarea {
  min-height: 80px;
  padding: 8px 9px;
  resize: vertical;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 42px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  color: #303b4b;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  height: 38px;
  background: #f7f8fa;
  color: #344256;
  font-size: 13px;
  font-weight: 900;
}

td {
  font-size: 13px;
}

tr:nth-child(even) td {
  background: #fbfcfd;
}

.cell-strong {
  font-weight: 850;
}

.cell-stack {
  display: grid;
  gap: 3px;
  min-width: 0;
  line-height: 1.35;
}

.cell-stack strong,
.cell-stack small,
.business-order-cell div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-stack small {
  color: var(--muted);
  font-size: 11px;
}

.business-order-cell .tag {
  margin-right: 6px;
}

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

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  border-radius: 4px;
  background: #edf1f5;
  color: #667085;
  font-size: 12px;
  font-weight: 900;
}

.media-dot.on {
  background: var(--blue-soft);
  color: var(--blue);
}

.media-card-grid {
  display: grid;
  gap: 10px;
}

.media-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfd;
}

.media-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.media-card-head strong {
  font-size: 13px;
}

.media-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.media-preview-wrap,
.media-placeholder {
  width: 100%;
  height: 138px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f3f5f8;
}

.media-preview-wrap {
  position: relative;
  overflow: hidden;
}

.media-preview {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #f3f5f8;
  object-fit: contain;
}

.media-preview-wrap.large,
.media-placeholder.large {
  height: min(52vh, 360px);
}

.media-preview-wrap.media-gif,
.media-placeholder.media-gif,
.media-preview-wrap.media-video,
.media-placeholder.media-video {
  width: min(100%, 360px);
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.media-preview-wrap.large.media-gif,
.media-placeholder.large.media-gif,
.media-preview-wrap.large.media-video,
.media-placeholder.large.media-video {
  width: min(100%, 420px);
}

.xll-media-watermark {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.xll-media-watermark .wm {
  position: absolute;
  color: rgba(32, 44, 42, 0.14);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

.xll-media-watermark .wm-1 { left: 10%; top: 10%; }
.xll-media-watermark .wm-2 { left: 44%; top: 12%; }
.xll-media-watermark .wm-3 { right: 10%; top: 10%; }
.xll-media-watermark .wm-4 { left: 10%; top: 43%; }
.xll-media-watermark .wm-5 { left: 44%; top: 45%; color: rgba(32, 44, 42, 0.2); font-weight: 900; }
.xll-media-watermark .wm-6 { right: 10%; top: 43%; }
.xll-media-watermark .wm-7 { left: 10%; bottom: 12%; }
.xll-media-watermark .wm-8 { left: 44%; bottom: 10%; }
.xll-media-watermark .wm-9 { right: 10%; bottom: 12%; }

.media-rule-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.media-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.media-preview-section {
  margin-top: 0;
}

.media-edit-field {
  gap: 6px;
}

.plan-actions-edit-field {
  gap: 8px;
}

.plan-action-editor,
.plan-action-rows,
.template-action-list {
  display: grid;
  gap: 8px;
}

.plan-action-select-grid label {
  display: grid;
  gap: 4px;
}

.plan-action-select-grid label span {
  color: #5f6b7a;
  font-size: 12px;
  font-weight: 800;
}

.plan-action-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.plan-action-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.plan-action-head strong {
  font-size: 13px;
}

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

.plan-action-row,
.template-action-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfd;
}

.plan-action-title,
.template-action-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.plan-action-title strong,
.template-action-item strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.plan-action-title small,
.template-action-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.plan-action-order,
.template-action-order {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.plan-action-select-grid {
  display: grid;
  grid-template-columns: minmax(96px, 0.9fr) minmax(0, 1.5fr);
  gap: 6px;
  margin-top: 8px;
}

.plan-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.plan-action-grid label {
  display: grid;
  gap: 4px;
}

.plan-action-grid span {
  color: #5f6b7a;
  font-size: 12px;
  font-weight: 800;
}

.unit-field {
  position: relative;
}

.unit-field input {
  padding-right: 34px;
}

.unit-field em {
  position: absolute;
  top: 50%;
  right: 9px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  transform: translateY(-50%);
}

.plan-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.template-action-prescription {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.template-action-prescription span {
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #3b4656;
  font-size: 12px;
  font-weight: 800;
}

.empty {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 14px;
}

.drawer {
  position: fixed;
  top: 0;
  right: -420px;
  bottom: 0;
  z-index: 10;
  width: 420px;
  max-width: calc(100vw - 224px);
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  transform: none;
  transition: right 0.18s ease;
}

.drawer.open {
  right: 0;
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

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

.drawer-body {
  height: calc(100vh - 65px);
  overflow: auto;
  padding: 12px 14px 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 112px 1fr;
  border: 1px solid var(--line);
  border-bottom: 0;
}

.detail-grid dt,
.detail-grid dd {
  min-height: 34px;
  margin: 0;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.detail-grid dt {
  background: #f7f8fa;
  color: #596579;
  font-weight: 800;
}

.detail-grid dd {
  overflow-wrap: anywhere;
}

.drawer-section pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f8fa;
  color: #344256;
  font-size: 12px;
  line-height: 1.5;
}

.drawer-section {
  margin-top: 12px;
}

.drawer-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.35);
}

.modal[hidden] {
  display: none;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-head p {
  margin: 4px 0 0;
  color: #6b778c;
  font-size: 13px;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 0;
}

.service-request-summary {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.service-request-summary h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.service-request-summary dl {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 6px 8px;
  margin: 0;
  font-size: 13px;
}

.service-request-summary dt {
  color: #596579;
  font-weight: 800;
}

.service-request-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.service-note-cell {
  display: grid;
  gap: 4px;
}

.service-user-cell,
.service-content-cell,
.service-state-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.service-user-cell strong,
.service-content-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-state-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.service-note-meta {
  color: #6b778c;
  font-size: 12px;
  line-height: 1.35;
}

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

.service-log-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfd;
}

.service-log-item strong {
  display: block;
  margin-bottom: 4px;
}

.service-log-item p {
  margin: 0;
  color: #596579;
  line-height: 1.5;
}

.technical-details summary {
  cursor: pointer;
  color: #344256;
  font-size: 14px;
  font-weight: 900;
}

.technical-details .detail-grid {
  margin-top: 8px;
}

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

.settlement-item {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfd;
}

.settlement-item strong,
.settlement-item span {
  overflow-wrap: anywhere;
}

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

.match-list {
  display: grid;
  gap: 10px;
}

.match-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.match-card.weak {
  background: #fffaf0;
}

.match-card-head,
.match-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.match-meta,
.match-score {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.edit-form {
  display: grid;
  gap: 10px;
}

.edit-form .drawer-section {
  margin-top: 0;
}

.edit-section {
  display: grid;
  gap: 10px;
}

.edit-section h3 {
  margin-bottom: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.edit-section-fields {
  display: grid;
  gap: 10px;
}

.edit-field {
  display: grid;
  gap: 5px;
}

.edit-field span {
  color: #4b5563;
  font-size: 12px;
  font-weight: 850;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 4px;
}

.checkbox-item input {
  width: auto;
  min-height: auto;
}

.checkbox-item span {
  color: #243044;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  max-width: 420px;
  padding: 10px 12px;
  border-radius: 4px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.show {
  display: block;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}

.auth-gate.open {
  display: grid;
}

.auth-locked .sidebar,
.auth-locked .main,
.auth-locked .drawer {
  visibility: hidden;
  pointer-events: none;
}

.auth-panel {
  width: min(420px, calc(100vw - 48px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-panel-narrow {
  width: min(390px, calc(100vw - 48px));
}

.auth-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

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

.auth-head strong {
  font-size: 18px;
}

.auth-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form .field span {
  color: #4b5563;
  font-size: 12px;
  font-weight: 850;
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 2px;
}

.auth-message {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #f1d7aa;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

@media (max-width: 1280px) {
  .metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
